Package io.micronaut.security.x509
Class X509AuthenticationFetcher
- java.lang.Object
-
- io.micronaut.security.x509.X509AuthenticationFetcher
-
- All Implemented Interfaces:
io.micronaut.core.order.Ordered,AuthenticationFetcher
@Singleton public class X509AuthenticationFetcher extends java.lang.Object implements AuthenticationFetcher
Creates an Authentication if an X.509 client certificate is present and a name (CN) can be extracted.- Since:
- 3.3
-
-
Field Summary
Fields Modifier and Type Field Description static intORDERThe order of the fetcher.
-
Constructor Summary
Constructors Constructor Description X509AuthenticationFetcher(X509Configuration x509Configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Optional<Authentication>createAuthentication(io.micronaut.http.HttpRequest<?> request)Creates anX509Authenticationfrom information in anX509Certificateif one is present in the request.protected java.util.Optional<Authentication>createX509Authentication(java.security.cert.X509Certificate certificate)Creates anX509Authenticationfrom information in anX509Certificate.protected java.util.Optional<java.lang.String>extractName(java.security.cert.X509Certificate certificate)Extracts the name from the certificate using the subject DN regex.org.reactivestreams.Publisher<Authentication>fetchAuthentication(io.micronaut.http.HttpRequest<?> request)Attempts to read anAuthenticationfrom aHttpRequestbeing executed.intgetOrder()
-
-
-
Constructor Detail
-
X509AuthenticationFetcher
public X509AuthenticationFetcher(X509Configuration x509Configuration)
- Parameters:
x509Configuration- x509 configuration
-
-
Method Detail
-
getOrder
public int getOrder()
- Specified by:
getOrderin interfaceio.micronaut.core.order.Ordered
-
fetchAuthentication
public org.reactivestreams.Publisher<Authentication> fetchAuthentication(io.micronaut.http.HttpRequest<?> request)
Description copied from interface:AuthenticationFetcherAttempts to read anAuthenticationfrom aHttpRequestbeing executed.- Specified by:
fetchAuthenticationin interfaceAuthenticationFetcher- Parameters:
request-HttpRequestbeing executed.- Returns:
Authenticationif found
-
createAuthentication
@NonNull protected java.util.Optional<Authentication> createAuthentication(io.micronaut.http.HttpRequest<?> request)
Creates anX509Authenticationfrom information in anX509Certificateif one is present in the request.- Parameters:
request- the request- Returns:
- the authentication if the certificate exists and contains a valid name
-
createX509Authentication
@NonNull protected java.util.Optional<Authentication> createX509Authentication(@NonNull java.security.cert.X509Certificate certificate)
Creates anX509Authenticationfrom information in anX509Certificate.- Parameters:
certificate- the certificate- Returns:
- the authentication if the certificate contains a valid name
-
extractName
@NonNull protected java.util.Optional<java.lang.String> extractName(@NonNull java.security.cert.X509Certificate certificate)Extracts the name from the certificate using the subject DN regex.- Parameters:
certificate- the client certificate- Returns:
- the name if found
-
-