public class MyFormAuthenticationFilter extends MyAuthenticatingFilter
loginUrl you configure.
This filter constructs a UsernamePasswordToken with the values found in
username, password,
and rememberMe request parameters. It then calls
Subject.login(usernamePasswordToken),
effectively automatically performing a login attempt. Note that the login attempt will only occur when the
isLoginSubmission(request,response)
is true, which by default occurs when the request is for the loginUrl and
is a POST request.
If the login attempt fails, the resulting AuthenticationException fully qualified class name will
failureKeyAttribute key. This
FQCN can be used as an i18n key or lookup mechanism to explain to the user why their login attempt failed
(e.g. no user, incorrect password, etc).
If you would prefer to handle the authentication validation and login in your own code, consider using the
PassThruAuthenticationFilter instead, which allows requests to the
MyAccessControlFilter.loginUrl to pass through to your application's code directly.PassThruAuthenticationFilter| 限定符和类型 | 字段和说明 |
|---|---|
static String |
DEFAULT_ERROR_KEY_ATTRIBUTE_NAME |
static String |
DEFAULT_PASSWORD_PARAM |
static String |
DEFAULT_REMEMBER_ME_PARAM |
static String |
DEFAULT_USERNAME_PARAM |
DEFAULT_CAPTCHA_PARAM, PERMISSIVEDEFAULT_SUCCESS_URLDEFAULT_LOGIN_URL, GET_METHOD, POST_METHOD| 构造器和说明 |
|---|
MyFormAuthenticationFilter() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
clearFailureAttribute(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response) |
protected CaptchaUsernamePasswordToken |
createToken(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response) |
String |
getFailureKeyAttribute() |
protected String |
getPassword(javax.servlet.ServletRequest request) |
String |
getPasswordParam() |
String |
getRememberMeParam() |
protected String |
getUsername(javax.servlet.ServletRequest request) |
String |
getUsernameParam() |
protected boolean |
isLoginSubmission(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response)
This default implementation merely returns
true if the request is an HTTP POST,
false otherwise. |
protected boolean |
isRememberMe(javax.servlet.ServletRequest request)
Returns
true if "rememberMe" should be enabled for the login attempt associated with the
current request, false otherwise. |
protected boolean |
onAccessDenied(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response)
Processes requests where the subject was denied access as determined by the
isAccessAllowed
method. |
protected boolean |
onLoginFailure(org.apache.shiro.authc.AuthenticationToken token,
org.apache.shiro.authc.AuthenticationException e,
javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response) |
protected boolean |
onLoginSuccess(org.apache.shiro.authc.AuthenticationToken token,
org.apache.shiro.subject.Subject subject,
javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response) |
protected void |
setFailureAttribute(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
org.apache.shiro.authc.AuthenticationException ae) |
void |
setFailureKeyAttribute(String failureKeyAttribute) |
void |
setFailureUrlMap(Map<String,String> failureUrlMap)
多个失败的跳转路径
|
void |
setLoginUrl(String loginUrl)
Sets the login URL used to authenticate a user.
|
void |
setLoginUrlMap(Map<String,String> loginUrlMap) |
void |
setPasswordParam(String passwordParam)
Sets the request parameter name to look for when acquiring the password.
|
void |
setRememberMeParam(String rememberMeParam)
Sets the request parameter name to look for when acquiring the rememberMe boolean value.
|
void |
setSuccessUrlMap(Map<String,String> successUrlMap)
多个成功的跳转路径
|
protected void |
setUserAttribute(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response)
已过时。
|
void |
setUsernameParam(String usernameParam)
Sets the request parameter name to look for when acquiring the username.
|
cleanup, createToken, createToken, createToken, doCaptchaValidate, executeLogin, getCaptcha, getHost, isAccessAllowed, isPermissivedynaRedirect, getSuccessUrl, getSuccessUrlMap, issueFailureRedirect, issueSuccessRedirect, setSuccessUrlgetFailureUrl, getFailureUrlMap, getLoginUrl, getLoginUrlMap, getRealFailureUrl, getRealLoginUrl, getSubject, isLoginRequest, onAccessDenied, onPreHandle, redirectToLogin, saveRequest, saveRequestAndRedirectToLogin, setFailureUrlgetPathWithinApplication, isEnabled, pathsMatch, pathsMatch, preHandle, processPathConfigafterCompletion, doFilterInternal, executeChain, postHandledoFilter, getAlreadyFilteredAttributeName, isEnabled, isEnabled, setEnabled, shouldNotFilterdestroy, getFilterConfig, getInitParam, init, onFilterConfigSet, setFilterConfigpublic static final String DEFAULT_ERROR_KEY_ATTRIBUTE_NAME
public void setLoginUrlMap(Map<String,String> loginUrlMap)
setLoginUrlMap 在类中 MyAccessControlFilterpublic void setSuccessUrlMap(Map<String,String> successUrlMap)
setSuccessUrlMap 在类中 MyAuthenticationFiltersuccessUrlMap - success url mappublic void setFailureUrlMap(Map<String,String> failureUrlMap)
setFailureUrlMap 在类中 MyAccessControlFilterfailureUrlMap - success url mappublic void setLoginUrl(String loginUrl)
MyAccessControlFilterDEFAULT_LOGIN_URL is assumed.setLoginUrl 在类中 MyAccessControlFilterloginUrl - the login URL used to authenticate a user, used when redirecting users if authentication is required.public String getUsernameParam()
public void setUsernameParam(String usernameParam)
username.usernameParam - the name of the request param to check for acquiring the username.public String getPasswordParam()
public void setPasswordParam(String passwordParam)
password.passwordParam - the name of the request param to check for acquiring the password.public String getRememberMeParam()
public void setRememberMeParam(String rememberMeParam)
rememberMe.
RememberMe will be true if the parameter value equals any of those supported by
WebUtils.isTrue(request,value), false
otherwise.rememberMeParam - the name of the request param to check for acquiring the rememberMe boolean value.public String getFailureKeyAttribute()
public void setFailureKeyAttribute(String failureKeyAttribute)
protected boolean onAccessDenied(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response)
throws Exception
MyAccessControlFilterisAccessAllowed
method.onAccessDenied 在类中 MyAccessControlFilterrequest - the incoming ServletRequestresponse - the outgoing ServletResponsetrue if the request should continue to be processed; false if the subclass will
handle/render the response directly.Exception - if there is an error processing the request.protected boolean isLoginSubmission(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response)
true if the request is an HTTP POST,
false otherwise. Can be overridden by subclasses for custom login submission detection behavior.request - the incoming ServletRequestresponse - the outgoing ServletResponse.true if the request is an HTTP POST, false otherwise.protected CaptchaUsernamePasswordToken createToken(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
createToken 在类中 MyAuthenticatingFilterprotected boolean isRememberMe(javax.servlet.ServletRequest request)
MyAuthenticatingFiltertrue if "rememberMe" should be enabled for the login attempt associated with the
current request, false otherwise.
This implementation always returns false and is provided as a template hook to subclasses that
support rememberMe logins and wish to determine rememberMe in a custom mannner
based on the current request.isRememberMe 在类中 MyAuthenticatingFilterrequest - the incoming ServletRequesttrue if "rememberMe" should be enabled for the login attempt associated with the
current request, false otherwise.protected boolean onLoginSuccess(org.apache.shiro.authc.AuthenticationToken token,
org.apache.shiro.subject.Subject subject,
javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response)
throws Exception
onLoginSuccess 在类中 MyAuthenticatingFilterExceptionprotected boolean onLoginFailure(org.apache.shiro.authc.AuthenticationToken token,
org.apache.shiro.authc.AuthenticationException e,
javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response)
throws Exception
onLoginFailure 在类中 MyAuthenticatingFilterExceptionprotected void setFailureAttribute(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
org.apache.shiro.authc.AuthenticationException ae)
protected void clearFailureAttribute(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response)
@Deprecated protected void setUserAttribute(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
protected String getUsername(javax.servlet.ServletRequest request)
protected String getPassword(javax.servlet.ServletRequest request)
Copyright © 2014. All rights reserved.