Search in sources :

Example 1 with ResourceOwnerOAuthContext

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);
}
Also used : AuthorizationCodeOAuthDancer(org.mule.runtime.oauth.api.AuthorizationCodeOAuthDancer) ResourceOwnerOAuthContext(org.mule.runtime.oauth.api.state.ResourceOwnerOAuthContext)

Example 2 with ResourceOwnerOAuthContext

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));
        }
    });
}
Also used : ResourceOwnerOAuthContext(org.mule.runtime.oauth.api.state.ResourceOwnerOAuthContext)

Aggregations

ResourceOwnerOAuthContext (org.mule.runtime.oauth.api.state.ResourceOwnerOAuthContext)2 AuthorizationCodeOAuthDancer (org.mule.runtime.oauth.api.AuthorizationCodeOAuthDancer)1