Package org.tynamo.security.shiro.authc
Class CasFilter
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.tynamo.security.shiro.AccessControlFilter
org.tynamo.security.shiro.authc.AuthenticationFilter
org.tynamo.security.shiro.authc.AuthenticatingFilter
org.tynamo.security.shiro.authc.CasFilter
- All Implemented Interfaces:
jakarta.servlet.Filter,org.apache.shiro.lang.util.Nameable
This filter validates the CAS service ticket to authenticate the user. It must be configured on the URL recognized
by the CAS server. For example, in
shiro.ini:
[main] casFilter = org.apache.shiro.cas.CasFilter ... [urls] /shiro-cas = casFilter ...(example : http://host:port/mycontextpath/shiro-cas)
- Since:
- 1.2
-
Field Summary
Fields inherited from class org.tynamo.security.shiro.AccessControlFilter
GET_METHOD, LOGIN_URL, pathMatcher, POST_METHOD, REDIRECT_TO_SAVED_URL, SUCCESS_URL, TAPESTRY_VERSION, UNAUTHORIZED_URLFields 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 TypeMethodDescriptionprotected org.apache.shiro.authc.AuthenticationTokencreateToken(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response) The token created for this authentication is a CasToken containing the CAS service ticket received on the CAS service url (on which the filter must be configured).protected booleanisAccessAllowed(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, Object mappedValue) Returnsfalseto always force authentication (user is never considered authenticated by this filter).protected booleanonAccessDenied(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response) Execute login by creatingtokenand logging subject with this token.protected booleanonLoginFailure(org.apache.shiro.authc.AuthenticationToken token, org.apache.shiro.authc.AuthenticationException ae, jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response) If login has failed, redirect user to the CAS error page (no ticket or ticket validation failed) except if the user is already authenticated, in which case redirect to the default success url.protected booleanonLoginSuccess(org.apache.shiro.authc.AuthenticationToken token, org.apache.shiro.subject.Subject subject, jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response) If login has been successful, redirect user to the original protected url.voidsetFailureUrl(String failureUrl) Methods inherited from class org.tynamo.security.shiro.authc.AuthenticatingFilter
createToken, createToken, executeLogin, getHost, isRememberMeMethods inherited from class org.tynamo.security.shiro.authc.AuthenticationFilter
issueSuccessRedirectMethods inherited from class org.tynamo.security.shiro.AccessControlFilter
addConfig, getLoginContextService, getLoginUrl, getSubject, getSuccessUrl, getUnauthorizedUrl, isLoginRequest, isRedirectToSavedUrl, onAccessDenied, onPreHandle, preHandle, redirectToLogin, saveRequest, saveRequestAndRedirectToLogin, setConfig, setLoginUrl, setRedirectToSavedUrl, setSuccessUrl, setUnauthorizedUrlMethods 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
-
Constructor Details
-
CasFilter
-
-
Method Details
-
createToken
protected org.apache.shiro.authc.AuthenticationToken createToken(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response) throws Exception The token created for this authentication is a CasToken containing the CAS service ticket received on the CAS service url (on which the filter must be configured).- Specified by:
createTokenin classAuthenticatingFilter- Parameters:
request- the incoming requestresponse- the outgoing response- Throws:
Exception- if there is an error processing the request.
-
onAccessDenied
protected boolean onAccessDenied(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response) throws Exception Execute login by creatingtokenand logging subject with this token.- Specified by:
onAccessDeniedin classAccessControlFilter- Parameters:
request- the incoming requestresponse- the outgoing response- Returns:
trueif the request should continue to be processed; false if the subclass will handle/render the response directly.- Throws:
Exception- if there is an error processing the request.
-
isAccessAllowed
protected boolean isAccessAllowed(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, Object mappedValue) Returnsfalseto always force authentication (user is never considered authenticated by this filter).- Overrides:
isAccessAllowedin classAuthenticationFilter- Parameters:
request- the incoming requestresponse- the outgoing responsemappedValue- the filter-specific config value mapped to this filter in the URL rules mappings.- Returns:
false
-
onLoginSuccess
protected boolean onLoginSuccess(org.apache.shiro.authc.AuthenticationToken token, org.apache.shiro.subject.Subject subject, jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response) throws Exception If login has been successful, redirect user to the original protected url.- Overrides:
onLoginSuccessin classAuthenticatingFilter- Parameters:
token- the token representing the current authenticationsubject- the current authenticated subjetrequest- the incoming requestresponse- the outgoing response- Throws:
Exception- if there is an error processing the request.
-
onLoginFailure
protected boolean onLoginFailure(org.apache.shiro.authc.AuthenticationToken token, org.apache.shiro.authc.AuthenticationException ae, jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response) If login has failed, redirect user to the CAS error page (no ticket or ticket validation failed) except if the user is already authenticated, in which case redirect to the default success url.- Overrides:
onLoginFailurein classAuthenticatingFilter- Parameters:
token- the token representing the current authenticationae- the current authentication exceptionrequest- the incoming requestresponse- the outgoing response
-
setFailureUrl
-