@Test(expected = AuthenticationServiceException.class) public void buildAuthRequestUrl_badUri() { Mockito.when(serverConfig.getAuthorizationEndpointUri()).thenReturn("e=mc^2"); urlBuilder.buildAuthRequestUrl(serverConfig, clientConfig, "example.com", "", "", options, null); }
@Override public String buildAuthRequestUrl(ServerConfiguration serverConfig, RegisteredClient clientConfig, String redirectUri, String nonce, String state, Map<String, String> options, String loginHint) { JWTClaimsSet.Builder claims = new JWTClaimsSet.Builder(); claims.claim("response_type", "code"); claims.claim("client_id", clientConfig.getClientId()); claims.claim("scope", Joiner.on(" ").join(clientConfig.getScope())); claims.claim("redirect_uri", redirectUri); claims.claim("nonce", nonce); claims.claim("state", state); for (Entry<String, String> option : options.entrySet()) { claims.claim(option.getKey(), option.getValue()); } if (!Strings.isNullOrEmpty(loginHint)) { claims.claim("login_hint", loginHint); } JWSAlgorithm alg = clientConfig.getRequestObjectSigningAlg(); if (alg == null) { alg = signingAndValidationService.getDefaultSigningAlgorithm(); } SignedJWT jwt = new SignedJWT(new JWSHeader(alg), claims.build()); signingAndValidationService.signJwt(jwt, alg); 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, String loginHint) { JWTClaimsSet.Builder claims = new JWTClaimsSet.Builder(); claims.claim("response_type", "code"); claims.claim("client_id", clientConfig.getClientId()); claims.claim("scope", Joiner.on(" ").join(clientConfig.getScope())); claims.claim("redirect_uri", redirectUri); claims.claim("nonce", nonce); claims.claim("state", state); for (Entry<String, String> option : options.entrySet()) { claims.claim(option.getKey(), option.getValue()); } if (!Strings.isNullOrEmpty(loginHint)) { claims.claim("login_hint", loginHint); } JWSAlgorithm alg = clientConfig.getRequestObjectSigningAlg(); if (alg == null) { alg = signingAndValidationService.getDefaultSigningAlgorithm(); } SignedJWT jwt = new SignedJWT(new JWSHeader(alg), claims.build()); signingAndValidationService.signJwt(jwt, alg); 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, String loginHint) { JWTClaimsSet.Builder claims = new JWTClaimsSet.Builder(); claims.claim("response_type", "code"); claims.claim("client_id", clientConfig.getClientId()); claims.claim("scope", Joiner.on(" ").join(clientConfig.getScope())); claims.claim("redirect_uri", redirectUri); claims.claim("nonce", nonce); claims.claim("state", state); for (Entry<String, String> option : options.entrySet()) { claims.claim(option.getKey(), option.getValue()); } if (!Strings.isNullOrEmpty(loginHint)) { claims.claim("login_hint", loginHint); } JWSAlgorithm alg = clientConfig.getRequestObjectSigningAlg(); if (alg == null) { alg = signingAndValidationService.getDefaultSigningAlgorithm(); } SignedJWT jwt = new SignedJWT(new JWSHeader(alg), claims.build()); signingAndValidationService.signJwt(jwt, alg); 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, String loginHint) { JWTClaimsSet.Builder claims = new JWTClaimsSet.Builder(); claims.claim("response_type", "code"); claims.claim("client_id", clientConfig.getClientId()); claims.claim("scope", Joiner.on(" ").join(clientConfig.getScope())); claims.claim("redirect_uri", redirectUri); claims.claim("nonce", nonce); claims.claim("state", state); for (Entry<String, String> option : options.entrySet()) { claims.claim(option.getKey(), option.getValue()); } if (!Strings.isNullOrEmpty(loginHint)) { claims.claim("login_hint", loginHint); } JWSAlgorithm alg = clientConfig.getRequestObjectSigningAlg(); if (alg == null) { alg = signingAndValidationService.getDefaultSigningAlgorithm(); } SignedJWT jwt = new SignedJWT(new JWSHeader(alg), claims.build()); signingAndValidationService.signJwt(jwt, alg); 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, String loginHint); 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, String loginHint) { JWTClaimsSet.Builder claims = new JWTClaimsSet.Builder(); claims.claim("response_type", "code"); claims.claim("client_id", clientConfig.getClientId()); claims.claim("scope", Joiner.on(" ").join(clientConfig.getScope())); claims.claim("redirect_uri", redirectUri); claims.claim("nonce", nonce); claims.claim("state", state); for (Entry<String, String> option : options.entrySet()) { claims.claim(option.getKey(), option.getValue()); } if (!Strings.isNullOrEmpty(loginHint)) { claims.claim("login_hint", loginHint); } JWSAlgorithm alg = clientConfig.getRequestObjectSigningAlg(); if (alg == null) { alg = signingAndValidationService.getDefaultSigningAlgorithm(); } SignedJWT jwt = new SignedJWT(new JWSHeader(alg), claims.build()); signingAndValidationService.signJwt(jwt, alg); 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, String loginHint); JWTSigningAndValidationService getSigningAndValidationService(); void setSigningAndValidationService(JWTSigningAndValidationService signingAndValidationService);  }