Class CertificatePrincipalExtractor
java.lang.Object
com.irurueta.authserver.authorization.api.web.x509.CertificatePrincipalExtractor
- All Implemented Interfaces:
org.springframework.security.web.authentication.preauth.x509.X509PrincipalExtractor
public class CertificatePrincipalExtractor
extends Object
implements org.springframework.security.web.authentication.preauth.x509.X509PrincipalExtractor
Takes the SHA-256 fingerprint of the client certificate as the principal, as 64 lower case hexadecimal digits, which
is what a binding stores and what
ResolveCertificateLoginUseCase looks up. The fingerprint, and not the
subject name, identifies a certificate: whoever controls a CA can issue a certificate with any subject, and none
with a given fingerprint. A certificate that is expired or not yet valid has no principal: neither the TLS handshake
of the dedicated port (no authority validates the chain) nor a proxy that forwards a certificate is trusted to have
checked it. One extractor serves both transports, because both leave the certificate in the same
request attribute.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringAlgorithm of the fingerprint.(package private) static final StringPrincipal of a certificate that cannot be encoded or is expired or not yet valid: it is not a fingerprint, so it is bound to no account and the sign-in fails like any unknown certificate. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionextractPrincipal(X509Certificate certificate) Extracts the principal.fingerprintOf(byte[] encoded) Computes the fingerprint of a DER encoded certificate.
-
Field Details
-
ALGORITHM
Algorithm of the fingerprint.- See Also:
-
UNREADABLE
Principal of a certificate that cannot be encoded or is expired or not yet valid: it is not a fingerprint, so it is bound to no account and the sign-in fails like any unknown certificate.- See Also:
-
-
Constructor Details
-
CertificatePrincipalExtractor
public CertificatePrincipalExtractor()
-
-
Method Details
-
extractPrincipal
Extracts the principal.- Specified by:
extractPrincipalin interfaceorg.springframework.security.web.authentication.preauth.x509.X509PrincipalExtractor- Parameters:
certificate- the client certificate.- Returns:
- its fingerprint, or
UNREADABLEwhen it cannot be encoded or is not within its validity period.
-
fingerprintOf
Computes the fingerprint of a DER encoded certificate.- Parameters:
encoded- the DER form of the certificate.- Returns:
- the SHA-256 digest as lower case hexadecimal digits.
-