Class CodeAuthentication
- java.lang.Object
-
- org.exoplatform.clouddrive.cmis.login.CodeAuthentication
-
public class CodeAuthentication extends Object
Maintain temporal codes for authentication in OAuth2 fashion. This component doesn't persist the codes. Only the last attempt actual (will work for the user).
Created by The eXo Platform SAS- Version:
- $Id: CodeAuthentication.java 00000 Aug 19, 2014 pnedonosko $
- Author:
- Peter Nedonosko
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classCodeAuthentication.IdentityThe Class Identity.
-
Field Summary
Fields Modifier and Type Field Description static longIDENTITY_LIFETIMELifetime of an identity in milliseconds.protected static org.exoplatform.services.log.LogLOGThe Constant LOG.
-
Constructor Summary
Constructors Constructor Description CodeAuthentication(org.exoplatform.services.idgenerator.IDGeneratorService idGenerator, org.exoplatform.services.jcr.RepositoryService jcrService)Instantiates a new code authentication.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Stringauthenticate(String serviceURL, String user, String password)Create user identity for given user name, password and a service URL.CodeAuthentication.IdentityexchangeCode(String code)Exchange given code on user identity associated with this code inauthenticate(String, String, String).booleanhasCode(String code)Deprecated.booleanhasCodeContext(String code)Deprecated.voidsetCodeContext(String code, String context)Set identity context for a code.
-
-
-
Field Detail
-
IDENTITY_LIFETIME
public static final long IDENTITY_LIFETIME
Lifetime of an identity in milliseconds.- See Also:
- Constant Field Values
-
LOG
protected static final org.exoplatform.services.log.Log LOG
The Constant LOG.
-
-
Constructor Detail
-
CodeAuthentication
public CodeAuthentication(org.exoplatform.services.idgenerator.IDGeneratorService idGenerator, org.exoplatform.services.jcr.RepositoryService jcrService)Instantiates a new code authentication.- Parameters:
idGenerator- the id generatorjcrService- the jcr service
-
-
Method Detail
-
authenticate
public String authenticate(String serviceURL, String user, String password)
Create user identity for given user name, password and a service URL. This identity will be stored internally and an authentication code will be returned to the caller. Later this code can be exchanged on the identity inexchangeCode(String).- Parameters:
serviceURL-Stringuser-Stringpassword-String- Returns:
String- See Also:
exchangeCode(String)
-
hasCode
@Deprecated public boolean hasCode(String code)
Deprecated.Checks for code.- Parameters:
code- the code- Returns:
- true, if successful
-
exchangeCode
public CodeAuthentication.Identity exchangeCode(String code) throws AuthenticationException
Exchange given code on user identity associated with this code inauthenticate(String, String, String). User identity after this method may be not fully initialized as for its context. Identity context is optional and can be initialized bysetCodeContext(String, String)method once, after that call identity will be fully removed from the authenticator.
If given code wasn't associated with an user previously thenAuthenticationExceptionwill be thrown.- Parameters:
code-String- Returns:
CodeAuthentication.Identityof an user- Throws:
AuthenticationException- if code doesn't match any user- See Also:
setCodeContext(String, String)
-
setCodeContext
public void setCodeContext(String code, String context) throws AuthenticationException
Set identity context for a code. The code may be already exchanged byexchangeCode(String), after this it will be fully removed from the authenticator.
If given code wasn't associated with an user previously thenAuthenticationExceptionwill be thrown.- Parameters:
code-Stringcontext-String- Throws:
AuthenticationException- the authentication exception- See Also:
exchangeCode(String)
-
hasCodeContext
@Deprecated public boolean hasCodeContext(String code)
Deprecated.Checks for code context.- Parameters:
code- the code- Returns:
- true, if successful
-
-