Skip to content

Instantly share code, notes, and snippets.

@brunokrebs
Created October 17, 2017 10:49
Show Gist options
  • Save brunokrebs/df809c4262293eeb4fd89860ed155a61 to your computer and use it in GitHub Desktop.
Save brunokrebs/df809c4262293eeb4fd89860ed155a61 to your computer and use it in GitHub Desktop.
// ...
public class JWTAuthorizationFilter extends BasicAuthenticationFilter{
// ...
private CustomAuthenticationToken getAuthentication(HttpServletRequest request) {
String token = request.getHeader(HEADER_STRING);
if(token != null) {
// get claims from JWT
Jws<Claims> claims = Jwts.parser()
.setSigningKey(SECRET.getBytes())
.parseClaimsJws(token.replace(TOKEN_PREFIX, ""));
String user = claims.getBody().getSubject();
String db = (String) claims.getBody().get("db");
System.out.println("=======> Printing the User in the GetAuthentication: " + user);
System.out.println("=======> Printing the Db in the GetAuthentication: " + db);
// ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment