Class CertUtils


  • public class CertUtils
    extends java.lang.Object
    Utility class with methods to support various operations on X.509 certs.
    Since:
    3.4.6
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String X509_CERTIFICATE_TYPE
      X509 certificate type.
    • Constructor Summary

      Constructors 
      Constructor Description
      CertUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.security.cert.CertificateFactory getCertificateFactory()
      Gets a certificate factory for creating X.509 artifacts.
      static boolean isExpired​(java.security.cert.X509CRL crl)
      Determines whether the given CRL is expired by examining the nextUpdate field.
      static boolean isExpired​(java.security.cert.X509CRL crl, java.time.ZonedDateTime reference)
      Determines whether the given CRL is expired by comparing the nextUpdate field with a given date.
      static java.security.cert.X509Certificate readCertificate​(java.io.InputStream resource)
      Read certificate x 509 certificate.
      static java.security.cert.X509Certificate readCertificate​(org.springframework.core.io.InputStreamSource resource)
      Read certificate.
      static java.lang.String toString​(java.security.cert.X509Certificate cert)
      Creates a unique and human-readable representation of the given certificate.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • X509_CERTIFICATE_TYPE

        public static final java.lang.String X509_CERTIFICATE_TYPE
        X509 certificate type.
        See Also:
        Constant Field Values
    • Constructor Detail

      • CertUtils

        public CertUtils()
    • Method Detail

      • isExpired

        public static boolean isExpired​(java.security.cert.X509CRL crl)
        Determines whether the given CRL is expired by examining the nextUpdate field.
        Parameters:
        crl - CRL to examine.
        Returns:
        True if current system time is after CRL next update, false otherwise.
      • isExpired

        public static boolean isExpired​(java.security.cert.X509CRL crl,
                                        java.time.ZonedDateTime reference)
        Determines whether the given CRL is expired by comparing the nextUpdate field with a given date.
        Parameters:
        crl - CRL to examine.
        reference - Reference date for comparison.
        Returns:
        True if reference date is after CRL next update, false otherwise.
      • readCertificate

        public static java.security.cert.X509Certificate readCertificate​(org.springframework.core.io.InputStreamSource resource)
        Read certificate.
        Parameters:
        resource - the resource to read the cert from
        Returns:
        the x 509 certificate
      • readCertificate

        public static java.security.cert.X509Certificate readCertificate​(java.io.InputStream resource)
        Read certificate x 509 certificate.
        Parameters:
        resource - the resource
        Returns:
        the x 509 certificate
      • toString

        public static java.lang.String toString​(java.security.cert.X509Certificate cert)
        Creates a unique and human-readable representation of the given certificate.
        Parameters:
        cert - Certificate.
        Returns:
        String representation of a certificate that includes the subject and serial number.
      • getCertificateFactory

        public static java.security.cert.CertificateFactory getCertificateFactory()
        Gets a certificate factory for creating X.509 artifacts.
        Returns:
        X509 certificate factory.