public class X509CertificateAuthenticationProvider extends Object implements AuthenticationProvider
AuthenticationProvider for X509Certificates. This provider only supports
X509CertificateAuthentications.| Modifier and Type | Field and Description |
|---|---|
static Function<X509CertificateAuthentication,String> |
CN_USERNAME_EXTRACTOR
The default way to extract the username from an
Authentication by using the CN. |
static Function<Authentication,String> |
FAIL_FALLBACK
A fallback that will fail to extract the username and will return null.
|
static Function<Authentication,String> |
PRINCIPAL_USERNAME_EXTRACTOR
The uses the name of the principal way to extract the username from an
Authentication. |
| Constructor and Description |
|---|
X509CertificateAuthenticationProvider(Function<? super X509CertificateAuthentication,String> usernameExtractor,
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(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 |
|---|---|
Authentication |
authenticate(Authentication authentication) |
static Function<X509CertificateAuthentication,String> |
patternExtractor(String key,
Function<? super X509CertificateAuthentication,String> fallback)
Creates a new case-insensitive pattern extractor with the given pattern.
|
boolean |
supports(Class<?> authentication) |
public static final Function<Authentication,String> PRINCIPAL_USERNAME_EXTRACTOR
Authentication.public static final Function<X509CertificateAuthentication,String> CN_USERNAME_EXTRACTOR
Authentication by using the CN.public static final Function<Authentication,String> FAIL_FALLBACK
UsernameNotFoundException.public X509CertificateAuthenticationProvider(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(Function<? super X509CertificateAuthentication,String> usernameExtractor, 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 Function<X509CertificateAuthentication,String> patternExtractor(String key, Function<? super X509CertificateAuthentication,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 Authentication authenticate(Authentication authentication) throws AuthenticationException
authenticate in interface AuthenticationProviderAuthenticationExceptionpublic boolean supports(Class<?> authentication)
supports in interface AuthenticationProvider