use of org.mule.runtime.oauth.api.state.ResourceOwnerOAuthContext in project mule by mulesoft.
the class DefaultExtensionsOAuthManager method getOAuthContext.
/**
* {@inheritDoc}
*/
@Override
public Optional<ResourceOwnerOAuthContext> getOAuthContext(OAuthConfig config) {
AuthorizationCodeOAuthDancer dancer = dancers.get(config.getOwnerConfigName());
if (dancer == null) {
return empty();
}
ResourceOwnerOAuthContext contextForResourceOwner = dancer.getContextForResourceOwner(config.getAuthCodeConfig().getResourceOwnerId());
if (contextForResourceOwner == null || contextForResourceOwner.getAccessToken() == null) {
return empty();
}
return of(contextForResourceOwner);
}
use of org.mule.runtime.oauth.api.state.ResourceOwnerOAuthContext in project mule by mulesoft.
the class OAuthConnectionProviderWrapper method updateAuthState.
public void updateAuthState() {
ResourceOwnerOAuthContext context = getContext();
final ConnectionProvider<C> delegate = getDelegate();
authCodeStateSetter.set(delegate, toAuthorizationCodeState(oauthConfig, context));
Map<String, Object> responseParameters = context.getTokenResponseParameters();
callbackValues.keySet().forEach(field -> {
String key = field.getName();
if (responseParameters.containsKey(key)) {
new FieldSetter<>(field).set(delegate, responseParameters.get(key));
}
});
}
Aggregations