Class AuthenticationFilter
java.lang.Object
org.apache.shiro.web.servlet.ServletContextSupport
org.apache.shiro.web.servlet.AbstractFilter
org.apache.shiro.web.servlet.NameableFilter
org.apache.shiro.web.servlet.OncePerRequestFilter
org.apache.shiro.web.servlet.AdviceFilter
org.apache.shiro.web.filter.PathMatchingFilter
org.apache.shiro.web.filter.AccessControlFilter
org.apache.shiro.web.filter.authc.AuthenticationFilter
- All Implemented Interfaces:
javax.servlet.Filter,org.apache.shiro.lang.util.Nameable,PathConfigProcessor
- Direct Known Subclasses:
AuthenticatingFilter,PassThruAuthenticationFilter
Base class for all Filters that require the current user to be authenticated. This class encapsulates the
logic of checking whether a user is already authenticated in the system while subclasses are required to perform
specific logic for unauthenticated requests.
- Since:
- 0.9
-
Field Summary
FieldsFields inherited from class org.apache.shiro.web.filter.AccessControlFilter
DEFAULT_LOGIN_URL, GET_METHOD, POST_METHODFields inherited from class org.apache.shiro.web.filter.PathMatchingFilter
appliedPaths, pathMatcherFields inherited from class org.apache.shiro.web.servlet.OncePerRequestFilter
ALREADY_FILTERED_SUFFIXFields inherited from class org.apache.shiro.web.servlet.AbstractFilter
filterConfig -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the success url to use as the default location a user is sent after logging in.protected booleanisAccessAllowed(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, Object mappedValue) Determines whether the current subject is authenticated.protected voidissueSuccessRedirect(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response) Redirects to user to the previously attempted URL after a successful login.voidsetSuccessUrl(String successUrl) Sets the default/fallback success url to use as the default location a user is sent after logging in.Methods inherited from class org.apache.shiro.web.filter.AccessControlFilter
getLoginUrl, getSubject, isLoginRequest, onAccessDenied, onAccessDenied, onPreHandle, redirectToLogin, saveRequest, saveRequestAndRedirectToLogin, setLoginUrlMethods inherited from class org.apache.shiro.web.filter.PathMatchingFilter
getPathWithinApplication, isEnabled, pathsMatch, pathsMatch, preHandle, processPathConfigMethods inherited from class org.apache.shiro.web.servlet.AdviceFilter
afterCompletion, cleanup, doFilterInternal, executeChain, postHandleMethods inherited from class org.apache.shiro.web.servlet.OncePerRequestFilter
doFilter, getAlreadyFilteredAttributeName, isEnabled, isEnabled, isFilterOncePerRequest, setEnabled, setFilterOncePerRequest, shouldNotFilterMethods inherited from class org.apache.shiro.web.servlet.NameableFilter
getName, setName, toStringBuilderMethods inherited from class org.apache.shiro.web.servlet.AbstractFilter
destroy, getFilterConfig, getInitParam, init, onFilterConfigSet, setFilterConfigMethods inherited from class org.apache.shiro.web.servlet.ServletContextSupport
getContextAttribute, getContextInitParam, getServletContext, removeContextAttribute, setContextAttribute, setServletContext, toString
-
Field Details
-
DEFAULT_SUCCESS_URL
- See Also:
-
-
Constructor Details
-
AuthenticationFilter
public AuthenticationFilter()
-
-
Method Details
-
getSuccessUrl
Returns the success url to use as the default location a user is sent after logging in. Typically a redirect after login will redirect to the originally request URL; this property is provided mainly as a fallback in case the original request URL is not available or not specified. The default value isDEFAULT_SUCCESS_URL.- Returns:
- the success url to use as the default location a user is sent after logging in.
-
setSuccessUrl
Sets the default/fallback success url to use as the default location a user is sent after logging in. Typically a redirect after login will redirect to the originally request URL; this property is provided mainly as a fallback in case the original request URL is not available or not specified. The default value isDEFAULT_SUCCESS_URL.- Parameters:
successUrl- the success URL to redirect the user to after a successful login.
-
isAccessAllowed
protected boolean isAccessAllowed(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, Object mappedValue) Determines whether the current subject is authenticated. The default implementationacquiresthe currently executing Subject and then returnssubject.isAuthenticated();- Specified by:
isAccessAllowedin classAccessControlFilter- Parameters:
request- the incomingServletRequestresponse- the outgoingServletResponsemappedValue- the filter-specific config value mapped to this filter in the URL rules mappings.- Returns:
- true if the subject is authenticated; false if the subject is unauthenticated
-
issueSuccessRedirect
protected void issueSuccessRedirect(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response) throws Exception Redirects to user to the previously attempted URL after a successful login. This implementation simply callsusing theWebUtils.redirectToSavedRequestsuccessUrlas thefallbackUrlargument to that call.- Parameters:
request- the incoming requestresponse- the outgoing response- Throws:
Exception- if there is a problem redirecting.
-