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();
}
Aggregations