Search in sources :

Example 1 with ClaimsParameter

use of com.predic8.membrane.core.interceptor.oauth2.parameter.ClaimsParameter in project service-proxy by membrane.

the class IdTokenTokenFlow method getValidIdTokenClaims.

private JwtGenerator.Claim[] getValidIdTokenClaims() {
    ClaimsParameter cp = new ClaimsParameter(authServer.getClaimList().getSupportedClaims(), session.getUserAttributes().get(ParamNames.CLAIMS));
    ArrayList<JwtGenerator.Claim> claims = new ArrayList<JwtGenerator.Claim>();
    if (cp.hasClaims()) {
        for (String claim : cp.getIdTokenClaims()) claims.add(new JwtGenerator.Claim(claim, session.getUserAttributes().get(ClaimRenamer.convert(claim))));
    }
    return claims.toArray(new JwtGenerator.Claim[0]);
}
Also used : JwtGenerator(com.predic8.membrane.core.interceptor.oauth2.tokengenerators.JwtGenerator) ArrayList(java.util.ArrayList) ClaimsParameter(com.predic8.membrane.core.interceptor.oauth2.parameter.ClaimsParameter)

Example 2 with ClaimsParameter

use of com.predic8.membrane.core.interceptor.oauth2.parameter.ClaimsParameter in project service-proxy by membrane.

the class ClaimsParameterTest method testValidParsing.

@Test
public void testValidParsing() throws Exception {
    cp = new ClaimsParameter(createSupportedClaims("email", "sub"), OAuth2TestUtil.getMockClaims());
    assertEquals(OAuth2TestUtil.getMockClaims(), cp.toJson());
}
Also used : ClaimsParameter(com.predic8.membrane.core.interceptor.oauth2.parameter.ClaimsParameter) Test(org.junit.Test)

Example 3 with ClaimsParameter

use of com.predic8.membrane.core.interceptor.oauth2.parameter.ClaimsParameter in project service-proxy by membrane.

the class ClaimsParameterTest method testParsingNoUserinfo.

@Test
public void testParsingNoUserinfo() throws Exception {
    cp = new ClaimsParameter(createSupportedClaims("sub"), OAuth2TestUtil.getMockClaims());
    assertEquals(getMockClaimsIdToken(), cp.toJson());
}
Also used : ClaimsParameter(com.predic8.membrane.core.interceptor.oauth2.parameter.ClaimsParameter) Test(org.junit.Test)

Example 4 with ClaimsParameter

use of com.predic8.membrane.core.interceptor.oauth2.parameter.ClaimsParameter in project service-proxy by membrane.

the class AuthorizationCodeFlow method getValidIdTokenClaims.

private JwtGenerator.Claim[] getValidIdTokenClaims(SessionManager.Session session) {
    ClaimsParameter cp = new ClaimsParameter(authServer.getClaimList().getSupportedClaims(), session.getUserAttributes().get(ParamNames.CLAIMS));
    ArrayList<JwtGenerator.Claim> claims = new ArrayList<JwtGenerator.Claim>();
    if (cp.hasClaims()) {
        for (String claim : cp.getIdTokenClaims()) claims.add(new JwtGenerator.Claim(claim, session.getUserAttributes().get(ClaimRenamer.convert(claim))));
    }
    return claims.toArray(new JwtGenerator.Claim[0]);
}
Also used : JwtGenerator(com.predic8.membrane.core.interceptor.oauth2.tokengenerators.JwtGenerator) ArrayList(java.util.ArrayList) ClaimsParameter(com.predic8.membrane.core.interceptor.oauth2.parameter.ClaimsParameter)

Example 5 with ClaimsParameter

use of com.predic8.membrane.core.interceptor.oauth2.parameter.ClaimsParameter in project service-proxy by membrane.

the class EmptyEndpointProcessor method processClaimsParameterToClaimsString.

private String[] processClaimsParameterToClaimsString(String claimsParam) {
    ClaimsParameter cp = new ClaimsParameter(authServer.getClaimList().getSupportedClaims(), claimsParam);
    StringBuilder builder = new StringBuilder();
    HashSet<String> userinfo = cp.getUserinfoClaims();
    for (String claim : userinfo) builder.append(" ").append(claim);
    HashSet<String> idToken = cp.getIdTokenClaims();
    for (String claim : idToken) builder.append(" ").append(claim);
    return builder.toString().trim().split(" ");
}
Also used : ClaimsParameter(com.predic8.membrane.core.interceptor.oauth2.parameter.ClaimsParameter)

Aggregations

ClaimsParameter (com.predic8.membrane.core.interceptor.oauth2.parameter.ClaimsParameter)6 Test (org.junit.Test)3 JwtGenerator (com.predic8.membrane.core.interceptor.oauth2.tokengenerators.JwtGenerator)2 ArrayList (java.util.ArrayList)2