Package org.apache.sling.auth.core.spi
Class AbstractJakartaAuthenticationFormServlet
java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
org.apache.sling.auth.core.spi.AbstractJakartaAuthenticationFormServlet
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable
public abstract class AbstractJakartaAuthenticationFormServlet
extends jakarta.servlet.http.HttpServlet
The
AbstractJakartaAuthenticationFormServlet provides a basic
implementation of a simple servlet to render a login form for authentication
purposes.- Since:
- 1.3.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe path to the custom login form.static final StringThe path to the default login form.Fields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Prepares and returns the login form.protected voiddoPost(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Prepares and returns the login form.protected StringgetContextPath(jakarta.servlet.http.HttpServletRequest request) Returns the context path for the authentication form request.protected StringReturns the path to the custom login form to load through the class loader of this instance usingClass.getResourceAsStream.protected StringReturns the path to the default login form to load through the class loader of this instance usingClass.getResourceAsStream.protected StringgetForm(jakarta.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 StringgetReason(jakarta.servlet.http.HttpServletRequest request) Returns an informational message according to the value provided in thej_reasonrequest parameter.protected StringgetResource(jakarta.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 noresourcerequest parameter.Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPatch, doPut, doTrace, getLastModified, init, isSensitiveHeader, service, serviceMethods inherited from class jakarta.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Field Details
-
DEFAULT_FORM_PATH
The path to the default login form.- See Also:
-
CUSTOM_FORM_PATH
The path to the custom login form.- See Also:
-
-
Constructor Details
-
AbstractJakartaAuthenticationFormServlet
public AbstractJakartaAuthenticationFormServlet()
-
-
Method Details
-
doGet
protected void doGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException Prepares and returns the login form. The response is sent as an UTF-8 encodedtext/htmlpage 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.
- Overrides:
doGetin classjakarta.servlet.http.HttpServlet- Throws:
IOException- if an error occurs preparing or sending back the login formIllegalStateException- if the response has already been committed and thus response reset is not possible.
-
doPost
protected void doPost(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException Prepares and returns the login form. The response is sent as an UTF-8 encodedtext/htmlpage 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.
- Overrides:
doPostin classjakarta.servlet.http.HttpServlet- Throws:
IOException- if an error occurs preparing or sending back the login formIllegalStateException- if the response has already been committed and thus response reset is not possible.
-
getForm
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.- Parameters:
request- The request providing parameters indicating the informational message and redirection target.- Returns:
- The login form to be returned to the client
- Throws:
IOException- If the login form cannot be loaded
-
getResource
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 noresourcerequest parameter.- Parameters:
request- The request providing theresourceparameter.- Returns:
- The target to redirect after successfully login or an empty string if no specific target has been requested.
-
getReason
Returns an informational message according to the value provided in thej_reasonrequest parameter. Supported reasons are invalid credentials and session timeout.- Parameters:
request- The request providing the parameter- Returns:
- The "translated" reason to render the login form or an empty string if there is no specific reason
-
getContextPath
Returns the context path for the authentication form request. This path is the path to the authenticated resource as returned bygetResource(HttpServletRequest)(without the optional query string which may be contained in the resource path). IfgetResource(HttpServletRequest)return an empty string, the servlet context path is used.- Parameters:
request- The request- Returns:
- The context path for the form action consisting of the resource to which the user is to authenticate.
-
getDefaultFormPath
Returns the path to the default login form to load through the class loader of this instance usingClass.getResourceAsStream.The default form is used intended to be included with the bundle implementing this abstract class.
This method returns
DEFAULT_FORM_PATHand may be overwritten by implementations.- Returns:
DEFAULT_FORM_PATH
-
getCustomFormPath
Returns the path to the custom login form to load through the class loader of this instance usingClass.getResourceAsStream.The custom form can be supplied by a fragment attaching to the bundle implementing this abstract class.
This method returns
CUSTOM_FORM_PATHand may be overwritten by implementations.- Returns:
CUSTOM_FORM_PATH
-