Package com.sodius.oslc.server.oauth
Class ClusterableTokenStrategy
- java.lang.Object
-
- com.sodius.oslc.server.oauth.ClusterableTokenStrategy
-
- All Implemented Interfaces:
OAuthIdentityTokenStrategy
,org.eclipse.lyo.server.oauth.core.token.TokenStrategy
public class ClusterableTokenStrategy extends Object implements OAuthIdentityTokenStrategy
DefaultOAuthIdentityTokenStrategy
implementation that is, depending on theCacheBuilder
cluster factory set by the application, able to work on cluster environments. Note: the defaultCacheBuilder
implementation is NOT cluster compatible, applications working in cluster environments MUST provide a cluster-compliant implementation.- Since:
- 3.3.0
-
-
Constructor Summary
Constructors Constructor Description ClusterableTokenStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
generateAccessToken(org.eclipse.lyo.server.oauth.core.OAuthRequest oAuthRequest)
void
generateRequestToken(org.eclipse.lyo.server.oauth.core.OAuthRequest oAuthRequest)
String
generateVerificationCode(HttpServletRequest httpRequest, String requestToken)
String
getCallback(HttpServletRequest httpRequest, String requestToken)
OAuthIdentity
getOAuthIdentity(String oauthToken)
Gets theOAuthIdentity
associated with an access/request token.String
getTokenSecret(HttpServletRequest httpRequest, String token)
OAuthIdentity
getTwoLeggedOAuthIdentity(String consumerKey)
Gets theOAuthIdentity
mapped to a consumer key by theOAuthIdentityTokenStrategy.setTwoLeggedOAuthIdentity(String, OAuthIdentity)
method.boolean
isRequestTokenAuthorized(HttpServletRequest httpRequest, String requestToken)
void
markRequestTokenAuthorized(HttpServletRequest httpRequest, String requestToken)
void
removeTwoLeggedOAuthIdentity(String consumerKey)
Removes theOAuthIdentity
mapped to a consumer key by theOAuthIdentityTokenStrategy.setTwoLeggedOAuthIdentity(String, OAuthIdentity)
method.void
setTwoLeggedOAuthIdentity(String consumerKey, OAuthIdentity identity)
Convenient method to associate anOAuthIdentity
with a consumer after a two-legged authentication.void
validateAccessToken(org.eclipse.lyo.server.oauth.core.OAuthRequest oAuthRequest)
String
validateRequestToken(HttpServletRequest httpRequest, net.oauth.OAuthMessage message)
void
validateVerificationCode(org.eclipse.lyo.server.oauth.core.OAuthRequest oAuthRequest)
-
-
-
Method Detail
-
generateRequestToken
public void generateRequestToken(org.eclipse.lyo.server.oauth.core.OAuthRequest oAuthRequest) throws net.oauth.OAuthException, IOException
- Specified by:
generateRequestToken
in interfaceorg.eclipse.lyo.server.oauth.core.token.TokenStrategy
- Throws:
net.oauth.OAuthException
IOException
-
validateRequestToken
public String validateRequestToken(HttpServletRequest httpRequest, net.oauth.OAuthMessage message) throws net.oauth.OAuthException, IOException
- Specified by:
validateRequestToken
in interfaceorg.eclipse.lyo.server.oauth.core.token.TokenStrategy
- Throws:
net.oauth.OAuthException
IOException
-
getCallback
public String getCallback(HttpServletRequest httpRequest, String requestToken) throws net.oauth.OAuthException
- Specified by:
getCallback
in interfaceorg.eclipse.lyo.server.oauth.core.token.TokenStrategy
- Throws:
net.oauth.OAuthException
-
markRequestTokenAuthorized
public void markRequestTokenAuthorized(HttpServletRequest httpRequest, String requestToken) throws net.oauth.OAuthException
- Specified by:
markRequestTokenAuthorized
in interfaceorg.eclipse.lyo.server.oauth.core.token.TokenStrategy
- Throws:
net.oauth.OAuthException
-
isRequestTokenAuthorized
public boolean isRequestTokenAuthorized(HttpServletRequest httpRequest, String requestToken) throws net.oauth.OAuthException
- Specified by:
isRequestTokenAuthorized
in interfaceorg.eclipse.lyo.server.oauth.core.token.TokenStrategy
- Throws:
net.oauth.OAuthException
-
generateVerificationCode
public String generateVerificationCode(HttpServletRequest httpRequest, String requestToken) throws net.oauth.OAuthException
- Specified by:
generateVerificationCode
in interfaceorg.eclipse.lyo.server.oauth.core.token.TokenStrategy
- Throws:
net.oauth.OAuthException
-
validateVerificationCode
public void validateVerificationCode(org.eclipse.lyo.server.oauth.core.OAuthRequest oAuthRequest) throws net.oauth.OAuthException, IOException
- Specified by:
validateVerificationCode
in interfaceorg.eclipse.lyo.server.oauth.core.token.TokenStrategy
- Throws:
net.oauth.OAuthException
IOException
-
generateAccessToken
public void generateAccessToken(org.eclipse.lyo.server.oauth.core.OAuthRequest oAuthRequest) throws net.oauth.OAuthException, IOException
- Specified by:
generateAccessToken
in interfaceorg.eclipse.lyo.server.oauth.core.token.TokenStrategy
- Throws:
net.oauth.OAuthException
IOException
-
validateAccessToken
public void validateAccessToken(org.eclipse.lyo.server.oauth.core.OAuthRequest oAuthRequest) throws net.oauth.OAuthException, IOException
- Specified by:
validateAccessToken
in interfaceorg.eclipse.lyo.server.oauth.core.token.TokenStrategy
- Throws:
net.oauth.OAuthException
IOException
-
getTokenSecret
public String getTokenSecret(HttpServletRequest httpRequest, String token) throws net.oauth.OAuthException
- Specified by:
getTokenSecret
in interfaceorg.eclipse.lyo.server.oauth.core.token.TokenStrategy
- Throws:
net.oauth.OAuthException
-
getOAuthIdentity
public OAuthIdentity getOAuthIdentity(String oauthToken)
Description copied from interface:OAuthIdentityTokenStrategy
Gets theOAuthIdentity
associated with an access/request token. Implementations must catch (and cache) this identity during theOAuth dance
.- Specified by:
getOAuthIdentity
in interfaceOAuthIdentityTokenStrategy
- Parameters:
oauthToken
- the access or request token key.- Returns:
- the associated identity if found,
null
otherwise.
-
setTwoLeggedOAuthIdentity
public void setTwoLeggedOAuthIdentity(String consumerKey, OAuthIdentity identity)
Description copied from interface:OAuthIdentityTokenStrategy
Convenient method to associate anOAuthIdentity
with a consumer after a two-legged authentication. Since no end-user is involved in two-legged authentication requests, this method allows associating the consumer with theOAuthIdentity
of the corresponding functional user once is resolved; subsequent requests can call then theOAuthIdentityTokenStrategy.getTwoLeggedOAuthIdentity(String)
method to get theOAuthIdentity
of the consumer without having to resolve it again.- Specified by:
setTwoLeggedOAuthIdentity
in interfaceOAuthIdentityTokenStrategy
- Parameters:
consumerKey
- the consumer key.identity
- the identity of the consumer's functional user.
-
getTwoLeggedOAuthIdentity
public OAuthIdentity getTwoLeggedOAuthIdentity(String consumerKey)
Description copied from interface:OAuthIdentityTokenStrategy
Gets theOAuthIdentity
mapped to a consumer key by theOAuthIdentityTokenStrategy.setTwoLeggedOAuthIdentity(String, OAuthIdentity)
method. This method will retrieve the identity until theOAuthIdentityTokenStrategy.removeTwoLeggedOAuthIdentity(String)
method is called or the map entry expires in the particular cache implementation.- Specified by:
getTwoLeggedOAuthIdentity
in interfaceOAuthIdentityTokenStrategy
- Parameters:
consumerKey
- the consumer key.- Returns:
- the corresponding
OAuthIdentity
if mapped;null
otherwise.
-
removeTwoLeggedOAuthIdentity
public void removeTwoLeggedOAuthIdentity(String consumerKey)
Description copied from interface:OAuthIdentityTokenStrategy
Removes theOAuthIdentity
mapped to a consumer key by theOAuthIdentityTokenStrategy.setTwoLeggedOAuthIdentity(String, OAuthIdentity)
method.- Specified by:
removeTwoLeggedOAuthIdentity
in interfaceOAuthIdentityTokenStrategy
- Parameters:
consumerKey
- the consumer key.
-
-