EncryptedConfiguration extends PropertiesFileConfiguration { protected String readPassphrase(String passphraseProperty) throws ConfigurationException { if (!containsKey(passphraseProperty)) { log.info("No secret file provided."); return null; } String secretFile = getString(passphraseProperty); if (StringUtils.isEmpty(secretFile)) { log.warn("{} is present in the configuration but unset", passphraseProperty); return null; } log.debug("reading secret file: {}", secretFile); try (InputStream bs = new FileInputStream(secretFile)) { return IOUtils.toString(bs, Charset.defaultCharset().name()); } catch (Exception e) { String msg = String.format("Could not read: %s", secretFile); log.error(msg); throw new ConfigurationException(msg, e); } } EncryptedConfiguration();  EncryptedConfiguration(String fileName);  EncryptedConfiguration(String fileName, Charset encoding);  EncryptedConfiguration(File file);  EncryptedConfiguration(File file, Charset encoding);  EncryptedConfiguration(InputStream inStream);  EncryptedConfiguration(InputStream inStream, Charset encoding);  EncryptedConfiguration(Properties properties); EncryptedConfiguration use(String passphraseProperty); void toDecrypt(String... encryptedProperties); void toDecrypt(String property);  }
@Test public void testUnusualPassword(@TempDir Path temp) throws Exception { File passphraseFile = temp.resolve("passphrase.txt").toFile(); Writer w = new FileWriter(passphraseFile); String expected = "Hello\nWorld\n"; w.write(expected); w.close(); props.setProperty("passphrase_file", passphraseFile.getAbsolutePath()); EncryptedConfiguration c = new EncryptedConfiguration(props); assertEquals(expected, c.readPassphrase("passphrase_file")); }