Class AuthenticationInfo
- java.lang.Object
 - 
- java.util.AbstractMap<K,V>
 - 
- java.util.HashMap<java.lang.String,java.lang.Object>
 - 
- org.apache.sling.commons.auth.spi.AuthenticationInfo
 
 
 
 
- 
- All Implemented Interfaces:
 java.io.Serializable,java.lang.Cloneable,java.util.Map<java.lang.String,java.lang.Object>
public class AuthenticationInfo extends java.util.HashMap<java.lang.String,java.lang.Object>TheAuthenticationInfoconveys any authentication credentials and/or details extracted by theAuthenticationHandler.extractCredentials(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)method from the request.AuthenticationHandlerimplementations must return instances of this class which may be constructed through any of the provided public constructors.Internally all values are stored in the map where some property names have special semantics and the data type of the properties are ensured by the
put(String, Object)method implementation.- See Also:
 - Serialized Form
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAUTH_TYPEThe name of the special property providing the authentication type provided by theAuthenticationHandler.static java.lang.StringCREDENTIALSThe name of the property providing the JCR credentials.static AuthenticationInfoDOING_AUTHA special instance of this class which may be returned from theAuthenticationHandler.extractCredentials(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)method to inform the caller, that a response has been sent to the client to request for credentials.static AuthenticationInfoFAIL_AUTHA special instance of this class which may be returned from theAuthenticationHandler.extractCredentials(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)method to inform the caller that credential extraction failed for some reason.static java.lang.StringPASSWORDThe name of the property providing the password of the user on whose behalf the request is being handled.static java.lang.StringUSERThe name of the property providing the name of the user on whose behalf the request is being handled. 
- 
Constructor Summary
Constructors Constructor Description AuthenticationInfo(java.lang.String authType)Creates an instance of this class with just the authentication type.AuthenticationInfo(java.lang.String authType, java.lang.String userId)Creates an instance of this class authenticating with the given type and userid.AuthenticationInfo(java.lang.String authType, java.lang.String userId, char[] password)Creates an instance of this class authenticating with the given type and userid/password connecting. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears all properties from the map with the exception of theAUTH_TYPEproperty.java.lang.StringgetAuthType()Returns the authentication type stored as theAUTH_TYPEproperty in this map.char[]getPassword()Returns the password stored as thePASSWORDproperty ornullif the password is not set in this map.java.lang.StringgetUser()Returns the user name stored as theUSERproperty ornullif the user is not set in this map.java.lang.Objectput(java.lang.String key, java.lang.Object value)Sets or resets a property with the givenkeyto a newvalue.java.lang.Objectremove(java.lang.Object key)Removes the entry with the givenkeyand returns its former value (if existing).voidsetAuthType(java.lang.String authType)voidsetPassword(char[] password)voidsetUser(java.lang.String user) 
 - 
 
- 
- 
Field Detail
- 
DOING_AUTH
public static final AuthenticationInfo DOING_AUTH
A special instance of this class which may be returned from theAuthenticationHandler.extractCredentials(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)method to inform the caller, that a response has been sent to the client to request for credentials.If this value is returned, the request should be considered finished and no further actions should be taken on this request.
 
- 
FAIL_AUTH
public static final AuthenticationInfo FAIL_AUTH
A special instance of this class which may be returned from theAuthenticationHandler.extractCredentials(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)method to inform the caller that credential extraction failed for some reason.If this value is returned, the handler signals that credentials would be present in the request but the credentials are not valid for use (for example OpenID identify failed to validate or some authentication cookie expired).
 
- 
AUTH_TYPE
public static final java.lang.String AUTH_TYPE
The name of the special property providing the authentication type provided by theAuthenticationHandler. This value must be supplied to one of the constructors and is ultimately used as the value of theHttpServletRequest.getAuthTypemethod.This property is always present (and cannot be removed) in this map and is of
Stringtype.- See Also:
 - Constant Field Values
 
 
- 
USER
public static final java.lang.String USER
The name of the property providing the name of the user on whose behalf the request is being handled. This property is set by theAuthenticationInfo(String, String, char[])constructor and may benullif this instance is created by either theAuthenticationInfo(String, String)orAuthenticationInfo(String, String, char[])constructors.The type of this property, if present, is
String.- See Also:
 - Constant Field Values
 
 
- 
PASSWORD
public static final java.lang.String PASSWORD
The name of the property providing the password of the user on whose behalf the request is being handled. This property is set by theAuthenticationInfo(String, String, char[])constructor and may benullif this instance is created by either theAuthenticationInfo(String, String)orAuthenticationInfo(String, String, char[])constructors.The type of this property, if present, is
char[].- See Also:
 - Constant Field Values
 
 
