Package jenkins.test.https
Class KeyStoreManager
java.lang.Object
jenkins.test.https.KeyStoreManager
Manages a Java keystore file.
-
Constructor Summary
ConstructorsConstructorDescriptionKeyStoreManager(Path path) Creates a new instance using the default keystore type.KeyStoreManager(Path path, String password) Creates a new instance using the default keystore type.KeyStoreManager(Path path, String password, String type) Creates a new instance using the specified keystore type. -
Method Summary
Modifier and TypeMethodDescriptionBuild a custom SSL context that trusts the default certificates as well as those in the current keystore.Build server context for server usage.voidconfigureWebClient(org.htmlunit.WebClient wc) getPath()String[]getType()getURL()voidsave()Persists the current keystore to disk.voidsetCertificateEntry(String alias, X509Certificate certificate) voidsetKeyEntry(String host, PrivateKey privateKey, Certificate[] certificates)
-
Constructor Details
-
KeyStoreManager
public KeyStoreManager(@NonNull Path path) throws CertificateException, KeyStoreException, IOException, NoSuchAlgorithmException Creates a new instance using the default keystore type.- Parameters:
path- path of the keystore file. If it exists, it will be loaded automatically.- Throws:
CertificateExceptionKeyStoreExceptionIOExceptionNoSuchAlgorithmException
-
KeyStoreManager
public KeyStoreManager(@NonNull Path path, @CheckForNull String password) throws CertificateException, KeyStoreException, IOException, NoSuchAlgorithmException Creates a new instance using the default keystore type.- Parameters:
path- path of the keystore file. If it exists, it will be loaded automatically.password- password for the keystore file.- Throws:
CertificateExceptionKeyStoreExceptionIOExceptionNoSuchAlgorithmException
-
KeyStoreManager
public KeyStoreManager(@NonNull Path path, @CheckForNull String password, @NonNull String type) throws CertificateException, KeyStoreException, IOException, NoSuchAlgorithmException Creates a new instance using the specified keystore type.- Parameters:
path- path of the keystore file. If it exists, it will be loaded automatically.password- password for the keystore file.type- type of the keystore file.- Throws:
CertificateExceptionKeyStoreExceptionIOExceptionNoSuchAlgorithmException
-
-
Method Details
-
getPassword
- Returns:
- the password for the managed keystore
-
getPath
- Returns:
- the path where the managed keystore is persisted to.
Make sure
save()has been called before using the path.
-
getType
- Returns:
- the type of the managed keystore.
-
getURL
- Returns:
- returns the URL representation of the keystore file.
Make sure
save()has been called before using the path.
-
save
public void save() throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateExceptionPersists the current keystore to disk. -
buildClientSSLContext
@NonNull public SSLContext buildClientSSLContext() throws NoSuchAlgorithmException, KeyStoreException, IOException, CertificateException, KeyManagementExceptionBuild a custom SSL context that trusts the default certificates as well as those in the current keystore. -
buildServerSSLContext
Build server context for server usage.- Returns:
- a SSLContext instance configured with the key store.
-
setCertificateEntry
- Throws:
KeyStoreException- See Also:
-
setKeyEntry
public void setKeyEntry(String host, PrivateKey privateKey, Certificate[] certificates) throws KeyStoreException - Throws:
KeyStoreException- See Also:
-
getTruststoreJavaOptions
-
configureWebClient
public void configureWebClient(org.htmlunit.WebClient wc)
-