public class SAMLEntryPoint
extends org.springframework.web.filter.GenericFilterBean
implements org.springframework.security.web.AuthenticationEntryPoint
There are two ways the entry point can get invoked. Either user accesses a URL configured to require some degree of authentication and throws AuthenticationException which is handled and invokes the entry point. The other way is direct invocation of the entry point by accessing the /saml/login URL.
Modifier and Type | Field and Description |
---|---|
protected SAMLContextProvider |
contextProvider |
protected WebSSOProfileOptions |
defaultOptions |
static java.lang.String |
DISCOVERY_RESPONSE_PARAMETER
Parameter is used to indicate response from IDP discovery service.
|
static java.lang.String |
FILTER_URL
Default name of path suffix which will invoke this filter.
|
protected java.lang.String |
filterProcessesUrl
Url this filter should get activated on.
|
static java.lang.String |
IDP_PARAMETER
Name of parameter of HttpRequest telling entry point that the login should use specified idp.
|
protected static org.slf4j.Logger |
log |
protected MetadataManager |
metadata |
protected SAMLDiscovery |
samlDiscovery |
protected SAMLLogger |
samlLogger |
protected WebSSOProfile |
webSSOprofile |
protected WebSSOProfile |
webSSOprofileECP |
protected WebSSOProfile |
webSSOprofileHoK |
Constructor and Description |
---|
SAMLEntryPoint() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Verifies that required entities were autowired or set.
|
void |
commence(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
org.springframework.security.core.AuthenticationException e)
Method starts a process used to ultimately authenticate user using WebSSO Profile.
|
void |
doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain) |
java.lang.String |
getFilterProcessesUrl() |
protected WebSSOProfileOptions |
getProfileOptions(SAMLMessageContext context,
org.springframework.security.core.AuthenticationException exception)
Method is supposed to populate preferences used to construct the SAML message.
|
protected void |
initializeDiscovery(SAMLMessageContext context)
Method initializes IDP Discovery Profile as defined in http://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-idp-discovery.pdf
It is presumed that metadata of the local Service Provider contains discovery return address.
|
protected void |
initializeECP(SAMLMessageContext context,
org.springframework.security.core.AuthenticationException e)
Initializes ECP profile.
|
protected void |
initializeSSO(SAMLMessageContext context,
org.springframework.security.core.AuthenticationException e)
WebSSO profile or WebSSO Holder-of-Key profile.
|
protected boolean |
isDiscovery(SAMLMessageContext context)
Determines whether IDP Discovery should be initialized.
|
protected boolean |
isECP(SAMLMessageContext context)
Determines whether ECP profile should get initialized.
|
protected boolean |
processFilter(javax.servlet.http.HttpServletRequest request)
The filter will be used in case the URL of the request contains the DEFAULT_FILTER_URL.
|
void |
setContextProvider(SAMLContextProvider contextProvider)
Sets entity responsible for populating local entity context data.
|
void |
setDefaultProfileOptions(WebSSOProfileOptions defaultOptions)
Sets object which determines default values to be used as basis for construction during getProfileOptions call.
|
void |
setFilterProcessesUrl(java.lang.String filterProcessesUrl)
Custom filter URL which overrides the default.
|
void |
setMetadata(MetadataManager metadata)
Metadata manager, cannot be null, must be set.
|
void |
setSamlDiscovery(SAMLDiscovery samlDiscovery)
Dependency for loading of discovery URL
|
void |
setSamlLogger(SAMLLogger samlLogger)
Logger for SAML events, cannot be null, must be set.
|
void |
setWebSSOprofile(WebSSOProfile webSSOprofile)
Profile for consumption of processed messages, cannot be null, must be set.
|
void |
setWebSSOprofileECP(WebSSOProfile webSSOprofileECP) |
void |
setWebSSOprofileHoK(WebSSOProfile webSSOprofileHoK) |
protected static final org.slf4j.Logger log
protected WebSSOProfileOptions defaultOptions
protected WebSSOProfile webSSOprofile
protected WebSSOProfile webSSOprofileECP
protected WebSSOProfile webSSOprofileHoK
protected MetadataManager metadata
protected SAMLLogger samlLogger
protected SAMLContextProvider contextProvider
protected SAMLDiscovery samlDiscovery
protected java.lang.String filterProcessesUrl
public static final java.lang.String FILTER_URL
public static final java.lang.String IDP_PARAMETER
public static final java.lang.String DISCOVERY_RESPONSE_PARAMETER
public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain) throws java.io.IOException, javax.servlet.ServletException
doFilter
in interface javax.servlet.Filter
java.io.IOException
javax.servlet.ServletException
protected boolean processFilter(javax.servlet.http.HttpServletRequest request)
request
- request used to determine whether to enable this filterpublic void commence(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException e) throws java.io.IOException, javax.servlet.ServletException
By default contextProvider determines IDP to use by parameter "idp". In case parameter is missing the defaultIDP is used instead.
Subclasses can customize the WebSSO initialization behavior.
commence
in interface org.springframework.security.web.AuthenticationEntryPoint
request
- requestresponse
- responsee
- exception causing this entry point to be invoked or null when EntryPoint is invoked directlyjava.io.IOException
- error sending responsejavax.servlet.ServletException
- error initializing SAML protocolprotected void initializeECP(SAMLMessageContext context, org.springframework.security.core.AuthenticationException e) throws org.opensaml.saml2.metadata.provider.MetadataProviderException, org.opensaml.common.SAMLException, org.opensaml.ws.message.encoder.MessageEncodingException
Subclasses can alter the initialization behaviour.
context
- saml context, also containing wrapped request and response objectse
- exception causing the entry point to be invoked (if any)org.opensaml.saml2.metadata.provider.MetadataProviderException
- in case metadata can't be queriedorg.opensaml.common.SAMLException
- in case message sending failsorg.opensaml.ws.message.encoder.MessageEncodingException
- in case SAML message encoding failsprotected void initializeSSO(SAMLMessageContext context, org.springframework.security.core.AuthenticationException e) throws org.opensaml.saml2.metadata.provider.MetadataProviderException, org.opensaml.common.SAMLException, org.opensaml.ws.message.encoder.MessageEncodingException
Subclasses can alter the initialization behaviour.
context
- saml context, also containing wrapped request and response objectse
- exception causing the entry point to be invoked (if any)org.opensaml.saml2.metadata.provider.MetadataProviderException
- in case metadata can't be queriedorg.opensaml.common.SAMLException
- in case message sending failsorg.opensaml.ws.message.encoder.MessageEncodingException
- in case SAML message encoding failsprotected void initializeDiscovery(SAMLMessageContext context) throws javax.servlet.ServletException, java.io.IOException, org.opensaml.saml2.metadata.provider.MetadataProviderException
context
- saml context also containing request and response objectsjavax.servlet.ServletException
- errorjava.io.IOException
- io errororg.opensaml.saml2.metadata.provider.MetadataProviderException
- in case metadata of the local entity can't be populatedprotected WebSSOProfileOptions getProfileOptions(SAMLMessageContext context, org.springframework.security.core.AuthenticationException exception) throws org.opensaml.saml2.metadata.provider.MetadataProviderException
context
- containing local entityexception
- exception causing invocation of this entry point (can be null)org.opensaml.saml2.metadata.provider.MetadataProviderException
- in case metadata loading failspublic void setDefaultProfileOptions(WebSSOProfileOptions defaultOptions)
defaultOptions
- default object to use for options constructionprotected boolean isDiscovery(SAMLMessageContext context)
context
- contextprotected boolean isECP(SAMLMessageContext context)
context
- context@Autowired @Qualifier(value="webSSOprofile") public void setWebSSOprofile(WebSSOProfile webSSOprofile)
webSSOprofile
- profile@Autowired(required=false) @Qualifier(value="ecpprofile") public void setWebSSOprofileECP(WebSSOProfile webSSOprofileECP)
@Autowired(required=false) @Qualifier(value="hokWebSSOProfile") public void setWebSSOprofileHoK(WebSSOProfile webSSOprofileHoK)
@Autowired public void setSamlLogger(SAMLLogger samlLogger)
samlLogger
- logger@Autowired(required=false) public void setSamlDiscovery(SAMLDiscovery samlDiscovery)
samlDiscovery
- saml discovery endpoint@Autowired public void setContextProvider(SAMLContextProvider contextProvider)
contextProvider
- provider implementation@Autowired public void setMetadata(MetadataManager metadata)
metadata
- managerpublic java.lang.String getFilterProcessesUrl()
public void setFilterProcessesUrl(java.lang.String filterProcessesUrl)
filterProcessesUrl
- filter URLpublic void afterPropertiesSet() throws javax.servlet.ServletException
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
afterPropertiesSet
in class org.springframework.web.filter.GenericFilterBean
javax.servlet.ServletException