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
DefaultOAuthIdentityTokenStrategyimplementation that is, depending on theCacheBuildercluster factory set by the application, able to work on cluster environments. Note: the defaultCacheBuilderimplementation 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 voidgenerateAccessToken(org.eclipse.lyo.server.oauth.core.OAuthRequest oAuthRequest)voidgenerateRequestToken(org.eclipse.lyo.server.oauth.core.OAuthRequest oAuthRequest)StringgenerateVerificationCode(HttpServletRequest httpRequest, String requestToken)StringgetCallback(HttpServletRequest httpRequest, String requestToken)OAuthIdentitygetOAuthIdentity(String oauthToken)Gets theOAuthIdentityassociated with an access/request token.StringgetTokenSecret(HttpServletRequest httpRequest, String token)OAuthIdentitygetTwoLeggedOAuthIdentity(String consumerKey)Gets theOAuthIdentitymapped to a consumer key by theOAuthIdentityTokenStrategy.setTwoLeggedOAuthIdentity(String, OAuthIdentity)method.booleanisRequestTokenAuthorized(HttpServletRequest httpRequest, String requestToken)voidmarkRequestTokenAuthorized(HttpServletRequest httpRequest, String requestToken)voidremoveTwoLeggedOAuthIdentity(String consumerKey)Removes theOAuthIdentitymapped to a consumer key by theOAuthIdentityTokenStrategy.setTwoLeggedOAuthIdentity(String, OAuthIdentity)method.voidsetTwoLeggedOAuthIdentity(String consumerKey, OAuthIdentity identity)Convenient method to associate anOAuthIdentitywith a consumer after a two-legged authentication.voidvalidateAccessToken(org.eclipse.lyo.server.oauth.core.OAuthRequest oAuthRequest)StringvalidateRequestToken(HttpServletRequest httpRequest, net.oauth.OAuthMessage message)voidvalidateVerificationCode(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:
generateRequestTokenin interfaceorg.eclipse.lyo.server.oauth.core.token.TokenStrategy- Throws:
net.oauth.OAuthExceptionIOException
-
validateRequestToken
public String validateRequestToken(HttpServletRequest httpRequest, net.oauth.OAuthMessage message) throws net.oauth.OAuthException, IOException
- Specified by:
validateRequestTokenin interfaceorg.eclipse.lyo.server.oauth.core.token.TokenStrategy- Throws:
net.oauth.OAuthExceptionIOException
-
getCallback
public String getCallback(HttpServletRequest httpRequest, String requestToken) throws net.oauth.OAuthException
- Specified by:
getCallbackin 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:
markRequestTokenAuthorizedin 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:
isRequestTokenAuthorizedin 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:
generateVerificationCodein 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:
validateVerificationCodein interfaceorg.eclipse.lyo.server.oauth.core.token.TokenStrategy- Throws:
net.oauth.OAuthExceptionIOException
-
generateAccessToken
public void generateAccessToken(org.eclipse.lyo.server.oauth.core.OAuthRequest oAuthRequest) throws net.oauth.OAuthException, IOException- Specified by:
generateAccessTokenin interfaceorg.eclipse.lyo.server.oauth.core.token.TokenStrategy- Throws:
net.oauth.OAuthExceptionIOException
-
validateAccessToken
public void validateAccessToken(org.eclipse.lyo.server.oauth.core.OAuthRequest oAuthRequest) throws net.oauth.OAuthException, IOException- Specified by:
validateAccessTokenin interfaceorg.eclipse.lyo.server.oauth.core.token.TokenStrategy- Throws:
net.oauth.OAuthExceptionIOException
-
getTokenSecret
public String getTokenSecret(HttpServletRequest httpRequest, String token) throws net.oauth.OAuthException
- Specified by:
getTokenSecretin interfaceorg.eclipse.lyo.server.oauth.core.token.TokenStrategy- Throws:
net.oauth.OAuthException
-
getOAuthIdentity
public OAuthIdentity getOAuthIdentity(String oauthToken)
Description copied from interface:OAuthIdentityTokenStrategyGets theOAuthIdentityassociated with an access/request token. Implementations must catch (and cache) this identity during theOAuth dance.- Specified by:
getOAuthIdentityin interfaceOAuthIdentityTokenStrategy- Parameters:
oauthToken- the access or request token key.- Returns:
- the associated identity if found,
nullotherwise.
-
setTwoLeggedOAuthIdentity
public void setTwoLeggedOAuthIdentity(String consumerKey, OAuthIdentity identity)
Description copied from interface:OAuthIdentityTokenStrategyConvenient method to associate anOAuthIdentitywith 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 theOAuthIdentityof the corresponding functional user once is resolved; subsequent requests can call then theOAuthIdentityTokenStrategy.getTwoLeggedOAuthIdentity(String)method to get theOAuthIdentityof the consumer without having to resolve it again.- Specified by:
setTwoLeggedOAuthIdentityin 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:OAuthIdentityTokenStrategyGets theOAuthIdentitymapped 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:
getTwoLeggedOAuthIdentityin interfaceOAuthIdentityTokenStrategy- Parameters:
consumerKey- the consumer key.- Returns:
- the corresponding
OAuthIdentityif mapped;nullotherwise.
-
removeTwoLeggedOAuthIdentity
public void removeTwoLeggedOAuthIdentity(String consumerKey)
Description copied from interface:OAuthIdentityTokenStrategyRemoves theOAuthIdentitymapped to a consumer key by theOAuthIdentityTokenStrategy.setTwoLeggedOAuthIdentity(String, OAuthIdentity)method.- Specified by:
removeTwoLeggedOAuthIdentityin interfaceOAuthIdentityTokenStrategy- Parameters:
consumerKey- the consumer key.
-
-