@Deprecated public void setEncryptedConfigurationValue(EncryptedConfigurationValue encryptedValue) { setEncryptedValue(encryptedValue); }
private void setEncryptedValue(String encryptedValue) { setEncryptedValue(new EncryptedConfigurationValue(encryptedValue)); }
@PostConstruct public void initialize() { if (configurationValue == null && encryptedValue == null) { configurationValue = new ConfigurationValue(""); } if (encryptedValue != null && isNotBlank(encryptedValue.getValue())) { setEncryptedValue(cipher.maybeReEncryptForPostConstructWithoutExceptions(encryptedValue.getValue())); } }
configuration.getProperty(key).setEncryptedValue(new EncryptedConfigurationValue(configurationMetadata.get("value"))); } else { configuration.getProperty(key).setConfigurationValue(new ConfigurationValue(configurationMetadata.get("value")));
public ConfigurationProperty deserialize(String name, String value, String encryptedValue) { setKey(new ConfigurationKey(name)); if (isNotBlank(value) && isNotBlank(encryptedValue)) { addError("value", "You may only specify `value` or `encrypted_value`, not both!"); addError(ENCRYPTED_VALUE, "You may only specify `value` or `encrypted_value`, not both!"); } if (isNotBlank(encryptedValue)) { setEncryptedValue(new EncryptedConfigurationValue(new GoCipher().maybeReEncryptForPostConstructWithoutExceptions(encryptedValue))); } if (isNotBlank(value)) { setConfigurationValue(new ConfigurationValue(value)); } return this; } }
configuration.getProperty(key).setEncryptedValue(new EncryptedConfigurationValue(configurationMetadata.get("value"))); } else { configuration.getProperty(key).setConfigurationValue(new ConfigurationValue(configurationMetadata.get("value")));
configurationProperty.setEncryptedValue(new EncryptedConfigurationValue(encryptedValue)); return configurationProperty; configurationProperty.setEncryptedValue(new EncryptedConfigurationValue(encryptedValue)); configurationProperty.setEncryptedValue(new EncryptedConfigurationValue(encrypt(value))); if (isNotBlank(encryptedValue)) { configurationProperty.addError("encryptedValue", "encrypted_value cannot be specified to a unsecured property."); configurationProperty.setEncryptedValue(new EncryptedConfigurationValue(encryptedValue)); configurationProperty.setEncryptedValue(new EncryptedConfigurationValue(new GoCipher().maybeReEncryptForPostConstructWithoutExceptions(configurationProperty.getEncryptedValue())));
@Test public void shouldReturnConfigWithMatadataAsMap() throws CryptoException { ConfigurationProperty configurationProperty1 = ConfigurationPropertyMother.create("key", false, "value"); String password = new GoCipher().encrypt("password"); ConfigurationProperty configurationProperty2 = ConfigurationPropertyMother.create("secure"); configurationProperty2.setEncryptedValue(new EncryptedConfigurationValue(password)); Configuration configuration = new Configuration(configurationProperty1, configurationProperty2); Map<String, Map<String, Object>> metadataAndValuesAsMap = configuration.getPropertyMetadataAndValuesAsMap(); HashMap<Object, Object> expectedMap = new HashMap<>(); HashMap<Object, Object> metadataMap1 = new HashMap<>(); metadataMap1.put("value", "value"); metadataMap1.put("displayValue", "value"); metadataMap1.put("isSecure", false); expectedMap.put("key", metadataMap1); HashMap<Object, Object> metadataMap2 = new HashMap<>(); metadataMap2.put("value", password); metadataMap2.put("displayValue", "****"); metadataMap2.put("isSecure", true); expectedMap.put("secure", metadataMap2); assertThat(metadataAndValuesAsMap, is(expectedMap)); } }