Search in sources :

Example 1 with JwtVerificationException

use of com.okta.jwt.JwtVerificationException in project ab2d by CMSgov.

the class JwtTokenAuthenticationFilter method getClientId.

/**
 * Retrieve the client id from a JWT token
 *
 * @param token - the token
 * @return - the {@link PdpClient#getClientId()}
 */
private String getClientId(String token) {
    Jwt jwt;
    try {
        jwt = accessTokenVerifier.decode(token);
    } catch (JwtVerificationException e) {
        log.error("Unable to decode JWT token {}", e.getMessage());
        throw new BadJWTTokenException("Unable to decode JWT token", e);
    }
    Object subClaim = jwt.getClaims().get("sub");
    if (subClaim == null) {
        String tokenErrorMsg = "Token did not contain client id field";
        log.error(tokenErrorMsg);
        throw new BadJWTTokenException(tokenErrorMsg);
    }
    return subClaim.toString();
}
Also used : Jwt(com.okta.jwt.Jwt) JwtVerificationException(com.okta.jwt.JwtVerificationException)

Aggregations

Jwt (com.okta.jwt.Jwt)1 JwtVerificationException (com.okta.jwt.JwtVerificationException)1