* @param the key of the object at the object store
*/
@Override
public final OAuth2Adapter makeObject(String key) throws Exception
{
OAuthState state = null;
Lock lock = this.getLock(key);
lock.lock();
try
{
if (!this.objectStore.contains(key))
{
throw new NotAuthorizedException(
String.format(
"There is no access token stored under the key %s . You need to call the <authorize> message processor. The key will be given to you via a flow variable after the OAuth dance is completed. You can extract it using flowVars['tokenId'].",
key));
}
state = this.retrieveOAuthState(key, true);
}
finally
{
lock.unlock();
}
OAuth2Adapter connector = this.getAdapterClass()
.getConstructor(OAuth2Manager.class)
.newInstance(this.oauthManager);
connector.setConsumerKey(oauthManager.getDefaultUnauthorizedConnector().getConsumerKey());
connector.setConsumerSecret(oauthManager.getDefaultUnauthorizedConnector().getConsumerSecret());
connector.setAccessToken(state.getAccessToken());
connector.setAuthorizationUrl(state.getAuthorizationUrl());
connector.setAccessTokenUrl(state.getAccessTokenUrl());
connector.setRefreshToken(state.getRefreshToken());
this.setCustomAdapterProperties(connector, state);
if (connector instanceof MuleContextAware)
{