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
Default
OAuthIdentityTokenStrategy implementation that is, depending on the CacheBuilder cluster factory set by the application,
able to work on cluster environments. Note: the default CacheBuilder implementation is NOT cluster compatible, applications working in
cluster environments MUST provide a cluster-compliant implementation.- Since:
- 3.3.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidgenerateAccessToken(org.eclipse.lyo.server.oauth.core.OAuthRequest oAuthRequest) voidgenerateRequestToken(org.eclipse.lyo.server.oauth.core.OAuthRequest oAuthRequest) generateVerificationCode(HttpServletRequest httpRequest, String requestToken) getCallback(HttpServletRequest httpRequest, String requestToken) getOAuthIdentity(String oauthToken) Gets theOAuthIdentityassociated with an access/request token.getTokenSecret(HttpServletRequest httpRequest, String token) getTwoLeggedOAuthIdentity(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) validateRequestToken(HttpServletRequest httpRequest, net.oauth.OAuthMessage message) voidvalidateVerificationCode(org.eclipse.lyo.server.oauth.core.OAuthRequest oAuthRequest)
-
Constructor Details
-
ClusterableTokenStrategy
public ClusterableTokenStrategy()
-
-
Method Details
-
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
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
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
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
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.
-