Class LoginProcessor
- java.lang.Object
-
- org.craftercms.security.processors.impl.LoginProcessor
-
- All Implemented Interfaces:
RequestSecurityProcessor
public class LoginProcessor extends Object implements RequestSecurityProcessor
Processes login requests.- Author:
- Alfonso Vásquez
-
-
Field Summary
Fields Modifier and Type Field Description protected AuthenticationManagerauthenticationManagerstatic StringDEFAULT_LOGIN_METHODstatic StringDEFAULT_LOGIN_URLstatic StringDEFAULT_PASSWORD_PARAMstatic StringDEFAULT_REMEMBER_ME_PARAMstatic StringDEFAULT_USERNAME_PARAMstatic org.slf4j.Loggerloggerprotected LoginFailureHandlerloginFailureHandlerprotected StringloginMethodprotected LoginSuccessHandlerloginSuccessHandlerprotected StringloginUrlprotected StringpasswordParameterprotected RememberMeManagerrememberMeManagerprotected StringrememberMeParameterprotected TenantsResolvertenantsResolverprotected StringusernameParameter
-
Constructor Summary
Constructors Constructor Description LoginProcessor()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidclearSession(javax.servlet.http.HttpServletRequest request)protected StringgetPassword(javax.servlet.http.HttpServletRequest request)protected booleangetRememberMe(javax.servlet.http.HttpServletRequest request)protected StringgetUsername(javax.servlet.http.HttpServletRequest request)protected booleanisLoginRequest(javax.servlet.http.HttpServletRequest request)protected voidonLoginFailure(org.craftercms.commons.http.RequestContext context, AuthenticationException e)protected voidonLoginSuccess(org.craftercms.commons.http.RequestContext context, Authentication authentication)voidprocessRequest(org.craftercms.commons.http.RequestContext context, RequestSecurityProcessorChain processorChain)Checks if the request URL matches theloginUrland the HTTP method matches theloginMethod.protected voidsaveException(javax.servlet.http.HttpServletRequest request, AuthenticationException e)voidsetAuthenticationManager(AuthenticationManager authenticationManager)voidsetLoginFailureHandler(LoginFailureHandler loginFailureHandler)voidsetLoginMethod(String loginMethod)voidsetLoginSuccessHandler(LoginSuccessHandler loginSuccessHandler)voidsetLoginUrl(String loginUrl)voidsetPasswordParameter(String passwordParameter)voidsetRememberMeManager(RememberMeManager rememberMeManager)voidsetRememberMeParameter(String rememberMeParameter)voidsetTenantsResolver(TenantsResolver tenantsResolver)voidsetUsernameParameter(String usernameParameter)
-
-
-
Field Detail
-
logger
public static final org.slf4j.Logger logger
-
DEFAULT_LOGIN_URL
public static final String DEFAULT_LOGIN_URL
- See Also:
- Constant Field Values
-
DEFAULT_LOGIN_METHOD
public static final String DEFAULT_LOGIN_METHOD
- See Also:
- Constant Field Values
-
DEFAULT_USERNAME_PARAM
public static final String DEFAULT_USERNAME_PARAM
- See Also:
- Constant Field Values
-
DEFAULT_PASSWORD_PARAM
public static final String DEFAULT_PASSWORD_PARAM
- See Also:
- Constant Field Values
-
DEFAULT_REMEMBER_ME_PARAM
public static final String DEFAULT_REMEMBER_ME_PARAM
- See Also:
- Constant Field Values
-
loginUrl
protected String loginUrl
-
loginMethod
protected String loginMethod
-
usernameParameter
protected String usernameParameter
-
passwordParameter
protected String passwordParameter
-
rememberMeParameter
protected String rememberMeParameter
-
tenantsResolver
protected TenantsResolver tenantsResolver
-
authenticationManager
protected AuthenticationManager authenticationManager
-
loginSuccessHandler
protected LoginSuccessHandler loginSuccessHandler
-
loginFailureHandler
protected LoginFailureHandler loginFailureHandler
-
rememberMeManager
protected RememberMeManager rememberMeManager
-
-
Method Detail
-
setLoginUrl
public void setLoginUrl(String loginUrl)
-
setLoginMethod
public void setLoginMethod(String loginMethod)
-
setPasswordParameter
public void setPasswordParameter(String passwordParameter)
-
setUsernameParameter
public void setUsernameParameter(String usernameParameter)
-
setRememberMeParameter
public void setRememberMeParameter(String rememberMeParameter)
-
setAuthenticationManager
public void setAuthenticationManager(AuthenticationManager authenticationManager)
-
setLoginSuccessHandler
public void setLoginSuccessHandler(LoginSuccessHandler loginSuccessHandler)
-
setLoginFailureHandler
public void setLoginFailureHandler(LoginFailureHandler loginFailureHandler)
-
setRememberMeManager
public void setRememberMeManager(RememberMeManager rememberMeManager)
-
setTenantsResolver
public void setTenantsResolver(TenantsResolver tenantsResolver)
-
processRequest
public void processRequest(org.craftercms.commons.http.RequestContext context, RequestSecurityProcessorChain processorChain) throws ExceptionChecks if the request URL matches theloginUrland the HTTP method matches theloginMethod. If it does, it proceeds to login the user using the username/password specified in the parameters.- Specified by:
processRequestin interfaceRequestSecurityProcessor- Parameters:
context- the context which holds the current request and responseprocessorChain- the processor chain, used to call the next processor- Throws:
Exception
-
isLoginRequest
protected boolean isLoginRequest(javax.servlet.http.HttpServletRequest request)
-
getUsername
protected String getUsername(javax.servlet.http.HttpServletRequest request)
-
getPassword
protected String getPassword(javax.servlet.http.HttpServletRequest request)
-
getRememberMe
protected boolean getRememberMe(javax.servlet.http.HttpServletRequest request)
-
onLoginSuccess
protected void onLoginSuccess(org.craftercms.commons.http.RequestContext context, Authentication authentication) throws Exception- Throws:
Exception
-
onLoginFailure
protected void onLoginFailure(org.craftercms.commons.http.RequestContext context, AuthenticationException e) throws Exception- Throws:
Exception
-
saveException
protected void saveException(javax.servlet.http.HttpServletRequest request, AuthenticationException e)
-
clearSession
protected void clearSession(javax.servlet.http.HttpServletRequest request)
-
-