Class KeyStoreBuilder
- java.lang.Object
-
- org.forgerock.openam.shared.security.crypto.KeyStoreBuilder
-
public final class KeyStoreBuilder extends Object
Builder class for loading keystores.- Since:
- 13.0.0
-
-
Constructor Summary
Constructors Constructor Description KeyStoreBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description KeyStorebuild()Builds and loads the keystore using the provided parameters.KeyStoreBuilderwithInputStream(InputStream inputStream)Specifies the input stream to load the keystore from.KeyStoreBuilderwithKeyStoreFile(File keyStoreFile)Specifies the file to load the keystore from.KeyStoreBuilderwithKeyStoreType(KeyStoreType type)Specifies the type of keystore to load.KeyStoreBuilderwithPassword(char[] password)Specifies the password to unlock the keystore.KeyStoreBuilderwithPassword(String password)Specifies the password to unlock the keystore.KeyStoreBuilderwithProvider(String providerName)Specifies the security provider to use for the keystore.KeyStoreBuilderwithProvider(Provider provider)Specifies the security provider to use for the keystore.
-
-
-
Method Detail
-
withInputStream
public KeyStoreBuilder withInputStream(InputStream inputStream)
Specifies the input stream to load the keystore from. Defaults tonullto create a fresh keystore.Note: the input stream will be closed automatically after the keystore is loaded.
- Parameters:
inputStream- the input stream to load the keystore from.- Returns:
- the same builder instance.
-
withKeyStoreFile
public KeyStoreBuilder withKeyStoreFile(File keyStoreFile) throws FileNotFoundException
Specifies the file to load the keystore from.- Parameters:
keyStoreFile- the keystore file to load.- Returns:
- the same builder instance.
- Throws:
FileNotFoundException- if the file does not exist, is not a file, or cannot be read.
-
withKeyStoreType
public KeyStoreBuilder withKeyStoreType(KeyStoreType type)
Specifies the type of keystore to load. Defaults to JKS.- Parameters:
type- the type of keystore to load. May not be null.- Returns:
- the same builder instance.
-
withPassword
public KeyStoreBuilder withPassword(char[] password)
Specifies the password to unlock the keystore. Defaults to no password. The password will be cleared after the keystore has been loaded.- Parameters:
password- the password to unlock the keystore.- Returns:
- the same builder instance.
-
withPassword
public KeyStoreBuilder withPassword(String password)
Specifies the password to unlock the keystore.- Parameters:
password- the password to use. May not be null.- Returns:
- the same builder instance.
- See Also:
withPassword(char[])
-
withProvider
public KeyStoreBuilder withProvider(Provider provider)
Specifies the security provider to use for the keystore.- Parameters:
provider- the security provider. May not be null.- Returns:
- the same builder instance.
-
withProvider
public KeyStoreBuilder withProvider(String providerName)
Specifies the security provider to use for the keystore.- Parameters:
providerName- the name of the provider to use.- Returns:
- the same builder instance.
- Throws:
IllegalArgumentException- if no such provider exists.
-
build
public KeyStore build()
Builds and loads the keystore using the provided parameters. If a password was provided, then it is blanked after the keystore has been loaded.- Returns:
- the configured keystore.
-
-