Class KeyStoreBuilder
- java.lang.Object
-
- com.norconex.commons.lang.security.KeyStoreBuilder
-
public final class KeyStoreBuilder extends Object
Builder for creating a KeyStore.- Since:
- 2.0.0
- Author:
- Pascal Essiembre
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description KeyStorecreate()Creates the key store.static KeyStoreBuilderempty()A builder for an empty key store.static KeyStoreBuilderfromFile(Path file)A builder for a key store initialized from a key store file.static KeyStoreBuilderfromJavaHome()A builder for a key store initialized from{JAVA_HOME}/lib/security/cacerts.KeyStoreBuildersetPassword(String password)Sets the key store password.KeyStoreBuildersetPasswordKey(EncryptionKey passwordKey)Sets the password encryption key.KeyStoreBuildersetProvider(String provider)Sets the security provider name.KeyStoreBuildersetType(String type)Sets the key store type.
-
-
-
Method Detail
-
setProvider
public KeyStoreBuilder setProvider(String provider)
Sets the security provider name. When not set, uses default provider for the key store type.- Parameters:
provider- provider name- Returns:
- this builder
-
setType
public KeyStoreBuilder setType(String type)
Sets the key store type. When not set, uses default key store type.- Parameters:
type- key store type- Returns:
- this builder
-
setPassword
public KeyStoreBuilder setPassword(String password)
Sets the key store password. When not set, it is assumed the key store does not require any password.- Parameters:
password- key store password.- Returns:
- this builder
-
setPasswordKey
public KeyStoreBuilder setPasswordKey(EncryptionKey passwordKey)
Sets the password encryption key. In case the password is encrypted.- Parameters:
passwordKey- password key- Returns:
- this builder
- See Also:
EncryptionKey
-
create
public KeyStore create() throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException, NoSuchProviderException
Creates the key store.- Returns:
- key store
- Throws:
NoSuchAlgorithmException- problem creating key storeCertificateException- problem creating key storeIOException- problem creating key storeKeyStoreException- problem creating key storeNoSuchProviderException- problem creating key store
-
fromJavaHome
public static KeyStoreBuilder fromJavaHome()
A builder for a key store initialized from{JAVA_HOME}/lib/security/cacerts.- Returns:
- a key store builder
-
fromFile
public static KeyStoreBuilder fromFile(Path file)
A builder for a key store initialized from a key store file.- Parameters:
file- key store file- Returns:
- a key store builder
-
empty
public static KeyStoreBuilder empty()
A builder for an empty key store.- Returns:
- a key store builder
-
-