summaryrefslogtreecommitdiffstats
path: root/ONAP-XACML
diff options
context:
space:
mode:
authorrb7147 <rb7147@att.com>2018-09-04 14:16:04 -0400
committerrb7147 <rb7147@att.com>2018-09-05 13:24:05 -0400
commit7fd58e9a2427a215daa6b543e901534e83d3c246 (patch)
tree196e418bee0cb53ae3af913fe9fbc93e4e9dd719 /ONAP-XACML
parent2cb76b3efe8ca385da3bc5f5afc5b26a52c6fd43 (diff)
XACML Platform Enhancements
To Support Raw Policy Creation from GUI and API. GetDecision on combining algorithim with Policy Set. Issue-ID: POLICY-902 Change-Id: Ie3189f8ded2e03366bc7d65d15b95b88c89b0acd Signed-off-by: rb7147 <rb7147@att.com>
Diffstat (limited to 'ONAP-XACML')
-rw-r--r--ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicy.java12
-rw-r--r--ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicyParams.java32
-rw-r--r--ONAP-XACML/src/main/java/org/onap/policy/xacml/util/XACMLPolicyWriter.java25
3 files changed, 40 insertions, 29 deletions
diff --git a/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicy.java b/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicy.java
index 185175907..2f752a0aa 100644
--- a/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicy.java
+++ b/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicy.java
@@ -81,7 +81,7 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable {
private String guard = null;
private String riskLevel;
private String ttlDate = null;
-
+ private String rawXacmlPolicy = null;
public StdPAPPolicy() {
//
@@ -155,7 +155,7 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable {
this.dictionaryType = stdPAPPolicyParams.getDictionaryType();
this.dictionary = stdPAPPolicyParams.getDictionary();
this.dictionaryFields = stdPAPPolicyParams.getDictionaryFields();
-
+ this.rawXacmlPolicy = stdPAPPolicyParams.getRawXacmlPolicy();
}
@Override
@@ -638,4 +638,12 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable {
public void setTreatments(Map<String, String> treatments) {
this.treatments = treatments;
}
+
+ public String getRawXacmlPolicy() {
+ return rawXacmlPolicy;
+ }
+
+ public void setRawXacmlPolicy(String rawXacmlPolicy) {
+ this.rawXacmlPolicy = rawXacmlPolicy;
+ }
}
diff --git a/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicyParams.java b/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicyParams.java
index 780decd88..1780dfc96 100644
--- a/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicyParams.java
+++ b/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicyParams.java
@@ -3,6 +3,7 @@
* ONAP-XACML
* ================================================================================
* Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Modifications Copyright (C) 2018 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -71,6 +72,7 @@ public class StdPAPPolicyParams {
private String dictionaryType;
private String dictionary;
private String dictionaryFields;
+ private String rawXacmlPolicy = null;
/**
@@ -236,18 +238,10 @@ public class StdPAPPolicyParams {
return uuid;
}
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
-
public String getMsLocation() {
return msLocation;
}
- public void setMsLocation(String msLocation) {
- this.msLocation = msLocation;
- }
-
public String getPriority() {
return priority;
}
@@ -260,34 +254,21 @@ public class StdPAPPolicyParams {
return deleteCondition;
}
- public void setDeleteCondition(String deleteCondition) {
- this.deleteCondition = deleteCondition;
- }
-
public String getDictionaryType() {
return dictionaryType;
}
- public void setDictionaryType(String dictionaryType) {
- this.dictionaryType = dictionaryType;
- }
-
public String getDictionary() {
return dictionary;
}
- public void setDictionary(String dictionary) {
- this.dictionary = dictionary;
- }
-
public String getDictionaryFields() {
return dictionaryFields;
}
- public void setDictionaryFields(String dictionaryFields) {
- this.dictionaryFields = dictionaryFields;
+ public String getRawXacmlPolicy() {
+ return rawXacmlPolicy;
}
-
/**
* Builder class for the Policy parameters
*/
@@ -518,5 +499,10 @@ public class StdPAPPolicyParams {
m.dictionaryFields = dictionaryFields;
return this;
}
+
+ public StdPAPPolicyParamsBuilder rawXacmlPolicy(String rawXacmlPolicy) {
+ m.rawXacmlPolicy = rawXacmlPolicy;
+ return this;
+ }
}
}
diff --git a/ONAP-XACML/src/main/java/org/onap/policy/xacml/util/XACMLPolicyWriter.java b/ONAP-XACML/src/main/java/org/onap/policy/xacml/util/XACMLPolicyWriter.java
index 928165909..e1d0223f6 100644
--- a/ONAP-XACML/src/main/java/org/onap/policy/xacml/util/XACMLPolicyWriter.java
+++ b/ONAP-XACML/src/main/java/org/onap/policy/xacml/util/XACMLPolicyWriter.java
@@ -137,11 +137,28 @@ public class XACMLPolicyWriter {
*
*
*/
- public static InputStream getXmlAsInputStream(PolicyType policy) {
- JAXBElement<PolicyType> policyElement = new ObjectFactory().createPolicy(policy);
+ public static InputStream getXmlAsInputStream(Object policy) {
+ JAXBElement<?> policyElement;
+ if (policy instanceof PolicyType) {
+ policyElement = new ObjectFactory().createPolicy((PolicyType) policy);
+ return getByteArrayInputStream(policyElement, PolicyType.class);
+ } else if (policy instanceof PolicyType) {
+ policyElement = new ObjectFactory().createPolicySet((PolicySetType) policy);
+ return getByteArrayInputStream(policyElement, PolicySetType.class);
+ }
+ return null;
+ }
+
+ /**
+ * Helper static class that reads the JAXB element and return policy input stream.
+ * @param policyElement
+ * @param className (PolicyType or PolicySetType ?).
+ * @return ByteArrayInputStream.
+ */
+ public static InputStream getByteArrayInputStream(JAXBElement<?> policyElement, Class<?> className) {
try {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- JAXBContext context = JAXBContext.newInstance(PolicyType.class);
+ JAXBContext context = JAXBContext.newInstance(className);
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
m.marshal(policyElement, byteArrayOutputStream);
@@ -149,7 +166,7 @@ public class XACMLPolicyWriter {
} catch (JAXBException e) {
PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "XACMLPolicyWriter", "writePolicyFile failed");
throw new IllegalArgumentException("XACMLPolicyWriter writePolicyFile failed", e);
- }
+ }
}
/**
* Helper static class that does the work to write a policy set to an output stream.