summaryrefslogtreecommitdiffstats
path: root/applications/native/src/main
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2020-03-16 11:09:36 -0400
committerPamela Dragosh <pdragosh@research.att.com>2020-03-16 11:24:19 -0400
commit6b4f9b69bc4acec28da8ef50b8f234d0182f0d78 (patch)
tree877cc134b10d08393f0868a7dae7d5f604e49a5b /applications/native/src/main
parentec20e47d350e16e1bf52f0396b777063b23770c7 (diff)
Missing support for PolicySetType
Adds support for PolicySetType specifically for Native policies. When/If the other applications change to support they can easily do so. Adding some more code coverage for Native application and translator. Issue-ID: POLICY-2433 Change-Id: I463ca9f04928d759624a2176598b463057d386bd Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'applications/native/src/main')
-rw-r--r--applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTranslator.java17
1 files changed, 9 insertions, 8 deletions
diff --git a/applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTranslator.java b/applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTranslator.java
index 546c29eb..5ce25fac 100644
--- a/applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTranslator.java
+++ b/applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTranslator.java
@@ -27,11 +27,9 @@ import com.att.research.xacml.api.Response;
import com.att.research.xacml.util.XACMLPolicyScanner;
import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Map;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.models.decisions.concepts.DecisionResponse;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
@@ -56,7 +54,7 @@ public class NativePdpApplicationTranslator implements ToscaPolicyTranslator {
}
@Override
- public PolicyType convertPolicy(ToscaPolicy toscaPolicy) throws ToscaPolicyConversionException {
+ public Object convertPolicy(ToscaPolicy toscaPolicy) throws ToscaPolicyConversionException {
//
// Extract the Base64 encoded policy xml string and decode it
//
@@ -67,16 +65,19 @@ public class NativePdpApplicationTranslator implements ToscaPolicyTranslator {
} catch (IllegalArgumentException exc) {
throw new ToscaPolicyConversionException("error on Base64 decoding the native policy", exc);
}
- LOGGER.debug("Decoded xacml policy {}",decodedXacmlPolicy);
+ LOGGER.debug("Decoded xacml policy {}", decodedXacmlPolicy);
//
// Scan the string and convert to xacml PolicyType
//
- try (InputStream is = new ByteArrayInputStream(decodedXacmlPolicy.getBytes(StandardCharsets.UTF_8))) {
+ try (ByteArrayInputStream is = new ByteArrayInputStream(decodedXacmlPolicy.getBytes(StandardCharsets.UTF_8))) {
//
- // Here we assume it is PolicyType, not PolicySetType
- // PolicySetType will be addressed later
+ // Read the Policy In
//
- return (PolicyType) XACMLPolicyScanner.readPolicy(is);
+ Object policy = XACMLPolicyScanner.readPolicy(is);
+ if (policy == null) {
+ throw new ToscaPolicyConversionException("Invalid XACML Policy");
+ }
+ return policy;
} catch (IOException exc) {
throw new ToscaPolicyConversionException("Failed to read policy", exc);
}