use of org.apache.cxf.rs.security.oauth2.grants.code.AuthorizationCodeGrant in project cxf by apache.
the class ClientCodeRequestFilter method prepareCodeGrant.
private AuthorizationCodeGrant prepareCodeGrant(String codeParam, URI absoluteRedirectUri) {
if (codeRequestJoseProducer == null) {
return new AuthorizationCodeGrant(codeParam, absoluteRedirectUri);
}
JwtRequestCodeGrant grant = new JwtRequestCodeGrant(codeParam, absoluteRedirectUri, consumer.getClientId());
grant.setClientSecret(consumer.getClientSecret());
grant.setJoseProducer(codeRequestJoseProducer);
return grant;
}
use of org.apache.cxf.rs.security.oauth2.grants.code.AuthorizationCodeGrant in project cxf by apache.
the class CodeAuthSupplier method getAuthorization.
public String getAuthorization(AuthorizationPolicy authPolicy, URI currentURI, Message message, String fullHeader) {
if (code != null) {
synchronized (tokenSupplier) {
if (tokenSupplier.getClientAccessToken().getTokenKey() == null) {
WebClient wc = tokenSupplier.createAccessTokenServiceClient();
ClientAccessToken at = OAuthClientUtils.getAccessToken(wc, tokenSupplier.getConsumer(), new AuthorizationCodeGrant(code));
code = null;
tokenSupplier.setClientAccessToken(at);
}
}
}
return tokenSupplier.getAuthorization(authPolicy, currentURI, message, fullHeader);
}
use of org.apache.cxf.rs.security.oauth2.grants.code.AuthorizationCodeGrant in project cxf by apache.
the class ClientCodeRequestFilter method processCodeResponse.
protected void processCodeResponse(ContainerRequestContext rc, UriInfo ui, MultivaluedMap<String, String> requestParams) {
MultivaluedMap<String, String> state = null;
if (clientStateManager != null) {
state = clientStateManager.fromRedirectState(mc, requestParams);
}
String codeParam = requestParams.getFirst(OAuthConstants.AUTHORIZATION_CODE_VALUE);
ClientAccessToken at = null;
if (codeParam != null) {
AuthorizationCodeGrant grant = prepareCodeGrant(codeParam, getAbsoluteRedirectUri(ui));
if (state != null) {
grant.setCodeVerifier(state.getFirst(OAuthConstants.AUTHORIZATION_CODE_VERIFIER));
}
at = OAuthClientUtils.getAccessToken(accessTokenServiceClient, consumer, grant, useAuthorizationHeader);
}
ClientTokenContext tokenContext = initializeClientTokenContext(rc, at, requestParams, state);
if (at != null && clientTokenContextManager != null) {
clientTokenContextManager.setClientTokenContext(mc, tokenContext);
}
setClientCodeRequest(tokenContext);
}
Aggregations