From 2288b5bf4f3281a8d0487c12932d5c44835161d4 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 8ce85704ca6..f9d0dfc7797 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 @@ -1749,7 +1749,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 a8589f571f9..7382ae3bf59 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(); /** @@ -158,8 +154,6 @@ public void testMaskedCredential() throws Exception { @BeforeClass public static void prepareKeyStores() throws Exception { - Security.addProvider(provider); - if (KEYSTORE_DIR.exists() == false) { KEYSTORE_DIR.mkdirs(); } @@ -178,6 +172,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()); } }