Class PemCertificateReader

java.lang.Object
com.irurueta.authserver.authorization.api.web.x509.PemCertificateReader

@Component public class PemCertificateReader extends Object
Reads the certificate sent to bind it to an account: exactly one X.509 certificate in PEM form, within its validity period, with a subject. A value that carries a private key is refused without being parsed: only the public certificate is ever sent. The fingerprint is computed exactly as CertificatePrincipalExtractor computes it at sign-in, so the binding matches the certificate the browser presents later.
  • Field Details

    • MAX_SUBJECT_LENGTH

      static final int MAX_SUBJECT_LENGTH
      Longest subject the x509_certificates table keeps.
      See Also:
    • CERTIFICATE_TYPE

      private static final String CERTIFICATE_TYPE
      Type of the certificates.
      See Also:
    • PRIVATE_KEY_MARKER

      private static final String PRIVATE_KEY_MARKER
      Marker of a PEM private key, of any algorithm.
      See Also:
    • fingerprints

      private final CertificatePrincipalExtractor fingerprints
      Computes the fingerprint the sign-in looks up.
  • Constructor Details

    • PemCertificateReader

      public PemCertificateReader()
  • Method Details

    • read

      public PresentedCertificate read(String pem)
      Reads a certificate.
      Parameters:
      pem - the certificate in PEM form.
      Returns:
      its fingerprint and subject.
      Throws:
      InvalidCertificateException - if the value carries a private key, is not exactly one X.509 certificate, is outside its validity period or has no usable subject.
    • parse

      private static X509Certificate parse(String pem)
      Parses exactly one X.509 certificate.
      Parameters:
      pem - the PEM text.
      Returns:
      the certificate.
      Throws:
      InvalidCertificateException - if the text is not exactly one X.509 certificate.