@Override
	public String buildAuthRequestUrl(ServerConfiguration serverConfig, RegisteredClient clientConfig, String redirectUri, String nonce, String state, Map<String, String> options, String loginHint) {

		// create our signed JWT for the request object
		JWTClaimsSet.Builder claims = new JWTClaimsSet.Builder();

		//set parameters to JwtClaims
		claims.claim("response_type", "code");
		claims.claim("client_id", clientConfig.getClientId());
		claims.claim("scope", Joiner.on(" ").join(clientConfig.getScope()));

		// build our redirect URI
		claims.claim("redirect_uri", redirectUri);

		// this comes back in the id token
		claims.claim("nonce", nonce);

		// this comes back in the auth request return
		claims.claim("state", state);

		// Optional parameters
		for (Entry<String, String> option : options.entrySet()) {
			claims.claim(option.getKey(), option.getValue());
		}

		// if there's a login hint, send it
		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());

			// build out the URI
			return uriBuilder.build().toString();
		} catch (URISyntaxException e) {
			throw new AuthenticationServiceException("Malformed Authorization Endpoint Uri", e);
		}
	}
@Test
	public void buildAuthRequestUrl() {

		String requestUri = urlBuilder.buildAuthRequestUrl(serverConfig, clientConfig, redirectUri, nonce, state, options, null);

		// parsing the result
		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);
		JWTClaimsSet 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));
		}
	}