Class KeyStoreUtil
java.lang.Object
de.xima.fc.cryptography.BouncyCastleSupport
de.xima.fc.certificate.ms.impl.util.KeyStoreUtil
Utility class for KeyStore operations.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidexportToPKCS12(List<KeyStoreEntry> entries, char[] password, OutputStream outputStream) Export certificate chain and private key to PKCS#12 formatstatic List<KeyStoreEntryInfo> getKeyStoreLayout(byte[] keystoreData, String keyStoreType, char[] password, boolean analyzeCertificates) Load a KeyStore and return the KeyStore layout.static List<KeyStoreEntryInfo> getKeyStoreLayout(InputStream ksInputStream, String keyStoreType, char[] password, boolean analyzeCertificates) Load a KeyStore and return the KeyStore layout.static Set<X509Certificate> readAllCertificates(InputStream ksInputStream, String keyStoreType, char[] keyStorePassword) Read certificates from a KeyStore input stream.static List<KeyStoreEntry> readKeyStoreEntries(byte[] keyStoreData, String keyStoreType, char[] keyStorePassword, Map<String, char[]> aliasesWithPasswords) Read KeyStore entries.static List<KeyStoreEntry> readKeyStoreEntries(InputStream ksInputStream, String keyStoreType, char[] keyStorePassword, Map<String, char[]> aliasesWithPasswords) Read KeyStore entries.validateKeyStoreEntryPasswords(InputStream ksInputStream, String keyStoreType, char[] keyStorePassword, Map<String, char[]> aliasesWithPasswords) Methods inherited from class BouncyCastleSupport
buildSignedCertificate, createCMSContentEncryptorBuilder, createContentSigner, createJceKeyTransRecipientInfoGenerator, createKeyFactory, createKeyPairGenerator, createKeyStore, createOpenSSLPKCS8DecryptorProviderBuilder, createPEMKeyConverter, createSignature, createX509CertificateConverter, createX509CertificateFactory
-
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 exportoutputStream- The output stream to write the PKCS#12 data to- Throws:
IOExceptionFcCertificateManagementException
-
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 fromkeyStoreType- The type of the KeyStorepassword- The password for the KeyStoreanalyzeCertificates- 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 fromkeyStoreType- The type of the KeyStorepassword- The password for the KeyStoreanalyzeCertificates- 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 FcCertificateManagementExceptionRead KeyStore entries.- Parameters:
keyStoreData- The KeyStore's byte[]keyStoreType- The type of the KeyStorekeyStorePassword- The password for the KeyStorealiasesWithPasswords- 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 FcCertificateManagementExceptionRead KeyStore entries.- Parameters:
ksInputStream- The input stream to read the KeyStore fromkeyStoreType- The type of the KeyStorekeyStorePassword- The password for the KeyStorealiasesWithPasswords- A map of aliases and their passwords- Returns:
- A list of KeyStore entries
- Throws:
FcCertificateManagementException- If an error occurs while reading the KeyStore entriesIllegalArgumentException- 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 fromkeyStoreType- The type of the KeyStorekeyStorePassword- 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
-