From a5cea70ed0123de73574f1e24b2049e54b49a75e Mon Sep 17 00:00:00 2001 From: Darran Lofthouse Date: Thu, 27 Jun 2024 19:42:56 +0100 Subject: [PATCH] [ELY-2774] Also make it possible to get the KeyStore type and location. --- .../security/ssl/test/util/CAGenerationTool.java | 10 +++++++++- .../wildfly/security/ssl/test/util/CommonIdentity.java | 7 +++++++ .../wildfly/security/ssl/test/util/CustomIdentity.java | 5 +++++ .../security/ssl/test/util/DefinedIdentity.java | 6 ++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/common/src/test/java/org/wildfly/security/ssl/test/util/CAGenerationTool.java b/tests/common/src/test/java/org/wildfly/security/ssl/test/util/CAGenerationTool.java index 5b5963794d..e28f884d99 100644 --- a/tests/common/src/test/java/org/wildfly/security/ssl/test/util/CAGenerationTool.java +++ b/tests/common/src/test/java/org/wildfly/security/ssl/test/util/CAGenerationTool.java @@ -144,6 +144,10 @@ public KeyStore getBeetlesKeyStore() { return loadKeyStore(new File(workingDir, BEETLES_STORE)); } + public String getKeyStoreType() { + return KEYSTORE_TYPE; + } + /** * @deprecated Use {@link CommonIdentity#getCertificate()} instead. */ @@ -364,8 +368,12 @@ private static KeyStore createEmptyKeyStore() { } } + File getKeyStoreFile(Identity identity) { + return new File(workingDir, identity.getKeyStoreName()); + } + KeyStore loadKeyStore(final Identity identity) { - return loadKeyStore(new File(workingDir, identity.getKeyStoreName())); + return loadKeyStore(getKeyStoreFile(identity)); } static KeyStore loadKeyStore(final File location) { diff --git a/tests/common/src/test/java/org/wildfly/security/ssl/test/util/CommonIdentity.java b/tests/common/src/test/java/org/wildfly/security/ssl/test/util/CommonIdentity.java index 2d8f366401..ffd89fbdf0 100644 --- a/tests/common/src/test/java/org/wildfly/security/ssl/test/util/CommonIdentity.java +++ b/tests/common/src/test/java/org/wildfly/security/ssl/test/util/CommonIdentity.java @@ -16,6 +16,7 @@ package org.wildfly.security.ssl.test.util; +import java.io.File; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; @@ -42,8 +43,14 @@ public X509Certificate getCertificate() { return certificate; } + public String getKeyStoreType() { + return caGenerationTool.getKeyStoreType(); + } + public abstract KeyStore loadKeyStore(); + public abstract File getKeyStoreFile(); + public X509ExtendedKeyManager createKeyManager() { caGenerationTool.assertNotClosed(); diff --git a/tests/common/src/test/java/org/wildfly/security/ssl/test/util/CustomIdentity.java b/tests/common/src/test/java/org/wildfly/security/ssl/test/util/CustomIdentity.java index a1ce69a2b5..f7f2100c53 100644 --- a/tests/common/src/test/java/org/wildfly/security/ssl/test/util/CustomIdentity.java +++ b/tests/common/src/test/java/org/wildfly/security/ssl/test/util/CustomIdentity.java @@ -34,4 +34,9 @@ public KeyStore loadKeyStore() { return CAGenerationTool.loadKeyStore(keyStoreFile); } + @Override + public File getKeyStoreFile() { + return keyStoreFile; + } + } diff --git a/tests/common/src/test/java/org/wildfly/security/ssl/test/util/DefinedIdentity.java b/tests/common/src/test/java/org/wildfly/security/ssl/test/util/DefinedIdentity.java index 28595b8e11..0983b2e928 100644 --- a/tests/common/src/test/java/org/wildfly/security/ssl/test/util/DefinedIdentity.java +++ b/tests/common/src/test/java/org/wildfly/security/ssl/test/util/DefinedIdentity.java @@ -16,6 +16,7 @@ package org.wildfly.security.ssl.test.util; +import java.io.File; import java.security.KeyStore; import java.security.cert.X509Certificate; @@ -38,4 +39,9 @@ public KeyStore loadKeyStore() { return caGenerationTool.loadKeyStore(identity); } + @Override + public File getKeyStoreFile() { + return caGenerationTool.getKeyStoreFile(identity); + } + }