KEYCLOAK-11495 Change name of PlaintextVaultProvider to FilesPlaintextVaultProvider
This commit is contained in:
parent
f0fb48fb76
commit
2f44c58a0d
7 changed files with 23 additions and 23 deletions
|
@ -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());
|
|
@ -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
|
|
@ -1 +1 @@
|
|||
org.keycloak.vault.PlainTextVaultProviderFactory
|
||||
org.keycloak.vault.FilesPlainTextVaultProviderFactory
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -187,7 +187,7 @@
|
|||
},
|
||||
|
||||
"vault": {
|
||||
"plaintext": {
|
||||
"files-plaintext": {
|
||||
"dir": "target/dependency/vault",
|
||||
"enabled": "${keycloak.vault.plaintext.provider.enabled:false}"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue