@ThreadSafe public final class KeyStoreHelper extends Object
| Modifier and Type | Method and Description |
|---|---|
static KeyStore |
createKeyStoreWithOnlyOneItem(KeyStore aBaseKeyStore,
String sAliasToCopy,
char[] aAliasPassword)
Create a new key store based on an existing key store
|
static com.helger.commons.io.resourceprovider.IReadableResourceProvider |
getResourceProvider() |
static KeyStore |
getSimiliarKeyStore(KeyStore aOther) |
static LoadedKeyStore |
loadKeyStore(IKeyStoreType aKeyStoreType,
String sKeyStorePath,
String sKeyStorePassword)
Load the provided key store in a safe manner.
|
static KeyStore |
loadKeyStoreDirect(IKeyStoreType aKeyStoreType,
String sKeyStorePath,
char[] aKeyStorePassword)
Load a key store from a resource.
|
static KeyStore |
loadKeyStoreDirect(IKeyStoreType aKeyStoreType,
String sKeyStorePath,
String sKeyStorePassword)
Load a key store from a resource.
|
static LoadedKey<KeyStore.PrivateKeyEntry> |
loadPrivateKey(KeyStore aKeyStore,
String sKeyStorePath,
String sKeyStoreKeyAlias,
char[] aKeyStoreKeyPassword)
Load the specified private key entry from the provided key store.
|
static LoadedKey<KeyStore.SecretKeyEntry> |
loadSecretKey(KeyStore aKeyStore,
String sKeyStorePath,
String sKeyStoreKeyAlias,
char[] aKeyStoreKeyPassword)
Load the specified secret key entry from the provided key store.
|
static LoadedKey<KeyStore.TrustedCertificateEntry> |
loadTrustedCertificateKey(KeyStore aKeyStore,
String sKeyStorePath,
String sKeyStoreKeyAlias,
char[] aKeyStoreKeyPassword)
Load the specified private key entry from the provided key store.
|
static void |
setResourceProvider(com.helger.commons.io.resourceprovider.IReadableResourceProvider aResourceProvider) |
@Nonnull public static com.helger.commons.io.resourceprovider.IReadableResourceProvider getResourceProvider()
public static void setResourceProvider(@Nonnull com.helger.commons.io.resourceprovider.IReadableResourceProvider aResourceProvider)
@Nonnull public static KeyStore getSimiliarKeyStore(@Nonnull KeyStore aOther) throws KeyStoreException
KeyStoreException@Nonnull public static KeyStore loadKeyStoreDirect(@Nonnull IKeyStoreType aKeyStoreType, @Nonnull String sKeyStorePath, @Nullable String sKeyStorePassword) throws GeneralSecurityException, IOException
aKeyStoreType - Type of key store. May not be null.sKeyStorePath - The path pointing to the key store. May not be null.sKeyStorePassword - The key store password. May be null to indicate that no
password is required.GeneralSecurityException - In case of a key store errorIOException - In case key store loading failsIllegalArgumentException - If the key store path is invalid@Nonnull public static KeyStore loadKeyStoreDirect(@Nonnull IKeyStoreType aKeyStoreType, @Nonnull String sKeyStorePath, @Nullable char[] aKeyStorePassword) throws GeneralSecurityException, IOException
aKeyStoreType - Type of key store. May not be null.sKeyStorePath - The path pointing to the key store. May not be null.aKeyStorePassword - The key store password. May be null to indicate that no
password is required.GeneralSecurityException - In case of a key store errorIOException - In case key store loading failsIllegalArgumentException - If the key store path is invalidKeyStore.load(InputStream, char[])@Nonnull public static KeyStore createKeyStoreWithOnlyOneItem(@Nonnull KeyStore aBaseKeyStore, @Nonnull String sAliasToCopy, @Nullable char[] aAliasPassword) throws GeneralSecurityException, IOException
aBaseKeyStore - The source key store. May not be nullsAliasToCopy - The name of the alias in the source key store that should be put in
the new key storeaAliasPassword - The optional password to access the alias in the source key store.
If it is not null the same password will be used in the
created key storeGeneralSecurityException - In case of a key store errorIOException - In case key store loading fails@Nonnull public static LoadedKeyStore loadKeyStore(@Nonnull IKeyStoreType aKeyStoreType, @Nullable String sKeyStorePath, @Nullable String sKeyStorePassword)
aKeyStoreType - Type of key store. May not be null.sKeyStorePath - Path to the key store. May not be null to succeed.sKeyStorePassword - Password for the key store. May not be null to succeed.null.@Nonnull public static LoadedKey<KeyStore.PrivateKeyEntry> loadPrivateKey(@Nonnull KeyStore aKeyStore, @Nonnull String sKeyStorePath, @Nullable String sKeyStoreKeyAlias, @Nullable char[] aKeyStoreKeyPassword)
aKeyStore - The key store to load the key from. May not be null.sKeyStorePath - Key store path. For nice error messages only. May not be
null.sKeyStoreKeyAlias - The alias to be resolved in the key store. Must be non-
null to succeed.aKeyStoreKeyPassword - The key password for the key store. Must be non-null to
succeed.null.@Nonnull public static LoadedKey<KeyStore.SecretKeyEntry> loadSecretKey(@Nonnull KeyStore aKeyStore, @Nonnull String sKeyStorePath, @Nullable String sKeyStoreKeyAlias, @Nullable char[] aKeyStoreKeyPassword)
aKeyStore - The key store to load the key from. May not be null.sKeyStorePath - Key store path. For nice error messages only. May not be
null.sKeyStoreKeyAlias - The alias to be resolved in the key store. Must be non-
null to succeed.aKeyStoreKeyPassword - The key password for the key store. Must be non-null to
succeed.null.@Nonnull public static LoadedKey<KeyStore.TrustedCertificateEntry> loadTrustedCertificateKey(@Nonnull KeyStore aKeyStore, @Nonnull String sKeyStorePath, @Nullable String sKeyStoreKeyAlias, @Nullable char[] aKeyStoreKeyPassword)
aKeyStore - The key store to load the key from. May not be null.sKeyStorePath - Key store path. For nice error messages only. May not be
null.sKeyStoreKeyAlias - The alias to be resolved in the key store. Must be non-
null to succeed.aKeyStoreKeyPassword - The key password for the key store. Must be non-null to
succeed.null.Copyright © 2016–2021 Philip Helger. All rights reserved.