diff options
author | ToineSiebelink <toine.siebelink@est.tech> | 2024-07-10 09:24:22 +0100 |
---|---|---|
committer | ToineSiebelink <toine.siebelink@est.tech> | 2024-07-10 10:04:04 +0100 |
commit | 4962922401c1c779c6b7d1161a995942750566ed (patch) | |
tree | e5f36152a6d3382246a5b22c9eb693c0e4280a03 /policy-executor-stub/src/main | |
parent | 8f3103dd1eaf5d537cd085dd8fab5ef39d7d914d (diff) |
Policy Executor API, make Authorization header optional
Issue-ID: CPS-22291
Change-Id: I2b8f9b97c92dfc640c8b40b7053c609bbdcb2f6e
Signed-off-by: ToineSiebelink <toine.siebelink@est.tech>
Diffstat (limited to 'policy-executor-stub/src/main')
-rw-r--r-- | policy-executor-stub/src/main/java/org/onap/cps/policyexecutor/stub/controller/PolicyExecutorStubController.java | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/policy-executor-stub/src/main/java/org/onap/cps/policyexecutor/stub/controller/PolicyExecutorStubController.java b/policy-executor-stub/src/main/java/org/onap/cps/policyexecutor/stub/controller/PolicyExecutorStubController.java index 7989c3fc8c..a5ec6dcac9 100644 --- a/policy-executor-stub/src/main/java/org/onap/cps/policyexecutor/stub/controller/PolicyExecutorStubController.java +++ b/policy-executor-stub/src/main/java/org/onap/cps/policyexecutor/stub/controller/PolicyExecutorStubController.java @@ -41,9 +41,9 @@ public class PolicyExecutorStubController implements PolicyExecutorApi { @Override public ResponseEntity<PolicyExecutionResponse> executePolicyAction( - final String authorization, final String action, - final PolicyExecutionRequest policyExecutionRequest) { + final PolicyExecutionRequest policyExecutionRequest, + final String authorization) { if (policyExecutionRequest.getPayload().isEmpty()) { return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } @@ -56,15 +56,19 @@ public class PolicyExecutorStubController implements PolicyExecutorApi { return new ResponseEntity<>(HttpStatusCode.valueOf(errorCode)); } - final PolicyExecutionResponse policyExecutionResponse = new PolicyExecutionResponse(); - policyExecutionResponse.setDecisionId(String.valueOf(++decisionCounter)); + final String decisionId = String.valueOf(++decisionCounter); + final String decision; + final String message; if (firstTargetFdn.toLowerCase(Locale.getDefault()).contains("cps-is-great")) { - policyExecutionResponse.setDecision("permit"); + decision = "permit"; + message = "All good"; } else { - policyExecutionResponse.setDecision("deny"); - policyExecutionResponse.setMessage("Only FDNs containing 'cps-is-great' are permitted"); + decision = "deny"; + message = "Only FDNs containing 'cps-is-great' are permitted"; } + final PolicyExecutionResponse policyExecutionResponse = + new PolicyExecutionResponse(decisionId, decision, message); return ResponseEntity.ok(policyExecutionResponse); } } |