use of org.xdi.oxauth.model.token.JwtSigner in project oxAuth by GluuFederation.
the class CreateRptWS method createJwr.
private JsonWebResponse createJwr(UmaRPT rpt, String authorization, List<String> gluuAccessTokenScopes) throws Exception {
final AuthorizationGrant grant = tokenService.getAuthorizationGrant(authorization);
JwtSigner jwtSigner = JwtSigner.newJwtSigner(appConfiguration, webKeysConfiguration, grant.getClient());
Jwt jwt = jwtSigner.newJwt();
jwt.getClaims().setExpirationTime(rpt.getExpirationDate());
jwt.getClaims().setIssuedAt(rpt.getCreationDate());
if (!gluuAccessTokenScopes.isEmpty()) {
jwt.getClaims().setClaim("scopes", gluuAccessTokenScopes);
}
return jwtSigner.sign();
}
use of org.xdi.oxauth.model.token.JwtSigner in project oxAuth by GluuFederation.
the class SessionStateService method generateJwt.
private Jwt generateJwt(SessionState sessionState, String audience) {
try {
JwtSigner jwtSigner = new JwtSigner(appConfiguration, webKeysConfiguration, SignatureAlgorithm.RS512, audience);
Jwt jwt = jwtSigner.newJwt();
// claims
jwt.getClaims().setClaim("id", sessionState.getId());
jwt.getClaims().setClaim("authentication_time", sessionState.getAuthenticationTime());
jwt.getClaims().setClaim("user_dn", sessionState.getUserDn());
jwt.getClaims().setClaim("state", sessionState.getState() != null ? sessionState.getState().getValue() : "");
jwt.getClaims().setClaim("session_attributes", JwtSubClaimObject.fromMap(sessionState.getSessionAttributes()));
jwt.getClaims().setClaim("last_used_at", sessionState.getLastUsedAt());
jwt.getClaims().setClaim("permission_granted", sessionState.getPermissionGranted());
jwt.getClaims().setClaim("permission_granted_map", JwtSubClaimObject.fromBooleanMap(sessionState.getPermissionGrantedMap().getPermissionGranted()));
jwt.getClaims().setClaim("involved_clients_map", JwtSubClaimObject.fromBooleanMap(sessionState.getInvolvedClients().getPermissionGranted()));
// sign
return jwtSigner.sign();
} catch (Exception e) {
log.error("Failed to sign session jwt! " + e.getMessage(), e);
throw new RuntimeException(e);
}
}
Aggregations