Java Code Examples for org.apache.cxf.rs.security.jose.jwt.JwtUtils#validateJwtExpiry()

The following examples show how to use org.apache.cxf.rs.security.jose.jwt.JwtUtils#validateJwtExpiry() . 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: OidcRpAuthenticationFilter.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected boolean checkSecurityContext(ContainerRequestContext rc) {
    OidcClientTokenContext tokenContext = (OidcClientTokenContext)stateManager.getClientTokenContext(mc);
    if (tokenContext == null) {
        return false;
    }
    IdToken idToken = tokenContext.getIdToken();
    try {
        // If ID token has expired then the context is no longer valid
        JwtUtils.validateJwtExpiry(idToken, 0, idToken.getExpiryTime() != null);
    } catch (JwtException ex) {
        stateManager.removeClientTokenContext(new MessageContextImpl(JAXRSUtils.getCurrentMessage()));
        return false;
    }
    OidcClientTokenContextImpl newTokenContext = new OidcClientTokenContextImpl();
    newTokenContext.setToken(tokenContext.getToken());
    newTokenContext.setIdToken(idToken);
    newTokenContext.setUserInfo(tokenContext.getUserInfo());
    newTokenContext.setState(toRequestState(rc));
    JAXRSUtils.getCurrentMessage().setContent(ClientTokenContext.class, newTokenContext);

    OidcSecurityContext oidcSecCtx = new OidcSecurityContext(newTokenContext);
    oidcSecCtx.setRoleClaim(roleClaim);
    rc.setSecurityContext(oidcSecCtx);
    return true;
}
 
Example 2
Source File: JwtVerifier.java    From deprecated-security-advanced-modules with Apache License 2.0 5 votes vote down vote up
private void validateClaims(JwtToken jwt) throws BadCredentialsException, JwtException {
	JwtClaims claims = jwt.getClaims();

	if (claims != null) {
		JwtUtils.validateJwtExpiry(claims, 0, false);
		JwtUtils.validateJwtNotBefore(claims, 0, false);
	}
}