Package jenkins.test.https
Class KeyStoreManager
java.lang.Object
jenkins.test.https.KeyStoreManager
Manages a Java keystore file.
-
Constructor Summary
ConstructorDescriptionKeyStoreManager
(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.void
configureWebClient
(org.htmlunit.WebClient wc) getPath()
String[]
getType()
getURL()
void
save()
Persists the current keystore to disk.void
setCertificateEntry
(String alias, X509Certificate certificate) void
setKeyEntry
(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:
CertificateException
KeyStoreException
IOException
NoSuchAlgorithmException
-
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:
CertificateException
KeyStoreException
IOException
NoSuchAlgorithmException
-
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:
CertificateException
KeyStoreException
IOException
NoSuchAlgorithmException
-
-
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)
-