From 2f44c58a0d17f6dc55b070eab03f5a2c8474fcc1 Mon Sep 17 00:00:00 2001 From: mhajas Date: Thu, 3 Oct 2019 09:14:22 +0200 Subject: [PATCH] KEYCLOAK-11495 Change name of PlaintextVaultProvider to FilesPlaintextVaultProvider --- ...vider.java => FilesPlainTextVaultProvider.java} | 6 +++--- ...ava => FilesPlainTextVaultProviderFactory.java} | 8 ++++---- .../org.keycloak.vault.VaultProviderFactory | 2 +- .../vault/PlainTextVaultProviderFactoryTest.java | 12 ++++++------ .../keycloak/vault/PlainTextVaultProviderTest.java | 14 +++++++------- .../org/keycloak/testsuite/util/VaultUtils.java | 2 +- .../test/resources/META-INF/keycloak-server.json | 2 +- 7 files changed, 23 insertions(+), 23 deletions(-) rename services/src/main/java/org/keycloak/vault/{PlainTextVaultProvider.java => FilesPlainTextVaultProvider.java} (92%) rename services/src/main/java/org/keycloak/vault/{PlainTextVaultProviderFactory.java => FilesPlainTextVaultProviderFactory.java} (83%) diff --git a/services/src/main/java/org/keycloak/vault/PlainTextVaultProvider.java b/services/src/main/java/org/keycloak/vault/FilesPlainTextVaultProvider.java similarity index 92% rename from services/src/main/java/org/keycloak/vault/PlainTextVaultProvider.java rename to services/src/main/java/org/keycloak/vault/FilesPlainTextVaultProvider.java index 6a61a4faa3..c2b7351759 100644 --- a/services/src/main/java/org/keycloak/vault/PlainTextVaultProvider.java +++ b/services/src/main/java/org/keycloak/vault/FilesPlainTextVaultProvider.java @@ -29,7 +29,7 @@ import java.util.Optional; * * @author Sebastian Łaskawiec */ -public class PlainTextVaultProvider implements VaultProvider { +public class FilesPlainTextVaultProvider implements VaultProvider { private static final Logger logger = Logger.getLogger(MethodHandles.lookup().lookupClass()); @@ -37,12 +37,12 @@ public class PlainTextVaultProvider implements VaultProvider { private final String realmName; /** - * Creates a new {@link PlainTextVaultProvider}. + * Creates a new {@link FilesPlainTextVaultProvider}. * * @param path A path to a vault. Can not be null. * @param realmName A realm name. Can not be null. */ - public PlainTextVaultProvider(@Nonnull Path path, @Nonnull String realmName) { + public FilesPlainTextVaultProvider(@Nonnull Path path, @Nonnull String realmName) { this.vaultPath = path; this.realmName = realmName; logger.debugf("PlainTextVaultProvider will operate in %s directory", vaultPath.toAbsolutePath()); diff --git a/services/src/main/java/org/keycloak/vault/PlainTextVaultProviderFactory.java b/services/src/main/java/org/keycloak/vault/FilesPlainTextVaultProviderFactory.java similarity index 83% rename from services/src/main/java/org/keycloak/vault/PlainTextVaultProviderFactory.java rename to services/src/main/java/org/keycloak/vault/FilesPlainTextVaultProviderFactory.java index f4e1a80c6e..c18cd93fa6 100644 --- a/services/src/main/java/org/keycloak/vault/PlainTextVaultProviderFactory.java +++ b/services/src/main/java/org/keycloak/vault/FilesPlainTextVaultProviderFactory.java @@ -11,15 +11,15 @@ import java.nio.file.Path; import java.nio.file.Paths; /** - * Creates and configures {@link PlainTextVaultProvider}. + * Creates and configures {@link FilesPlainTextVaultProvider}. * * @author Sebastian Łaskawiec */ -public class PlainTextVaultProviderFactory implements VaultProviderFactory { +public class FilesPlainTextVaultProviderFactory implements VaultProviderFactory { private static final Logger logger = Logger.getLogger(MethodHandles.lookup().lookupClass()); - public static final String PROVIDER_ID = "plaintext"; + public static final String PROVIDER_ID = "files-plaintext"; private String vaultDirectory; private Path vaultPath; @@ -30,7 +30,7 @@ public class PlainTextVaultProviderFactory implements VaultProviderFactory { logger.debug("Can not create a vault since it's disabled or not initialized correctly"); return null; } - return new PlainTextVaultProvider(vaultPath, session.getContext().getRealm().getName()); + return new FilesPlainTextVaultProvider(vaultPath, session.getContext().getRealm().getName()); } @Override diff --git a/services/src/main/resources/META-INF/services/org.keycloak.vault.VaultProviderFactory b/services/src/main/resources/META-INF/services/org.keycloak.vault.VaultProviderFactory index d3331b2ab4..4977fb5de4 100644 --- a/services/src/main/resources/META-INF/services/org.keycloak.vault.VaultProviderFactory +++ b/services/src/main/resources/META-INF/services/org.keycloak.vault.VaultProviderFactory @@ -1 +1 @@ -org.keycloak.vault.PlainTextVaultProviderFactory \ No newline at end of file +org.keycloak.vault.FilesPlainTextVaultProviderFactory \ No newline at end of file diff --git a/services/src/test/java/org/keycloak/vault/PlainTextVaultProviderFactoryTest.java b/services/src/test/java/org/keycloak/vault/PlainTextVaultProviderFactoryTest.java index d8adacdfa1..3156949e7a 100644 --- a/services/src/test/java/org/keycloak/vault/PlainTextVaultProviderFactoryTest.java +++ b/services/src/test/java/org/keycloak/vault/PlainTextVaultProviderFactoryTest.java @@ -33,7 +33,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; /** - * Tests for {@link PlainTextVaultProviderFactory}. + * Tests for {@link FilesPlainTextVaultProviderFactory}. * * @author Sebastian Łaskawiec */ @@ -46,7 +46,7 @@ public class PlainTextVaultProviderFactoryTest { public void shouldInitializeVaultCorrectly() { //given VaultConfig config = new VaultConfig(Scenario.EXISTING.getAbsolutePathAsString()); - PlainTextVaultProviderFactory factory = new PlainTextVaultProviderFactory(); + FilesPlainTextVaultProviderFactory factory = new FilesPlainTextVaultProviderFactory(); KeycloakSession session = new DefaultKeycloakSession(new DefaultKeycloakSessionFactory()); session.getContext().setRealm(new VaultRealmModel()); @@ -63,7 +63,7 @@ public class PlainTextVaultProviderFactoryTest { public void shouldThrowAnExceptionWhenUsingNonExistingDirectory() { //given VaultConfig config = new VaultConfig(Scenario.NON_EXISTING.getAbsolutePathAsString()); - PlainTextVaultProviderFactory factory = new PlainTextVaultProviderFactory(); + FilesPlainTextVaultProviderFactory factory = new FilesPlainTextVaultProviderFactory(); expectedException.expect(VaultNotFoundException.class); @@ -77,7 +77,7 @@ public class PlainTextVaultProviderFactoryTest { public void shouldReturnNullWhenWithNullDirectory() { //given VaultConfig config = new VaultConfig(null); - PlainTextVaultProviderFactory factory = new PlainTextVaultProviderFactory(); + FilesPlainTextVaultProviderFactory factory = new FilesPlainTextVaultProviderFactory(); //when factory.init(config); @@ -89,7 +89,7 @@ public class PlainTextVaultProviderFactoryTest { /** * A whitebox implementation of the Realm model, which is needed to extract realm name. - * Please use only for testing {@link PlainTextVaultProviderFactory}. + * Please use only for testing {@link FilesPlainTextVaultProviderFactory}. */ private static class VaultRealmModel implements RealmModel { @@ -1245,7 +1245,7 @@ public class PlainTextVaultProviderFactoryTest { } /** - * A whitebox implementation of the config. Please use only for testing {@link PlainTextVaultProviderFactory}. + * A whitebox implementation of the config. Please use only for testing {@link FilesPlainTextVaultProviderFactory}. */ private static class VaultConfig implements Config.Scope { diff --git a/services/src/test/java/org/keycloak/vault/PlainTextVaultProviderTest.java b/services/src/test/java/org/keycloak/vault/PlainTextVaultProviderTest.java index ac05657937..d7a0368d87 100644 --- a/services/src/test/java/org/keycloak/vault/PlainTextVaultProviderTest.java +++ b/services/src/test/java/org/keycloak/vault/PlainTextVaultProviderTest.java @@ -13,7 +13,7 @@ import static org.junit.Assert.assertThat; import static org.keycloak.vault.SecretContains.secretContains; /** - * Tests for {@link PlainTextVaultProvider}. + * Tests for {@link FilesPlainTextVaultProvider}. * * @author Sebastian Łaskawiec */ @@ -22,7 +22,7 @@ public class PlainTextVaultProviderTest { @Test public void shouldObtainSecret() throws Exception { //given - PlainTextVaultProvider provider = new PlainTextVaultProvider(Scenario.EXISTING.getPath(), "test"); + FilesPlainTextVaultProvider provider = new FilesPlainTextVaultProvider(Scenario.EXISTING.getPath(), "test"); //when VaultRawSecret secret1 = provider.obtainSecret("key1"); @@ -36,7 +36,7 @@ public class PlainTextVaultProviderTest { @Test public void shouldReplaceUnderscoreWithTwoUnderscores() throws Exception { //given - PlainTextVaultProvider provider = new PlainTextVaultProvider(Scenario.EXISTING.getPath(), "test_realm"); + FilesPlainTextVaultProvider provider = new FilesPlainTextVaultProvider(Scenario.EXISTING.getPath(), "test_realm"); //when VaultRawSecret secret1 = provider.obtainSecret("underscore_key1"); @@ -50,7 +50,7 @@ public class PlainTextVaultProviderTest { @Test public void shouldReturnEmptyOptionalOnMissingSecret() throws Exception { //given - PlainTextVaultProvider provider = new PlainTextVaultProvider(Scenario.EXISTING.getPath(), "test"); + FilesPlainTextVaultProvider provider = new FilesPlainTextVaultProvider(Scenario.EXISTING.getPath(), "test"); //when VaultRawSecret secret = provider.obtainSecret("non-existing-key"); @@ -63,7 +63,7 @@ public class PlainTextVaultProviderTest { @Test public void shouldOperateOnNonExistingVaultDirectory() throws Exception { //given - PlainTextVaultProvider provider = new PlainTextVaultProvider(Scenario.NON_EXISTING.getPath(), "test"); + FilesPlainTextVaultProvider provider = new FilesPlainTextVaultProvider(Scenario.NON_EXISTING.getPath(), "test"); //when VaultRawSecret secret = provider.obtainSecret("non-existing-key"); @@ -80,7 +80,7 @@ public class PlainTextVaultProviderTest { Path vaultDirectory = temporarySecretFile.getParent(); String secretName = temporarySecretFile.getFileName().toString(); - PlainTextVaultProvider provider = new PlainTextVaultProvider(vaultDirectory, "ignored") { + FilesPlainTextVaultProvider provider = new FilesPlainTextVaultProvider(vaultDirectory, "ignored") { @Override protected Path resolveSecretPath(String vaultSecretId) { return vaultDirectory.resolve(vaultSecretId); @@ -113,7 +113,7 @@ public class PlainTextVaultProviderTest { Path vaultDirectory = temporarySecretFile.getParent(); String secretName = temporarySecretFile.getFileName().toString(); - PlainTextVaultProvider provider = new PlainTextVaultProvider(vaultDirectory, "ignored") { + FilesPlainTextVaultProvider provider = new FilesPlainTextVaultProvider(vaultDirectory, "ignored") { @Override protected Path resolveSecretPath(String vaultSecretId) { return vaultDirectory.resolve(vaultSecretId); diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/VaultUtils.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/VaultUtils.java index 3b313b62c5..cad6658b3c 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/VaultUtils.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/VaultUtils.java @@ -27,7 +27,7 @@ public class VaultUtils { Administration administration = new Administration(client); client.execute("/subsystem=keycloak-server/spi=vault/:add"); - client.execute("/subsystem=keycloak-server/spi=vault/provider=plaintext/:add(enabled=true,properties={dir => \"${jboss.home.dir}/standalone/configuration/vault\"})"); + client.execute("/subsystem=keycloak-server/spi=vault/provider=files-plaintext/:add(enabled=true,properties={dir => \"${jboss.home.dir}/standalone/configuration/vault\"})"); administration.reload(); diff --git a/testsuite/integration-arquillian/tests/base/src/test/resources/META-INF/keycloak-server.json b/testsuite/integration-arquillian/tests/base/src/test/resources/META-INF/keycloak-server.json index fd3b3b0b10..57105221ef 100755 --- a/testsuite/integration-arquillian/tests/base/src/test/resources/META-INF/keycloak-server.json +++ b/testsuite/integration-arquillian/tests/base/src/test/resources/META-INF/keycloak-server.json @@ -187,7 +187,7 @@ }, "vault": { - "plaintext": { + "files-plaintext": { "dir": "target/dependency/vault", "enabled": "${keycloak.vault.plaintext.provider.enabled:false}" }