public class FormClient extends IndirectClient<UsernamePasswordCredentials,CommonProfile>
This class is the client to authenticate users through HTTP form.
The login url of the form must be defined through the setLoginUrl(String)
method. For authentication, the user is
redirected to this login form. The username and password inputs must be posted on the callback url. Their names can be defined by using
the setUsernameParameter(String)
and setPasswordParameter(String)
methods.
Modifier and Type | Field and Description |
---|---|
static String |
ERROR_PARAMETER |
static String |
MISSING_FIELD_ERROR |
ATTEMPTED_AUTHENTICATION_SUFFIX, callbackUrl, urlResolver
logger
Constructor and Description |
---|
FormClient() |
FormClient(String loginUrl,
Authenticator usernamePasswordAuthenticator) |
FormClient(String loginUrl,
Authenticator usernamePasswordAuthenticator,
ProfileCreator profileCreator) |
FormClient(String loginUrl,
String usernameParameter,
String passwordParameter,
Authenticator usernamePasswordAuthenticator) |
Modifier and Type | Method and Description |
---|---|
protected void |
clientInit(WebContext context)
Initialize the client.
|
protected String |
computeErrorMessage(Exception e)
Return the error message depending on the thrown exception.
|
String |
getLoginUrl() |
String |
getPasswordParameter() |
String |
getUsernameParameter() |
protected HttpAction |
handleInvalidCredentials(WebContext context,
String username,
String message,
String errorMessage) |
protected UsernamePasswordCredentials |
retrieveCredentials(WebContext context)
Retrieve the credentials.
|
void |
setLoginUrl(String loginUrl) |
void |
setPasswordParameter(String passwordParameter) |
void |
setUsernameParameter(String usernameParameter) |
String |
toString() |
computeFinalCallbackUrl, defaultLogoutActionBuilder, defaultRedirectActionBuilder, getAjaxRequestResolver, getCallbackUrl, getCallbackUrlResolver, getCredentials, getLogoutAction, getLogoutActionBuilder, getRedirectAction, getRedirectActionBuilder, getUrlResolver, internalInit, isIncludeClientNameInCallbackUrl, redirect, setAjaxRequestResolver, setCallbackUrl, setCallbackUrlResolver, setIncludeClientNameInCallbackUrl, setLogoutActionBuilder, setRedirectActionBuilder, setUrlResolver
addAuthorizationGenerator, addAuthorizationGenerators, defaultAuthenticator, defaultCredentialsExtractor, defaultProfileCreator, getAuthenticator, getAuthorizationGenerators, getCredentialsExtractor, getName, getProfileCreator, getUserProfile, notifySessionRenewal, retrieveUserProfile, setAuthenticator, setAuthorizationGenerator, setAuthorizationGenerators, setAuthorizationGenerators, setCredentialsExtractor, setName, setProfileCreator
init, reinit
public static final String ERROR_PARAMETER
public static final String MISSING_FIELD_ERROR
public FormClient()
public FormClient(String loginUrl, Authenticator usernamePasswordAuthenticator)
public FormClient(String loginUrl, String usernameParameter, String passwordParameter, Authenticator usernamePasswordAuthenticator)
public FormClient(String loginUrl, Authenticator usernamePasswordAuthenticator, ProfileCreator profileCreator)
protected void clientInit(WebContext context)
IndirectClient
clientInit
in class IndirectClient<UsernamePasswordCredentials,CommonProfile>
context
- the web contextprotected UsernamePasswordCredentials retrieveCredentials(WebContext context) throws HttpAction
BaseClient
retrieveCredentials
in class BaseClient<UsernamePasswordCredentials,CommonProfile>
context
- the web contextHttpAction
- whether an additional HTTP action is requiredprotected HttpAction handleInvalidCredentials(WebContext context, String username, String message, String errorMessage) throws HttpAction
HttpAction
protected String computeErrorMessage(Exception e)
e
- the technical exceptionpublic String getLoginUrl()
public void setLoginUrl(String loginUrl)
public String getUsernameParameter()
public void setUsernameParameter(String usernameParameter)
public String getPasswordParameter()
public void setPasswordParameter(String passwordParameter)
public String toString()
toString
in class IndirectClient<UsernamePasswordCredentials,CommonProfile>
Copyright © 2017. All rights reserved.