@Test public void unencryptedPropertyShouldDoNothing() { String notSecretKey = "testNotSoSecret"; Object returnedValue = secretAwarePropertySource.getProperty(notSecretKey); verify(secretManager, never()).decrypt(any()); verify(secretManager, never()).decryptAsFile(any()); assertEquals(testValues.get(notSecretKey), returnedValue); }
@Override public Object getProperty(String name) { Object o = source.getProperty(name); if (o instanceof String && EncryptedSecret.isEncryptedSecret((String) o)) { String propertyValue = (String) o; if (secretManager == null) { throw new SecretException("No secret manager to decrypt value of " + name); } String lName = name.toLowerCase(); if (isSamlFile(lName)) { return "file:" + secretManager.decryptAsFile(propertyValue).toString(); } else if (isFile(lName) || EncryptedSecret.isEncryptedFile(propertyValue)) { return secretManager.decryptAsFile(propertyValue).toString(); } else { return secretManager.decrypt(propertyValue); } } return o; }
SecretAwarePropertySource extends EnumerablePropertySource<EnumerablePropertySource> { @Override public Object getProperty(String name) { Object o = source.getProperty(name); if (o instanceof String && EncryptedSecret.isEncryptedSecret((String) o)) { String propertyValue = (String) o; if (secretManager == null) { throw new SecretException("No secret manager to decrypt value of " + name); } String lName = name.toLowerCase(); if (isSamlFile(lName)) { return "file:" + secretManager.decryptAsFile(propertyValue).toString(); } else if (isFile(lName) || EncryptedSecret.isEncryptedFile(propertyValue)) { return secretManager.decryptAsFile(propertyValue).toString(); } else { return secretManager.decrypt(propertyValue); } } return o; } }
SecretAwarePropertySource extends EnumerablePropertySource<EnumerablePropertySource> { @Override public Object getProperty(String name) { Object o = source.getProperty(name); if (o instanceof String && EncryptedSecret.isEncryptedSecret((String) o)) { String propertyValue = (String) o; if (secretManager == null) { throw new SecretException("No secret manager to decrypt value of " + name); } String lName = name.toLowerCase(); if (isSamlFile(lName)) { return "file:" + secretManager.decryptAsFile(propertyValue).toString(); } else if (isFile(lName) || EncryptedSecret.isEncryptedFile(propertyValue)) { return secretManager.decryptAsFile(propertyValue).toString(); } else { return secretManager.decrypt(propertyValue); } } return o; } SecretAwarePropertySource(EnumerablePropertySource source, SecretManager secretManager); }
SecretAwarePropertySource extends EnumerablePropertySource<EnumerablePropertySource> { @Override public Object getProperty(String name) { Object o = source.getProperty(name); if (o instanceof String && EncryptedSecret.isEncryptedSecret((String) o)) { String propertyValue = (String) o; if (secretManager == null) { throw new SecretException("No secret manager to decrypt value of " + name); } String lName = name.toLowerCase(); if (isSamlFile(lName)) { return "file:" + secretManager.decryptAsFile(propertyValue).toString(); } else if (isFile(lName) || EncryptedSecret.isEncryptedFile(propertyValue)) { return secretManager.decryptAsFile(propertyValue).toString(); } else { return secretManager.decrypt(propertyValue); } } return o; } SecretAwarePropertySource(EnumerablePropertySource source, SecretManager secretManager); @Override Object getProperty(String name); @Override String[] getPropertyNames(); }
SecretAwarePropertySource extends EnumerablePropertySource<EnumerablePropertySource> { @Override public Object getProperty(String name) { Object o = source.getProperty(name); if (o instanceof String && EncryptedSecret.isEncryptedSecret((String) o)) { String propertyValue = (String) o; if (secretManager == null) { throw new SecretException("No secret manager to decrypt value of " + name); } String lName = name.toLowerCase(); if (isSamlFile(lName)) { return "file:" + secretManager.decryptAsFile(propertyValue).toString(); } else if (isFile(lName) || EncryptedSecret.isEncryptedFile(propertyValue)) { return secretManager.decryptAsFile(propertyValue).toString(); } else { return secretManager.decrypt(propertyValue); } } return o; } SecretAwarePropertySource(EnumerablePropertySource source, SecretManager secretManager); @Override Object getProperty(String name); @Override String[] getPropertyNames();  }