public abstract class AuthenticationInterceptor<U>
extends java.lang.Object
implements jodd.madvoc.interceptor.ActionInterceptor
AuthorizationInterceptor.
Provides auto-login using cookies.
Authentication pertains to the question "Who are you?". Usually a user authenticates himself by successfully associating his "principal" (often a username) with his "credentials" (often a password).
| Modifier and Type | Field and Description |
|---|---|
protected int |
cookieMaxAge
Cookie max age, when cookies are used.
|
protected boolean |
recreateCookieOnLogin
When user just logs in with cookie, should we recreate the cookie
(and therefore prolong cookie valid time) or leave it as it is.
|
protected boolean |
useCookie
If
true, cookie will be created for keeping user sessions. |
| Constructor and Description |
|---|
AuthenticationInterceptor() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
closeAuthSession(javax.servlet.http.HttpServletRequest servletRequest,
javax.servlet.http.HttpServletResponse servletResponse)
Closes auth session by removing auth session object from the http session
and clearing the auth cookie.
|
protected abstract java.lang.String[] |
createCookieData(U userSession)
Prepares cookie data from session object.
|
java.lang.Object |
intercept(jodd.madvoc.ActionRequest actionRequest) |
protected boolean |
isLoginAction(java.lang.String actionPath)
Detects login path.
|
protected boolean |
isLogoutAction(java.lang.String actionPath)
Detects logout path.
|
protected boolean |
isRegisterAction(java.lang.String actionPath)
Detects registration path.
|
protected abstract U |
loginUsernamePassword(java.lang.String username,
java.lang.String password)
Tries to login a user using username and password.
|
protected abstract U |
loginViaCookie(java.lang.String[] cookieData)
Tries to login user with cookie data.
|
protected U |
loginViaRequest(javax.servlet.http.HttpServletRequest servletRequest)
Tires to login user with form data.
|
protected java.lang.Object |
resultLoginFailed(int reason)
Prepares result for login failed page.
|
protected java.lang.Object |
resultLoginSuccess(java.lang.String path)
Prepares result to continue to, after success login.
|
protected java.lang.Object |
resultLogoutSuccess()
Prepares result for logout success page.
|
protected java.lang.Object |
resultRegistrationSuccess()
Prepares result for registration success page.
|
protected void |
startAuthSession(javax.servlet.http.HttpServletRequest servletRequest,
javax.servlet.http.HttpServletResponse servletResponse,
U userSession,
boolean isNew)
Starts auth session by saving session auth object and optionally creating an auth cookie.
|
protected boolean useCookie
true, cookie will be created for keeping user sessions.protected int cookieMaxAge
protected boolean recreateCookieOnLogin
public java.lang.Object intercept(jodd.madvoc.ActionRequest actionRequest)
throws java.lang.Exception
intercept in interface jodd.madvoc.interceptor.ActionInterceptorjava.lang.Exceptionprotected void startAuthSession(javax.servlet.http.HttpServletRequest servletRequest,
javax.servlet.http.HttpServletResponse servletResponse,
U userSession,
boolean isNew)
servletRequest - http requestservletResponse - http responseuserSession - created session objectisNew - if true indicated the session is new (i.e. user is either registered or signed in), if false means that session is continued (i.e. user is signed in via cookie).protected void closeAuthSession(javax.servlet.http.HttpServletRequest servletRequest,
javax.servlet.http.HttpServletResponse servletResponse)
protected boolean isLoginAction(java.lang.String actionPath)
protected boolean isLogoutAction(java.lang.String actionPath)
protected boolean isRegisterAction(java.lang.String actionPath)
protected java.lang.Object resultLoginSuccess(java.lang.String path)
protected java.lang.Object resultLogoutSuccess()
protected java.lang.Object resultRegistrationSuccess()
protected java.lang.Object resultLoginFailed(int reason)
protected abstract U loginViaCookie(java.lang.String[] cookieData)
null.protected U loginViaRequest(javax.servlet.http.HttpServletRequest servletRequest)
null.
By default, calls loginUsernamePassword(String, String).protected abstract U loginUsernamePassword(java.lang.String username, java.lang.String password)
username - entered user name from login formpassword - entered raw passwordprotected abstract java.lang.String[] createCookieData(U userSession)
Copyright © 2003-present Jodd Team