Class CasAuthenticationEntryPoint
- java.lang.Object
-
- org.springframework.security.cas.web.CasAuthenticationEntryPoint
-
- All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean,AuthenticationEntryPoint
public class CasAuthenticationEntryPoint extends java.lang.Object implements AuthenticationEntryPoint, org.springframework.beans.factory.InitializingBean
Used by theExceptionTranslationFilterto commence authentication via the JA-SIG Central Authentication Service (CAS).The user's browser will be redirected to the JA-SIG CAS enterprise-wide login page. This page is specified by the
loginUrlproperty. Once login is complete, the CAS login page will redirect to the page indicated by theserviceproperty. Theserviceis a HTTP URL belonging to the current application. TheserviceURL is monitored by theCasAuthenticationFilter, which will validate the CAS login was successful.
-
-
Constructor Summary
Constructors Constructor Description CasAuthenticationEntryPoint()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()voidcommence(javax.servlet.http.HttpServletRequest servletRequest, javax.servlet.http.HttpServletResponse response, AuthenticationException authenticationException)Commences an authentication scheme.protected java.lang.StringcreateRedirectUrl(java.lang.String serviceUrl)Constructs the Url for Redirection to the CAS server.protected java.lang.StringcreateServiceUrl(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Constructs a new Service Url.protected booleangetEncodeServiceUrlWithSessionId()Sets whether to encode the service url with the session id or not.java.lang.StringgetLoginUrl()The enterprise-wide CAS login URL.ServicePropertiesgetServiceProperties()protected voidpreCommence(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Template method for you to do your own pre-processing before the redirect occurs.voidsetEncodeServiceUrlWithSessionId(boolean encodeServiceUrlWithSessionId)Sets whether to encode the service url with the session id or not.voidsetLoginUrl(java.lang.String loginUrl)voidsetServiceProperties(ServiceProperties serviceProperties)
-
-
-
Method Detail
-
afterPropertiesSet
public void afterPropertiesSet()
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
commence
public final void commence(javax.servlet.http.HttpServletRequest servletRequest, javax.servlet.http.HttpServletResponse response, AuthenticationException authenticationException) throws java.io.IOExceptionDescription copied from interface:AuthenticationEntryPointCommences an authentication scheme.ExceptionTranslationFilterwill populate theHttpSessionattribute namedAbstractAuthenticationProcessingFilter.SPRING_SECURITY_SAVED_REQUEST_KEYwith the requested target URL before calling this method.Implementations should modify the headers on the
ServletResponseas necessary to commence the authentication process.- Specified by:
commencein interfaceAuthenticationEntryPoint- Parameters:
servletRequest- that resulted in anAuthenticationExceptionresponse- so that the user agent can begin authenticationauthenticationException- that caused the invocation- Throws:
java.io.IOException
-
createServiceUrl
protected java.lang.String createServiceUrl(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Constructs a new Service Url. The default implementation relies on the CAS client to do the bulk of the work.- Parameters:
request- the HttpServletRequestresponse- the HttpServlet Response- Returns:
- the constructed service url. CANNOT be NULL.
-
createRedirectUrl
protected java.lang.String createRedirectUrl(java.lang.String serviceUrl)
Constructs the Url for Redirection to the CAS server. Default implementation relies on the CAS client to do the bulk of the work.- Parameters:
serviceUrl- the service url that should be included.- Returns:
- the redirect url. CANNOT be NULL.
-
preCommence
protected void preCommence(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Template method for you to do your own pre-processing before the redirect occurs.- Parameters:
request- the HttpServletRequestresponse- the HttpServletResponse
-
getLoginUrl
public final java.lang.String getLoginUrl()
The enterprise-wide CAS login URL. Usually something likehttps://www.mycompany.com/cas/login.- Returns:
- the enterprise-wide CAS login URL
-
getServiceProperties
public final ServiceProperties getServiceProperties()
-
setLoginUrl
public final void setLoginUrl(java.lang.String loginUrl)
-
setServiceProperties
public final void setServiceProperties(ServiceProperties serviceProperties)
-
setEncodeServiceUrlWithSessionId
public final void setEncodeServiceUrlWithSessionId(boolean encodeServiceUrlWithSessionId)
Sets whether to encode the service url with the session id or not.- Parameters:
encodeServiceUrlWithSessionId- whether to encode the service url with the session id or not.
-
getEncodeServiceUrlWithSessionId
protected boolean getEncodeServiceUrlWithSessionId()
Sets whether to encode the service url with the session id or not.- Returns:
- whether to encode the service url with the session id or not.
-
-