Class X509CertChainUtils


  • public class X509CertChainUtils
    extends Object
    X.509 certificate chain utilities.
    Version:
    2020-02-22
    Author:
    Vladimir Dzhuvinov
    • Method Detail

      • toBase64List

        public static List<Base64toBase64List​(List<Object> jsonArray)
                                         throws ParseException
        Converts the specified JSON array of strings to a list of Base64 encoded objects.
        Parameters:
        jsonArray - The JSON array of string, null if not specified.
        Returns:
        The Base64 list, null if not specified.
        Throws:
        ParseException - If parsing failed.
      • parse

        public static List<X509Certificateparse​(List<Base64> b64List)
                                           throws ParseException
        Parses a X.509 certificate chain from the specified Base64-encoded DER-encoded representation.
        Parameters:
        b64List - The Base64-encoded DER-encoded X.509 certificate chain, null if not specified.
        Returns:
        The X.509 certificate chain, null if not specified.
        Throws:
        ParseException - If parsing failed.
      • parse

        public static List<X509Certificateparse​(File pemFile)
                                           throws IOException,
                                                  CertificateException
        Parses a X.509 certificate chain from the specified PEM-encoded representation. PEM-encoded objects that are not X.509 certificates are ignored. Requires BouncyCastle.
        Parameters:
        pemFile - The PEM-encoded X.509 certificate chain file. Must not be null.
        Returns:
        The X.509 certificate chain, empty list if no certificates are found.
        Throws:
        IOException - On I/O exception.
        CertificateException - On a certificate exception.
      • parse

        public static List<X509Certificateparse​(String pemString)
                                           throws IOException,
                                                  CertificateException
        Parses a X.509 certificate chain from the specified PEM-encoded representation. PEM-encoded objects that are not X.509 certificates are ignored. Requires BouncyCastle.
        Parameters:
        pemString - The PEM-encoded X.509 certificate chain. Must not be null.
        Returns:
        The X.509 certificate chain, empty list if no certificates are found.
        Throws:
        IOException - On I/O exception.
        CertificateException - On a certificate exception.
      • store

        public static List<UUIDstore​(KeyStore trustStore,
                                       List<X509Certificate> certChain)
                                throws KeyStoreException
        Stores a X.509 certificate chain into the specified Java trust (key) store. The name (alias) for each certificate in the store is a generated UUID.
        Parameters:
        trustStore - The trust (key) store. Must be initialised and not null.
        certChain - The X.509 certificate chain. Must not be null.
        Returns:
        The UUIDs for the stored entry.
        Throws:
        KeyStoreException - On a key store exception.