Search in sources :

Example 6 with JwtAuthorizationRequest

use of io.jans.as.server.model.authorize.JwtAuthorizationRequest in project jans by JanssenProject.

the class IdTokenFactory method setClaimsFromJwtAuthorizationRequest.

private void setClaimsFromJwtAuthorizationRequest(JsonWebResponse jwr, IAuthorizationGrant authorizationGrant, Set<String> scopes) throws InvalidClaimException {
    final JwtAuthorizationRequest requestObject = authorizationGrant.getJwtAuthorizationRequest();
    if (requestObject == null || requestObject.getIdTokenMember() == null) {
        return;
    }
    for (Claim claim : requestObject.getIdTokenMember().getClaims()) {
        // ClaimValueType.OPTIONAL.equals(claim.getClaimValue().getClaimValueType());
        boolean optional = true;
        GluuAttribute gluuAttribute = attributeService.getByClaimName(claim.getName());
        if (gluuAttribute == null) {
            continue;
        }
        Client client = authorizationGrant.getClient();
        if (validateRequesteClaim(gluuAttribute, client.getClaims(), scopes)) {
            String ldapClaimName = gluuAttribute.getName();
            Object attribute = authorizationGrant.getUser().getAttribute(ldapClaimName, optional, gluuAttribute.getOxMultiValuedAttribute());
            jwr.getClaims().setClaimFromJsonObject(claim.getName(), attribute);
        }
    }
}
Also used : JwtAuthorizationRequest(io.jans.as.server.model.authorize.JwtAuthorizationRequest) JSONObject(org.json.JSONObject) JwtSubClaimObject(io.jans.as.model.jwt.JwtSubClaimObject) Client(io.jans.as.common.model.registration.Client) Claim(io.jans.as.server.model.authorize.Claim) GluuAttribute(io.jans.model.GluuAttribute)

Aggregations

JwtAuthorizationRequest (io.jans.as.server.model.authorize.JwtAuthorizationRequest)6 Client (io.jans.as.common.model.registration.Client)4 Date (java.util.Date)3 WebApplicationException (javax.ws.rs.WebApplicationException)3 User (io.jans.as.common.model.common.User)2 InvalidJwtException (io.jans.as.model.exception.InvalidJwtException)2 Claim (io.jans.as.server.model.authorize.Claim)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 Response (javax.ws.rs.core.Response)2 JSONObject (org.json.JSONObject)2 JwkClient (io.jans.as.client.JwkClient)1 ECDSAPublicKey (io.jans.as.model.crypto.signature.ECDSAPublicKey)1 RSAPublicKey (io.jans.as.model.crypto.signature.RSAPublicKey)1 SignatureAlgorithm (io.jans.as.model.crypto.signature.SignatureAlgorithm)1 DefaultErrorResponse (io.jans.as.model.error.DefaultErrorResponse)1 InvalidClaimException (io.jans.as.model.exception.InvalidClaimException)1 ECDSASigner (io.jans.as.model.jws.ECDSASigner)1 RSASigner (io.jans.as.model.jws.RSASigner)1 Jwt (io.jans.as.model.jwt.Jwt)1 JwtSubClaimObject (io.jans.as.model.jwt.JwtSubClaimObject)1