Skip to content

Commit

Permalink
fix command response filtering for non query commands
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Jaeckle <thomas.jaeckle@bosch.io>
  • Loading branch information
thjaeckle committed May 4, 2022
1 parent 288deb6 commit 84d4148
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
Expand Up @@ -57,7 +57,7 @@ public CompletionStage<ConnectivityCommand<?>> authorizeSignalWithMissingEnforce
}

@Override
public boolean shouldFilterCommandResponses() {
public boolean shouldFilterCommandResponse(final ConnectivityCommandResponse<?> commandResponse) {
return false;
}

Expand Down
Expand Up @@ -351,7 +351,7 @@ private void filterResponse(final R commandResponse) {
final ActorRef sender = getSender();
final ActorRef parent = getContext().getParent();

if (enforcement.shouldFilterCommandResponses()) {
if (enforcement.shouldFilterCommandResponse(commandResponse)) {
if (null != policyEnforcer) {
try {
final CompletionStage<R> filteredResponseStage =
Expand Down
Expand Up @@ -46,9 +46,10 @@ public interface EnforcementReloaded<S extends Signal<?>, R extends CommandRespo

/**
* TODO TJ doc
* @param commandResponse
* @return
*/
boolean shouldFilterCommandResponses();
boolean shouldFilterCommandResponse(R commandResponse);

/**
* Filters the given {@code commandResponse} by using the given {@code enforcer}.
Expand Down
Expand Up @@ -137,8 +137,8 @@ public CompletionStage<PolicyCommand<?>> authorizeSignalWithMissingEnforcer(fina
}

@Override
public boolean shouldFilterCommandResponses() {
return true;
public boolean shouldFilterCommandResponse(final PolicyCommandResponse<?> commandResponse) {
return commandResponse instanceof PolicyQueryCommandResponse<?>;
}

@Override
Expand Down
Expand Up @@ -265,9 +265,10 @@ public CompletionStage<ThingCommand<?>> authorizeSignalWithMissingEnforcer(final
}

@Override
public boolean shouldFilterCommandResponses() {
return true;
public boolean shouldFilterCommandResponse(final ThingCommandResponse<?> commandResponse) {
return commandResponse instanceof ThingQueryCommandResponse<?>;
}

@Override
public CompletionStage<ThingCommandResponse<?>> filterResponse(final ThingCommandResponse<?> commandResponse,
final PolicyEnforcer policyEnforcer) {
Expand Down
4 changes: 3 additions & 1 deletion things/service/src/test/resources/test.conf
Expand Up @@ -73,7 +73,9 @@ akka {
"things",
"thing-event-aware",
"live-signal-aware",
"acks-aware"
"acks-aware",
"ddata-aware",
"blocked-namespaces-aware"
]
}

Expand Down

0 comments on commit 84d4148

Please sign in to comment.