@Test public void loadKeyVaultConfigFromNoConfig() { KeyConfiguration keyConfiguration = new KeyConfiguration(); Optional<DefaultKeyVaultConfig> result = keyConfiguration.getKeyVaultConfig(KeyVaultType.AZURE); assertThat(result).isNotPresent(); }
public Optional<DefaultKeyVaultConfig> getKeyVaultConfig(KeyVaultType type) { if (type == null) { return Optional.empty(); } if (KeyVaultType.AZURE.equals(type) && azureKeyVaultConfig != null) { return Optional.of(KeyVaultConfigConverter.convert(azureKeyVaultConfig)); } if (KeyVaultType.HASHICORP.equals(type) && hashicorpKeyVaultConfig != null) { return Optional.of(KeyVaultConfigConverter.convert(hashicorpKeyVaultConfig)); } if (keyVaultConfigs == null) { return Optional.empty(); } return keyVaultConfigs.stream().filter(c -> type.equals(c.getKeyVaultType())).findFirst(); }
KeyConfiguration extends ConfigItem { public Optional<DefaultKeyVaultConfig> getKeyVaultConfig(KeyVaultType type) { if (type == null) { return Optional.empty(); } if (KeyVaultType.AZURE.equals(type) && azureKeyVaultConfig != null) { return Optional.of(KeyVaultConfigConverter.convert(azureKeyVaultConfig)); } if (KeyVaultType.HASHICORP.equals(type) && hashicorpKeyVaultConfig != null) { return Optional.of(KeyVaultConfigConverter.convert(hashicorpKeyVaultConfig)); } if (keyVaultConfigs == null) { return Optional.empty(); } return keyVaultConfigs.stream().filter(c -> type.equals(c.getKeyVaultType())).findFirst(); } }
KeyConfiguration extends ConfigItem { public Optional<DefaultKeyVaultConfig> getKeyVaultConfig(KeyVaultType type) { if (type == null) { return Optional.empty(); } if (KeyVaultType.AZURE.equals(type) && azureKeyVaultConfig != null) { return Optional.of(KeyVaultConfigConverter.convert(azureKeyVaultConfig)); } if (KeyVaultType.HASHICORP.equals(type) && hashicorpKeyVaultConfig != null) { return Optional.of(KeyVaultConfigConverter.convert(hashicorpKeyVaultConfig)); } if (keyVaultConfigs == null) { return Optional.empty(); } return keyVaultConfigs.stream().filter(c -> type.equals(c.getKeyVaultType())).findFirst(); } KeyConfiguration(
            final Path passwordFile,
            final List<String> passwords,
            final List<KeyData> keyData,
            final AzureKeyVaultConfig azureKeyVaultConfig,
            final HashicorpKeyVaultConfig hashicorpKeyVaultConfig);  KeyConfiguration(); }
KeyConfiguration extends ConfigItem { public Optional<DefaultKeyVaultConfig> getKeyVaultConfig(KeyVaultType type) { if (type == null) { return Optional.empty(); } if (KeyVaultType.AZURE.equals(type) && azureKeyVaultConfig != null) { return Optional.of(KeyVaultConfigConverter.convert(azureKeyVaultConfig)); } if (KeyVaultType.HASHICORP.equals(type) && hashicorpKeyVaultConfig != null) { return Optional.of(KeyVaultConfigConverter.convert(hashicorpKeyVaultConfig)); } if (keyVaultConfigs == null) { return Optional.empty(); } return keyVaultConfigs.stream().filter(c -> type.equals(c.getKeyVaultType())).findFirst(); } KeyConfiguration(
            final Path passwordFile,
            final List<String> passwords,
            final List<KeyData> keyData,
            final AzureKeyVaultConfig azureKeyVaultConfig,
            final HashicorpKeyVaultConfig hashicorpKeyVaultConfig);  KeyConfiguration(); Path getPasswordFile(); List<String> getPasswords(); List<KeyData> getKeyData(); AzureKeyVaultConfig getAzureKeyVaultConfig(); HashicorpKeyVaultConfig getHashicorpKeyVaultConfig(); List<KeyVaultConfig> getKeyVaultConfigs(); Optional<DefaultKeyVaultConfig> getKeyVaultConfig(KeyVaultType type); void setPasswordFile(Path passwordFile); void setPasswords(List<String> passwords); void setKeyData(List<KeyData> keyData); void addKeyVaultConfig(KeyVaultConfig keyVaultConfig); }
KeyConfiguration extends ConfigItem { public Optional<DefaultKeyVaultConfig> getKeyVaultConfig(KeyVaultType type) { if (type == null) { return Optional.empty(); } if (KeyVaultType.AZURE.equals(type) && azureKeyVaultConfig != null) { return Optional.of(KeyVaultConfigConverter.convert(azureKeyVaultConfig)); } if (KeyVaultType.HASHICORP.equals(type) && hashicorpKeyVaultConfig != null) { return Optional.of(KeyVaultConfigConverter.convert(hashicorpKeyVaultConfig)); } if (keyVaultConfigs == null) { return Optional.empty(); } return keyVaultConfigs.stream().filter(c -> type.equals(c.getKeyVaultType())).findFirst(); } KeyConfiguration(
            final Path passwordFile,
            final List<String> passwords,
            final List<KeyData> keyData,
            final AzureKeyVaultConfig azureKeyVaultConfig,
            final HashicorpKeyVaultConfig hashicorpKeyVaultConfig);  KeyConfiguration(); Path getPasswordFile(); List<String> getPasswords(); List<KeyData> getKeyData(); AzureKeyVaultConfig getAzureKeyVaultConfig(); HashicorpKeyVaultConfig getHashicorpKeyVaultConfig(); List<KeyVaultConfig> getKeyVaultConfigs(); Optional<DefaultKeyVaultConfig> getKeyVaultConfig(KeyVaultType type); void setPasswordFile(Path passwordFile); void setPasswords(List<String> passwords); void setKeyData(List<KeyData> keyData); void addKeyVaultConfig(KeyVaultConfig keyVaultConfig); @Valid
    @NotNull
    @Size(min = 1, message = "At least 1 public/private key pair must be provided")
    private List<KeyData> keyData; }