public class AuthenticationInfo
extends java.util.HashMap<java.lang.String,java.lang.Object>
AuthenticationInfo
conveys any authentication credentials
and/or details extracted by the
AuthenticationHandler.extractCredentials(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
method from the request.
AuthenticationHandler
implementations 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.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AUTH_TYPE
The name of the special property providing the authentication type
provided by the
AuthenticationHandler . |
static AuthenticationInfo |
DOING_AUTH
A special instance of this class which may be returned from the
AuthenticationHandler.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 AuthenticationInfo |
FAIL_AUTH
A special instance of this class which may be returned from the
AuthenticationHandler.extractCredentials(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
method to inform the caller that credential extraction failed for some
reason. |
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears all properties from the map with the exception of the
AUTH_TYPE property. |
java.lang.String |
getAuthType()
Returns the authentication type as stored in the
AUTH_TYPE property
in this map. |
char[] |
getPassword()
Returns the password stored as the
ResourceResolverFactory.PASSWORD property or
null if the password is not set in this map. |
java.lang.String |
getUser()
Returns the user name stored as the
ResourceResolverFactory.USER property or
null if the user is not set in this map. |
java.lang.Object |
put(java.lang.String key,
java.lang.Object value)
Sets or resets a property with the given
key to a new
value . |
java.lang.Object |
remove(java.lang.Object key)
Removes the entry with the given
key and returns its former
value (if existing). |
void |
setAuthType(java.lang.String authType) |
void |
setPassword(char[] password) |
void |
setUser(java.lang.String user) |
clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, replace, replace, replaceAll, size, values
public static final AuthenticationInfo DOING_AUTH
AuthenticationHandler.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.
public static final AuthenticationInfo FAIL_AUTH
AuthenticationHandler.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).
public static final java.lang.String AUTH_TYPE
AuthenticationHandler
. This value must be
supplied to one of the constructors and is ultimately used as the value
of the HttpServletRequest.getAuthType
method.
This property is always present (and cannot be removed) in this map and
is of String
type.
public AuthenticationInfo(java.lang.String authType)
authType
- The authentication type, must not be null
.public AuthenticationInfo(java.lang.String authType, java.lang.String userId)
authType
- The authentication type, must not be null
.userId
- The name of the user to authenticate as. This may be
null
for the constructor and later be set.java.lang.NullPointerException
- if authType
is
null
.public AuthenticationInfo(java.lang.String authType, java.lang.String userId, char[] password)
authType
- The authentication type, must not be null
.userId
- The name of the user to authenticate as. This may be
null
for the constructor and later be set.password
- The password to authenticate with or null
if
no password can be supplied.java.lang.NullPointerException
- if authType
is
null
.public final void setAuthType(java.lang.String authType)
authType
- The authentication type to set. If this is
null
the current authentication type is not
replaced.public final java.lang.String getAuthType()
AUTH_TYPE
property
in this map. This value is expected to never be null
.
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 HttpServletRequest
interface. Otherwise the value may
be specific to the AuthenticationHandler
implementation.
AUTH_TYPE
property.public final void setUser(java.lang.String user)
user
- The name of the user to authenticate as. If this is
null
the current user name is not replaced.public final java.lang.String getUser()
ResourceResolverFactory.USER
property or
null
if the user is not set in this map.ResourceResolverFactory.USER
property.public final void setPassword(char[] password)
password
- The password to authenticate with. If this is
null
the current password is not replaced.public final char[] getPassword()
ResourceResolverFactory.PASSWORD
property or
null
if the password is not set in this map.ResourceResolverFactory.PASSWORD
propertypublic java.lang.Object put(java.lang.String key, java.lang.Object value)
key
to a new
value
. Some keys have special meanings and their values are
required to have predefined as listed in the following table:
AUTH_TYPE |
String |
ResourceResolverFactory.USER |
String |
ResourceResolverFactory.PASSWORD |
char[] |
If the value for the special key does not match the required type an
IllegalArgumentException
is thrown.
put
in interface java.util.Map<java.lang.String,java.lang.Object>
put
in class java.util.HashMap<java.lang.String,java.lang.Object>
key
- The name of the property to setvalue
- The value of the property which must be of a special type if
the key
designates one of the predefined
properties.key
.java.lang.IllegalArgumentException
- if key
designates one of
the special properties and the value
does not
have the correct type for the respective key.public java.lang.Object remove(java.lang.Object key)
key
and returns its former
value (if existing). If the key
is AUTH_TYPE
the
value is not actually removed and null
is always returned.remove
in interface java.util.Map<java.lang.String,java.lang.Object>
remove
in class java.util.HashMap<java.lang.String,java.lang.Object>
key
- Removes the value associated with this key.public void clear()
AUTH_TYPE
property.clear
in interface java.util.Map<java.lang.String,java.lang.Object>
clear
in class java.util.HashMap<java.lang.String,java.lang.Object>
Copyright © 2022 The Apache Software Foundation. All rights reserved.