Class CertificateUtils


  • public class CertificateUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.security.KeyStore createTrustStore​(java.lang.String certFilePath)
      Creates a truststore with certificates from PEM-encoded (ASCII) or DER-encoded (binary) file at the specified certFilePath.
      static java.security.cert.X509Certificate[] extractCerts​(java.lang.String certFilePath)
      Retrieves certificates from PEM-encoded (ASCII) or DER-encoded (binary) file at the specified certFilePath.
      static java.lang.String toString​(java.security.cert.X509Certificate[] certificateChain)  
      • Methods inherited from class java.lang.Object

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

      • CertificateUtils

        public CertificateUtils()
    • Method Detail

      • extractCerts

        public static java.security.cert.X509Certificate[] extractCerts​(java.lang.String certFilePath)
                                                                 throws java.security.cert.CertificateException,
                                                                        java.io.IOException
        Retrieves certificates from PEM-encoded (ASCII) or DER-encoded (binary) file at the specified certFilePath.
        Parameters:
        certFilePath - the path of the file containing a certificate(s).
        Returns:
        a sequence of X509Certificate certificates found in the file.
        Throws:
        java.security.cert.CertificateException - if parsing of the certificate fails
        java.io.IOException - if a file in not found at the specified certFilePath or some other IO error occurs.
        java.lang.NullPointerException - if certFilePath is null
        java.lang.IllegalArgumentException - if certFilePath is empty
      • toString

        public static java.lang.String toString​(java.security.cert.X509Certificate[] certificateChain)
      • createTrustStore

        public static java.security.KeyStore createTrustStore​(java.lang.String certFilePath)
                                                       throws java.security.cert.CertificateException,
                                                              java.io.IOException,
                                                              java.security.KeyStoreException,
                                                              java.security.NoSuchAlgorithmException
        Creates a truststore with certificates from PEM-encoded (ASCII) or DER-encoded (binary) file at the specified certFilePath.
        Parameters:
        certFilePath - the path of the file containing a certificate chain.
        Returns:
        a truststore loaded with the certificate chain present in the specified certFilePath
        Throws:
        java.security.cert.CertificateException - if parsing of the certificate fails
        java.io.IOException - if a file in not found at the specified certFilePath, or some other IO error occurs
        java.security.KeyStoreException - if creating an instance of the truststore fails for some reason.
        java.security.NoSuchAlgorithmException - if the algorithm used for verifying rhe truststore's integrity is missing
        java.lang.NullPointerException - if certFilePath is null
        java.lang.IllegalArgumentException - if certFilePath is empty