@Test public void buildAuthRequestUrl_withLoginHint() { String expectedUrl = "https: "response_type=code" + "&client_id=s6BhdRkqt3" + "&scope=openid+profile" + "&redirect_uri=https%3A%2F%2Fclient.example.org%2F" + "&nonce=34fasf3ds" + "&state=af0ifjsldkj" + "&foo=bar" + "&login_hint=bob"; Map<String, String> options = ImmutableMap.of("foo", "bar"); String actualUrl = urlBuilder.buildAuthRequestUrl(serverConfig, clientConfig, "https: assertThat(actualUrl, equalTo(expectedUrl)); }
@Override public String buildAuthRequestUrl(ServerConfiguration serverConfig, RegisteredClient clientConfig, String redirectUri, String nonce, String state, Map<String, String> options, String loginHint) { try { URIBuilder uriBuilder = new URIBuilder(serverConfig.getAuthorizationEndpointUri()); uriBuilder.addParameter("response_type", "code"); uriBuilder.addParameter("client_id", clientConfig.getClientId()); uriBuilder.addParameter("scope", Joiner.on(" ").join(clientConfig.getScope())); uriBuilder.addParameter("redirect_uri", redirectUri); uriBuilder.addParameter("nonce", nonce); uriBuilder.addParameter("state", state); for (Entry<String, String> option : options.entrySet()) { uriBuilder.addParameter(option.getKey(), option.getValue()); } if (!Strings.isNullOrEmpty(loginHint)) { uriBuilder.addParameter("login_hint", loginHint); } return uriBuilder.build().toString(); } catch (URISyntaxException e) { throw new AuthenticationServiceException("Malformed Authorization Endpoint Uri", e); } }
PlainAuthRequestUrlBuilder implements AuthRequestUrlBuilder { @Override public String buildAuthRequestUrl(ServerConfiguration serverConfig, RegisteredClient clientConfig, String redirectUri, String nonce, String state, Map<String, String> options, String loginHint) { try { URIBuilder uriBuilder = new URIBuilder(serverConfig.getAuthorizationEndpointUri()); uriBuilder.addParameter("response_type", "code"); uriBuilder.addParameter("client_id", clientConfig.getClientId()); uriBuilder.addParameter("scope", Joiner.on(" ").join(clientConfig.getScope())); uriBuilder.addParameter("redirect_uri", redirectUri); uriBuilder.addParameter("nonce", nonce); uriBuilder.addParameter("state", state); for (Entry<String, String> option : options.entrySet()) { uriBuilder.addParameter(option.getKey(), option.getValue()); } if (!Strings.isNullOrEmpty(loginHint)) { uriBuilder.addParameter("login_hint", loginHint); } return uriBuilder.build().toString(); } catch (URISyntaxException e) { throw new AuthenticationServiceException("Malformed Authorization Endpoint Uri", e); } } }
PlainAuthRequestUrlBuilder implements AuthRequestUrlBuilder { @Override public String buildAuthRequestUrl(ServerConfiguration serverConfig, RegisteredClient clientConfig, String redirectUri, String nonce, String state, Map<String, String> options, String loginHint) { try { URIBuilder uriBuilder = new URIBuilder(serverConfig.getAuthorizationEndpointUri()); uriBuilder.addParameter("response_type", "code"); uriBuilder.addParameter("client_id", clientConfig.getClientId()); uriBuilder.addParameter("scope", Joiner.on(" ").join(clientConfig.getScope())); uriBuilder.addParameter("redirect_uri", redirectUri); uriBuilder.addParameter("nonce", nonce); uriBuilder.addParameter("state", state); for (Entry<String, String> option : options.entrySet()) { uriBuilder.addParameter(option.getKey(), option.getValue()); } if (!Strings.isNullOrEmpty(loginHint)) { uriBuilder.addParameter("login_hint", loginHint); } return uriBuilder.build().toString(); } catch (URISyntaxException e) { throw new AuthenticationServiceException("Malformed Authorization Endpoint Uri", e); } }  }
PlainAuthRequestUrlBuilder implements AuthRequestUrlBuilder { @Override public String buildAuthRequestUrl(ServerConfiguration serverConfig, RegisteredClient clientConfig, String redirectUri, String nonce, String state, Map<String, String> options, String loginHint) { try { URIBuilder uriBuilder = new URIBuilder(serverConfig.getAuthorizationEndpointUri()); uriBuilder.addParameter("response_type", "code"); uriBuilder.addParameter("client_id", clientConfig.getClientId()); uriBuilder.addParameter("scope", Joiner.on(" ").join(clientConfig.getScope())); uriBuilder.addParameter("redirect_uri", redirectUri); uriBuilder.addParameter("nonce", nonce); uriBuilder.addParameter("state", state); for (Entry<String, String> option : options.entrySet()) { uriBuilder.addParameter(option.getKey(), option.getValue()); } if (!Strings.isNullOrEmpty(loginHint)) { uriBuilder.addParameter("login_hint", loginHint); } 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); }
PlainAuthRequestUrlBuilder implements AuthRequestUrlBuilder { @Override public String buildAuthRequestUrl(ServerConfiguration serverConfig, RegisteredClient clientConfig, String redirectUri, String nonce, String state, Map<String, String> options, String loginHint) { try { URIBuilder uriBuilder = new URIBuilder(serverConfig.getAuthorizationEndpointUri()); uriBuilder.addParameter("response_type", "code"); uriBuilder.addParameter("client_id", clientConfig.getClientId()); uriBuilder.addParameter("scope", Joiner.on(" ").join(clientConfig.getScope())); uriBuilder.addParameter("redirect_uri", redirectUri); uriBuilder.addParameter("nonce", nonce); uriBuilder.addParameter("state", state); for (Entry<String, String> option : options.entrySet()) { uriBuilder.addParameter(option.getKey(), option.getValue()); } if (!Strings.isNullOrEmpty(loginHint)) { uriBuilder.addParameter("login_hint", loginHint); } 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);  }