use of io.jans.ca.common.response.GetAuthorizationCodeResponse in project jans by JanssenProject.
the class GetAuthorizationCodeOperation method execute.
@Override
public IOpResponse execute(GetAuthorizationCodeParams params) {
final Rp rp = getRp();
String nonce = Strings.isNullOrEmpty(params.getNonce()) ? UUID.randomUUID().toString() : params.getNonce();
String state = Strings.isNullOrEmpty(params.getState()) ? UUID.randomUUID().toString() : params.getState();
final AuthorizationRequest request = new AuthorizationRequest(responseTypes(rp.getResponseTypes()), rp.getClientId(), rp.getScope(), rp.getRedirectUri(), nonce);
request.setState(state);
request.setAuthUsername(params.getUsername());
request.setAuthPassword(params.getPassword());
request.getPrompts().add(Prompt.NONE);
request.setAcrValues(acrValues(params, rp));
getStateService().putNonce(nonce);
getStateService().putState(state);
final AuthorizeClient authorizeClient = getOpClientFactory().createAuthorizeClient(getDiscoveryService().getConnectDiscoveryResponse(rp).getAuthorizationEndpoint());
authorizeClient.setRequest(request);
authorizeClient.setExecutor(getHttpService().getClientEngine());
final AuthorizationResponse response = authorizeClient.exec();
if (response != null) {
if (!getStateService().isExpiredObjectPresent(params.getState())) {
getStateService().putState(params.getState());
}
return new GetAuthorizationCodeResponse(response.getCode());
} else {
LOG.error("Failed to get response from oxauth client.");
}
return null;
}
Aggregations