74 lines
1.5 KiB
Java
74 lines
1.5 KiB
Java
package org.scribe.oauth;
|
|
|
|
import org.scribe.builder.api.*;
|
|
import org.scribe.model.*;
|
|
|
|
public class OAuth20ServiceImpl implements OAuthService
|
|
{
|
|
private static final String VERSION = "2.0";
|
|
|
|
private final DefaultApi20 api;
|
|
private final OAuthConfig config;
|
|
|
|
/**
|
|
* Default constructor
|
|
*
|
|
* @param api OAuth2.0 api information
|
|
* @param config OAuth 2.0 configuration param object
|
|
*/
|
|
public OAuth20ServiceImpl(DefaultApi20 api, OAuthConfig config)
|
|
{
|
|
this.api = api;
|
|
this.config = config;
|
|
}
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
public void addScope(String scope)
|
|
{
|
|
throw new UnsupportedOperationException("OAuth 2 does not use scopes");
|
|
}
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
public Token getAccessToken(Token requestToken, Verifier verifier)
|
|
{
|
|
throw new UnsupportedOperationException("Unsupported operation, please use 'getAuthorizationUrl' and redirect your users there");
|
|
}
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
public Token getRequestToken()
|
|
{
|
|
throw new UnsupportedOperationException("Unsupported operation, please use 'getAuthorizationUrl' and redirect your users there");
|
|
}
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
public String getVersion()
|
|
{
|
|
return VERSION;
|
|
}
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
public void signRequest(Token accessToken, OAuthRequest request)
|
|
{
|
|
request.addQuerystringParam(OAuthConstants.ACCESS_TOKEN, accessToken.getToken());
|
|
}
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
public String getAuthorizationUrl(Token requestToken)
|
|
{
|
|
return api.getAuthorizationUrl(config);
|
|
}
|
|
|
|
}
|