public abstract class AbstractAuthenticationFormServlet
extends javax.servlet.http.HttpServlet
AbstractAuthenticationFormServlet
provides a basic
implementation of a simple servlet to render a login form for authentication
purposes.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CUSTOM_FORM_PATH
The path to the custom login form.
|
static java.lang.String |
DEFAULT_FORM_PATH
The path to the default login form.
|
Constructor and Description |
---|
AbstractAuthenticationFormServlet() |
Modifier and Type | Method and Description |
---|---|
protected void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Prepares and returns the login form.
|
protected void |
doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Prepares and returns the login form.
|
protected java.lang.String |
getContextPath(javax.servlet.http.HttpServletRequest request)
Returns the context path for the authentication form request.
|
protected java.lang.String |
getCustomFormPath()
Returns the path to the custom login form to load through the class
loader of this instance using
Class.getResourceAsStream . |
protected java.lang.String |
getDefaultFormPath()
Returns the path to the default login form to load through the class
loader of this instance using
Class.getResourceAsStream . |
protected java.lang.String |
getForm(javax.servlet.http.HttpServletRequest request)
Returns the form to be sent back to the client for login providing an
optional informational message and the optional target to redirect to
after successfully logging in.
|
protected abstract java.lang.String |
getReason(javax.servlet.http.HttpServletRequest request)
Returns an informational message according to the value provided in the
j_reason request parameter. |
protected java.lang.String |
getResource(javax.servlet.http.HttpServletRequest request)
Returns the path to the resource to which the request should be
redirected after successfully completing the form or an empty string if
there is no
resource request parameter. |
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
public static final java.lang.String DEFAULT_FORM_PATH
getDefaultFormPath()
,
Constant Field Valuespublic static final java.lang.String CUSTOM_FORM_PATH
getCustomFormPath()
,
Constant Field Valuesprotected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException
text/html
page with all known cache control headers
set to prevent all caching.
This servlet is to be called to handle the request directly, that is it expected to not be included and for the response to not be committed yet because it first resets the response.
doGet
in class javax.servlet.http.HttpServlet
java.io.IOException
- if an error occurs preparing or sending back the
login formjava.lang.IllegalStateException
- if the response has already been committed
and thus response reset is not possible.protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException
text/html
page with all known cache control headers
set to prevent all caching.
This servlet is to be called to handle the request directly, that is it expected to not be included and for the response to not be committed yet because it first resets the response.
doPost
in class javax.servlet.http.HttpServlet
java.io.IOException
- if an error occurs preparing or sending back the
login formjava.lang.IllegalStateException
- if the response has already been committed
and thus response reset is not possible.protected java.lang.String getForm(javax.servlet.http.HttpServletRequest request) throws java.io.IOException
request
- The request providing parameters indicating the
informational message and redirection target.java.io.IOException
- If the login form cannot be loadedprotected java.lang.String getResource(javax.servlet.http.HttpServletRequest request)
resource
request parameter.request
- The request providing the resource
parameter.protected abstract java.lang.String getReason(javax.servlet.http.HttpServletRequest request)
j_reason
request parameter. Supported reasons are invalid
credentials and session timeout.request
- The request providing the parameterprotected java.lang.String getContextPath(javax.servlet.http.HttpServletRequest request)
getResource(HttpServletRequest)
(without the optional query
string which may be contained in the resource path). If getResource(HttpServletRequest)
return an empty string, the servlet context path is used.request
- The requestprotected java.lang.String getDefaultFormPath()
Class.getResourceAsStream
.
The default form is used intended to be included with the bundle implementing this abstract class.
This method returns DEFAULT_FORM_PATH
and may be overwritten by
implementations.
DEFAULT_FORM_PATH
protected java.lang.String getCustomFormPath()
Class.getResourceAsStream
.
The custom form can be supplied by a fragment attaching to the bundle implementing this abstract class.
This method returns CUSTOM_FORM_PATH
and may be overwritten by
implementations.
CUSTOM_FORM_PATH
Copyright © 2022 The Apache Software Foundation. All rights reserved.