@Override
public AuthorizationRequest createAuthorizationRequest(Map<String, String> inputParams) {
AuthorizationRequest request = new AuthorizationRequest(inputParams, Collections.<String, String> emptyMap(),
inputParams.get(OAuth2Utils.CLIENT_ID),
OAuth2Utils.parseParameterList(inputParams.get(OAuth2Utils.SCOPE)), null,
null, false, inputParams.get(OAuth2Utils.STATE),
inputParams.get(OAuth2Utils.REDIRECT_URI),
OAuth2Utils.parseParameterList(inputParams.get(OAuth2Utils.RESPONSE_TYPE)));
//Add extension parameters to the 'extensions' map
if (inputParams.containsKey("prompt")) {
request.getExtensions().put("prompt", inputParams.get("prompt"));
}
if (inputParams.containsKey("nonce")) {
request.getExtensions().put("nonce", inputParams.get("nonce"));
}
if (inputParams.containsKey("claims")) {
JsonObject claimsRequest = parseClaimRequest(inputParams.get("claims"));
if (claimsRequest != null) {
request.getExtensions().put("claims", claimsRequest.toString());
}
}
if (inputParams.containsKey("max_age")) {
request.getExtensions().put("max_age", inputParams.get("max_age"));
}
if (inputParams.containsKey("request")) {
request.getExtensions().put("request", inputParams.get("request"));
processRequestObject(inputParams.get("request"), request);
}
if (request.getClientId() != null) {
try {
ClientDetailsEntity client = clientDetailsService.loadClientByClientId(request.getClientId());
if ((request.getScope() == null || request.getScope().isEmpty())) {
Set<String> clientScopes = client.getScope();
request.setScope(clientScopes);
}
if (request.getExtensions().get("max_age") == null && client.getDefaultMaxAge() != null) {
request.getExtensions().put("max_age", client.getDefaultMaxAge().toString());
}
} catch (OAuth2Exception e) {
logger.error("Caught OAuth2 exception trying to test client scopes and max age:", e);
}
}
// add CSRF protection to the request on first parse
String csrf = UUID.randomUUID().toString();
request.getExtensions().put("csrf", csrf);
return request;
}