Example usage for org.springframework.security.oauth.consumer UnverifiedRequestTokenException UnverifiedRequestTokenException

List of usage examples for org.springframework.security.oauth.consumer UnverifiedRequestTokenException UnverifiedRequestTokenException

Introduction

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

Prototype

public UnverifiedRequestTokenException(String msg) 

Source Link

Usage

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

public OAuthConsumerToken getAccessToken(ProtectedResourceDetails details, OAuthConsumerToken requestToken,
        String verifier) {//ww w . j  av  a 2 s .c om
    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;/*from w w  w .j ava  2  s . c o m*/
    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);
}