@Test public void buildAuthRequestUrl() { String requestUri = urlBuilder.buildAuthRequestUrl(serverConfig, clientConfig, redirectUri, nonce, state, options); UriComponentsBuilder builder = null; try { builder = UriComponentsBuilder.fromUri(new URI(requestUri)); } catch (URISyntaxException e1) { fail("URISyntaxException was thrown."); } UriComponents components = builder.build(); String jwtString = components.getQueryParams().get("request").get(0); ReadOnlyJWTClaimsSet claims = null; try { SignedJWT jwt = SignedJWT.parse(jwtString); claims = jwt.getJWTClaimsSet(); } catch (ParseException e) { fail("ParseException was thrown."); } assertEquals(responseType, claims.getClaim("response_type")); assertEquals(clientConfig.getClientId(), claims.getClaim("client_id")); List<String> scopeList = Arrays.asList(((String) claims.getClaim("scope")).split(" ")); assertTrue(scopeList.containsAll(clientConfig.getScope())); assertEquals(redirectUri, claims.getClaim("redirect_uri")); assertEquals(nonce, claims.getClaim("nonce")); assertEquals(state, claims.getClaim("state")); for (String claim : options.keySet()) { assertEquals(options.get(claim), claims.getClaim(claim)); } }
@Override public String buildAuthRequestUrl(ServerConfiguration serverConfig, RegisteredClient clientConfig, String redirectUri, String nonce, String state, Map<String, String> options) { JWTClaimsSet claims = new JWTClaimsSet(); claims.setClaim("response_type", "code"); claims.setClaim("client_id", clientConfig.getClientId()); claims.setClaim("scope", Joiner.on(" ").join(clientConfig.getScope())); claims.setClaim("redirect_uri", redirectUri); claims.setClaim("nonce", nonce); claims.setClaim("state", state); for (Entry<String, String> option : options.entrySet()) { claims.setClaim(option.getKey(), option.getValue()); } SignedJWT jwt = new SignedJWT(new JWSHeader(signingAndValidationService.getDefaultSigningAlgorithm()), claims); signingAndValidationService.signJwt(jwt); try { URIBuilder uriBuilder = new URIBuilder(serverConfig.getAuthorizationEndpointUri()); uriBuilder.addParameter("request", jwt.serialize()); return uriBuilder.build().toString(); } catch (URISyntaxException e) { throw new AuthenticationServiceException("Malformed Authorization Endpoint Uri", e); } }
SignedAuthRequestUrlBuilder implements AuthRequestUrlBuilder { @Override public String buildAuthRequestUrl(ServerConfiguration serverConfig, RegisteredClient clientConfig, String redirectUri, String nonce, String state, Map<String, String> options) { JWTClaimsSet claims = new JWTClaimsSet(); claims.setClaim("response_type", "code"); claims.setClaim("client_id", clientConfig.getClientId()); claims.setClaim("scope", Joiner.on(" ").join(clientConfig.getScope())); claims.setClaim("redirect_uri", redirectUri); claims.setClaim("nonce", nonce); claims.setClaim("state", state); for (Entry<String, String> option : options.entrySet()) { claims.setClaim(option.getKey(), option.getValue()); } SignedJWT jwt = new SignedJWT(new JWSHeader(signingAndValidationService.getDefaultSigningAlgorithm()), claims); signingAndValidationService.signJwt(jwt); try { URIBuilder uriBuilder = new URIBuilder(serverConfig.getAuthorizationEndpointUri()); uriBuilder.addParameter("request", jwt.serialize()); return uriBuilder.build().toString(); } catch (URISyntaxException e) { throw new AuthenticationServiceException("Malformed Authorization Endpoint Uri", e); } } }
SignedAuthRequestUrlBuilder implements AuthRequestUrlBuilder { @Override public String buildAuthRequestUrl(ServerConfiguration serverConfig, RegisteredClient clientConfig, String redirectUri, String nonce, String state, Map<String, String> options) { JWTClaimsSet claims = new JWTClaimsSet(); claims.setClaim("response_type", "code"); claims.setClaim("client_id", clientConfig.getClientId()); claims.setClaim("scope", Joiner.on(" ").join(clientConfig.getScope())); claims.setClaim("redirect_uri", redirectUri); claims.setClaim("nonce", nonce); claims.setClaim("state", state); for (Entry<String, String> option : options.entrySet()) { claims.setClaim(option.getKey(), option.getValue()); } SignedJWT jwt = new SignedJWT(new JWSHeader(signingAndValidationService.getDefaultSigningAlgorithm()), claims); signingAndValidationService.signJwt(jwt); try { URIBuilder uriBuilder = new URIBuilder(serverConfig.getAuthorizationEndpointUri()); uriBuilder.addParameter("request", jwt.serialize()); return uriBuilder.build().toString(); } catch (URISyntaxException e) { throw new AuthenticationServiceException("Malformed Authorization Endpoint Uri", e); } }  }
SignedAuthRequestUrlBuilder implements AuthRequestUrlBuilder { @Override public String buildAuthRequestUrl(ServerConfiguration serverConfig, RegisteredClient clientConfig, String redirectUri, String nonce, String state, Map<String, String> options) { JWTClaimsSet claims = new JWTClaimsSet(); claims.setClaim("response_type", "code"); claims.setClaim("client_id", clientConfig.getClientId()); claims.setClaim("scope", Joiner.on(" ").join(clientConfig.getScope())); claims.setClaim("redirect_uri", redirectUri); claims.setClaim("nonce", nonce); claims.setClaim("state", state); for (Entry<String, String> option : options.entrySet()) { claims.setClaim(option.getKey(), option.getValue()); } SignedJWT jwt = new SignedJWT(new JWSHeader(signingAndValidationService.getDefaultSigningAlgorithm()), claims); signingAndValidationService.signJwt(jwt); try { URIBuilder uriBuilder = new URIBuilder(serverConfig.getAuthorizationEndpointUri()); uriBuilder.addParameter("request", jwt.serialize()); return uriBuilder.build().toString(); } catch (URISyntaxException e) { throw new AuthenticationServiceException("Malformed Authorization Endpoint Uri", e); } }  @Override String buildAuthRequestUrl(ServerConfiguration serverConfig, RegisteredClient clientConfig, String redirectUri, String nonce, String state, Map<String, String> options); JwtSigningAndValidationService getSigningAndValidationService(); void setSigningAndValidationService(JwtSigningAndValidationService signingAndValidationService); }
SignedAuthRequestUrlBuilder implements AuthRequestUrlBuilder { @Override public String buildAuthRequestUrl(ServerConfiguration serverConfig, RegisteredClient clientConfig, String redirectUri, String nonce, String state, Map<String, String> options) { JWTClaimsSet claims = new JWTClaimsSet(); claims.setClaim("response_type", "code"); claims.setClaim("client_id", clientConfig.getClientId()); claims.setClaim("scope", Joiner.on(" ").join(clientConfig.getScope())); claims.setClaim("redirect_uri", redirectUri); claims.setClaim("nonce", nonce); claims.setClaim("state", state); for (Entry<String, String> option : options.entrySet()) { claims.setClaim(option.getKey(), option.getValue()); } SignedJWT jwt = new SignedJWT(new JWSHeader(signingAndValidationService.getDefaultSigningAlgorithm()), claims); signingAndValidationService.signJwt(jwt); try { URIBuilder uriBuilder = new URIBuilder(serverConfig.getAuthorizationEndpointUri()); uriBuilder.addParameter("request", jwt.serialize()); return uriBuilder.build().toString(); } catch (URISyntaxException e) { throw new AuthenticationServiceException("Malformed Authorization Endpoint Uri", e); } }  @Override String buildAuthRequestUrl(ServerConfiguration serverConfig, RegisteredClient clientConfig, String redirectUri, String nonce, String state, Map<String, String> options); JwtSigningAndValidationService getSigningAndValidationService(); void setSigningAndValidationService(JwtSigningAndValidationService signingAndValidationService);  }