Package org.mule.common.security.oauth

Examples of org.mule.common.security.oauth.OAuthState


            throw new IllegalArgumentException("Invalid connector type");
        }

        OAuth2Adapter connector = (OAuth2Adapter) obj;

        OAuthState state = null;

        Lock lock = this.getLock(key);
        lock.lock();

        try
        {
            if (this.objectStore.contains(key))
            {
                state = this.retrieveOAuthState(key, false);
                this.objectStore.remove(key);
            }
            else
            {
                state = new OAuthState();
            }

            state.setAccessToken(connector.getAccessToken());
            state.setAccessTokenUrl(connector.getAccessTokenUrl());
            state.setAuthorizationUrl(connector.getAuthorizationUrl());
            state.setRefreshToken(connector.getRefreshToken());

            this.setCustomStateProperties(connector, state);

            this.objectStore.store(key, state);
        }
View Full Code Here


     * @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)
        {
View Full Code Here

        }

        if (state != null && !(state instanceof OAuthState))
        {

            OAuthState newState = new OAuthState();

            try
            {
                for (PropertyDescriptor beanProperty : Introspector.getBeanInfo(state.getClass(),
                    Object.class).getPropertyDescriptors())
                {
                    Object value = beanProperty.getReadMethod().invoke(state, (Object[]) null);
                    if (value != null)
                    {
                        PropertyDescriptor stateProperty = oauthStateProperties.get(beanProperty.getName());
                        if (stateProperty != null)
                        {
                            stateProperty.getWriteMethod().invoke(newState, value);
                        }
                        else
                        {
                            newState.setCustomProperty(beanProperty.getName(), value.toString());
                        }
                    }
                }
            }
            catch (IllegalAccessException e)
View Full Code Here

            if (!this.objectStore.contains(key))
            {
                return false;
            }

            OAuthState state = this.retrieveOAuthState(key, true);

            if (connector.getAccessToken() == null)
            {
                return false;
            }

            if (!connector.getAccessToken().equals(state.getAccessToken()))
            {
                return false;
            }
            if (connector.getRefreshToken() == null && state.getRefreshToken() != null)
            {
                return false;
            }

            if (connector.getRefreshToken() != null
                && !connector.getRefreshToken().equals(state.getRefreshToken()))
            {
                return false;
            }
        }
        catch (ObjectStoreException e)
View Full Code Here

TOP

Related Classes of org.mule.common.security.oauth.OAuthState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.