- 
CREDENTIALS
public static final java.lang.String CREDENTIALS
The name of the property providing the JCR credentials. These credentials are preset to the credentials given to theAuthenticationInfo(String, String)orAuthenticationInfo(String, String, char[])constructors. is used the credentials property is set to a JCRSimpleCredentialsinstance containing the user id and password passed to the constructor.- See Also:
 - Constant Field Values
 
 
 - 
 
- 
Constructor Detail
- 
AuthenticationInfo
public AuthenticationInfo(java.lang.String authType)
Creates an instance of this class with just the authentication type. To effectively use this instance the user Id with optional password and/or the credentials should be set.- Parameters:
 authType- The authentication type, must not benull.
 
- 
AuthenticationInfo
public AuthenticationInfo(java.lang.String authType, java.lang.String userId)Creates an instance of this class authenticating with the given type and userid.- Parameters:
 authType- The authentication type, must not benull.userId- The name of the user to authenticate as. This may benullfor the constructor and later be set.- Throws:
 java.lang.NullPointerException- ifauthTypeisnull.
 
- 
AuthenticationInfo
public AuthenticationInfo(java.lang.String authType, java.lang.String userId, char[] password)Creates an instance of this class authenticating with the given type and userid/password connecting.- Parameters:
 authType- The authentication type, must not benull.userId- The name of the user to authenticate as. This may benullfor the constructor and later be set.password- The password to authenticate with ornullif no password can be supplied.- Throws:
 java.lang.NullPointerException- ifauthTypeisnull.
 
 - 
 
- 
Method Detail
- 
setAuthType
public final void setAuthType(java.lang.String authType)
- Parameters:
 authType- The authentication type to set. If this isnullthe current authentication type is not replaced.
 
- 
getAuthType
public final java.lang.String getAuthType()
Returns the authentication type stored as theAUTH_TYPEproperty in this map. This value is expected to never benull.If authentication is taking place through one of the standard ways, such as Basic or Digest, the return value is one of the predefined constants of the
HttpServletRequestinterface. Otherwise the value may be specific to theAuthenticationHandlerimplementation. 
- 
setUser
public final void setUser(java.lang.String user)
- Parameters:
 user- The name of the user to authenticate as. If this isnullthe current user name is not replaced.
 
- 
getUser
public final java.lang.String getUser()
Returns the user name stored as theUSERproperty ornullif the user is not set in this map. 
- 
setPassword
public final void setPassword(char[] password)
- Parameters:
 password- The password to authenticate with. If this isnullthe current password is not replaced.
 
- 
getPassword
public final char[] getPassword()
Returns the password stored as thePASSWORDproperty ornullif the password is not set in this map. 
- 
put
public java.lang.Object put(java.lang.String key, java.lang.Object value)Sets or resets a property with the givenkeyto a newvalue. Some keys have special meanings and their values are required to have predefined as listed in the following table:AUTH_TYPEStringUSERStringPASSWORDchar[]CREDENTIALSjavax.jcr.CredentialsIf the value for the special key does not match the required type an
IllegalArgumentExceptionis thrown.- Specified by:
 putin interfacejava.util.Map<java.lang.String,java.lang.Object>- Overrides:
 putin classjava.util.HashMap<java.lang.String,java.lang.Object>- Parameters:
 key- The name of the property to setvalue- The value of the property which must be of a special type if thekeydesignates one of the predefined properties.- Returns:
 - The value previously set for the given 
key. - Throws:
 java.lang.IllegalArgumentException- ifkeydesignates one of the special properties and thevaluedoes not have the correct type for the respective key.
 
- 
remove
public java.lang.Object remove(java.lang.Object key)
Removes the entry with the givenkeyand returns its former value (if existing). If thekeyisAUTH_TYPEthe value is not actually removed andnullis always returned.- Specified by:
 removein interfacejava.util.Map<java.lang.String,java.lang.Object>- Overrides:
 removein classjava.util.HashMap<java.lang.String,java.lang.Object>- Parameters:
 key- Removes the value associated with this key.- Returns:
 - The former value associated with the key.
 
 
- 
clear
public void clear()
Clears all properties from the map with the exception of theAUTH_TYPEproperty.- Specified by:
 clearin interfacejava.util.Map<java.lang.String,java.lang.Object>- Overrides:
 clearin classjava.util.HashMap<java.lang.String,java.lang.Object>
 
 - 
 
 -