|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.lyo.server.oauth.core.token.SimpleTokenStrategy
public class SimpleTokenStrategy
A simple strategy for generating and validating tokens. Generates random tokens and stores them in memory. Tokens are only good for the life of the process. Least recently used tokens are invalidated when cached limits are reached.
Nested Class Summary | |
---|---|
protected class |
SimpleTokenStrategy.RequestTokenData
Holds information associated with a request token such as the callback URL and OAuth verification code. |
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
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 trackMethod Detail |
---|
public void generateRequestToken(OAuthRequest oAuthRequest) throws IOException
TokenStrategy
OAuthRequest
.
generateRequestToken
in interface TokenStrategy
oAuthRequest
- the OAuth request
IOException
- 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 message
net.oauth.OAuthException
- if the tokens are not valid
IOException
- 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 token
net.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 string
net.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 token
net.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 token
net.oauth.OAuthProblemException
public void validateVerificationCode(OAuthRequest oAuthRequest) throws net.oauth.OAuthException, IOException
TokenStrategy
validateVerificationCode
in interface TokenStrategy
oAuthRequest
- the OAuth request
net.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 request
IOException
- on I/O errors
net.oauth.OAuthProblemException
OAuthRequest.getAccessor()
public void validateAccessToken(OAuthRequest oAuthRequest) throws net.oauth.OAuthException, IOException
TokenStrategy
validateAccessToken
in interface TokenStrategy
oAuthRequest
- the OAuth request
net.oauth.OAuthException
- if the token is invalid
IOException
- 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 token
net.oauth.OAuthProblemException
protected String generateTokenString()
protected SimpleTokenStrategy.RequestTokenData getRequestTokenData(OAuthRequest oAuthRequest) throws net.oauth.OAuthProblemException, IOException
oAuthRequest
- the OAuth request
net.oauth.OAuthProblemException
- if the request token is invalid
IOException
- on reading OAuth parametersprotected SimpleTokenStrategy.RequestTokenData getRequestTokenData(String requestToken) throws net.oauth.OAuthProblemException
requestToken
- the request token string
net.oauth.OAuthProblemException
- if the request token is invalid
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |