Java Code Examples for org.apache.cxf.rs.security.jose.jwt.JwtUtils#validateTokenClaims()
The following examples show how to use
org.apache.cxf.rs.security.jose.jwt.JwtUtils#validateTokenClaims() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JwtBearerAuthHandler.java From cxf with Apache License 2.0 | 6 votes |
@Override protected void validateToken(JwtToken jwt) { super.validateToken(jwt); // We must have an issuer if (jwt.getClaim(JwtConstants.CLAIM_ISSUER) == null) { throw new OAuthServiceException(OAuthConstants.INVALID_GRANT); } // We must have a Subject if (jwt.getClaim(JwtConstants.CLAIM_SUBJECT) == null) { throw new OAuthServiceException(OAuthConstants.INVALID_GRANT); } // We must have an Expiry if (jwt.getClaim(JwtConstants.CLAIM_EXPIRY) == null) { throw new OAuthServiceException(OAuthConstants.INVALID_GRANT); } JwtUtils.validateTokenClaims(jwt.getClaims(), getTtl(), getClockOffset(), isValidateAudience()); }
Example 2
Source File: TrustedIdpOIDCProtocolHandler.java From cxf-fediz with Apache License 2.0 | 6 votes |
protected void validateToken(JwtToken jwt, String clientId) { // We must have the following claims if (jwt.getClaim(JwtConstants.CLAIM_ISSUER) == null || jwt.getClaim(JwtConstants.CLAIM_SUBJECT) == null || jwt.getClaim(JwtConstants.CLAIM_AUDIENCE) == null || jwt.getClaim(JwtConstants.CLAIM_EXPIRY) == null || jwt.getClaim(JwtConstants.CLAIM_ISSUED_AT) == null) { LOG.warn("The IdToken is missing a required claim"); throw new IllegalStateException("The IdToken is missing a required claim"); } // The audience must match the client_id of this client boolean match = false; for (String audience : jwt.getClaims().getAudiences()) { if (clientId.equals(audience)) { match = true; break; } } if (!match) { LOG.warn("The audience of the token does not match this client"); throw new IllegalStateException("The audience of the token does not match this client"); } JwtUtils.validateTokenClaims(jwt.getClaims(), 300, 0, false); }
Example 3
Source File: AbstractJwtHandler.java From cxf with Apache License 2.0 | 5 votes |
protected void validateClaims(Client client, JwtClaims claims) { if (getAudience() != null) { JAXRSUtils.getCurrentMessage().put(JwtConstants.EXPECTED_CLAIM_AUDIENCE, getAudience()); } JwtUtils.validateTokenClaims(claims, ttl, clockOffset, true); validateIssuer(claims.getIssuer()); validateSubject(client, claims.getSubject()); // We must have an Expiry if (claims.getClaim(JwtConstants.CLAIM_EXPIRY) == null) { throw new OAuthServiceException(OAuthConstants.INVALID_GRANT); } }
Example 4
Source File: JWTTokenValidator.java From cxf with Apache License 2.0 | 4 votes |
protected void validateToken(JwtToken jwt) { JwtUtils.validateTokenClaims(jwt.getClaims(), ttl, clockOffset, false); }
Example 5
Source File: AbstractJwtAuthenticationFilter.java From cxf with Apache License 2.0 | 4 votes |
@Override protected void validateToken(JwtToken jwt) { JwtUtils.validateTokenClaims(jwt.getClaims(), getTtl(), getClockOffset(), isValidateAudience()); }