Package io.milton.http.http11.auth
Class FormAuthenticationHandler
java.lang.Object
io.milton.http.http11.auth.FormAuthenticationHandler
- All Implemented Interfaces:
AuthenticationHandler
Supports authentication from form parameters.
Note that this will not by itself result in a persistent login. It should
be used with cookie authentication handler, or some equivalent session
based handler
- Author:
- brad
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappendChallenges(Resource resource, Request request, List<String> challenges) Create a challenge for this authentication method.authenticate(Resource resource, Request request) The authentication result is written to a request attribute called "loginResult".booleancredentialsPresent(Request request) Determine if there are login credentials present.Get the attribute name used to store the login result.booleanisCompatible(Resource resource, Request request) Returns true if this authentication handler is compatible with the given resource This is used when authorisation has failed, in generating challenge responses If you don't want to add a challenge response, return falsevoidsetLoginResultAttName(String loginResultAttName) voidsetPasswordParam(String passwordParam) voidsetUserNameParam(String userNameParam) booleanReturns true if this supports authenticating with the given Auth data on the given resource.
-
Constructor Details
-
FormAuthenticationHandler
public FormAuthenticationHandler()
-
-
Method Details
-
supports
Description copied from interface:AuthenticationHandlerReturns true if this supports authenticating with the given Auth data on the given resource. Only the first AuthenticationHandler which returns true for supports will be used for authentication. Ie supports implementations should be mutually exclusive- Specified by:
supportsin interfaceAuthenticationHandler- Parameters:
r- - the resource being access- Returns:
-
authenticate
The authentication result is written to a request attribute called "loginResult". Its value is "true" if login succeeded and "false" if not. Note that a successful login does not ensure that that authorisation will succeed. If rendering a login page based on authentication and authorisation you should also look at the "authReason" attribute set by the LoginResponseHandler which gives the reason for an authorisation failure- Specified by:
authenticatein interfaceAuthenticationHandler- Parameters:
resource-request-- Returns:
-
credentialsPresent
Description copied from interface:AuthenticationHandlerDetermine if there are login credentials present. Should not attempt to validate credentials. Should only determine if something has been provided- Specified by:
credentialsPresentin interfaceAuthenticationHandler- Returns:
-
appendChallenges
Description copied from interface:AuthenticationHandlerCreate a challenge for this authentication method. This should be completely formatted as per http://tools.ietf.org/html/rfc2617 and appended to the given list of challenges. It is allowable to append more then one challenge if appropriate- Specified by:
appendChallengesin interfaceAuthenticationHandlerchallenges- - the list of challenges to append to, or not, as appropriate
-
isCompatible
Description copied from interface:AuthenticationHandlerReturns true if this authentication handler is compatible with the given resource This is used when authorisation has failed, in generating challenge responses If you don't want to add a challenge response, return false- Specified by:
isCompatiblein interfaceAuthenticationHandler- Returns:
- - true if this can authenticate the resource, and it should issue a http challenge
-
getUserNameParam
-
setUserNameParam
-
getPasswordParam
-
setPasswordParam
-
getLoginResultAttName
Get the attribute name used to store the login result. The login result is a Boolean which indicates if authentication was successful or not. A null value indicates that authentication was not attempted- Returns:
-
setLoginResultAttName
-