use of com.nimbusds.openid.connect.sdk.ClaimsRequest in project OpenConext-oidcng by OpenConext.
the class JWTRequestTest method fullBlown.
@Test
public void fullBlown() throws Exception {
OpenIDClient client = getClient();
setCertificateFields(client, getStrippedCertificate(), null, null);
String keyID = getCertificateKeyID(client);
SignedJWT signedJWT = signedJWT(client.getClientId(), keyID, client.getRedirectUrls().get(0));
ClaimsRequest claimsRequest = new ClaimsRequest();
claimsRequest.addIDTokenClaim("email");
List<LangTag> langTags = Collections.singletonList(new LangTag("en"));
List<ACR> acrValues = Collections.singletonList(new ACR("loa"));
AuthenticationRequest authenticationRequest = new AuthenticationRequest(new URI("http://localhost/authorize"), ResponseType.getDefault(), ResponseMode.FRAGMENT, new Scope("openid"), new ClientID(client.getClientId()), new URI(client.getRedirectUrls().get(0)), new State("state"), new Nonce("nonce"), Display.getDefault(), Prompt.parse("consent"), 1200, langTags, langTags, null, "hint", acrValues, claimsRequest, "purpose", signedJWT, null, CodeChallenge.compute(CodeChallengeMethod.S256, new CodeVerifier()), CodeChallengeMethod.S256, Collections.singletonList(new URI("http://localhost")), true, Collections.singletonMap("custom", Collections.singletonList("value")));
authenticationRequest = JWTRequest.parse(authenticationRequest, client);
assertEquals("login", authenticationRequest.getPrompt().toString());
}
use of com.nimbusds.openid.connect.sdk.ClaimsRequest in project OpenConext-oidcng by OpenConext.
the class OidcEndpoint method getClaims.
default List<String> getClaims(AuthorizationRequest authorizationRequest) {
List<String> idTokenClaims = new ArrayList<>();
if (isOpenIDRequest(authorizationRequest)) {
AuthenticationRequest authenticationRequest = (AuthenticationRequest) authorizationRequest;
ClaimsRequest claimsRequest = authenticationRequest.getClaims();
if (claimsRequest != null) {
idTokenClaims.addAll(claimsRequest.getIDTokenClaims().stream().map(entry -> entry.getClaimName()).collect(Collectors.toList()));
}
}
return idTokenClaims;
}
use of com.nimbusds.openid.connect.sdk.ClaimsRequest in project OpenConext-oidcng by OpenConext.
the class SignedJWTTest method getJwtClaimsSet.
default JWTClaimsSet getJwtClaimsSet(String clientId, String redirectURI) {
Instant instant = Clock.systemDefaultZone().instant();
ClaimsRequest claimsRequest = new ClaimsRequest();
claimsRequest.addIDTokenClaim("email");
JWTClaimsSet.Builder builder = new JWTClaimsSet.Builder().audience("audience").expirationTime(Date.from(instant.plus(3600, ChronoUnit.SECONDS))).jwtID(UUID.randomUUID().toString()).issuer(clientId).issueTime(Date.from(instant)).subject(clientId).notBeforeTime(new Date(System.currentTimeMillis())).claim("redirect_uri", redirectURI).claim("scope", "openid groups").claim("nonce", "123456").claim("state", "new").claim("prompt", "login").claim("claims", claimsRequest.toString()).claim("acr_values", "loa1 loa2 loa3");
JWTClaimsSet claimsSet = builder.build();
return claimsSet;
}
use of com.nimbusds.openid.connect.sdk.ClaimsRequest in project OpenConext-oidcng by OpenConext.
the class AbstractIntegrationTest method doAuthorizeQueryParameters.
protected Response doAuthorizeQueryParameters(String clientId, String responseType, String responseMode, String nonce, String codeChallenge, List<String> claims, String scopes, String state, String codeChallengeMethod, JWT signedJWT, String requestURL) throws IOException {
Map<String, String> queryParams = new HashMap<>();
queryParams.put("scope", scopes);
queryParams.put("response_type", responseType);
queryParams.put("client_id", clientId);
if (StringUtils.hasText(clientId)) {
queryParams.put("redirect_uri", openIDClient(clientId).getRedirectUrls().get(0));
}
queryParams.put("state", state);
if (StringUtils.hasText(responseMode)) {
queryParams.put("response_mode", responseMode);
}
if (StringUtils.hasText(nonce)) {
queryParams.put("nonce", nonce);
}
if (StringUtils.hasText(codeChallenge)) {
queryParams.put("code_challenge", codeChallenge);
queryParams.put("code_challenge_method", codeChallengeMethod);
}
if (!CollectionUtils.isEmpty(claims)) {
ClaimsRequest claimsRequest = new ClaimsRequest();
claims.forEach(claim -> claimsRequest.addIDTokenClaim(claim));
String claimsRequestString = claimsRequest.toString();
queryParams.put("claims", claimsRequestString);
}
if (signedJWT != null) {
queryParams.put("request", signedJWT.serialize());
}
if (StringUtils.hasText(requestURL)) {
queryParams.put("request_uri", requestURL);
}
Response response = given().redirects().follow(false).when().header("Content-type", "application/json").queryParams(queryParams).get("oidc/authorize");
return response;
}
Aggregations