Class X509CertChainUtils

java.lang.Object
com.nimbusds.jose.util.X509CertChainUtils

public class X509CertChainUtils extends Object
X.509 certificate chain utilities.
Version:
2024-09-12
Author:
Vladimir Dzhuvinov
  • Method Details

    • toBase64List

      public static List<Base64> toBase64List(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<X509Certificate> parse(List<Base64> b64List) throws ParseException
      Parses an 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<X509Certificate> parse(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<X509Certificate> parse(String pemString) throws IOException, CertificateException
      Parses an 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<UUID> store(KeyStore trustStore, List<X509Certificate> certChain) throws KeyStoreException
      Stores an 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.