Package org.apache.sling.auth.core.spi
Class DefaultAuthenticationFeedbackHandler
java.lang.Object
org.apache.sling.auth.core.spi.DefaultAuthenticationFeedbackHandler
- All Implemented Interfaces:
AuthenticationFeedbackHandler
- Direct Known Subclasses:
AbstractAuthenticationHandler
public class DefaultAuthenticationFeedbackHandler
extends Object
implements AuthenticationFeedbackHandler
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidauthenticationFailed(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, AuthenticationInfo authInfo) This default implementation does nothing.booleanauthenticationSucceeded(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, AuthenticationInfo authInfo) This default implementation calls thehandleRedirect(HttpServletRequest, HttpServletResponse)method to optionally redirect the request after successful authentication.static booleanhandleRedirect(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Handles an optional request for a redirect after successful authentication andtrueif the request has been redirected.
-
Constructor Details
-
DefaultAuthenticationFeedbackHandler
public DefaultAuthenticationFeedbackHandler()
-
-
Method Details
-
handleRedirect
public static boolean handleRedirect(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Handles an optional request for a redirect after successful authentication andtrueif the request has been redirected.This method checks
AuthenticationSupport.REDIRECT_PARAMETERrequest parameter for the redirect target. This parameter is handled as follows:- If the parameter does not exist, the method does not redirect and
falseis returned. - If the parameter is the string
trueor is empty, a redirect response to the request URI (HttpServletRequest.getRequestURI()) is sent andtrueis returned. - If the parameter is a relative path, the path is made absolute
by resolving it relative to the request URI
(
HttpServletRequest.getRequestURI()). The resulting target is validated with theAbstractAuthenticationHandler.isRedirectValid(HttpServletRequest, String)method. If valid a redirect to that target is sent back andtrueis returned. Otherwise a redirect to the servlet context root is sent back andtrueis returned. - If the parameter is an absolute path it is validated with the
AbstractAuthenticationHandler.isRedirectValid(HttpServletRequest, String)method. If valid a redirect to that path is sent back andtrueis returned. Otherwise a redirect to the servlet context root is sent back andtrueis returned.
- Parameters:
request- The servlet requestresponse- The servlet response- Returns:
trueif redirect was requested. Otherwisefalseis returned. Note, thattrueis returned regardless of whether sending the redirect response succeeded or not.- Since:
- 1.0.4 (bundle version 1.0.8) the target is validated with the
AbstractAuthenticationHandler.isRedirectValid(HttpServletRequest, String)method.
- If the parameter does not exist, the method does not redirect and
-
authenticationFailed
public void authenticationFailed(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, AuthenticationInfo authInfo) This default implementation does nothing.Extensions of this class may overwrite to cleanup any internal state.
- Specified by:
authenticationFailedin interfaceAuthenticationFeedbackHandler- Parameters:
request- The current requestresponse- The current responseauthInfo- TheAuthenticationInfoobject used to authenticate the request.
-
authenticationSucceeded
public boolean authenticationSucceeded(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, AuthenticationInfo authInfo) This default implementation calls thehandleRedirect(HttpServletRequest, HttpServletResponse)method to optionally redirect the request after successful authentication.Extensions of this class may overwrite this method to perform additional cleanup etc.
- Specified by:
authenticationSucceededin interfaceAuthenticationFeedbackHandler- Parameters:
request- The current requestresponse- The current responseauthInfo- TheAuthenticationInfoobject used to authenticate the request.- Returns:
- the result of calling the
handleRedirect(HttpServletRequest, HttpServletResponse)method.
-