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 String |
DISCOVERY_RESPONSE_PARAMETER
Parameter is used to indicate response from IDP discovery service.
|
static String |
FILTER_URL
Default name of path suffix which will invoke this filter.
|
protected String |
filterProcessesUrl
Url this filter should get activated on.
|
static 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(HttpServletRequest request,
HttpServletResponse response,
org.springframework.security.core.AuthenticationException e)
Method starts a process used to ultimately authenticate user using WebSSO Profile.
|
void |
doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain) |
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 https://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(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(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 String filterProcessesUrl
public static final String FILTER_URL
public static final String IDP_PARAMETER
public static final String DISCOVERY_RESPONSE_PARAMETER
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
doFilter
in interface Filter
IOException
ServletException
protected boolean processFilter(HttpServletRequest request)
request
- request used to determine whether to enable this filterpublic void commence(HttpServletRequest request, HttpServletResponse response, org.springframework.security.core.AuthenticationException e) throws IOException, 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 directlyIOException
- error sending responseServletException
- 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 ServletException, IOException, org.opensaml.saml2.metadata.provider.MetadataProviderException
context
- saml context also containing request and response objectsServletException
- errorIOException
- 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 String getFilterProcessesUrl()
public void setFilterProcessesUrl(String filterProcessesUrl)
filterProcessesUrl
- filter URLpublic void afterPropertiesSet() throws ServletException
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
afterPropertiesSet
in class org.springframework.web.filter.GenericFilterBean
ServletException