Added OAuth 2.0 classes

This commit is contained in:
Pablo Fernandez committed 2011-01-09 15:51:34 -03:00
1 parent 7e92db3413
commit 9ea686a3f8
3 files changed
+36 -6

No files matched your search

@@ -1,15 +1,42 @@
package org.scribe.builder.api;
import org.scribe.model.OAuthConfig;
import org.scribe.oauth.OAuthService;
import org.scribe.model.*;
import org.scribe.oauth.*;
public class DefaultApi20 implements Api
/**
* Default implementation of the OAuth protocol, version 2.0 (draft 11)
*
* This class is meant to be extended by concrete implementations of the API,
* providing the endpoints and endpoint-http-verbs.
*
* If your Api adheres to the 2.0 (draft 11) protocol correctly, you just need to extend
* this class and define the getters for your endpoints.
*
* If your Api does something a bit different, you can override the different
* extractors or services, in order to fine-tune the process. Please read the
* javadocs of the interfaces to get an idea of what to do.
*
* @author Diego Silveira
*
*/
public abstract class DefaultApi20 implements Api
{
@Override
/**
* Returns the URL where you should redirect your users to authenticate
* your application.
*
* @param config OAuth 2.0 configuration param object
* @return the URL where you should redirect your users
*/
public abstract String getAuthorizationUrl(OAuthConfig config);
/**
* {@inheritDoc}
*/
public OAuthService createService(OAuthConfig config, String scope)
{
return null;
return new OAuth20ServiceImpl(this, config);
}
}
@@ -38,4 +38,7 @@ public class OAuthConstants
public static final String HEADER = "Authorization";
public static final Token EMPTY_TOKEN = new Token("", "");
public static final String SCOPE = "scope";
//OAuth 2.0
public static final String ACCESS_TOKEN = "access_token";
}
@@ -59,7 +59,7 @@ public class OAuth20ServiceImpl implements OAuthService
*/
public void signRequest(Token accessToken, OAuthRequest request)
{
request.addParameter(OAuthConstants.ACCESS_TOKEN, accessToken.getToken());
request.addQuerystringParam(OAuthConstants.ACCESS_TOKEN, accessToken.getToken());
}
/**