public abstract class AuthenticationMethod extends Object
AuthenticationMethod
represents an authentication method that can be used to
authenticate an entity in a particular web application.Modifier and Type | Class and Description |
---|---|
static class |
AuthenticationMethod.UnsupportedAuthenticationCredentialsException
Thrown when an unsupported type of credentials is used with a
AuthenticationMethod . |
Modifier and Type | Field and Description |
---|---|
static String |
AUTH_STATE_LOGGED_IN_STATS |
static String |
AUTH_STATE_LOGGED_OUT_STATS |
static String |
AUTH_STATE_NO_INDICATOR_STATS |
static String |
AUTH_STATE_UNKNOWN_STATS |
static String |
CONTEXT_CONFIG_AUTH |
static String |
CONTEXT_CONFIG_AUTH_LOGGEDIN |
static String |
CONTEXT_CONFIG_AUTH_LOGGEDOUT |
static String |
CONTEXT_CONFIG_AUTH_TYPE |
protected Pattern |
loggedInIndicatorPattern
The logged in indicator pattern.
|
protected Pattern |
loggedOutIndicatorPattern
The logged out indicator pattern.
|
Constructor and Description |
---|
AuthenticationMethod() |
Modifier and Type | Method and Description |
---|---|
abstract WebSession |
authenticate(SessionManagementMethod sessionManagementMethod,
AuthenticationCredentials credentials,
User user)
Performs an authentication in a web application, returning an authenticated.
|
AuthenticationMethod |
clone()
Clones the current authentication method, creating a deep-copy of it.
|
abstract AuthenticationCredentials |
createAuthenticationCredentials()
Creates a new, empty, Authentication Credentials object corresponding to this type of
Authentication method.
|
protected abstract AuthenticationMethod |
duplicate()
Internal method for cloning the current authentication method, creating a deep-copy of it.
|
boolean |
equals(Object obj) |
abstract ApiResponse |
getApiResponseRepresentation()
Gets an api response that represents the Authentication Method.
|
Pattern |
getLoggedInIndicatorPattern()
Gets the logged in indicator pattern.
|
Pattern |
getLoggedOutIndicatorPattern()
Gets the logged out indicator pattern.
|
abstract AuthenticationMethodType |
getType()
Gets the
AuthenticationMethodType corresponding to this authentication method. |
int |
hashCode() |
boolean |
isAuthenticated(HttpMessage msg)
Checks if the response received by the Http Message corresponds to an authenticated Web
Session.
|
abstract boolean |
isConfigured()
Checks if the authentication method is fully configured.
|
boolean |
isSameType(AuthenticationMethod other)
Checks if another method is of the same type.
|
void |
onMethodDiscarded()
Called when the Authentication Method is discarded from/not used in a Context.
|
void |
onMethodPersisted()
Called when the Authentication Method is persisted/saved in a Context.
|
void |
setLoggedInIndicatorPattern(String loggedInIndicatorPattern)
Sets the logged in indicator pattern.
|
void |
setLoggedOutIndicatorPattern(String loggedOutIndicatorPattern)
Sets the logged out indicator pattern.
|
boolean |
validateCreationOfAuthenticationCredentials()
Validates that the creation of authentication credentials is possible, returning
true
if it is, false otherwise. |
public static final String CONTEXT_CONFIG_AUTH
public static final String CONTEXT_CONFIG_AUTH_TYPE
public static final String CONTEXT_CONFIG_AUTH_LOGGEDIN
public static final String CONTEXT_CONFIG_AUTH_LOGGEDOUT
public static final String AUTH_STATE_LOGGED_IN_STATS
public static final String AUTH_STATE_LOGGED_OUT_STATS
public static final String AUTH_STATE_NO_INDICATOR_STATS
public static final String AUTH_STATE_UNKNOWN_STATS
protected Pattern loggedInIndicatorPattern
protected Pattern loggedOutIndicatorPattern
public abstract boolean isConfigured()
public AuthenticationMethod clone()
protected abstract AuthenticationMethod duplicate()
public boolean validateCreationOfAuthenticationCredentials()
true
if it is, false
otherwise.
If view is enabled the user should be informed that it's not possible to create authentication credentials.
Default implementation returns, always, true
.
true
if the creation of authentication credentials is possible, false
otherwisecreateAuthenticationCredentials()
public abstract AuthenticationCredentials createAuthenticationCredentials()
validateCreationOfAuthenticationCredentials()
public abstract AuthenticationMethodType getType()
AuthenticationMethodType
corresponding to this authentication method.
Implementations may return new instantiations at every call, so performance considerations should be taken by users.
public abstract WebSession authenticate(SessionManagementMethod sessionManagementMethod, AuthenticationCredentials credentials, User user) throws AuthenticationMethod.UnsupportedAuthenticationCredentialsException
sessionManagementMethod
- the set up session management method is provided so it can be
used, if needed, to automatically extract session information from Http Messages.credentials
- the credentialsuser
- the user to authenticateAuthenticationMethod.UnsupportedAuthenticationCredentialsException
- the unsupported authentication
credentials exception WebSession
.public abstract ApiResponse getApiResponseRepresentation()
public void onMethodPersisted()
public void onMethodDiscarded()
public boolean isAuthenticated(HttpMessage msg)
If none of the indicators are set up, the method defaults to returning true, so that no authentications are tried when there is no way to check authentication. A message is also shown on the output console in this case.
msg
- the http messagepublic Pattern getLoggedInIndicatorPattern()
public void setLoggedInIndicatorPattern(String loggedInIndicatorPattern)
loggedInIndicatorPattern
- the new logged in indicator patternpublic Pattern getLoggedOutIndicatorPattern()
public void setLoggedOutIndicatorPattern(String loggedOutIndicatorPattern)
loggedOutIndicatorPattern
- the new logged out indicator patternpublic boolean isSameType(AuthenticationMethod other)
other
- the other