From 0d967f6b0c490695313abc579d24d3ff29d5cfe4 Mon Sep 17 00:00:00 2001 From: rmartinc Date: Wed, 9 Dec 2020 09:19:20 +0100 Subject: [PATCH] [ELY-2053] key-store-masked-password needs the elytron provider to be manually registered --- .../wildfly/security/auth/client/ElytronXmlParser.java | 2 +- .../security/auth/client/ElytronXmlParserTest.java | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/auth/client/src/main/java/org/wildfly/security/auth/client/ElytronXmlParser.java b/auth/client/src/main/java/org/wildfly/security/auth/client/ElytronXmlParser.java index 3c35f2928d9..6dcdaef7dfa 100644 --- a/auth/client/src/main/java/org/wildfly/security/auth/client/ElytronXmlParser.java +++ b/auth/client/src/main/java/org/wildfly/security/auth/client/ElytronXmlParser.java @@ -1970,7 +1970,7 @@ static void parseKeyStoreType(ConfigurationXMLStreamReader reader, final Version passwordFactory = () -> { try { Password password = maskedPassword.get(); - PasswordFactory factory = PasswordFactory.getInstance(password.getAlgorithm()); + PasswordFactory factory = PasswordFactory.getInstance(password.getAlgorithm(), providersSupplier); ClearPasswordSpec spec = factory.getKeySpec(password, ClearPasswordSpec.class); return spec.getEncodedPassword(); } catch (GeneralSecurityException e) { diff --git a/auth/client/src/test/java/org/wildfly/security/auth/client/ElytronXmlParserTest.java b/auth/client/src/test/java/org/wildfly/security/auth/client/ElytronXmlParserTest.java index 38032795bd1..372247102ad 100644 --- a/auth/client/src/test/java/org/wildfly/security/auth/client/ElytronXmlParserTest.java +++ b/auth/client/src/test/java/org/wildfly/security/auth/client/ElytronXmlParserTest.java @@ -26,9 +26,7 @@ import java.security.KeyPairGenerator; import java.security.KeyStore; import java.security.PrivateKey; -import java.security.Provider; import java.security.PublicKey; -import java.security.Security; import java.security.cert.X509Certificate; import javax.net.ssl.SSLContext; @@ -40,7 +38,6 @@ import org.junit.Test; import org.wildfly.client.config.ConfigXMLParseException; import org.wildfly.security.SecurityFactory; -import org.wildfly.security.WildFlyElytronProvider; import org.wildfly.security.credential.PasswordCredential; import org.wildfly.security.password.Password; import org.wildfly.security.password.interfaces.ClearPassword; @@ -55,7 +52,6 @@ public class ElytronXmlParserTest { private static File KEYSTORE_DIR = new File("./target/keystore"); private static final String CLIENT_KEYSTORE_FILENAME = "/client.keystore"; private static final char[] PASSWORD = "password".toCharArray(); - private static final Provider provider = new WildFlyElytronProvider(); /** @@ -199,8 +195,6 @@ private void checkSSLContext(SecurityFactory authContext, @BeforeClass public static void prepareKeyStores() throws Exception { - Security.addProvider(provider); - if (KEYSTORE_DIR.exists() == false) { KEYSTORE_DIR.mkdirs(); } @@ -219,6 +213,7 @@ public static void prepareKeyStores() throws Exception { @AfterClass public static void removeProvider() { - Security.removeProvider(provider.getName()); + Assert.assertTrue("Keystore deleted", new File(KEYSTORE_DIR, CLIENT_KEYSTORE_FILENAME).delete()); + Assert.assertTrue("Keystore directory deleted", KEYSTORE_DIR.delete()); } }