Skip to content

Commit

Permalink
Rearrange methods in InternalAuthenticationManager
Browse files Browse the repository at this point in the history
  • Loading branch information
dain committed Feb 2, 2020
1 parent 01a42ef commit 189018f
Showing 1 changed file with 18 additions and 18 deletions.
Expand Up @@ -66,24 +66,6 @@ public InternalAuthenticationManager(Optional<String> sharedSecret, String nodeI
this.nodeId = nodeId;
}

private String generateJwt()
{
return Jwts.builder()
.signWith(SignatureAlgorithm.HS256, hmac)
.setSubject(nodeId)
.setExpiration(Date.from(ZonedDateTime.now().plusMinutes(5).toInstant()))
.compact();
}

private String parseJwt(String jwt)
{
return Jwts.parser()
.setSigningKey(hmac)
.parseClaimsJws(jwt)
.getBody()
.getSubject();
}

public boolean isInternalRequest(HttpServletRequest request)
{
return request.getHeader(PRESTO_INTERNAL_BEARER) != null;
Expand Down Expand Up @@ -121,4 +103,22 @@ public Request filterRequest(Request request)
.addHeader(PRESTO_INTERNAL_BEARER, generateJwt())
.build();
}

private String generateJwt()
{
return Jwts.builder()
.signWith(SignatureAlgorithm.HS256, hmac)
.setSubject(nodeId)
.setExpiration(Date.from(ZonedDateTime.now().plusMinutes(5).toInstant()))
.compact();
}

private String parseJwt(String jwt)
{
return Jwts.parser()
.setSigningKey(hmac)
.parseClaimsJws(jwt)
.getBody()
.getSubject();
}
}

0 comments on commit 189018f

Please sign in to comment.