public class X509CertificateAuthenticationProvider
extends java.lang.Object
implements org.springframework.security.authentication.AuthenticationProvider
AuthenticationProvider
for X509Certificate
s. This provider only supports
X509CertificateAuthentication
s.Modifier and Type | Field and Description |
---|---|
static java.util.function.Function<X509CertificateAuthentication,java.lang.String> |
CN_USERNAME_EXTRACTOR
The default way to extract the username from an
Authentication by using the CN. |
static java.util.function.Function<org.springframework.security.core.Authentication,java.lang.String> |
FAIL_FALLBACK
A fallback that will fail to extract the username and will return null.
|
static java.util.function.Function<org.springframework.security.core.Authentication,java.lang.String> |
PRINCIPAL_USERNAME_EXTRACTOR
The uses the name of the principal way to extract the username from an
Authentication . |
Constructor and Description |
---|
X509CertificateAuthenticationProvider(java.util.function.Function<? super X509CertificateAuthentication,java.lang.String> usernameExtractor,
org.springframework.security.core.userdetails.UserDetailsService userDetailsService)
Creates a new X509CertificateAuthenticationProvider, which uses the given
Function to extract the
username and uses the given UserDetailsService to lookup the user. |
X509CertificateAuthenticationProvider(org.springframework.security.core.userdetails.UserDetailsService userDetailsService)
Creates a new X509CertificateAuthenticationProvider, which uses the
default way
(via CN) to extract the username and uses the given UserDetailsService to lookup the user. |
Modifier and Type | Method and Description |
---|---|
org.springframework.security.core.Authentication |
authenticate(org.springframework.security.core.Authentication authentication) |
static java.util.function.Function<X509CertificateAuthentication,java.lang.String> |
patternExtractor(java.lang.String key,
java.util.function.Function<? super X509CertificateAuthentication,java.lang.String> fallback)
Creates a new case-insensitive pattern extractor with the given pattern.
|
boolean |
supports(java.lang.Class<?> authentication) |
public static final java.util.function.Function<org.springframework.security.core.Authentication,java.lang.String> PRINCIPAL_USERNAME_EXTRACTOR
Authentication
.public static final java.util.function.Function<X509CertificateAuthentication,java.lang.String> CN_USERNAME_EXTRACTOR
Authentication
by using the CN.public static final java.util.function.Function<org.springframework.security.core.Authentication,java.lang.String> FAIL_FALLBACK
UsernameNotFoundException
.public X509CertificateAuthenticationProvider(org.springframework.security.core.userdetails.UserDetailsService userDetailsService)
default way
(via CN)
to extract the username and uses the given UserDetailsService
to lookup the user.userDetailsService
- The user details service to use.public X509CertificateAuthenticationProvider(java.util.function.Function<? super X509CertificateAuthentication,java.lang.String> usernameExtractor, org.springframework.security.core.userdetails.UserDetailsService userDetailsService)
Function
to extract the
username and uses the given UserDetailsService
to lookup the user.usernameExtractor
- The username extractor to use. The function should return null, if the username is
missing.userDetailsService
- The user details service to use.public static java.util.function.Function<X509CertificateAuthentication,java.lang.String> patternExtractor(java.lang.String key, java.util.function.Function<? super X509CertificateAuthentication,java.lang.String> fallback)
key
- The case insensitive key to use (Example: 'CN').fallback
- The fallback function to use if the key was not present in the subject.public org.springframework.security.core.Authentication authenticate(org.springframework.security.core.Authentication authentication) throws org.springframework.security.core.AuthenticationException
authenticate
in interface org.springframework.security.authentication.AuthenticationProvider
org.springframework.security.core.AuthenticationException
public boolean supports(java.lang.Class<?> authentication)
supports
in interface org.springframework.security.authentication.AuthenticationProvider