From 8408c85d2f07a6c492929173541e9fe968968c6a Mon Sep 17 00:00:00 2001 From: zanninso Date: Thu, 18 Jul 2024 20:53:56 +0100 Subject: [PATCH] docs: adding more details --- subjects/java/checkpoints/config-protector/README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/subjects/java/checkpoints/config-protector/README.md b/subjects/java/checkpoints/config-protector/README.md index baa7389ec..69937698a 100644 --- a/subjects/java/checkpoints/config-protector/README.md +++ b/subjects/java/checkpoints/config-protector/README.md @@ -4,10 +4,19 @@ Create a class `ConfigProtector` that provides a method to hide sensitive data in a configuration file using `Regex`. The method should replace sensitive values with asterisks. The configuration file will be provided as a string, and the keys for the sensitive data will be given in a list. +The config file format will always be as follows: +``` +username=admin +npassword=secret +... +``` + ### Expected Class ```java import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class ConfigProtector { public String hideSensitiveData(String configFile, List sensitiveKeys) { @@ -29,7 +38,7 @@ public class ExerciseRunner { ConfigProtector protector = new ConfigProtector(); // Test case 1 - String configFile1 = "username=admin\npassword=secret\nhost=localhost\n"; + String configFile1 = "username=admin\n=localhost\n"; List sensitiveKeys1 = Arrays.asList("password"); System.out.println("Protected Config 1:\n" + protector.hideSensitiveData(configFile1, sensitiveKeys1));