Skip to content

Commit

Permalink
feat: allowing maliciously behaving node providing service incorrectly
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanCapistrano committed Mar 15, 2024
1 parent 0237372 commit 6923f87
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions src/main/java/reputation/node/models/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,28 @@ private void publishNodeServices(String serviceType, String target) {
this.mutex.unlock();
}

for (Device d : tempDevices) {
d
.getSensors()
.stream()
.filter(s -> s.getType().equals(serviceType))
.forEach(s ->
deviceSensorIdList.add(new DeviceSensorId(d.getId(), s.getId()))
);
/* Se o nó estiver com o comportamento malicioso, irá oferecer um
dispositivo e sensor inexistente. */
if (
this.getNodeType()
.getNode()
.getConductType()
.toString()
.equals("MALICIOUS")
) {
deviceSensorIdList.add(
new DeviceSensorId("nonexistentDevice", "nonexistentSensor")
);
} else {
for (Device d : tempDevices) {
d
.getSensors()
.stream()
.filter(s -> s.getType().equals(serviceType))
.forEach(s ->
deviceSensorIdList.add(new DeviceSensorId(d.getId(), s.getId()))
);
}
}

if (
Expand Down

0 comments on commit 6923f87

Please sign in to comment.