Package io.micronaut.security.x509
Class X509AuthenticationFetcher
java.lang.Object
io.micronaut.security.x509.X509AuthenticationFetcher
- All Implemented Interfaces:
io.micronaut.core.order.Ordered
,AuthenticationFetcher<io.micronaut.http.HttpRequest<?>>
@Requires(classes=io.micronaut.http.HttpRequest.class)
@Singleton
public class X509AuthenticationFetcher
extends Object
implements AuthenticationFetcher<io.micronaut.http.HttpRequest<?>>
Creates an Authentication if an X.509 client certificate is present and a
name (CN) can be extracted.
- Since:
- 3.3
- Author:
- Burt Beckwith
-
Field Summary
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected @NonNull Optional<Authentication>
createAuthentication
(io.micronaut.http.HttpRequest<?> request) Creates anX509Authentication
from information in anX509Certificate
if one is present in the request.protected @NonNull Optional<Authentication>
createX509Authentication
(@NonNull X509Certificate certificate) Creates anX509Authentication
from information in anX509Certificate
.extractName
(@NonNull 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 anAuthentication
from an HTTP Request being executed.int
getOrder()
-
Field Details
-
ORDER
public static final int ORDERThe order of the fetcher.
-
-
Constructor Details
-
X509AuthenticationFetcher
- Parameters:
x509Configuration
- x509 configuration
-
-
Method Details
-
getOrder
public int getOrder()- Specified by:
getOrder
in interfaceio.micronaut.core.order.Ordered
-
fetchAuthentication
public org.reactivestreams.Publisher<Authentication> fetchAuthentication(io.micronaut.http.HttpRequest<?> request) Description copied from interface:AuthenticationFetcher
Attempts to read anAuthentication
from an HTTP Request being executed.- Specified by:
fetchAuthentication
in interfaceAuthenticationFetcher<io.micronaut.http.HttpRequest<?>>
- Parameters:
request
- an HTTP Request being executed.- Returns:
Authentication
if found
-
createAuthentication
@NonNull protected @NonNull Optional<Authentication> createAuthentication(io.micronaut.http.HttpRequest<?> request) Creates anX509Authentication
from information in anX509Certificate
if 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 @NonNull Optional<Authentication> createX509Authentication(@NonNull @NonNull X509Certificate certificate) Creates anX509Authentication
from information in anX509Certificate
.- Parameters:
certificate
- the certificate- Returns:
- the authentication if the certificate contains a valid name
-
extractName
@NonNull protected @NonNull Optional<String> extractName(@NonNull @NonNull X509Certificate certificate) Extracts the name from the certificate using the subject DN regex.- Parameters:
certificate
- the client certificate- Returns:
- the name if found
-