Example usage for org.springframework.security.oauth.consumer OAuthConsumerToken getResourceId

List of usage examples for org.springframework.security.oauth.consumer OAuthConsumerToken getResourceId

Introduction

In this page you can find the example usage for org.springframework.security.oauth.consumer OAuthConsumerToken getResourceId.

Prototype

public String getResourceId() 

Source Link

Document

The id of the resource to which this token applies.

Usage

From source file:org.springframework.security.oauth.consumer.client.CoreOAuthConsumerSupport.java

public OAuthConsumerToken getAccessToken(OAuthConsumerToken requestToken, String verifier)
        throws OAuthRequestFailedException {
    ProtectedResourceDetails details = getProtectedResourceDetailsService()
            .loadProtectedResourceDetailsById(requestToken.getResourceId());
    return getAccessToken(details, requestToken, verifier);
}

From source file:org.springframework.security.oauth.consumer.client.CoreOAuthConsumerSupport.java

public InputStream readProtectedResource(URL url, OAuthConsumerToken accessToken, String httpMethod)
        throws OAuthRequestFailedException {
    if (accessToken == null) {
        throw new OAuthRequestFailedException("A valid access token must be supplied.");
    }//from ww w .  j a  va2 s.  c o  m

    ProtectedResourceDetails resourceDetails = getProtectedResourceDetailsService()
            .loadProtectedResourceDetailsById(accessToken.getResourceId());
    if ((!resourceDetails.isAcceptsAuthorizationHeader()) && !"POST".equalsIgnoreCase(httpMethod)
            && !"PUT".equalsIgnoreCase(httpMethod)) {
        throw new IllegalArgumentException("Protected resource " + resourceDetails.getId()
                + " cannot be accessed with HTTP method " + httpMethod
                + " because the OAuth provider doesn't accept the OAuth Authorization header.");
    }

    return readResource(resourceDetails, url, httpMethod, accessToken,
            resourceDetails.getAdditionalParameters(), null);
}

From source file:org.springframework.security.oauth.consumer.client.CoreOAuthConsumerSupport.java

/**
 * Create a configured URL.  If the HTTP method to access the resource is "POST" or "PUT" and the "Authorization"
 * header isn't supported, then the OAuth parameters will be expected to be sent in the body of the request. Otherwise,
 * you can assume that the given URL is ready to be used without further work.
 *
 * @param url         The base URL.//w ww . j av  a  2 s  . c o  m
 * @param accessToken The access token.
 * @param httpMethod The HTTP method.
 * @param additionalParameters Any additional request parameters.
 * @return The configured URL.
 */
public URL configureURLForProtectedAccess(URL url, OAuthConsumerToken accessToken, String httpMethod,
        Map<String, String> additionalParameters) throws OAuthRequestFailedException {
    return configureURLForProtectedAccess(url, accessToken,
            getProtectedResourceDetailsService().loadProtectedResourceDetailsById(accessToken.getResourceId()),
            httpMethod, additionalParameters);
}