Package org.wildfly.security.keystore
Class KeyStoreUtil
- java.lang.Object
-
- org.wildfly.security.keystore.KeyStoreUtil
-
public class KeyStoreUtil extends Object
Utility functions for manipulating KeyStores.- Author:
- Martin Mazanek
-
-
Constructor Summary
Constructors Constructor Description KeyStoreUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static KeyStoreloadKeyStore(Supplier<Provider[]> providers, String providerName, FileInputStream is, String filename, char[] password)Tries to parse a keystore based on known recognizable patterns.static KeyStoreloadPemAsKeyStore(InputStream is, char[] password)
-
-
-
Method Detail
-
loadKeyStore
public static KeyStore loadKeyStore(Supplier<Provider[]> providers, String providerName, FileInputStream is, String filename, char[] password) throws IOException, KeyStoreException
Tries to parse a keystore based on known recognizable patterns.This method can parse JKS, JCEKS, PKCS12, BKS, BCFKS and UBER key stores as well as PEM files. At first the method looks for recognizable patterns of JKS, JCEKS, PKCS12 and BKS key store types and tries to parse them if found. If the pattern recognition fails, brute force is used to load the key store.
The provider supplier is used for loading the key stores.
- Parameters:
providers- provider supplier for loading the keystore (must not benull)providerName- if specified only providers with this name will be usedis- the key store file input stream (must not benull)filename- the filename for prioritizing brute force checks using the file extensionpassword- password of the key store. Should be the empty string for PEM files.- Returns:
- loaded key store if recognized
- Throws:
IOExceptionKeyStoreException
-
loadPemAsKeyStore
public static KeyStore loadPemAsKeyStore(InputStream is, char[] password) throws KeyStoreException, IOException
- Throws:
KeyStoreExceptionIOException
-
-