SensitiveDataObfuscator { public static String hashSensitiveData(String key, String value, List<String> expandedSensitiveData) { if ((sensitiveData != null && sensitiveData.contains(key)) || (expandedSensitiveData != null && expandedSensitiveData.contains(key)) && !CommonUtil.isBlank(value)) { return parseStrToSHA256(value); } else { return value; } }  static List<String> getSensitiveDataFromFile(); static String hashSensitiveDataHierarchically(String key, String value, List<String> expandedSensitiveData); static String hashSensitiveData(String key, String value, List<String> expandedSensitiveData); static String parseStrToSHA256(String str);  }
@Test(groups = { "SensitiveDataObfuscatorTest" }) public void testHashSensitiveData() { String value = SensitiveDataObfuscator.hashSensitiveData( CollectionConstants.OPERATION_NAME, CollectionConstants.METHOD_CONFIG_CLUSTER, null); assertEquals(value, CollectionConstants.METHOD_CONFIG_CLUSTER); value = SensitiveDataObfuscator.hashSensitiveData( "password","1234567abc", null); assertEquals(SensitiveDataObfuscator.getSensitiveDataFromFile().size(), 55); assertEquals(value, "4D74CDB3F355C750B8FE2E4C86CC062F41CA1C7373A8CD19D2C7C2D6974C3002"); }