@Test(expected = AuthenticationServiceException.class) public void buildAuthRequestUrl_badUri() { Mockito.when(serverConfig.getAuthorizationEndpointUri()).thenReturn("e=mc^2"); urlBuilder.buildAuthRequestUrl(serverConfig, clientConfig, "example.com", "", "", options); }
@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);  }