-
Notifications
You must be signed in to change notification settings - Fork 0
/
LeakageDetector.java
33 lines (26 loc) · 1.1 KB
/
LeakageDetector.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.util.Map;
public class LeakageDetector {
private DataStorage dataStorage;
public LeakageDetector(DataStorage dataStorage) {
this.dataStorage = dataStorage;
}
public void detectLeakage(String leakedData, String alteration) {
boolean leakDetected = false;
for (Map.Entry<Agent, Map<String, String>> entry : dataStorage.getStorage().entrySet()) {
Agent agent = entry.getKey();
Map<String, String> agentData = entry.getValue();
for (Map.Entry<String, String> dataEntry : agentData.entrySet()) {
String allocatedData = dataEntry.getKey();
String allocatedAlteration = dataEntry.getValue();
if (leakedData.equals(allocatedData) && alteration.equals(allocatedAlteration)) {
System.out.println("Data leaked from Agent: " + agent.getAgentId());
leakDetected = true;
break;
}
}
}
if (!leakDetected) {
System.out.println("Source of leaked data not found.");
}
}
}