Example usage for org.springframework.security.oauth.common OAuthConsumerParameter oauth_verifier

List of usage examples for org.springframework.security.oauth.common OAuthConsumerParameter oauth_verifier

Introduction

In this page you can find the example usage for org.springframework.security.oauth.common OAuthConsumerParameter oauth_verifier.

Prototype

OAuthConsumerParameter oauth_verifier

To view the source code for org.springframework.security.oauth.common OAuthConsumerParameter oauth_verifier.

Click Source Link

Document

Parameter for the verifier.

Usage

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

public OAuthConsumerToken getAccessToken(ProtectedResourceDetails details, OAuthConsumerToken requestToken,
        String verifier) {/*from w w  w.j a  va2 s  .  co m*/
    URL accessTokenURL;
    try {
        accessTokenURL = new URL(details.getAccessTokenURL());
    } catch (MalformedURLException e) {
        throw new IllegalStateException("Malformed URL for obtaining an access token.", e);
    }

    String httpMethod = details.getAccessTokenHttpMethod();

    Map<String, String> additionalParameters = new TreeMap<String, String>();
    if (details.isUse10a()) {
        if (verifier == null) {
            throw new UnverifiedRequestTokenException("Unverified request token: " + requestToken);
        }
        additionalParameters.put(OAuthConsumerParameter.oauth_verifier.toString(), verifier);
    }
    Map<String, String> specifiedParams = details.getAdditionalParameters();
    if (specifiedParams != null) {
        additionalParameters.putAll(specifiedParams);
    }
    return getTokenFromProvider(details, accessTokenURL, httpMethod, requestToken, additionalParameters);
}

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

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

    URL accessTokenURL;//w w  w  .  j av  a  2s.  c om
    try {
        accessTokenURL = new URL(details.getAccessTokenURL());
    } catch (MalformedURLException e) {
        throw new IllegalStateException("Malformed URL for obtaining an access token.", e);
    }

    String httpMethod = details.getAccessTokenHttpMethod();

    Map<String, String> additionalParameters = new TreeMap<String, String>();
    if (details.isUse10a()) {
        if (verifier == null) {
            throw new UnverifiedRequestTokenException("Unverified request token: " + requestToken.getValue());
        }
        additionalParameters.put(OAuthConsumerParameter.oauth_verifier.toString(), verifier);
    }
    Map<String, String> specifiedParams = details.getAdditionalParameters();
    if (specifiedParams != null) {
        additionalParameters.putAll(specifiedParams);
    }
    return getTokenFromProvider(details, accessTokenURL, httpMethod, requestToken, additionalParameters);
}