Class KeyStoreUtil

java.lang.Object
de.xima.fc.cryptography.BouncyCastleSupport
de.xima.fc.certificate.ms.impl.util.KeyStoreUtil

public final class KeyStoreUtil extends BouncyCastleSupport
Utility class for KeyStore operations.
  • Method Details

    • exportToPKCS12

      public static void exportToPKCS12(List<KeyStoreEntry> entries, char[] password, OutputStream outputStream) throws IOException, FcCertificateManagementException
      Export certificate chain and private key to PKCS#12 format
      Parameters:
      entries - The list of KeyStore entries to export
      outputStream - The output stream to write the PKCS#12 data to
      Throws:
      IOException
      FcCertificateManagementException
    • getKeyStoreLayout

      public static List<KeyStoreEntryInfo> getKeyStoreLayout(byte[] keystoreData, String keyStoreType, char[] password, boolean analyzeCertificates) throws FcCertificateManagementException
      Load a KeyStore and return the KeyStore layout.
      Parameters:
      keystoreData - The data to load the KeyStore from
      keyStoreType - The type of the KeyStore
      password - The password for the KeyStore
      analyzeCertificates - Whether to analyze the certificates for extended usage information
      Returns:
      A list of KeyStore entry information. This includes extended certificate usage information if requested.
      Throws:
      FcCertificateManagementException - If an error occurs while loading the KeyStore
    • getKeyStoreLayout

      public static List<KeyStoreEntryInfo> getKeyStoreLayout(InputStream ksInputStream, String keyStoreType, char[] password, boolean analyzeCertificates) throws FcCertificateManagementException
      Load a KeyStore and return the KeyStore layout.
      Parameters:
      ksInputStream - The input stream to load the KeyStore from
      keyStoreType - The type of the KeyStore
      password - The password for the KeyStore
      analyzeCertificates - Whether to analyze the certificates for extended usage information
      Returns:
      A list of KeyStore entry information. This includes extended certificate usage information if requested.
      Throws:
      FcCertificateManagementException - If an error occurs while loading the KeyStore
    • readKeyStoreEntries

      public static List<KeyStoreEntry> readKeyStoreEntries(byte[] keyStoreData, String keyStoreType, char[] keyStorePassword, Map<String,char[]> aliasesWithPasswords) throws FcCertificateManagementException
      Read KeyStore entries.
      Parameters:
      keyStoreData - The KeyStore's byte[]
      keyStoreType - The type of the KeyStore
      keyStorePassword - The password for the KeyStore
      aliasesWithPasswords - A map of aliases and their passwords
      Returns:
      A list of KeyStore entries
      Throws:
      FcCertificateManagementException - If an error occurs while reading the KeyStore entries
    • readKeyStoreEntries

      public static List<KeyStoreEntry> readKeyStoreEntries(InputStream ksInputStream, String keyStoreType, char[] keyStorePassword, Map<String,char[]> aliasesWithPasswords) throws FcCertificateManagementException
      Read KeyStore entries.
      Parameters:
      ksInputStream - The input stream to read the KeyStore from
      keyStoreType - The type of the KeyStore
      keyStorePassword - The password for the KeyStore
      aliasesWithPasswords - A map of aliases and their passwords
      Returns:
      A list of KeyStore entries
      Throws:
      FcCertificateManagementException - If an error occurs while reading the KeyStore entries
      IllegalArgumentException - If an alias is not a valid KeyStore entry
    • readAllCertificates

      public static Set<X509Certificate> readAllCertificates(InputStream ksInputStream, String keyStoreType, char[] keyStorePassword) throws FcCertificateManagementException
      Read certificates from a KeyStore input stream.
      Parameters:
      ksInputStream - The input stream to read the KeyStore from
      keyStoreType - The type of the KeyStore
      keyStorePassword - The password for the KeyStore
      Returns:
      A set of X509 certificates
      Throws:
      FcCertificateManagementException - If an error occurs while reading the certificates
    • validateKeyStoreEntryPasswords

      public static Map<String,Boolean> validateKeyStoreEntryPasswords(InputStream ksInputStream, String keyStoreType, char[] keyStorePassword, Map<String,char[]> aliasesWithPasswords) throws FcCertificateManagementException
      Throws:
      FcCertificateManagementException