Search in sources :

Example 1 with AuthenticationJsonWebToken

use of com.auth0.spring.security.api.authentication.AuthenticationJsonWebToken in project c4sg-services by Code4SocialGood.

the class JwtUtil method match.

/**
 * Checks if the email matches
 * @param email Email address
 * @return True if match
 */
public static boolean match(String email) {
    AuthenticationJsonWebToken auth = (AuthenticationJsonWebToken) SecurityContextHolder.getContext().getAuthentication();
    if (auth != null) {
        DecodedJWT jwt = (DecodedJWT) auth.getDetails();
        String emailFromClaim = jwt.getClaim("http://email").asString();
        if (email.equals(emailFromClaim))
            return true;
    }
    return false;
}
Also used : AuthenticationJsonWebToken(com.auth0.spring.security.api.authentication.AuthenticationJsonWebToken) DecodedJWT(com.auth0.jwt.interfaces.DecodedJWT)

Aggregations

DecodedJWT (com.auth0.jwt.interfaces.DecodedJWT)1 AuthenticationJsonWebToken (com.auth0.spring.security.api.authentication.AuthenticationJsonWebToken)1