Class DelegatingAuthenticationEntryPoint
java.lang.Object
org.springframework.security.web.authentication.DelegatingAuthenticationEntryPoint
- All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean
,AuthenticationEntryPoint
public class DelegatingAuthenticationEntryPoint
extends Object
implements AuthenticationEntryPoint, org.springframework.beans.factory.InitializingBean
An
AuthenticationEntryPoint
which selects a concrete
AuthenticationEntryPoint
based on a RequestMatcher
evaluation.
A configuration might look like this:
<bean id="daep" class="org.springframework.security.web.authentication.DelegatingAuthenticationEntryPoint"> <constructor-arg> <map> <entry key="hasIpAddress('192.168.1.0/24') and hasHeader('User-Agent','Mozilla')" value-ref="firstAEP" /> <entry key="hasHeader('User-Agent','MSIE')" value-ref="secondAEP" /> </map> </constructor-arg> <property name="defaultEntryPoint" ref="defaultAEP"/> </bean>This example uses the
RequestMatcherEditor
which creates a
ELRequestMatcher
instances for the map keys.- Since:
- 3.0.2
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Used to build a new instance ofDelegatingAuthenticationEntryPoint
. -
Constructor Summary
ConstructorsConstructorDescriptionDelegatingAuthenticationEntryPoint
(LinkedHashMap<RequestMatcher, AuthenticationEntryPoint> entryPoints) Deprecated, for removal: This API element is subject to removal in a future version.DelegatingAuthenticationEntryPoint
(AuthenticationEntryPoint defaultEntryPoint, List<RequestMatcherEntry<AuthenticationEntryPoint>> entryPoints) Creates a new instance with the provided mappings.DelegatingAuthenticationEntryPoint
(AuthenticationEntryPoint defaultEntryPoint, RequestMatcherEntry<AuthenticationEntryPoint>... entryPoints) Creates a new instance with the provided mappings. -
Method Summary
Modifier and TypeMethodDescriptionvoid
builder()
Creates a newDelegatingAuthenticationEntryPoint.Builder
void
commence
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, AuthenticationException authException) Commences an authentication scheme.void
setDefaultEntryPoint
(AuthenticationEntryPoint defaultEntryPoint) Deprecated, for removal: This API element is subject to removal in a future version.
-
Constructor Details
-
DelegatingAuthenticationEntryPoint
public DelegatingAuthenticationEntryPoint(AuthenticationEntryPoint defaultEntryPoint, RequestMatcherEntry<AuthenticationEntryPoint>... entryPoints) Creates a new instance with the provided mappings.- Parameters:
entryPoints
- the mapping ofRequestMatcher
toAuthenticationEntryPoint
. Cannot be null or empty.defaultEntryPoint
- the defaultAuthenticationEntryPoint
. Cannot be null.
-
DelegatingAuthenticationEntryPoint
public DelegatingAuthenticationEntryPoint(AuthenticationEntryPoint defaultEntryPoint, List<RequestMatcherEntry<AuthenticationEntryPoint>> entryPoints) Creates a new instance with the provided mappings.- Parameters:
defaultEntryPoint
- the defaultAuthenticationEntryPoint
. Cannot be null.entryPoints
- the mapping ofRequestMatcher
toAuthenticationEntryPoint
. Cannot be null or empty.
-
DelegatingAuthenticationEntryPoint
@Deprecated(forRemoval=true) public DelegatingAuthenticationEntryPoint(LinkedHashMap<RequestMatcher, AuthenticationEntryPoint> entryPoints) Deprecated, for removal: This API element is subject to removal in a future version.Creates a new instance.- Parameters:
entryPoints
-
-
-
Method Details
-
commence
public void commence(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, AuthenticationException authException) throws IOException, jakarta.servlet.ServletException Description copied from interface:AuthenticationEntryPoint
Commences an authentication scheme.ExceptionTranslationFilter
will populate theHttpSession
attribute namedAbstractAuthenticationProcessingFilter.SPRING_SECURITY_SAVED_REQUEST_KEY
with the requested target URL before calling this method.Implementations should modify the headers on the
ServletResponse
as necessary to commence the authentication process.- Specified by:
commence
in interfaceAuthenticationEntryPoint
- Parameters:
request
- that resulted in anAuthenticationException
response
- so that the user agent can begin authenticationauthException
- that caused the invocation- Throws:
IOException
jakarta.servlet.ServletException
-
setDefaultEntryPoint
@Deprecated(forRemoval=true) public void setDefaultEntryPoint(AuthenticationEntryPoint defaultEntryPoint) Deprecated, for removal: This API element is subject to removal in a future version.EntryPoint which is used when no RequestMatcher returned true -
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
-
builder
Creates a newDelegatingAuthenticationEntryPoint.Builder
- Returns:
- the new
DelegatingAuthenticationEntryPoint.Builder
-
DelegatingAuthenticationEntryPoint(AuthenticationEntryPoint, List)