Added bunch of javadocs and restricted some visibility.
No functional changes
This commit is contained in:
1 parent
aad8dac580
commit
59f16bfdda
35 files changed
+393
-64
No files matched your search
@@ -2,7 +2,18 @@ package org.scribe.extractors;
|
||||
|
||||
import org.scribe.model.*;
|
||||
|
||||
/**
|
||||
* Simple command object that extracts a {@link Token} from a String
|
||||
*
|
||||
* @author Pablo Fernandez
|
||||
*/
|
||||
public interface AccessTokenExtractor
|
||||
{
|
||||
/**
|
||||
* Extracts the access token from the contents of an Http Response
|
||||
*
|
||||
* @param response the contents of the response
|
||||
* @return OAuth access token
|
||||
*/
|
||||
public Token extract(String response);
|
||||
}
|
||||
@@ -2,7 +2,20 @@ package org.scribe.extractors;
|
||||
|
||||
import org.scribe.model.*;
|
||||
|
||||
/**
|
||||
* Simple command object that extracts a base string from a {@link OAuthRequest}
|
||||
*
|
||||
* @author Pablo Fernandez
|
||||
*/
|
||||
public interface BaseStringExtractor
|
||||
{
|
||||
/**
|
||||
* Extracts an url-encoded base string from the {@link OAuthRequest}.
|
||||
*
|
||||
* See <a href="http://oauth.net/core/1.0/#anchor14">the oauth spec</a> for more info on this.
|
||||
*
|
||||
* @param request the OAuthRequest
|
||||
* @return the url-encoded base string
|
||||
*/
|
||||
String extract(OAuthRequest request);
|
||||
}
|
||||
@@ -6,11 +6,20 @@ import org.scribe.exceptions.*;
|
||||
import org.scribe.model.*;
|
||||
import org.scribe.utils.*;
|
||||
|
||||
/**
|
||||
* Default implementation of {@link BaseStringExtractor}. Conforms to OAuth 1.0a
|
||||
*
|
||||
* @author Pablo Fernandez
|
||||
*
|
||||
*/
|
||||
public class BaseStringExtractorImpl implements BaseStringExtractor
|
||||
{
|
||||
|
||||
private static final String AMPERSAND_SEPARATED_STRING = "%s&%s&%s";
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String extract(OAuthRequest request)
|
||||
{
|
||||
checkPreconditions(request);
|
||||
|
||||
@@ -2,7 +2,18 @@ package org.scribe.extractors;
|
||||
|
||||
import org.scribe.model.*;
|
||||
|
||||
/**
|
||||
* Simple command object that generates an OAuth Authorization header to include in the request.
|
||||
*
|
||||
* @author Pablo Fernandez
|
||||
*/
|
||||
public interface HeaderExtractor
|
||||
{
|
||||
/**
|
||||
* Generates an OAuth 'Authorization' Http header to include in requests as the signature.
|
||||
*
|
||||
* @param request the OAuthRequest to inspect and generate the header
|
||||
* @return the Http header value
|
||||
*/
|
||||
String extract(OAuthRequest request);
|
||||
}
|
||||
@@ -6,11 +6,20 @@ import org.scribe.exceptions.*;
|
||||
import org.scribe.model.*;
|
||||
import org.scribe.utils.*;
|
||||
|
||||
/**
|
||||
* Default implementation of {@link HeaderExtractor}. Conforms to OAuth 1.0a
|
||||
*
|
||||
* @author Pablo Fernandez
|
||||
*
|
||||
*/
|
||||
public class HeaderExtractorImpl implements HeaderExtractor
|
||||
{
|
||||
private static final String PARAM_SEPARATOR = ", ";
|
||||
private static final String PREAMBLE = "OAuth ";
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public String extract(OAuthRequest request)
|
||||
{
|
||||
checkPreconditions(request);
|
||||
|
||||
@@ -2,8 +2,18 @@ package org.scribe.extractors;
|
||||
|
||||
import org.scribe.model.*;
|
||||
|
||||
/**
|
||||
* Simple command object that extracts a {@link Token} from a String
|
||||
*
|
||||
* @author Pablo Fernandez
|
||||
*/
|
||||
public interface RequestTokenExtractor
|
||||
{
|
||||
|
||||
/**
|
||||
* Extracts the request token from the contents of an Http Response
|
||||
*
|
||||
* @param response the contents of the response
|
||||
* @return OAuth access token
|
||||
*/
|
||||
public Token extract(String response);
|
||||
}
|
||||
@@ -6,11 +6,20 @@ import org.scribe.exceptions.*;
|
||||
import org.scribe.model.*;
|
||||
import org.scribe.utils.*;
|
||||
|
||||
/**
|
||||
* Default implementation of {@RequestTokenExtractor} and {@AccessTokenExtractor}. Conforms to OAuth 1.0a
|
||||
*
|
||||
* The process for extracting access and request tokens is similar so this class can do both things.
|
||||
*
|
||||
* @author Pablo Fernandez
|
||||
*/
|
||||
public class TokenExtractorImpl implements RequestTokenExtractor, AccessTokenExtractor
|
||||
{
|
||||
|
||||
private static final String TOKEN_REGEX = "oauth_token=(\\S*)&oauth_token_secret=(\\S*?)(&(.*))?";
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Token extract(String response)
|
||||
{
|
||||
Preconditions.checkEmptyString(response, "Cant extract a token from null object or an empty string.");
|
||||
|
||||
Reference in new issue
Block a user