Package org.apache.sling.auth.form.impl
Class FormAuthenticationHandler
- java.lang.Object
-
- org.apache.sling.auth.core.spi.DefaultAuthenticationFeedbackHandler
-
- org.apache.sling.auth.form.impl.FormAuthenticationHandler
-
- All Implemented Interfaces:
org.apache.sling.auth.core.spi.AuthenticationFeedbackHandler,org.apache.sling.auth.core.spi.AuthenticationHandler
public class FormAuthenticationHandler extends org.apache.sling.auth.core.spi.DefaultAuthenticationFeedbackHandler implements org.apache.sling.auth.core.spi.AuthenticationHandlerTheFormAuthenticationHandlerclass implements the authorization steps based on a cookie.
-
-
Constructor Summary
Constructors Constructor Description FormAuthenticationHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidactivate(FormAuthenticationHandlerConfig config, org.osgi.service.component.ComponentContext componentContext)Called by SCR to activate the authentication handler.voidauthenticationFailed(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.apache.sling.auth.core.spi.AuthenticationInfo authInfo)Called after an unsuccessful login attempt.booleanauthenticationSucceeded(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.apache.sling.auth.core.spi.AuthenticationInfo authInfo)Called after successful login with the given authentication info.protected voiddeactivate()voiddropCredentials(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Clears all authentication state which might have been prepared by this authentication handler.org.apache.sling.auth.core.spi.AuthenticationInfoextractCredentials(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Extracts cookie/session based credentials from the request.booleanisValid(javax.jcr.Credentials credentials)booleanrequestCredentials(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Unless thesling:authRequestLoginto anything other thanFormthis method either sends back a 403/FORBIDDEN response if thej_verifyparameter is set totrueor redirects to the login form to ask for credentials.StringtoString()
-
-
-
Method Detail
-
extractCredentials
public org.apache.sling.auth.core.spi.AuthenticationInfo extractCredentials(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Extracts cookie/session based credentials from the request. Returnsnullif the handler assumes HTTP Basic authentication would be more appropriate, if no form fields are present in the request and if the secure user data is not present either in the cookie or an HTTP Session.- Specified by:
extractCredentialsin interfaceorg.apache.sling.auth.core.spi.AuthenticationHandler
-
requestCredentials
public boolean requestCredentials(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOExceptionUnless thesling:authRequestLoginto anything other thanFormthis method either sends back a 403/FORBIDDEN response if thej_verifyparameter is set totrueor redirects to the login form to ask for credentials.This method assumes the
j_verifyrequest parameter to only be set in the initial username/password submission through the login form. No further checks are applied, though, before sending back the 403/FORBIDDEN response.- Specified by:
requestCredentialsin interfaceorg.apache.sling.auth.core.spi.AuthenticationHandler- Throws:
IOException
-
dropCredentials
public void dropCredentials(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Clears all authentication state which might have been prepared by this authentication handler.- Specified by:
dropCredentialsin interfaceorg.apache.sling.auth.core.spi.AuthenticationHandler
-
authenticationFailed
public void authenticationFailed(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.apache.sling.auth.core.spi.AuthenticationInfo authInfo)Called after an unsuccessful login attempt. This implementation makes sure the authentication data is removed either by removing the cookie or by remove the HTTP Session attribute.- Specified by:
authenticationFailedin interfaceorg.apache.sling.auth.core.spi.AuthenticationFeedbackHandler- Overrides:
authenticationFailedin classorg.apache.sling.auth.core.spi.DefaultAuthenticationFeedbackHandler
-
authenticationSucceeded
public boolean authenticationSucceeded(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.apache.sling.auth.core.spi.AuthenticationInfo authInfo)Called after successful login with the given authentication info. This implementation ensures the authentication data is set in either the cookie or the HTTP session with the correct security tokens.If no authentication data already exists, it is created. Otherwise if the data has expired the data is updated with a new security token and a new expiry time.
If creating or updating the authentication data fails, it is actually removed from the cookie or the HTTP session and future requests will not be authenticated any longer.
- Specified by:
authenticationSucceededin interfaceorg.apache.sling.auth.core.spi.AuthenticationFeedbackHandler- Overrides:
authenticationSucceededin classorg.apache.sling.auth.core.spi.DefaultAuthenticationFeedbackHandler
-
isValid
public boolean isValid(javax.jcr.Credentials credentials)
-
activate
protected void activate(FormAuthenticationHandlerConfig config, org.osgi.service.component.ComponentContext componentContext) throws InvalidKeyException, NoSuchAlgorithmException, IllegalStateException, UnsupportedEncodingException
Called by SCR to activate the authentication handler.
-
deactivate
protected void deactivate()
-
-