public class SimpleTokenStrategy extends Object implements TokenStrategy
Modifier and Type | Class and Description |
---|---|
protected class |
SimpleTokenStrategy.RequestTokenData
Holds information associated with a request token such as the callback
URL and OAuth verification code.
|
Constructor and Description |
---|
SimpleTokenStrategy()
Constructs a SimpleTokenStrategy using the defaults for cache limits on request and access tokens.
|
SimpleTokenStrategy(int requestTokenMaxCount,
int accessTokenMaxCount)
Constructs a SimpleTokenStrategy with cache limits on the number of
request and access tokens.
|
Modifier and Type | Method and Description |
---|---|
void |
generateAccessToken(OAuthRequest oAuthRequest)
Generates an access token and token secret and sets it in the accessor in
the
OAuthRequest . |
void |
generateRequestToken(OAuthRequest oAuthRequest)
Generates a request token and token secret and sets it in the accessor in
the
OAuthRequest . |
protected String |
generateTokenString()
Creates a unique, random string to use for tokens.
|
String |
generateVerificationCode(javax.servlet.http.HttpServletRequest httpRequest,
String requestToken)
Generates an "unguessable" OAuth verification code.
|
String |
getCallback(javax.servlet.http.HttpServletRequest httpRequest,
String requestToken)
Gets the OAuth callback associated with this consumer for OAuth 1.0a
authentication flows.
|
protected SimpleTokenStrategy.RequestTokenData |
getRequestTokenData(OAuthRequest oAuthRequest)
Gets the request token data from this OAuth request.
|
protected SimpleTokenStrategy.RequestTokenData |
getRequestTokenData(String requestToken)
Gets the request token data for this request token.
|
String |
getTokenSecret(javax.servlet.http.HttpServletRequest httpRequest,
String token)
Gets the token secret for token to validate signatures.
|
boolean |
isRequestTokenAuthorized(javax.servlet.http.HttpServletRequest httpRequest,
String requestToken)
Checks with the request token has been authorized by the end user.
|
void |
markRequestTokenAuthorized(javax.servlet.http.HttpServletRequest httpRequest,
String requestToken)
Indicates that a user has typed in a valid ID and password, and that the
request token can now be exchanged for an access token.
|
void |
validateAccessToken(OAuthRequest oAuthRequest)
Validates that the access token is valid, throwing an exception if not.
|
String |
validateRequestToken(javax.servlet.http.HttpServletRequest httpRequest,
net.oauth.OAuthMessage message)
Validates that the request token is valid, throwing an exception if not.
|
void |
validateVerificationCode(OAuthRequest oAuthRequest)
Validates that the verification code is recognized and associated with
the request token.
|
public SimpleTokenStrategy()
SimpleTokenStrategy(int, int)
public SimpleTokenStrategy(int requestTokenMaxCount, int accessTokenMaxCount)
requestTokenMaxCount
- the maximum number of request tokens to trackaccessTokenMaxCount
- the maximum number of access tokens to trackpublic void generateRequestToken(OAuthRequest oAuthRequest) throws IOException
TokenStrategy
OAuthRequest
.generateRequestToken
in interface TokenStrategy
oAuthRequest
- the OAuth requestIOException
- on errors reading from the request messageOAuthRequest.getAccessor()
public String validateRequestToken(javax.servlet.http.HttpServletRequest httpRequest, net.oauth.OAuthMessage message) throws net.oauth.OAuthException, IOException
TokenStrategy
validateRequestToken
in interface TokenStrategy
httpRequest
- the HTTP requestmessage
- the OAuth messagenet.oauth.OAuthException
- if the tokens are not validIOException
- on I/O errorspublic String getCallback(javax.servlet.http.HttpServletRequest httpRequest, String requestToken) throws net.oauth.OAuthProblemException
TokenStrategy
getCallback
in interface TokenStrategy
httpRequest
- the HTTP requestrequestToken
- the request tokennet.oauth.OAuthProblemException
public void markRequestTokenAuthorized(javax.servlet.http.HttpServletRequest httpRequest, String requestToken) throws net.oauth.OAuthProblemException
TokenStrategy
markRequestTokenAuthorized
in interface TokenStrategy
httpRequest
- the servlet requestrequestToken
- the request token stringnet.oauth.OAuthProblemException
TokenStrategy.isRequestTokenAuthorized(HttpServletRequest, String)
public boolean isRequestTokenAuthorized(javax.servlet.http.HttpServletRequest httpRequest, String requestToken) throws net.oauth.OAuthProblemException
TokenStrategy
isRequestTokenAuthorized
in interface TokenStrategy
httpRequest
- the servlet requestrequestToken
- the request tokennet.oauth.OAuthProblemException
#markRequestTokenAuthorized(HttpServletRequest, OAuthAccessor)
public String generateVerificationCode(javax.servlet.http.HttpServletRequest httpRequest, String requestToken) throws net.oauth.OAuthProblemException
TokenStrategy
generateVerificationCode
in interface TokenStrategy
httpRequest
- the HTTP requestrequestToken
- the request tokennet.oauth.OAuthProblemException
public void validateVerificationCode(OAuthRequest oAuthRequest) throws net.oauth.OAuthException, IOException
TokenStrategy
validateVerificationCode
in interface TokenStrategy
oAuthRequest
- the OAuth requestnet.oauth.OAuthException
- on OAuth problems (e.g., the request token is invalid)IOException
- on I/O errorspublic void generateAccessToken(OAuthRequest oAuthRequest) throws net.oauth.OAuthProblemException, IOException
TokenStrategy
OAuthRequest
. Clears any request tokens set.generateAccessToken
in interface TokenStrategy
oAuthRequest
- the OAuth requestIOException
- on I/O errorsnet.oauth.OAuthProblemException
OAuthRequest.getAccessor()
public void validateAccessToken(OAuthRequest oAuthRequest) throws net.oauth.OAuthException, IOException
TokenStrategy
validateAccessToken
in interface TokenStrategy
oAuthRequest
- the OAuth requestnet.oauth.OAuthException
- if the token is invalidIOException
- on I/O errorspublic String getTokenSecret(javax.servlet.http.HttpServletRequest httpRequest, String token) throws net.oauth.OAuthProblemException
TokenStrategy
getTokenSecret
in interface TokenStrategy
httpRequest
- the HTTP requesttoken
- the token string, either a request token or access tokennet.oauth.OAuthProblemException
protected String generateTokenString()
protected SimpleTokenStrategy.RequestTokenData getRequestTokenData(OAuthRequest oAuthRequest) throws net.oauth.OAuthProblemException, IOException
oAuthRequest
- the OAuth requestnet.oauth.OAuthProblemException
- if the request token is invalidIOException
- on reading OAuth parametersprotected SimpleTokenStrategy.RequestTokenData getRequestTokenData(String requestToken) throws net.oauth.OAuthProblemException
requestToken
- the request token stringnet.oauth.OAuthProblemException
- if the request token is invalidCopyright © 2018. All Rights Reserved.