From 52514db567933b3df89fa11043434d3b879ca316 Mon Sep 17 00:00:00 2001 From: Georg Hoelger Date: Wed, 18 Sep 2024 14:59:09 +0200 Subject: [PATCH] fix: disallow servers to read environmental data --- .../ambassador/simulation/AbstractSimulationUnit.java | 2 +- .../fed/application/ambassador/simulation/ServerUnit.java | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/AbstractSimulationUnit.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/AbstractSimulationUnit.java index 19802a3f3..ebfc34c30 100644 --- a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/AbstractSimulationUnit.java +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/AbstractSimulationUnit.java @@ -427,7 +427,7 @@ public final void cleanPastEnvironmentEvents() { } @Override - public final int getStateOfEnvironmentSensor(SensorType type) { + public int getStateOfEnvironmentSensor(SensorType type) { EnvironmentEvent event = environmentEvents.get(type); // If an event of this type in the map yet? if (event != null) { diff --git a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/ServerUnit.java b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/ServerUnit.java index 458bb4cc5..339f2cb76 100644 --- a/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/ServerUnit.java +++ b/fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/ServerUnit.java @@ -20,6 +20,7 @@ import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.IRoutingModule; import org.eclipse.mosaic.fed.application.ambassador.simulation.navigation.NavigationModule; import org.eclipse.mosaic.fed.application.app.api.os.ServerOperatingSystem; +import org.eclipse.mosaic.lib.enums.SensorType; import org.eclipse.mosaic.lib.objects.mapping.ServerMapping; import org.eclipse.mosaic.lib.util.scheduling.Event; @@ -53,10 +54,15 @@ public ServerUnit(String unitName) { } @Override - public CamBuilder assembleCamMessage(CamBuilder camBuilder) { + public final CamBuilder assembleCamMessage(CamBuilder camBuilder) { throw new UnsupportedOperationException("Servers can't send CAMs."); } + @Override + public final int getStateOfEnvironmentSensor(SensorType type) { + throw new UnsupportedOperationException("Servers can't access Environment functionality."); + } + @Override public IRoutingModule getRoutingModule() { return routingModule;