Search in sources :

Example 1 with GetAuthorizationCodeResponse

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;
}
Also used : AuthorizationRequest(io.jans.as.client.AuthorizationRequest) GetAuthorizationCodeResponse(io.jans.ca.common.response.GetAuthorizationCodeResponse) AuthorizeClient(io.jans.as.client.AuthorizeClient) Rp(io.jans.ca.server.service.Rp) AuthorizationResponse(io.jans.as.client.AuthorizationResponse)

Aggregations

AuthorizationRequest (io.jans.as.client.AuthorizationRequest)1 AuthorizationResponse (io.jans.as.client.AuthorizationResponse)1 AuthorizeClient (io.jans.as.client.AuthorizeClient)1 GetAuthorizationCodeResponse (io.jans.ca.common.response.GetAuthorizationCodeResponse)1 Rp (io.jans.ca.server.service.Rp)1