Class KeyStoreBuilder
java.lang.Object
com.norconex.commons.lang.security.KeyStoreBuilder
Builder for creating a KeyStore.
- Since:
- 2.0.0
-
Method Summary
Modifier and TypeMethodDescriptioncreate()Creates the key store.static KeyStoreBuilderempty()A builder for an empty key store.static KeyStoreBuilderA builder for a key store initialized from a key store file.static KeyStoreBuilderA builder for a key store initialized from{JAVA_HOME}/lib/security/cacerts.setPassword(String password) Sets the key store password.setPasswordKey(EncryptionKey passwordKey) Sets the password encryption key.setProvider(String provider) Sets the security provider name.Sets the key store type.
-
Method Details
-
setProvider
Sets the security provider name. When not set, uses default provider for the key store type.- Parameters:
provider- provider name- Returns:
- this builder
-
setType
Sets the key store type. When not set, uses default key store type.- Parameters:
type- key store type- Returns:
- this builder
-
setPassword
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
Sets the password encryption key. In case the password is encrypted.- Parameters:
passwordKey- password key- Returns:
- this builder
- See Also:
-
create
public KeyStore create() throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException, NoSuchProviderExceptionCreates 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
A builder for a key store initialized from{JAVA_HOME}/lib/security/cacerts.- Returns:
- a key store builder
-
fromFile
A builder for a key store initialized from a key store file.- Parameters:
file- key store file- Returns:
- a key store builder
-
empty
A builder for an empty key store.- Returns:
- a key store builder
-