@Test public void shouldNotEncryptCommentedProperties() throws Exception { String commentedLines = "# admin.password = administrator password"; Path tempFile = Files.createTempFile("dataprep-PropertiesEncryptionTest.", ".properties"); try (BufferedWriter bufferedWriter = Files.newBufferedWriter(tempFile, Charsets.UTF_8)) { bufferedWriter.write("# file.password = the file password"); bufferedWriter.newLine(); bufferedWriter.write("file = /tmp"); bufferedWriter.newLine(); } new PropertiesEncryption().encryptAndSave(tempFile.toString(), Sets.newHashSet("file.password")); try (BufferedReader reader = Files.newBufferedReader(tempFile)) { String line = reader.readLine(); assertEquals("# file.password = the file password", line); line = reader.readLine(); assertEquals("file = /tmp", line); } }
public void encryptAndSave(String input, Set<String> mustBeEncrypted) { modifyAndSave(input, mustBeEncrypted, this::encryptIfNot); }
PropertiesEncryption { public void encryptAndSave(String input, Set<String> mustBeEncrypted) { modifyAndSave(input, mustBeEncrypted, this::encryptIfNot); } }
PropertiesEncryption { public void encryptAndSave(String input, Set<String> mustBeEncrypted) { modifyAndSave(input, mustBeEncrypted, this::encryptIfNot); }  }
PropertiesEncryption { public void encryptAndSave(String input, Set<String> mustBeEncrypted) { modifyAndSave(input, mustBeEncrypted, this::encryptIfNot); }  void encryptAndSave(String input, Set<String> mustBeEncrypted); void decryptAndSave(String input, Set<String> mustBeDecrypted); }
PropertiesEncryption { public void encryptAndSave(String input, Set<String> mustBeEncrypted) { modifyAndSave(input, mustBeEncrypted, this::encryptIfNot); }  void encryptAndSave(String input, Set<String> mustBeEncrypted); void decryptAndSave(String input, Set<String> mustBeDecrypted);  }