use of org.apache.cxf.rs.security.oauth2.common.OAuthRedirectionState in project cxf by apache.
the class AuthorizationCodeGrantService method createGrant.
protected Response createGrant(OAuthRedirectionState state, Client client, List<String> requestedScope, List<String> approvedScope, UserSubject userSubject, ServerAccessToken preauthorizedToken) {
// in this flow the code is still created, the preauthorized token
// will be retrieved by the authorization code grant handler
ServerAuthorizationCodeGrant grant = null;
try {
grant = getGrantRepresentation(state, client, requestedScope, approvedScope, userSubject, preauthorizedToken);
} catch (OAuthServiceException ex) {
return createErrorResponse(state.getState(), state.getRedirectUri(), OAuthConstants.ACCESS_DENIED);
}
String grantCode = processCodeGrant(client, grant.getCode(), grant.getSubject());
if (state.getRedirectUri() == null) {
OOBAuthorizationResponse bean = new OOBAuthorizationResponse();
bean.setClientId(client.getClientId());
bean.setClientDescription(client.getApplicationDescription());
bean.setAuthorizationCode(grantCode);
bean.setUserId(userSubject.getLogin());
bean.setExpiresIn(grant.getExpiresIn());
return deliverOOBResponse(bean);
} else if (isFormResponse(state)) {
FormAuthorizationResponse bean = new FormAuthorizationResponse();
bean.setAuthorizationCode(grantCode);
bean.setExpiresIn(grant.getExpiresIn());
bean.setState(state.getState());
bean.setRedirectUri(state.getRedirectUri());
return createHtmlResponse(bean);
} else {
// return the code by appending it as a query parameter to the redirect URI
UriBuilder ub = getRedirectUriBuilder(state.getState(), state.getRedirectUri());
ub.queryParam(OAuthConstants.AUTHORIZATION_CODE_VALUE, grantCode);
return Response.seeOther(ub.build()).build();
}
}
use of org.apache.cxf.rs.security.oauth2.common.OAuthRedirectionState in project cxf by apache.
the class AuthorizationCodeGrantService method recreateRedirectionStateFromParams.
protected OAuthRedirectionState recreateRedirectionStateFromParams(MultivaluedMap<String, String> params) {
OAuthRedirectionState state = super.recreateRedirectionStateFromParams(params);
setCodeChallenge(state, params);
return state;
}
use of org.apache.cxf.rs.security.oauth2.common.OAuthRedirectionState in project cxf by apache.
the class RedirectionBasedGrantService method recreateRedirectionStateFromParams.
protected OAuthRedirectionState recreateRedirectionStateFromParams(MultivaluedMap<String, String> params) {
OAuthRedirectionState state = new OAuthRedirectionState();
state.setClientId(params.getFirst(OAuthConstants.CLIENT_ID));
state.setRedirectUri(params.getFirst(OAuthConstants.REDIRECT_URI));
state.setAudience(params.getFirst(OAuthConstants.CLIENT_AUDIENCE));
state.setProposedScope(params.getFirst(OAuthConstants.SCOPE));
state.setState(params.getFirst(OAuthConstants.STATE));
state.setNonce(params.getFirst(OAuthConstants.NONCE));
state.setResponseType(params.getFirst(OAuthConstants.RESPONSE_TYPE));
return state;
}
Aggregations