summaryrefslogtreecommitdiffstats
path: root/PolicyEngineAPI/src/main/java
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2017-02-14 19:41:00 -0500
committerPamela Dragosh <pdragosh@research.att.com>2017-02-14 19:41:32 -0500
commit91d04c64771832a0b8815ffbe1f0f9920320d94d (patch)
treefb02d5e1c84a3d91def9a7ee95bc87f9c046cc96 /PolicyEngineAPI/src/main/java
parentb9d4caa40ef8e3566ac475968bce17b9b64b6939 (diff)
Initial OpenECOMP policy/engine commit
Change-Id: I7dbff37733b661643dd4d1caefa3d7dccc361b6e Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'PolicyEngineAPI/src/main/java')
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/AttributeType.java66
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/ConfigRequestParameters.java148
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DecisionRequestParameters.java104
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DecisionResponse.java43
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DeletePolicyCondition.java53
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DeletePolicyParameters.java101
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DictionaryParameters.java83
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DictionaryType.java73
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/EventRequestParameters.java89
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/ImportParameters.java194
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/NotificationScheme.java61
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyChangeResponse.java44
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyClass.java56
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfig.java123
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigException.java49
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigStatus.java68
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigType.java73
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyDecision.java57
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyDecisionException.java50
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEngine.java575
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEngineException.java49
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEventException.java49
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyParameters.java497
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyResponse.java77
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyResponseStatus.java73
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyType.java61
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PushPolicyParameters.java131
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/RuleProvider.java53
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/api/package-info.java36
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientEnd.java244
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientUEB.java170
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEnd.java138
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndUEB.java173
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/MatchStore.java246
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/Matches.java48
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/NotificationUnMarshal.java69
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdDecisionResponse.java55
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyChangeResponse.java47
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyConfig.java168
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyEngine.java4227
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyResponse.java98
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdStatus.java235
-rw-r--r--PolicyEngineAPI/src/main/java/org/openecomp/policy/std/package-info.java27
43 files changed, 9081 insertions, 0 deletions
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/AttributeType.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/AttributeType.java
new file mode 100644
index 000000000..2a887919b
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/AttributeType.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+/**
+ * Enumeration of the Attribute Types that is used as a part of
+ * {@link org.openecomp.policy.api.PolicyParameters}.
+ *
+ * @version 0.1
+ */
+public enum AttributeType {
+ /**
+ * Indicates Attributes required to Match the Policy.
+ */
+ MATCHING("matching"),
+ /**
+ * Indicates Attributes required to create DRL based Rules.
+ */
+ RULE("rule"),
+ /**
+ * Indicates Attributes required to create MicroService policy.
+ */
+ MICROSERVICE("microService"),
+ /**
+ * Indicates Attributes required to create settings for Decision Policy.
+ */
+ SETTINGS("settings"),
+ /**
+ * Indicates Attributes required to create dictionary fields for creating Dictionary Items
+ */
+ DICTIONARY("dictionary")
+ ;
+
+
+ private String name;
+
+ private AttributeType(String typeName){
+ this.name = typeName;
+ }
+
+ /**
+ * Returns the <code>String</code> format of Type for this <code>AttributeType</code>
+ * @return the <code>String</code> of the Type for this <code>AttributeType</code>
+ */
+ public String toString() {
+ return this.name;
+ }
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/ConfigRequestParameters.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/ConfigRequestParameters.java
new file mode 100644
index 000000000..1830679e0
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/ConfigRequestParameters.java
@@ -0,0 +1,148 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * <code>ConfigRequestParameters</code> defines the Config Policy Request Parameters
+ * which retrieve(s) the policy from PDP if the request parameters match with any Config Policy.
+ *
+ * @version 0.1
+ */
+public class ConfigRequestParameters {
+ private String policyName;
+ private String eCOMPComponentName;
+ private String configName;
+ private Map<String,String> configAttributes;
+ private UUID requestID;
+ private Boolean unique = false;
+
+ /**
+ * Sets the PolicyName of the Config policy which needs to be retrieved.
+ *
+ * @param policyName the <code>String</code> format of the PolicyFile Name whose configuration is required.
+ */
+ public void setPolicyName(String policyName){
+ this.policyName = policyName;
+ }
+
+ /**
+ * Sets the ECOMP Component Name of the Config policy which needs to be retrieved.
+ *
+ * @param eCOMPComponentName the <code>String</code> format of the eCOMPComponentName whose configuration is required.
+ */
+ public void setEcompName(String eCOMPComponentName){
+ this.eCOMPComponentName = eCOMPComponentName;
+ }
+
+ /**
+ * Sets the Config Name of the Config policy which needs to be retrieved.
+ *
+ * @param configName the <code>String</code> format of the configurationName whose configuration is required.
+ */
+ public void setConfigName(String configName){
+ this.configName = configName;
+ }
+
+ /**
+ * Sets the ConfigAttributes of the Config policy which needs to be retrieved.
+ *
+ * @param configAttributes the <code>Map</code> of <code>String,String</code> format of the configuration attributes which are required.
+ */
+ public void setConfigAttributes(Map<String, String> configAttributes){
+ this.configAttributes = configAttributes;
+ }
+
+ /**
+ * Sets the Request ID of the ECOMP request.
+ *
+ * @param requestID unique <code>UUID</code> requestID which will be passed throughout the ECOMP components to correlate logging messages.
+ */
+ public void setRequestID(UUID requestID){
+ this.requestID = requestID;
+ }
+
+ /**
+ * Gets the policyName of the Request Parameters.
+ *
+ * @return <code>String</code> format of the policyName.
+ */
+ public String getPolicyName(){
+ return policyName;
+ }
+
+ /**
+ * Gets the ECOMP Component Name of the Request Parameters.
+ *
+ * @return <code>String</code> format of the ECOMP Component Name.
+ */
+ public String getEcompName(){
+ return eCOMPComponentName;
+ }
+
+ /**
+ * Gets the Config name of the Request Parameters.
+ *
+ * @return <code>String</code> format of the Config Name.
+ */
+ public String getConfigName(){
+ return configName;
+ }
+
+ /**
+ * Gets the Config Attributes of the Request Parameters.
+ *
+ * @return <code>Map</code> of <code>String</code>,<code>String</code> format of the config Attributes.
+ */
+ public Map<String,String> getConfigAttributes(){
+ return configAttributes;
+ }
+
+ /**
+ * Gets the Request ID of the Request Paramters.
+ *
+ * @return <code>UUID</code> format of requestID.
+ */
+ public UUID getRequestID(){
+ return requestID;
+ }
+
+ /**
+ * Makes the results Unique, priority based. If set to True. Default Value is set to False.
+ *
+ * @param unique flag which is either true or false.
+ */
+ public void makeUnique(Boolean unique){
+ this.unique = unique;
+ }
+
+ /**
+ * Gets the Unique flag value from the Config Request Parameters.
+ *
+ * @return unique flag which is either true or false.
+ */
+ public Boolean getUnique(){
+ return this.unique;
+ }
+
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DecisionRequestParameters.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DecisionRequestParameters.java
new file mode 100644
index 000000000..dc485f7b3
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DecisionRequestParameters.java
@@ -0,0 +1,104 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * <code>DecisionRequestParameters</code> defines the Decision Policy Request Parameters
+ * which retrieve(s) the response from PDP if the request parameters match with any Decision Policy.
+ *
+ * @version 0.1
+ */
+public class DecisionRequestParameters {
+ private String eCOMPComponentName;
+ private Map<String,String> decisionAttributes;
+ private UUID requestID;
+
+ /**
+ * Constructor with no Parameters
+ */
+ public DecisionRequestParameters(){
+ }
+
+ /**
+ * Constructor with Parameters
+ *
+ * @param eCOMPComponentName the <code>String</code> format of the eCOMPComponentName whose Decision is required.
+ * @param decisionAttributes the <code>Map</code> of <code>String,String</code> format of the decisionAttributes that contain the ID and values.
+ * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ */
+ public DecisionRequestParameters(String eCOMPComponentName, Map<String,String> decisionAttributes, UUID requestID){
+ this.eCOMPComponentName = eCOMPComponentName;
+ this.decisionAttributes = decisionAttributes;
+ this.requestID = requestID;
+ }
+
+ /**
+ * Gets the ECOMPComponentName of the Decision Request Parameters.
+ *
+ * @return ECOMPComponentName the <code>String</code> format of the eCOMPComponentName of the Decision Request Parameters.
+ */
+ public String getECOMPComponentName() {
+ return eCOMPComponentName;
+ }
+ /**
+ * Sets the ECOMPComponentName of the Decision Request parameters.
+ *
+ * @param eCOMPComponentName the <code>String</code> format of the eCOMPComponentName whose Decision is required.
+ */
+ public void setECOMPComponentName(String eCOMPComponentName) {
+ this.eCOMPComponentName = eCOMPComponentName;
+ }
+ /**
+ * Gets the Decision Attributes from Decision Request Parameters.
+ *
+ * @return decisionAttributes the <code>Map</code> of <code>String,String</code> format of the decisionAttributes that contain the ID and values.
+ */
+ public Map<String,String> getDecisionAttributes() {
+ return decisionAttributes;
+ }
+ /**
+ * Sets the Decision Attributes which contain ID and values for obtaining Decision from PDP.
+ *
+ * @param decisionAttributes the <code>Map</code> of <code>String,String</code> format of the decisionAttributes that must contain the ID and values.
+ */
+ public void setDecisionAttributes(Map<String,String> decisionAttributes) {
+ this.decisionAttributes = decisionAttributes;
+ }
+ /**
+ * Gets the request ID of Decision Request Parameters.
+ *
+ * @return the requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ */
+ public UUID getRequestID() {
+ return requestID;
+ }
+ /**
+ * Sets the ReqestID of Decision Request Parameters which will be passed around ECOMP requests.
+ *
+ * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ */
+ public void setRequestID(UUID requestID) {
+ this.requestID = requestID;
+ }
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DecisionResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DecisionResponse.java
new file mode 100644
index 000000000..caa9fda74
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DecisionResponse.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+/**
+ * Defines the Object that represents the Policy Decision Response elements.
+ * DecisionResponse communicates the decision and details
+ *
+ * @version 0.1
+ */
+public interface DecisionResponse {
+ /**
+ * Gets the Decision of the Policy, Either a Permit or Deny.
+ *
+ * @return {@link org.openecomp.policy.api.PolicyDecision} Enumeration.
+ */
+ public PolicyDecision getDecision();
+
+ /**
+ * Gets the details of the result. Would be required in case of Deny.
+ *
+ * @return <code>String</code> format of the details of Deny cause.
+ */
+ public String getDetails();
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DeletePolicyCondition.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DeletePolicyCondition.java
new file mode 100644
index 000000000..3440c99aa
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DeletePolicyCondition.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+/**
+ * Enumeration of the Policy Delete Condition that is used as a part of
+ * {@link org.openecomp.policy.api.DeletePolicyParameters}.
+ *
+ * @version 0.1
+ */
+public enum DeletePolicyCondition {
+
+ /**
+ * Indicates a condition to only delete the current version of the policy.
+ */
+ ONE("Current Version"),
+
+ /**
+ * Indicates a condition to delete all versions of the policy.
+ */
+ ALL("All Versions");
+ private String name;
+
+ private DeletePolicyCondition(String name){
+ this.name = name;
+ }
+
+ /**
+ * Returns the <code>String</code> format of delete condition for this Policy
+ * @return the <code>String</code> of the delete condition for this Policy
+ */
+ public String toString(){
+ return this.name;
+ }
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DeletePolicyParameters.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DeletePolicyParameters.java
new file mode 100644
index 000000000..3999c5e22
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DeletePolicyParameters.java
@@ -0,0 +1,101 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+import java.util.UUID;
+
+/**
+ * <code>PushPolicyParameters</code> defines the Policy Parameters
+ * which are required to Push a Policy to PDPGroup.
+ *
+ * @version 0.1
+ */
+public class DeletePolicyParameters {
+
+ private String policyName;
+ private String policyComponent;
+ private DeletePolicyCondition deleteCondition;
+ private String pdpGroup;
+ private UUID requestID;
+
+
+ /**
+ * @return the policyName
+ */
+ public String getPolicyName() {
+ return policyName;
+ }
+ /**
+ * @param policyName the policyName to set
+ */
+ public void setPolicyName(String policyName) {
+ this.policyName = policyName;
+ }
+ /**
+ * @return the policyComponent
+ */
+ public String getPolicyComponent() {
+ return policyComponent;
+ }
+ /**
+ * @param policyComponent the policyComponent to set
+ */
+ public void setPolicyComponent(String policyComponent) {
+ this.policyComponent = policyComponent;
+ }
+ /**
+ * @return the deleteCondition
+ */
+ public DeletePolicyCondition getDeleteCondition() {
+ return deleteCondition;
+ }
+ /**
+ * @param deleteCondition the deleteCondition to set
+ */
+ public void setDeleteCondition(DeletePolicyCondition deleteCondition) {
+ this.deleteCondition = deleteCondition;
+ }
+ /**
+ * @return the requestID
+ */
+ public UUID getRequestID() {
+ return requestID;
+ }
+ /**
+ * @param requestID the requestID to set
+ */
+ public void setRequestID(UUID requestID) {
+ this.requestID = requestID;
+ }
+ /**
+ * @return the pdpGroup
+ */
+ public String getPdpGroup() {
+ return pdpGroup;
+ }
+ /**
+ * @param pdpGroup the pdpGroup to set
+ */
+ public void setPdpGroup(String pdpGroup) {
+ this.pdpGroup = pdpGroup;
+ }
+
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DictionaryParameters.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DictionaryParameters.java
new file mode 100644
index 000000000..1506effd7
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DictionaryParameters.java
@@ -0,0 +1,83 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+import java.util.Map;
+import java.util.UUID;
+
+public class DictionaryParameters {
+
+ private DictionaryType dictionaryType;
+ private String dictionary;
+ private Map<AttributeType, Map<String,String>> dictionaryFields;
+ private UUID requestID;
+
+
+ /**
+ * @return the dictionaryType
+ */
+ public DictionaryType getDictionaryType() {
+ return dictionaryType;
+ }
+ /**
+ * @param dictionaryType the dictionaryType to set
+ */
+ public void setDictionaryType(DictionaryType dictionaryType) {
+ this.dictionaryType = dictionaryType;
+ }
+ /**
+ * @return the dictionary
+ */
+ public String getDictionary() {
+ return dictionary;
+ }
+ /**
+ * @param dictionary the dictionary to set
+ */
+ public void setDictionary(String dictionary) {
+ this.dictionary = dictionary;
+ }
+ /**
+ * @return the dictionaryFields
+ */
+ public Map<AttributeType, Map<String,String>> getDictionaryFields() {
+ return dictionaryFields;
+ }
+ /**
+ * @param dictionaryFields the dictionaryFields to set
+ */
+ public void setDictionaryFields(Map<AttributeType, Map<String,String>> dictionaryFields) {
+ this.dictionaryFields = dictionaryFields;
+ }
+ /**
+ * @return the requestID
+ */
+ public UUID getRequestID() {
+ return requestID;
+ }
+ /**
+ * @param requestID the requestID to set
+ */
+ public void setRequestID(UUID requestID) {
+ this.requestID = requestID;
+ }
+
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DictionaryType.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DictionaryType.java
new file mode 100644
index 000000000..0935f64b9
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/DictionaryType.java
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+public enum DictionaryType {
+ /**
+ * Indicates Common Dictionaries.
+ */
+ Common("Common"),
+ /**
+ * Indicates ClosedLoop Policy Dictionaries.
+ */
+ ClosedLoop("ClosedLoop"),
+ /**
+ * Indicates Firewall Config Policy Dictionaries.
+ */
+ Firewall("FW"),
+ /**
+ * Indicates Decision Policy Dictionaries.
+ */
+ Decision("Decision"),
+ /**
+ * Indicates BRMS Policy Dictionaries.
+ */
+ BRMS("BRMS"),
+ /**
+ * Indicates DCAE Micro Service Policy Dictionaries.
+ */
+ MicroService("MS"),
+ /**
+ * Indicates Descriptive Scope Dictionaries
+ */
+ DescriptiveScope("DescriptiveScope"),
+ /**
+ * Indicates Policy Scope Dictionaries
+ */
+ PolicyScope("PolicyScope"),
+ ;
+
+ private String name;
+
+ private DictionaryType(String typeName){
+ this.name = typeName;
+ }
+
+ /**
+ * Returns the <code>String</code> format of Type for this <code>PolicyClass</code>
+ * @return the <code>String</code> of the Type for this <code>PolicyClass</code>
+ */
+ public String toString() {
+ return this.name;
+ }
+
+
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/EventRequestParameters.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/EventRequestParameters.java
new file mode 100644
index 000000000..155d9c6a5
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/EventRequestParameters.java
@@ -0,0 +1,89 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * <code>EventRequestParameters</code> defines the Event Policy Request Parameters
+ * which retrieve(s) the response from PDP if the request parameters match with any Action Policy.
+ *
+ * @version 0.1
+ */
+public class EventRequestParameters {
+ private Map<String,String> eventAttributes;
+ private UUID requestID;
+
+ /**
+ * Constructor with no Parameters
+ */
+ public EventRequestParameters(){
+ }
+
+ /**
+ * Constructor with Parameters
+ *
+ * @param eventAttributes the <code>Map</code> of <code>String,String</code> format of the eventAttributes that contains the event ID and values.
+ * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ */
+ public EventRequestParameters(Map<String,String> eventAttributes, UUID requestID){
+ this.eventAttributes = eventAttributes;
+ this.requestID = requestID;
+ }
+
+ /**
+ * Gets the eventAttributes of Event Request Parameters.
+ *
+ * @return eventAttributes the <code>Map</code> of <code>String,String</code> format of the eventAttributes that contains the event ID and values.
+ */
+ public Map<String,String> getEventAttributes() {
+ return eventAttributes;
+ }
+
+ /**
+ * Sets the eventAttributes that contain the eventID and values to the Event Request Parameters.
+ *
+ * @param eventAttributes the <code>Map</code> of <code>String,String</code> format of the eventAttributes that must contain the event ID and values.
+ */
+ public void setEventAttributes(Map<String,String> eventAttributes) {
+ this.eventAttributes = eventAttributes;
+ }
+
+ /**
+ * Gets the ReqestID of Event Request Parameters which will be passed around ECOMP requests.
+ *
+ * @return requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ */
+ public UUID getRequestID() {
+ return requestID;
+ }
+
+ /**
+ * Sets the ReqestID of Event Request Parameters which will be passed around ECOMP requests.
+ *
+ * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ */
+ public void setRequestID(UUID requestID) {
+ this.requestID = requestID;
+ }
+
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/ImportParameters.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/ImportParameters.java
new file mode 100644
index 000000000..299f29a93
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/ImportParameters.java
@@ -0,0 +1,194 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+import java.util.List;
+import java.util.UUID;
+
+
+/**
+ * <code>ImportParameters</code> defines the Policy Engine Import Parameters
+ * which are required to import a new Policy Service or Value.
+ *
+ * @version 0.1
+ */
+public class ImportParameters {
+ private String serviceName;
+ private String description;
+ private UUID requestID;
+ private String filePath;
+ private String importBody;
+ private String version;
+ private IMPORT_TYPE importType;
+
+ public enum IMPORT_TYPE {
+ MICROSERVICE
+ }
+
+ /**
+ * Sets Import Policy Parameters.
+ *
+ * @param serviceName the <code>String</code> format of the Service Name
+ * @param description the <code>String</code> format of the i Description
+ * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ * @param filePath the <code>List</code> format of the file paths for the service files
+ * @param importType the {@link IMPORT_TYPE} format of the Policy Service List
+ * @param version the <code>String</code> format of the Policy Import Version
+ * A different request ID should be passed for each request.
+ */
+ public void setImportParameters(String serviceName, String description, UUID requestID, String filePath, IMPORT_TYPE importType, String version){
+
+ this.setServiceName(serviceName);
+ this.setDescription(description);
+ this.setRequestID(requestID);
+ this.setFilePath(filePath);
+ this.setServiceType(importType);
+ this.setVersion(version);
+
+ }
+
+ /**
+ * Gets the Policy Service of the Policy Service Import Parameters.
+ *
+ * @return serviceName the <code>String</code> format of the Policy Service Name
+ */
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ /**
+ * Sets the serviceName of the Policy Service Parameters.
+ *
+ * @param serviceName the <code>String</code> format of the Policy Service Name
+ */
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ /**
+ * Gets the Policy Import Description.
+ *
+ * @return description the <code>String</code> format of the Policy Import Description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Sets the Description of the new Policy Import Description.
+ *
+ * @param description the <code>String</code> format of the Policy Import Description
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * Gets the requestID of the Policy Parameters.
+ *
+ * @return unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ */
+ public UUID getRequestID() {
+ return requestID;
+ }
+
+ /**
+ * Sets the requestID of the Policy Parameters.
+ *
+ * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ */
+ public void setRequestID(UUID requestID) {
+ this.requestID = requestID;
+ }
+
+ /**
+ * Gets the importBody of the new policy import.
+ *
+ * @return importBody the <code>String</code> format of the Policy Import Body
+ */
+ public String getImportBody() {
+ return importBody;
+ }
+
+ /**
+ * Sets the importBody of the Policy Import Body.
+ *
+ * @param importBody the <code>String</code> format of the Policy Import Body
+ */
+ public void setImportBody(String importBody) {
+ this.importBody = importBody;
+ }
+
+ /**
+ * Gets the List of File Paths of the new import.
+ *
+ * @return filePath the <code>List</code> format of the Policy Import File
+ */
+ public String getFilePath() {
+ return filePath;
+ }
+
+ /**
+ * Sets the policy Import File List of the new Policy Import.
+ *
+ * @param filePath the <code>List</code> format of the Policy Import File
+ */
+ public void setFilePath(String filePath) {
+ this.filePath = filePath;
+ }
+
+ /**
+ * Gets the Service Type of the new policy import.
+ *
+ * @return ImportType {@link IMPORT_TYPE} format of the Policy Service List
+ */
+ public IMPORT_TYPE getServiceType() {
+ return importType;
+ }
+
+ /**
+ * Sets the policy Service Type of the new Policy Service.
+ *
+ * @param enumImportType the <code>enumServiceType</code> format of the Policy Service List
+ */
+ public void setServiceType(IMPORT_TYPE enumImportType) {
+ this.importType = enumImportType;
+ }
+
+ /**
+ *
+ * Gets the Import Version of the new policy import.
+ *
+ * @return version the <code>String</code> format of the Policy Import Version
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * Sets the policy Import Version of the new Policy Import.
+ *
+ * @param version the <code>String</code> format of the Policy Import Version
+ */
+ public void setVersion(String version) {
+ this.version = version;
+ }
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/NotificationScheme.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/NotificationScheme.java
new file mode 100644
index 000000000..2e88d9c38
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/NotificationScheme.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+/**
+ * Enumeration of <code>NotificationScheme</code> describes the Notification Scheme that will be used by the PolicyEngine.
+ *
+ * @version 0.1
+ */
+public enum NotificationScheme {
+ /**
+ * Notifications for policyUpdates on policy Configs already retrieved
+ */
+ AUTO_NOTIFICATIONS("auto_notifications"),
+ /**
+ * Subscribing to all notifications from the PDP
+ */
+ AUTO_ALL_NOTIFICATIONS("auto_all_notifications"),
+ /**
+ * Client can poll for updates that receive policyUpdates on policy Configs that have already been retrieved
+ */
+ MANUAL_NOTIFICATIONS("manual_notifications"),
+ /**
+ * Client can poll for updates that receive all notifications from the PDP
+ */
+ MANUAL_ALL_NOTIFICATIONS("manual_all_notifications")
+ ;
+
+ private String name;
+ private NotificationScheme(String name){
+ this.name = name;
+ }
+
+ /**
+ * Returns the <code>String</code> name for this <code>NotificationScheme</code>
+ *
+ * @return the <code>String</code> name for this <code>NotificationScheme</code>
+ */
+ @Override
+ public String toString(){
+ return this.name;
+ }
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyChangeResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyChangeResponse.java
new file mode 100644
index 000000000..98bfdc2e3
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyChangeResponse.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+/**
+ * <code>PolicyChangeResponse</code> defines the Policy Response
+ * which is Contains responseCode corresponding to HTTP response Codes with response Message.
+ *
+ * @version 0.1
+ */
+public interface PolicyChangeResponse {
+
+ /**
+ * Policy Change Response Message in <code>String</code> format from the Policy Engine.
+ *
+ * @return the responseMessage in <code>String</code> format related to Response from Policy Engine.
+ */
+ public String getResponseMessage();
+
+ /**
+ * Response code of type <code>Integer</code> which corresponds to the HTTP Response code explaining the response from Policy Engine.
+ *
+ * @return the responseCode in <code>Integer</code> format corresponding to the HTTP response code from Policy Engine.
+ */
+ public int getResponseCode();
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyClass.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyClass.java
new file mode 100644
index 000000000..caf3c11f1
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyClass.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+/**
+ * Enumeration of the Policy Types that is used as a part of
+ * {@link org.openecomp.policy.api.PolicyParameters}.
+ *
+ * @version 0.1
+ */
+public enum PolicyClass {
+ /**
+ * Indicates Config based Policy.
+ */
+ Config("Config"),
+ /**
+ * Indicates Action based Policy.
+ */
+ Action("Action"),
+ /**
+ * Indicates Decision based Policy.
+ */
+ Decision("Decision")
+ ;
+ private String name;
+
+ private PolicyClass(String typeName){
+ this.name = typeName;
+ }
+
+ /**
+ * Returns the <code>String</code> format of Type for this <code>PolicyClass</code>
+ * @return the <code>String</code> of the Type for this <code>PolicyClass</code>
+ */
+ public String toString() {
+ return this.name;
+ }
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfig.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfig.java
new file mode 100644
index 000000000..5cb7d8176
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfig.java
@@ -0,0 +1,123 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+import java.util.Map;
+import java.util.Properties;
+
+import javax.json.JsonObject;
+
+import org.w3c.dom.Document;
+/**
+ * Defines the objects that represent PolicyEngine config elements. PolicyConfig communicates the PolicyConfigStatus,
+ * PolicyConfigMessage, PolicyType, Properties, JsonObject, String and Document.
+ *
+ * @version 0.7
+ */
+
+public interface PolicyConfig {
+ /**
+ * Gets the {@link org.openecomp.policy.api.PolicyType} associated with <code>PolicyConfig</code>
+ *
+ * @return the <code>PolicyType</code> associated with this <code>PolicyConfig</code>
+ */
+ public PolicyType getType();
+
+ /**
+ * Gives the <code>Properties</code> response associated with the <code>PolicyConfig</code>
+ *
+ * @return the <code>Properties</code> associated with this <code>PolicyConfig</code>
+ */
+ public Properties toProperties();
+
+ /**
+ * Gives the <code>JsonObject</code> response associated with the <code>PolicyConfig</code>
+ *
+ * @return the <code>JsonObject</code> result associated with <code>PolicyConfig</code>
+ */
+ public JsonObject toJSON();
+
+ /**
+ * Gives the XML <code>Document</code> result associated with <code>PolicyConfig</code>
+ *
+ * @return the <code>Document</code> result associated with <code>PolicyConfig</code>
+ */
+ public Document toXML();
+
+ /**
+ * Gives the Other <code>String</code> response associated with <code>PolicyConfig</code>
+ *
+ * @return the <code>String</code> result associated with <code>PolicyConfig</code>
+ */
+ public String toOther();
+
+ /**
+ * Gets the {@link org.openecomp.policy.api.PolicyConfigStatus} associated with this <code>PolicyConfig</code>.
+ *
+ * @return the <code>PolicyConfigStatus</code> associated with this <code>PolicyConfig</code>
+ */
+ public PolicyConfigStatus getPolicyConfigStatus();
+
+ /**
+ * Gets the <code>String</code> of the PolicyConfigMessage from <code>PolicyConfig</code>.
+ *
+ * @return the <code>String</code> which consists of PolicyConfigMessage from <code>PolicyConfig</code>
+ */
+ public String getPolicyConfigMessage();
+
+ /**
+ * Gets the <code>String</code> of the PolicyName retrieved.
+ *
+ * @return the <code>String</code> which consists of Policy Name which has been retrieved.
+ */
+ public String getPolicyName();
+
+
+ /**
+ * Gets the <code>String</code> of the PolicyVersion retrieved.
+ *
+ * @return the <code>String</code> which consists of the Policy Version number which has been retrieved.
+ */
+ public String getPolicyVersion();
+
+ /**
+ * Gets the Matching Conditions of the policy retrieved which can be used in the getConfig call.
+ *
+ * @return <code>Map</code> of <code>String, String</code> which consists of the Matching conditions of the Policy retrieved.
+ */
+ public Map<String,String> getMatchingConditions();
+
+ /**
+ * Gets the Response Attributes of the policy retrieved. Which can hold additional information about the policy retrieved.
+ *
+ * @return <code>Map</code> of <code>String, String</code> which consists of the Response Attributes of the Policy retrieved.
+ */
+ public Map<String,String> getResponseAttributes();
+
+ /**
+ * Returns the <code>String</code> version of the <code>PolicyConfig</code> object.
+ *
+ * @return <code>String</code> of the <code>PolicyConfig</code> Object.
+ */
+ @Override
+ public String toString();
+
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigException.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigException.java
new file mode 100644
index 000000000..ad6948e77
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigException.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+/**
+ * PolicyConfigException extends <code>Exception</code> to implement exceptions thrown by {@link org.openecomp.policy.api.PolicyEngine}
+ *
+ * @version 0.1
+ */
+public class PolicyConfigException extends Exception{
+ private static final long serialVersionUID = -188355220060684215L;
+
+ public PolicyConfigException() {
+ }
+
+ public PolicyConfigException(String message) {
+ super(message);
+ }
+
+ public PolicyConfigException(Throwable cause){
+ super(cause);
+ }
+
+ public PolicyConfigException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public PolicyConfigException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigStatus.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigStatus.java
new file mode 100644
index 000000000..9f45b652b
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigStatus.java
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+/**
+ * Enumeration of PolicyConfigStatus that can be returned as a part of
+ * {@link org.openecomp.policy.api.PolicyConfig}.
+ *
+ * @version 0.1
+ */
+public enum PolicyConfigStatus {
+ /**
+ * Indicates that the Configuration has been successfully retrieved.
+ */
+ CONFIG_RETRIEVED("retrieved"),
+ /**
+ * Indicates that there is no Configuration Retrieved from PolicyConfig.
+ */
+ CONFIG_NOT_FOUND("not_found"),
+ ;
+
+ private String name;
+ private PolicyConfigStatus(String name){
+ this.name = name;
+ }
+
+ /**
+ * Get the <code>PolicyConfigStatus</code> based on <code>String</code> representation of <code>PolicyConfig</code>
+ *
+ * @param configStatus the <code>String</code> Configuration Status
+ * @return the <code>PolicyConfigResponse</code> with the name matching <code>CONFIG_RETRIEVED</code> or <code>CONFIG_NOT_FOUND</code>
+ * if no match is found
+ */
+ public static PolicyConfigStatus getStatus(String configStatus) {
+ if(configStatus.equalsIgnoreCase("retrieved")) {
+ return CONFIG_RETRIEVED;
+ }else {
+ return CONFIG_NOT_FOUND;
+ }
+ }
+
+ /**
+ * Returns the <code>String</code> name for this <code>PolicyConfigStatus</code>
+ *
+ * @return the <code>String</code> name for this <code>PolicyConfigStatus</code>
+ */
+ public String toString(){
+ return this.name;
+ }
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigType.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigType.java
new file mode 100644
index 000000000..111c85623
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyConfigType.java
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+/**
+ * Enumeration of the Policy Config Types that is used as a part of
+ * {@link org.openecomp.policy.api.PolicyParameters}.
+ *
+ * @version 0.1
+ */
+public enum PolicyConfigType {
+ /**
+ * Indicates Base Config Policy.
+ */
+ Base("Base"),
+ /**
+ * Indicates ClosedLoop Fault Policy.
+ */
+ ClosedLoop_Fault("Fault"),
+ /**
+ * Indicates ClosedLoop Performance Metrics Policy.
+ */
+ ClosedLoop_PM("PM"),
+ /**
+ * Indicates Firewall Config Policy.
+ */
+ Firewall("FW"),
+ /**
+ * Indicates BRMS based raw DRL Rule Policy.
+ */
+ BRMS_RAW("BRMS_Raw"),
+ /**
+ * Indicates BRMS based Param DRL policy.
+ */
+ BRMS_PARAM("BRMS_Param"),
+ /**
+ * Indicates DCAE Micro Service based Policy.
+ */
+ MicroService("MS")
+ ;
+
+ private String name;
+
+ private PolicyConfigType(String typeName){
+ this.name = typeName;
+ }
+
+ /**
+ * Returns the <code>String</code> format of Type for this <code>PolicyClass</code>
+ * @return the <code>String</code> of the Type for this <code>PolicyClass</code>
+ */
+ public String toString() {
+ return this.name;
+ }
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyDecision.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyDecision.java
new file mode 100644
index 000000000..18d066905
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyDecision.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+/**
+ * Enumeration of PolicyDecision that can be returned as a part of
+ * {@link org.openecomp.policy.api.DecisionResponse} getDecision().
+ *
+ * @version 0.1
+ */
+public enum PolicyDecision {
+ /**
+ * Indicates that the Decision is to Permit.
+ */
+ PERMIT("permit"),
+ /**
+ * Indicates that the Decision is to Deny.
+ */
+ DENY("deny"),
+ /**
+ * Indicates that the Decision process has some issues.
+ */
+ ERROR("error")
+ ;
+
+ private String name;
+ private PolicyDecision(String name){
+ this.name = name;
+ }
+
+ /**
+ * Returns the <code>String</code> name for this <code>PolicyDecision</code>
+ *
+ * @return the <code>String</code> name for this <code>PolicyDecision</code>
+ */
+ public String toString(){
+ return this.name;
+ }
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyDecisionException.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyDecisionException.java
new file mode 100644
index 000000000..7f08fcb36
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyDecisionException.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+/**
+ * PolicyDecisionException extends <code>Exception</code> to implement exceptions thrown by {@link org.openecomp.policy.api.PolicyEngine}
+ *
+ * @version 0.1
+ */
+public class PolicyDecisionException extends Exception {
+
+ private static final long serialVersionUID = -2080072039363261175L;
+
+ public PolicyDecisionException() {
+ }
+
+ public PolicyDecisionException(String message) {
+ super(message);
+ }
+
+ public PolicyDecisionException(Throwable cause){
+ super(cause);
+ }
+
+ public PolicyDecisionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public PolicyDecisionException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEngine.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEngine.java
new file mode 100644
index 000000000..0b46c57cf
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEngine.java
@@ -0,0 +1,575 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.json.JsonObject;
+
+import org.openecomp.policy.api.NotificationHandler;
+import org.openecomp.policy.api.PDPNotification;
+import org.openecomp.policy.std.StdPolicyEngine;
+
+/**
+ * PolicyEngine is the Interface that applications use to make policy queries against a PEPEngine
+ *
+ * @version 1.0
+ */
+public class PolicyEngine{
+ private String propertyFilePath = null;
+ private StdPolicyEngine stdPolicyEngine;
+ private NotificationScheme scheme = null;
+ private NotificationHandler handler = null;
+
+ /**
+ * Gets the configuration from the PolicyDecisionPoint(PDP) for the <code>String</code> which represents the Policy File Name
+ *
+ * @param policyName the <code>String</code> format of the PolicyFile Name whose configuration is required.
+ * @return <code>Collection</code> of {@link org.openecomp.policy.api.PolicyConfig} which has the configuration.
+ * @throws PolicyConfigException
+ * @deprecated use {@link #getConfigByPolicyName(String policyName, UUID requestID)} Instead.
+ */
+ @Deprecated
+ public Collection<PolicyConfig> getConfigByPolicyName(String policyName) throws PolicyConfigException {
+ Collection<PolicyConfig> policyConfig = stdPolicyEngine.policyName(policyName,(UUID)null);
+ return policyConfig;
+ }
+
+ /**
+ * Gets the configuration from the PolicyDecisionPoint(PDP) for the <code>String</code> which represents the Policy File Name
+ *
+ * @param policyName the <code>String</code> format of the PolicyFile Name whose configuration is required.
+ * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ * A different request ID should be passed for each request.
+ * @return <code>Collection</code> of {@link org.openecomp.policy.api.PolicyConfig} which has the configuration.
+ * @throws PolicyConfigException
+ * @deprecated use {@link #getConfigByPolicyName(String policyName, UUID requestID)} Instead.
+ */
+ @Deprecated
+ public Collection<PolicyConfig> getConfigByPolicyName(String policyName, UUID requestID) throws PolicyConfigException {
+ Collection<PolicyConfig> policyConfig = stdPolicyEngine.policyName(policyName,requestID);
+ return policyConfig;
+ }
+
+ /**
+ * Gets the configuration from the PolicyDecisionPoint(PDP) for the <code>String</code> which represents the eCOMPComponentName
+ *
+ * @param eCOMPComponentName the <code>String</code> format of the eCOMPComponentName whose configuration is required.
+ * @return <code>Collection</code> of {@link org.openecomp.policy.api.PolicyConfig} which has the configuration.
+ * @throws PolicyConfigException
+ * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
+ */
+ @Deprecated
+ public Collection<PolicyConfig> getConfig(String eCOMPComponentName) throws PolicyConfigException {
+ Collection<PolicyConfig> policyConfig = stdPolicyEngine.config(eCOMPComponentName,(UUID)null);
+ return policyConfig;
+ }
+
+ /**
+ * Gets the configuration from the PolicyDecisionPoint(PDP) for the <code>String</code> which represents the eCOMPComponentName
+ *
+ * @param eCOMPComponentName the <code>String</code> format of the eCOMPComponentName whose configuration is required.
+ * @return <code>Collection</code> of {@link org.openecomp.policy.api.PolicyConfig} which has the configuration.
+ * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ * A different request ID should be passed for each request.
+ * @throws PolicyConfigException
+ * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
+ */
+ @Deprecated
+ public Collection<PolicyConfig> getConfig(String eCOMPComponentName, UUID requestID) throws PolicyConfigException {
+ Collection<PolicyConfig> policyConfig = stdPolicyEngine.config(eCOMPComponentName,requestID);
+ return policyConfig;
+ }
+
+ /**
+ * Requests the configuration of the <code>String</code> which represents the eCOMPComponentName and <code>String</code>
+ * which represents the configName and returns the configuration if different Configurations exist for the
+ * particular eCOMPComponentName.
+ *
+ * @param eCOMPComponentName the <code>String</code> format of the eCOMPComponentName whose configuration is required.
+ * @param configName the <code>String</code> format of the configurationName whose configuration is required.
+ * @return <code>Collection</code> of {@link org.openecomp.policy.api.PolicyConfig} which has the configuration.
+ * @throws PolicyConfigException
+ * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
+ */
+ @Deprecated
+ public Collection<PolicyConfig> getConfig(String eCOMPComponentName, String configName) throws PolicyConfigException {
+ Collection<PolicyConfig> policyConfig = stdPolicyEngine.config(eCOMPComponentName,configName,(UUID)null);
+ return policyConfig;
+ }
+
+ /**
+ * Requests the configuration of the <code>String</code> which represents the eCOMPComponentName and <code>String</code>
+ * which represents the configName and returns the configuration if different Configurations exist for the
+ * particular eCOMPComponentName.
+ *
+ * @param eCOMPComponentName the <code>String</code> format of the eCOMPComponentName whose configuration is required.
+ * @param configName the <code>String</code> format of the configurationName whose configuration is required.
+ * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ * A different request ID should be passed for each request.
+ * @return <code>Collection</code> of {@link org.openecomp.policy.api.PolicyConfig} which has the configuration.
+ * @throws PolicyConfigException
+ * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
+ */
+ @Deprecated
+ public Collection<PolicyConfig> getConfig(String eCOMPComponentName, String configName, UUID requestID) throws PolicyConfigException {
+ Collection<PolicyConfig> policyConfig = stdPolicyEngine.config(eCOMPComponentName,configName,requestID);
+ return policyConfig;
+ }
+
+ /**
+ * Requests the configuration of the <code>String</code> which represents the eCOMPComponentName, <code>String</code>
+ * which represents the configName and <code>Map</code> of <code>String,String</code> which has the configAttribute and returns the specific
+ * configuration related to the configAttributes mentioned.
+ *
+ * @param eCOMPComponentName the <code>String</code> format of the eCOMPComponentName whose configuration is required.
+ * @param configName the <code>String</code> format of the configurationName whose configuration is required.
+ * @param configAttributes the <code>Map</code> of <code>String,String</code> format of the configuration attributes which are required.
+ * @return <code>Collection</code> of {@link org.openecomp.policy.api.PolicyConfig} which has the configuration.
+ * @throws PolicyConfigException
+ * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
+ */
+ @Deprecated
+ public Collection<PolicyConfig> getConfig(String eCOMPComponentName, String configName, Map<String, String> configAttributes) throws PolicyConfigException{
+ Collection<PolicyConfig> policyConfig = stdPolicyEngine.config(eCOMPComponentName,configName,configAttributes,(UUID)null);
+ return policyConfig;
+ }
+
+ /**
+ * Requests the configuration of the <code>String</code> which represents the eCOMPComponentName, <code>String</code>
+ * which represents the configName and <code>Map</code> of <code>String,String</code> which has the configAttribute and returns the specific
+ * configuration related to the configAttributes mentioned.
+ *
+ * @param eCOMPComponentName the <code>String</code> format of the eCOMPComponentName whose configuration is required.
+ * @param configName the <code>String</code> format of the configurationName whose configuration is required.
+ * @param configAttributes the <code>Map</code> of <code>String,String</code> format of the configuration attributes which are required.
+ * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ * A different request ID should be passed for each request.
+ * @return <code>Collection</code> of {@link org.openecomp.policy.api.PolicyConfig} which has the configuration.
+ * @throws PolicyConfigException
+ * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
+ */
+ @Deprecated
+ public Collection<PolicyConfig> getConfig(String eCOMPComponentName, String configName, Map<String, String> configAttributes, UUID requestID) throws PolicyConfigException{
+ Collection<PolicyConfig> policyConfig = stdPolicyEngine.config(eCOMPComponentName,configName,configAttributes,requestID);
+ return policyConfig;
+ }
+
+ /**
+ * Requests the configuration of the <code>ConfigRequestParameters</code> which represents the Config policy request parameters
+ * and returns the specific configuration related to the matching parameters.
+ *
+ * @param configRequestParameters {@link org.openecomp.policy.api.ConfigRequestParameters} which represents the Config policy request parameters.
+ * @return <code>Collection</code> of {@link org.openecomp.policy.api.PolicyConfig} which has the configuration.
+ * @throws PolicyConfigException
+ */
+ public Collection<PolicyConfig> getConfig(ConfigRequestParameters configRequestParameters) throws PolicyConfigException{
+ Collection<PolicyConfig> policyConfig = stdPolicyEngine.config(configRequestParameters);
+ return policyConfig;
+ }
+
+ /**
+ * Requests the list of policies based on the <code>ConfigRequestParameters</code> which represents the policy request parameters
+ * and returns the list of policies filtered by the parameters.
+ *
+ * @param configRequestParameters {@link org.openecomp.policy.api.ConfigRequestParameters} which represents the List Policy request parameters.
+ * @return <code>Collection</code> of <code>String</code> which returns the list of policies.
+ * @throws PolicyConfigException
+ */
+ public Collection<String> listConfig(ConfigRequestParameters listPolicyRequestParameters) throws PolicyConfigException{
+ Collection<String> policyList = stdPolicyEngine.listConfig(listPolicyRequestParameters);
+ return policyList;
+ }
+
+
+ /**
+ * Sends the Events specified to the PEP and returns back the PolicyResponse.
+ *
+ * @param eventAttributes the <code>Map</code> of <code>String,String</code> format of the eventAttributes that must contain the event ID and values.
+ * @return <code>Collection</code> of {@link org.openecomp.policy.api.PolicyResponse} which has the Response.
+ * @throws PolicyEventException
+ * @deprecated use {@link #sendEvent(EventRequestParameters)} Instead.
+ */
+ @Deprecated
+ public Collection<PolicyResponse> sendEvent(Map<String, String> eventAttributes) throws PolicyEventException {
+ Collection<PolicyResponse> policyResponse = stdPolicyEngine.event(eventAttributes, (UUID) null);
+ return policyResponse;
+ }
+
+ /**
+ * Sends the Events specified to the PEP and returns back the PolicyResponse.
+ *
+ * @param eventAttributes the <code>Map</code> of <code>String,String</code> format of the eventAttributes that must contain the event ID and values.
+ * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ * A different request ID should be passed for each request.
+ * @return <code>Collection</code> of {@link org.openecomp.policy.api.PolicyResponse} which has the Response.
+ * @throws PolicyEventException
+ * @deprecated use {@link #sendEvent(EventRequestParameters)} Instead.
+ */
+ @Deprecated
+ public Collection<PolicyResponse> sendEvent(Map<String, String> eventAttributes, UUID requestID) throws PolicyEventException {
+ Collection<PolicyResponse> policyResponse = stdPolicyEngine.event(eventAttributes, requestID);
+ return policyResponse;
+ }
+
+ /**
+ * Sends the Events specified to the PEP and returns back the PolicyResponse.
+ *
+ * @param eventRequestParameters {@link org.openecomp.policy.api.EventRequestParameters} which represents the Event Request Parameters.
+ * @return <code>Collection</code> of {@link org.openecomp.policy.api.PolicyResponse} which has the Response.
+ * @throws PolicyEventException
+ */
+ public Collection<PolicyResponse> sendEvent(EventRequestParameters eventRequestParameters) throws PolicyEventException {
+ Collection<PolicyResponse> policyResponse = stdPolicyEngine.event(eventRequestParameters);
+ return policyResponse;
+ }
+
+ /**
+ * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision.
+ *
+ * @param eCOMPComponentName the <code>String</code> format of the eCOMPComponentName whose Decision is required.
+ * @param decisionAttributes the <code>Map</code> of <code>String,String</code> format of the decisionAttributes that must contain the ID and values.
+ * @return {@link org.openecomp.policy.api.DecisionResponse} which has the Decision.
+ * @throws PolicyDecisionException
+ * @deprecated use {@link #getDecision(DecisionRequestParameters)} Instead.
+ */
+ @Deprecated
+ public DecisionResponse getDecision(String eCOMPComponentName, Map<String,String> decisionAttributes) throws PolicyDecisionException {
+ DecisionResponse policyDecision = stdPolicyEngine.decide(eCOMPComponentName, decisionAttributes, null);
+ return policyDecision;
+ }
+
+ /**
+ * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision.
+ *
+ * @param eCOMPComponentName the <code>String</code> format of the eCOMPComponentName whose Decision is required.
+ * @param decisionAttributes the <code>Map</code> of <code>String,String</code> format of the decisionAttributes that must contain the ID and values.
+ * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ * A different request ID should be passed for each request.
+ * @return {@link org.openecomp.policy.api.DecisionResponse} which has the Decision.
+ * @throws PolicyDecisionException
+ * @deprecated use {@link #getDecision(DecisionRequestParameters)} Instead.
+ */
+ @Deprecated
+ public DecisionResponse getDecision(String eCOMPComponentName, Map<String,String> decisionAttributes, UUID requestID) throws PolicyDecisionException {
+ DecisionResponse policyDecision = stdPolicyEngine.decide(eCOMPComponentName, decisionAttributes, requestID);
+ return policyDecision;
+ }
+
+ /**
+ * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision.
+ *
+ * @param decisionRequestParameters {@link org.openecomp.policy.api.DecisionRequestParameters} which represents the Decision Request Parameters.
+ * @return {@link org.openecomp.policy.api.DecisionResponse} which has the Decision.
+ * @throws PolicyDecisionException
+ */
+ public DecisionResponse getDecision(DecisionRequestParameters decisionRequestParameters) throws PolicyDecisionException {
+ DecisionResponse policyDecision = stdPolicyEngine.decide(decisionRequestParameters);
+ return policyDecision;
+ }
+
+ /**
+ * <code>setNotification</code> allows changes to the Notification Scheme and Notification Handler
+ *
+ * @param scheme the <code>NotificationScheme</code> of {@link org.openecomp.policy.api.NotificationScheme} which defines the Notification Scheme
+ * @param handler the <code>NotificationHandler</code> of {@link org.openecomp.policy.api.NotificationHandler} which defines what should happen when a notification is received.
+ */
+ public void setNotification(NotificationScheme scheme, NotificationHandler handler) {
+ this.scheme = scheme;
+ this.handler = handler;
+ stdPolicyEngine.notification(this.scheme,this.handler);
+ }
+
+ /**
+ * <code>clearNotification</code> shutsDown the Notification Service if the Auto Scehme Notification service is running.
+ */
+ public void clearNotification(){
+ stdPolicyEngine.stopNotification();
+ }
+
+ /**
+ * <code>setNotification</code> allows changes to the Notification Scheme
+ *
+ * @param scheme the <code>NotificationScheme</code> of {@link org.openecomp.policy.api.NotificationScheme} which defines the Notification Scheme
+ */
+ public void setScheme(NotificationScheme scheme){
+ this.scheme = scheme;
+ stdPolicyEngine.setScheme(this.scheme);
+ }
+ /**
+ * Gets the <code>PDPNotification</code> if there is one exists. This is used for Polling Patterns.
+ *
+ * @return <code>PDPNotification</code> of {@link org.openecomp.policy.api.PDPNotification} which has the Notification.
+ */
+ public PDPNotification getNotification() {
+ return stdPolicyEngine.getNotification();
+ }
+
+ /**
+ * Creates a Config Policy based on given arguments
+ * @param policyName the <code>String</code> format of the Policy Name
+ * @param policyDescription the <code>String</code> format of the Policy Description
+ * @param ecompName the <code>String</code> format of the ECOMP Name
+ * @param configName the <code>String</code> format of the Config Name
+ * @param configAttributes the <code>List</code> the <code>Map</code> Attributes that must contain the key and value.
+ * @param configType the <code>String</code> format of the Config Type
+ * @param body the <code>String</code> format of the Policy Body
+ * @param policyScope the <code>String</code> value of the sub scope directory where the policy will be created and stored
+ * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ * A different request ID should be passed for each request.
+ * @throws Exception
+ * @return <code>String</code> format of response
+ * @deprecated use {@link #createPolicy(PolicyParameters)} Instead.
+ */
+ @Deprecated
+ public String createConfigPolicy(String policyName, String policyDescription, String ecompName, String configName,
+ Map<String, String> configAttributes, String configType, String body, String policyScope, UUID requestID,
+ String riskLevel, String riskType, String guard, String ttlDate) throws Exception {
+
+ String response = stdPolicyEngine.createConfigPolicy(policyName, policyDescription, ecompName, configName,
+ configAttributes, configType, body, policyScope, requestID,
+ riskLevel, riskType, guard, ttlDate);
+
+ return response;
+
+ }
+
+ /**
+ * Creates a Config Policy based on given arguments
+ * @param policyName the <code>String</code> format of the Policy Name
+ * @param policyDescription the <code>String</code> format of the Policy Description
+ * @param ecompName the <code>String</code> format of the ECOMP Name
+ * @param configName the <code>String</code> format of the Config Name
+ * @param configAttributes the <code>List</code> the <code>Map</code> Attributes that must contain the key and value.
+ * @param configType the <code>String</code> format of the Config Type
+ * @param body the <code>String</code> format of the Policy Body
+ * @param policyScope the <code>String</code> value of the sub scope directory where the policy will be created and stored
+ * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ * A different request ID should be passed for each request.
+ * @throws Exception
+ * @return <code>String</code> format of response
+ * @deprecated use {@link #updatePolicy(PolicyParameters)} Instead.
+ */
+ @Deprecated
+ public String updateConfigPolicy(String policyName, String policyDescription, String ecompName, String configName,
+ Map<String, String> configAttributes, String configType, String body, String policyScope, UUID requestID,
+ String riskLevel, String riskType, String guard, String ttlDate) throws Exception {
+
+ String response = stdPolicyEngine.updateConfigPolicy(policyName, policyDescription, ecompName, configName,
+ configAttributes, configType, body, policyScope, requestID,riskLevel, riskType, guard, ttlDate);
+
+ return response;
+
+ }
+
+ /**
+ * Creates a Config Firewall Policy based on given arguments
+ * @param policyName the <code>String</code> format of the Policy Name
+ * @param firewallJson the <code>JsonObject</code> representation of the Firewall Rules List
+ * @param policyScope the <code>String</code> value of the sub scope directory where the policy will be created and stored
+ * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ * A different request ID should be passed for each request.
+ * @throws Exception
+ * @return <code>String</code> format of response.
+ * @deprecated use {@link #createPolicy(PolicyParameters)} Instead.
+ */
+ @Deprecated
+ public String createConfigFirewallPolicy(String policyName, JsonObject firewallJson, String policyScope, UUID requestID,
+ String riskLevel, String riskType, String guard, String ttlDate) throws Exception {
+
+ String response = stdPolicyEngine.createConfigFirewallPolicy(policyName, firewallJson, policyScope, requestID,riskLevel,
+ riskType, guard, ttlDate);
+
+ return response;
+
+ }
+
+ /**
+ * Updates a Config Firewall Policy based on given arguments
+ * @param policyName the <code>String</code> format of the Policy Name
+ * @param firewallJson the <code>JsonObject</code> representation of the Firewall Rules List
+ * @param policyScope the <code>String</code> value of the sub scope directory where the policy will be created and stored
+ * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ * A different request ID should be passed for each request.
+ * @throws Exception
+ * @return <code>String</code> format of response.
+ * @deprecated use {@link #updatePolicy(PolicyParameters)} Instead.
+ */
+ @Deprecated
+ public String updateConfigFirewallPolicy(String policyName, JsonObject firewallJson, String policyScope, UUID requestID,
+ String riskLevel, String riskType, String guard, String ttlDate) throws Exception {
+
+ String response = stdPolicyEngine.updateConfigFirewallPolicy(policyName, firewallJson, policyScope, requestID,riskLevel, riskType, guard, ttlDate);
+
+ return response;
+
+ }
+
+ /**
+ * Creates a Dictionary Item based on given Dictionary Parameters
+ *
+ * @param policyParameters {@link org.openecomp.policy.api.DictionaryParameters} which represents the Dictionary Parameters required to create a Dictionary Item.
+ * @return {@link org.openecomp.policy.api.PolicyChangeResponse} which consists of the response related to create dictionary item Request.
+ * @throws Exception
+ */
+ public PolicyChangeResponse createDictionaryItem(DictionaryParameters parameters) throws Exception {
+ PolicyChangeResponse response = stdPolicyEngine.createDictionaryItem(parameters);
+ return response;
+ }
+
+ /**
+ * Creates a Policy based on given Policy Parameters.
+ *
+ * @param policyParameters {@link org.openecomp.policy.api.PolicyParameters} which represents the Policy Parameters required to create a Policy.
+ * @return {@link org.openecomp.policy.api.PolicyChangeResponse} which consists of the response related to create policy Request.
+ * @throws Exception
+ */
+ public PolicyChangeResponse createPolicy(PolicyParameters policyParameters) throws Exception {
+ PolicyChangeResponse response = stdPolicyEngine.createPolicy(policyParameters);
+ return response;
+ }
+
+ /**
+ * Update Policy based on given Policy Parameters.
+ *
+ * @param policyParameters {@link org.openecomp.policy.api.PolicyParameters} which represents the Policy Parameters required to update a Policy.
+ * @return {@link org.openecomp.policy.api.PolicyChangeResponse} which consists of the response related to create policy Request.
+ * @throws Exception
+ */
+ public PolicyChangeResponse updatePolicy(PolicyParameters policyParameters) throws Exception {
+ PolicyChangeResponse response = stdPolicyEngine.updatePolicy(policyParameters);
+ return response;
+ }
+
+ /**
+ * Pushes the specified policy to the PDP Group. If no PDP group is selected default is used.
+ *
+ * @param policyScope the <code>String</code> value of the sub scope directory where the policy is located
+ * @param policyName the <code>String</code> format of the Policy Name being pushed.
+ * @param policyType the <code>String</code> format of the Policy Type which is being pushed.
+ * @param pdpGroup the <code>String</code> format of the PDP Group name to which the policy needs to be pushed to.
+ * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ * @return <code>String</code> format of the response related to the push Policy Request.
+ * @throws Exception
+ * @deprecated use {@link #pushPolicy(PushPolicyParameters)} instead.
+ */
+ @Deprecated
+ public String pushPolicy(String policyScope, String policyName, String policyType, String pdpGroup, UUID requestID) throws Exception {
+
+ String response = stdPolicyEngine.pushPolicy(policyScope, policyName, policyType, pdpGroup, requestID);
+
+ return response;
+ }
+
+ /**
+ * Pushes the specified policy to the PDP Group. If no PDP group is selected default is used.
+ *
+ * @param pushPolicyParameters {@link org.openecomp.policy.api.PushPolicyParameters} which represents the Push Policy parameters required to push a policy.
+ * @return {@link org.openecomp.policy.api.PolicyChangeResponse} which consists of the response related to the push Policy Request.
+ * @throws Exception
+ */
+ public PolicyChangeResponse pushPolicy(PushPolicyParameters pushPolicyParameters) throws Exception {
+ PolicyChangeResponse response = stdPolicyEngine.pushPolicy(pushPolicyParameters);
+ return response;
+ }
+
+ /**
+ * Deletes the specified policy from the PAP or PDP.
+ *
+ * @param deletePolicyParameters {@link org.openecomp.policy.api.DeletePolicyParameters} which represents the Delete Policy parameters to delete a policy.
+ * @return {@link org.openecomp.policy.api.PolicyChangeResponse} which consists of the response related to the Delete Policy Request.
+ * @throws Exception
+ */
+ public PolicyChangeResponse deletePolicy(DeletePolicyParameters deletePolicyParameters) throws Exception {
+ PolicyChangeResponse response = stdPolicyEngine.deletePolicy(deletePolicyParameters);
+ return response;
+ }
+
+ /**
+ * PolicyEngine Constructor with <code>String</code> format of propertiesFilePathname
+ *
+ * @param propertiesFilePathname the <code>String</code> format of the propertiesFilePathname
+ * @throws PolicyEngineException
+ */
+ public PolicyEngine(String propertiesFilePathname) throws PolicyEngineException {
+ this.propertyFilePath = propertiesFilePathname ;
+ this.stdPolicyEngine= new StdPolicyEngine(this.propertyFilePath);
+ }
+
+ /**
+ * PolicyEngine Constructor with <code>String</code> format of PropertiesFilePathname, <code>NotificationScheme</code> and <code>NotificationHandler</code>
+ *
+ * @param propertiesFilePathname the <code>String</code> format of the propertiesFilePathname
+ * @param scheme the <code>NotificationScheme</code> of {@link org.openecomp.policy.api.NotificationScheme} which defines the Notification Scheme
+ * @param handler the <code>NotificationHandler</code> of {@link org.openecomp.policy.api.NotificationHandler} which defines what should happen when a notification is received.
+ * @throws PolicyEngineException
+ */
+ public PolicyEngine(String propertiesFilePathname, NotificationScheme scheme, NotificationHandler handler) throws PolicyEngineException {
+ this.propertyFilePath = propertiesFilePathname ;
+ this.scheme = scheme;
+ this.handler = handler;
+ this.stdPolicyEngine= new StdPolicyEngine(this.propertyFilePath,this.scheme,this.handler);
+ }
+
+ /**
+ * Creates a new Policy Service based on given Service Parameters.
+ *
+ * @param importParameters {@link org.openecomp.policy.api.ImportParameters} which represents the Service Parameters required to create a Policy Service.
+ * @return {@link org.openecomp.policy.api.PolicyChangeResponse} which consists of the response related to create import Service.
+ * @throws Exception
+ */
+ public PolicyChangeResponse policyEngineImport(ImportParameters importParameters) throws Exception {
+ PolicyChangeResponse response = stdPolicyEngine.policyEngineImport(importParameters);
+ return response;
+ }
+
+ /**
+ * PolicyEngine Constructor with <code>String</code> format of PropertiesFilePathname and <code>NotificationScheme</code>
+ *
+ * @param propertiesFilePathname the <code>String</code> format of the propertiesFilePathname
+ * @param scheme the <code>NotificationScheme</code> of {@link org.openecomp.policy.api.NotificationScheme} which defines the Notification Scheme
+ * @throws PolicyEngineException
+ */
+ public PolicyEngine(String propertiesFilePathname, NotificationScheme scheme) throws PolicyEngineException{
+ this.propertyFilePath = propertiesFilePathname;
+ this.scheme = scheme;
+ this.stdPolicyEngine = new StdPolicyEngine(this.propertyFilePath, this.scheme);
+ }
+ /**
+ * PolicyEngine Constructor with no parameters.
+ *//*
+ public PolicyEngine(){
+
+ }
+ public void createFirewallPolicy(String filterName, String termName, String preIPSource, String preIPDest,
+ String sourcePort, String destPort, String Port, String protocol, String direction, String action ) throws PolicyDecisionException {
+ stdPolicyEngine.createFirewallPolicy(filterName, termName, preIPSource, preIPDest, sourcePort, destPort, Port,
+ protocol, direction, action);
+ }
+
+ public void updateFirewallPolicy(String filterName, String termName, String preIPSource, String preIPDest,
+ String sourcePort, String destPort, String Port, String protocol, String direction, String action ) throws PolicyDecisionException {
+ stdPolicyEngine.updateFirewallPolicy(filterName, termName, preIPSource, preIPDest, sourcePort, destPort, Port,
+ protocol, direction, action);
+ }*/
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEngineException.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEngineException.java
new file mode 100644
index 000000000..e80513ad8
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEngineException.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+/**
+ * PolicyEngineException extends <code>Exception</code> to implement exceptions thrown by {@link org.openecomp.policy.api.PolicyEngine}
+ *
+ * @version 0.1
+ */
+public class PolicyEngineException extends Exception{
+ private static final long serialVersionUID = 4945973094200118969L;
+
+ public PolicyEngineException() {
+ }
+
+ public PolicyEngineException(String message) {
+ super(message);
+ }
+
+ public PolicyEngineException(Throwable cause){
+ super(cause);
+ }
+
+ public PolicyEngineException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public PolicyEngineException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEventException.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEventException.java
new file mode 100644
index 000000000..8e4c81990
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEventException.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+/**
+ * PolicyEventException extends <code>Exception</code> to implement exceptions thrown by {@link org.openecomp.policy.api.PolicyEngine}
+ *
+ * @version 0.1
+ */
+public class PolicyEventException extends Exception {
+ private static final long serialVersionUID = -1477625011320634608L;
+
+ public PolicyEventException() {
+ }
+
+ public PolicyEventException(String message) {
+ super(message);
+ }
+
+ public PolicyEventException(Throwable cause){
+ super(cause);
+ }
+
+ public PolicyEventException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public PolicyEventException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyParameters.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyParameters.java
new file mode 100644
index 000000000..32cd75b5f
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyParameters.java
@@ -0,0 +1,497 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * <code>PolicyParameters</code> defines the Policy Parameters
+ * which are required to Create/Update a Policy.
+ *
+ * @version 0.1
+ */
+public class PolicyParameters {
+ private PolicyClass policyClass;
+ private PolicyConfigType policyConfigType;
+ private String policyName;
+ private String policyDescription;
+ private String ecompName;
+ private String configName;
+ private Map<AttributeType, Map<String,String>> attributes;
+ private String configBody;
+ private PolicyType configBodyType;
+ private String actionPerformer;
+ private String actionAttribute;
+ private UUID requestID;
+ private List<String> dynamicRuleAlgorithmLabels;
+ private List<String> dynamicRuleAlgorithmFunctions;
+ private List<String> dynamicRuleAlgorithmField1;
+ private List<String> dynamicRuleAlgorithmField2;
+ private String priority;
+ private RuleProvider ruleProvider;
+ private Date TTLDate;
+ private boolean guard = false;
+ private String riskLevel = "5";
+ private String riskType = "defualt";
+
+ /**
+ * Sets Config Policy Parameters.
+ *
+ * @param policyConfigType the {@link org.openecomp.policy.api.PolicyConfigType} Enum format of the Config Type
+ * @param policyName the <code>String</code> format of the Policy Name
+ * @param policyDescription the <code>String</code> format of the Policy Description
+ * @param ecompName the <code>String</code> format of the ECOMP Name
+ * @param configName the <code>String</code> format of the Config Name
+ * @param attributes the <code>Map</code> Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it.
+ * @param configBodyType the {@link org.openecomp.policy.api.PolicyType} Enum format of the config Body Type.
+ * @param configBody the <code>String</code> format of the Policy Body
+ * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ * A different request ID should be passed for each request.
+ */
+ public void setConfigPolicyParameters(PolicyConfigType policyConfigType, String policyName, String policyDescription, String ecompName, String configName,
+ Map<AttributeType, Map<String, String>> attributes, PolicyType configBodyType, String configBody, UUID requestID){
+ this.setPolicyConfigType(policyConfigType);
+ this.setPolicyName(policyName);
+ this.setPolicyDescription(policyDescription);
+ this.setEcompName(ecompName);
+ this.setConfigName(configName);
+ this.setAttributes(attributes);
+ this.setConfigBody(configBody);
+ this.setConfigBodyType(configBodyType);
+ this.setRequestID(requestID);
+ }
+
+ /**
+ * Sets config Firewall Policy Parameters.
+ *
+ * @param policyName the <code>String</code> format of the Policy Name
+ * @param firewallJson the <code>String</code> representation of the Firewall Rules List
+ * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ * A different request ID should be passed for each request.
+ */
+ public void setConfigFirewallPolicyParameters(String policyName, String firewallJson, UUID requestID){
+ this.setPolicyConfigType(PolicyConfigType.Firewall);
+ this.setPolicyName(policyName);
+ this.setConfigBody(firewallJson);
+ this.setConfigBodyType(PolicyType.JSON);
+ this.setRequestID(requestID);
+ }
+
+ /**
+ * Gets the PolicyName of the Policy Parameters.
+ *
+ * @return policyName the <code>String</code> format of the Policy Name
+ */
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ /**
+ * Sets the policyName of the Policy Parameters.
+ *
+ * @param policyName the <code>String</code> format of the Policy Name
+ */
+ public void setPolicyName(String policyName) {
+ this.policyName = policyName;
+ }
+
+ /**
+ * Gets the policy Description.
+ *
+ * @return the <code>String</code> format of the Policy Description
+ */
+ public String getPolicyDescription() {
+ return policyDescription;
+ }
+
+ /**
+ * Sets the policy Description of the Policy Description.
+ *
+ * @param policyDescription the <code>String</code> format of the Policy Description
+ */
+ public void setPolicyDescription(String policyDescription) {
+ this.policyDescription = policyDescription;
+ }
+
+ /**
+ * Gets the ECOMP Name value of the Policy Paramters.
+ *
+ * @return <code>String</code> format of the ECOMP Name
+ */
+ public String getEcompName() {
+ return ecompName;
+ }
+
+ /**
+ * Sets the ECOMP Name field of the Policy Parameters.
+ *
+ * @param ecompName the <code>String</code> format of the ECOMP Name
+ */
+ public void setEcompName(String ecompName) {
+ this.ecompName = ecompName;
+ }
+
+ /**
+ * Gets the Config Name value of the Policy Parameters.
+ *
+ * @return <code>String</code> format of the Config Name
+ */
+ public String getConfigName() {
+ return configName;
+ }
+
+ /**
+ * Sets the Config Name field of the Policy Parameters.
+ *
+ * @param configName the <code>String</code> format of the Config Name
+ */
+ public void setConfigName(String configName) {
+ this.configName = configName;
+ }
+
+ /**
+ * Gets the Attributes of the policy Parameters.
+ *
+ * @return <code>List</code> the <code>Map</code> Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it.
+ */
+ public Map<AttributeType, Map<String, String>> getAttributes() {
+ return attributes;
+ }
+
+ /**
+ * Sets the Attributes of the Policy Parameters.
+ *
+ * @param attributes the <code>Map</code> Attributes that must contain the AttributeType and Map of key,value pairs corresponding to it.
+ */
+ public void setAttributes(Map<AttributeType, Map<String, String>> attributes) {
+ this.attributes = attributes;
+ }
+
+ /**
+ * Gets the Policy Config Type value the Policy parameters.
+ *
+ * @return {@link org.openecomp.policy.api.PolicyConfigType} Enum of the Config Type
+ */
+ public PolicyConfigType getPolicyConfigType() {
+ return policyConfigType;
+ }
+
+ /**
+ * Sets the Policy Config Type field of the policy Parameters.
+ *
+ * @param policyConfigType the {@link org.openecomp.policy.api.PolicyConfigType} Enum format of the Config Type
+ */
+ public void setPolicyConfigType(PolicyConfigType policyConfigType) {
+ setPolicyClass(PolicyClass.Config);
+ this.policyConfigType = policyConfigType;
+ }
+
+ /**
+ * Gets the configBody value of the Policy Parameters.
+ *
+ * @return the <code>String</code> format of the Policy Body
+ */
+ public String getConfigBody() {
+ return configBody;
+ }
+
+ /**
+ * Sets the configBody field of the Policy Parameters.
+ *
+ * @param configBody the <code>String</code> format of the Policy Body
+ */
+ public void setConfigBody(String configBody) {
+ this.configBody = configBody;
+ }
+
+ /**
+ * Gets the config Body Type value of the Policy Parameters.
+ *
+ * @return the <code>PolicyType</code> representation of the configBodyType
+ */
+ public PolicyType getConfigBodyType() {
+ return configBodyType;
+ }
+
+ /**
+ * Sets the configBodyType field of the Policy Parameters.
+ *
+ * @param configBodyType the <code>PolicyType</code> representation of the config BodyType
+ */
+ public void setConfigBodyType(PolicyType configBodyType) {
+ this.configBodyType = configBodyType;
+ }
+
+ /**
+ * Gets the requestID of the Policy Parameters.
+ *
+ * @return unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ */
+ public UUID getRequestID() {
+ return requestID;
+ }
+
+ /**
+ * Sets the requestID of the Policy Parameters.
+ *
+ * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ */
+ public void setRequestID(UUID requestID) {
+ this.requestID = requestID;
+ }
+
+ /**
+ * Gets the Policy Class of the Policy Parameters.
+ *
+ * @return {@link org.openecomp.policy.api.PolicyClass} of the Policy Parameters.
+ */
+ public PolicyClass getPolicyClass() {
+ return policyClass;
+ }
+
+ /**
+ * Sets the Policy Class of the Policy Parameters.
+ *
+ * @param policyClass the Enum {@link org.openecomp.policy.api.PolicyClass} to set Policy Class Type of Policy parameters.
+ */
+ public void setPolicyClass(PolicyClass policyClass) {
+ this.policyClass = policyClass;
+ }
+
+ /**
+ * Gets the Action Performer value of the Policy Parameters for Action Policies.
+ *
+ * @return the <code>String</code> value of the Action Performer for Action Policies
+ */
+ public String getActionPerformer() {
+ return actionPerformer;
+ }
+
+ /**
+ * Sets the Action Performer value of the Policy Parameters for Action Policies.
+ *
+ * @param actionPerformer the <code>String</code> format of the Action Performer
+ */
+ public void setActionPerformer(String actionPerformer) {
+ this.actionPerformer = actionPerformer;
+ }
+
+ /**
+ * Gets the Action Attribute value of the Policy Parameters for Action Policies.
+ *
+ * @return the <code>String</code> value of the Action Attribute for Action Policies
+ */
+ public String getActionAttribute() {
+ return actionAttribute;
+ }
+
+ /**
+ * Sets the Action Attribute value of the Policy Parameters for Action Policies.
+ *
+ * @param actionAttribute the <code>String</code> format of the Action Attribute
+ */
+ public void setActionAttribute(String actionAttribute) {
+ this.actionAttribute = actionAttribute;
+ }
+
+ /**
+ * Gets the Dynamic Rule Algorithm Label of the policy Parameters. Used in conjunction with the Label, Field1,
+ * Function, and Field2 to complete the complex and simple Rule Algorithms
+ *
+ * @return <code>List</code> the Dynamic Rule Algorithm Label that must contain the Labels in order
+ */
+ public List<String> getDynamicRuleAlgorithmLabels() {
+ return dynamicRuleAlgorithmLabels;
+ }
+
+ /**
+ * Sets the Dynamic Rule Algorithm Labels used in conjunction with the Label, Field1,
+ * Function, and Field2 to complete the complex and simple Rule Algorithms
+ *
+ * @param dynamicRuleAlgorithmLabels the <code>List</code> dynamicRuleAlgoritmLabels in order
+ */
+ public void setDynamicRuleAlgorithmLabels(
+ List<String> dynamicRuleAlgorithmLabels) {
+ this.dynamicRuleAlgorithmLabels = dynamicRuleAlgorithmLabels;
+ }
+
+ /**
+ * Gets the Dynamic Rule Algorithm Function of the policy Parameters. Used in conjunction with the Label, Field1,
+ * FunctionDef, and Field2 to complete the complex and simple Rule Algorithms
+ *
+ * @return <code>List</code> the Dynamic Rule Algorithm Functions that must contain the values in order
+ */
+ public List<String> getDynamicRuleAlgorithmFunctions() {
+ return dynamicRuleAlgorithmFunctions;
+ }
+
+ /**
+ * Sets the Dynamic Rule Algorithm Functions used in conjunction with the Label, Field1,
+ * Function, and Field2 to complete the complex and simple Rule Algorithms
+ *
+ * @param dynamicRuleAlgorithmFunctions the <code>List</code> dynamicRuleAlgorithmFunctions in order
+ */
+ public void setDynamicRuleAlgorithmFunctions(List<String> dynamicRuleAlgorithmFunctions) {
+ this.dynamicRuleAlgorithmFunctions = dynamicRuleAlgorithmFunctions;
+ }
+
+ /**
+ * Gets the Dynamic Rule Algorithm Field1 of the policy Parameters. Used in conjunction with the Label, Field1,
+ * Function, and Field2 to complete the complex and simple Rule Algorithms
+ *
+ * @return <code>List</code> the Dynamic Rule Algorithm Field1 that must contain the Field1 values in order
+ */
+ public List<String> getDynamicRuleAlgorithmField1() {
+ return dynamicRuleAlgorithmField1;
+ }
+
+ /**
+ * Sets the Dynamic Rule Algorithm Field1 used in conjunction with the Label, Field1,
+ * Function, and Field2 to complete the complex and simple Rule Algorithms
+ *
+ * @param dynamicRuleAlgorithmField1 the <code>List</code> dynamicRuleAlgorithmField1 in order
+ */
+ public void setDynamicRuleAlgorithmField1(
+ List<String> dynamicRuleAlgorithmField1) {
+ this.dynamicRuleAlgorithmField1 = dynamicRuleAlgorithmField1;
+ }
+
+ /**
+ * Gets the Dynamic Rule Algorithm Field2 of the policy Parameters. Used in conjunction with the Label, Field1,
+ * Operator, and Field2 to complete the complex and simple Rule Algorithms
+ *
+ * @return <code>List</code> the Dynamic Rule Algorithm Field2 that must contain the Field2 values in order
+ */
+ public List<String> getDynamicRuleAlgorithmField2() {
+ return dynamicRuleAlgorithmField2;
+ }
+
+ /**
+ * Sets the Dynamic Rule Algorithm Field2 used in conjunction with the Label, Field1,
+ * Function, and Field2 to complete the complex and simple Rule Algorithms
+ *
+ * @param dynamicRuleAlgorithmField2 the <code>List</code> dynamicRuleAlgorithmField2 in order
+ */
+ public void setDynamicRuleAlgorithmField2(
+ List<String> dynamicRuleAlgorithmField2) {
+ this.dynamicRuleAlgorithmField2 = dynamicRuleAlgorithmField2;
+ }
+
+ /**
+ * Gets the Priority of the Policy Parameters.
+ *
+ * @return priority the <code>String</code> format of the Micro Services priority
+ */
+ public String getPriority() {
+ return priority;
+ }
+
+ /**
+ * Sets the Priority of the Policy Parameters.
+ *
+ * @param priority the <code>String</code> format of the Micro Services priority
+ */
+ public void setPriority(String priority) {
+ this.priority = priority;
+ }
+
+ public RuleProvider getRuleProvider() {
+ return ruleProvider;
+ }
+
+ public void setRuleProvider(RuleProvider ruleProvider) {
+ this.ruleProvider = ruleProvider;
+ }
+ /**
+ * Sets the Guard field of the Policy Parameters.
+ *
+ * @param guard the <code>Boolean</code> format of the guard value
+ */
+ public void setGuard(boolean guard){
+ this.guard = guard;
+ }
+
+ /**
+ * Gets the guard value of the Policy Parameters for Action Policies.
+ *
+ * @return the <code>boolean</code> value of the Guard for Config Policies
+ */
+ public boolean getGuard(){
+ return guard;
+ }
+
+ /**
+ * Sets the riskType field of the Policy Parameters.
+ *
+ * @param guard the <code>String</code> format of the riskType value
+ */
+ public void setRiskType(String riskType){
+ this.riskType = riskType;
+ }
+
+ /**
+ * Gets the riskType value of the Policy Parameters for Config Policies.
+ *
+ * @return the <code>String</code> value of the riskType for Config Policies
+ */
+ public String getRiskType(){
+ return riskType;
+ }
+
+ /**
+ * Sets the riskLevel field of the Policy Parameters.
+ *
+ * @param riskLevel the <code>String</code> format of the riskType value
+ */
+ public void setRiskLevel(String riskLevel){
+ this.riskLevel = riskLevel;
+ }
+
+ /**
+ * Gets the riskLevel value of the Policy Parameters for Config Policies.
+ *
+ * @return the <code>String</code> value of the riskLevel for Config Policies
+ */
+ public String getRiskLevel(){
+ return riskLevel;
+ }
+
+ /**
+ * Sets the TTLDate field of the Policy Parameters.
+ *
+ * @param TTLDate the <code>Date</code> format of the TTLDate value
+ */
+ public void setTtlDate(Date TTLDate){
+ this.TTLDate = TTLDate;
+ }
+
+ /**
+ * Gets the TTLDate value of the Policy Parameters for Config Policies.
+ *
+ * @return the <code>Date</code> value of the TTLDate for Config Policies
+ */
+ public Date getTtlDate(){
+ return TTLDate;
+ }
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyResponse.java
new file mode 100644
index 000000000..316f7dd83
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyResponse.java
@@ -0,0 +1,77 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.openecomp.policy.api;
+
+import java.util.Map;
+
+/**
+ * Defines the objects that represent PolicyEngine Response elements. PolicyResponse communicates the PolicyResponseStatus,
+ * PolicyResponseMessage, ActionAdvised, ActionTaken and RequestAttributes.
+ *
+ * @version 0.3
+ */
+public interface PolicyResponse {
+ /**
+ * Gets the {@link org.openecomp.policy.api.PolicyResponseStatus} associated with this <code>PolicyResponse</code>.
+ *
+ * @return the <code>PolicyResponseStatus</code> associated with this <code>PolicyResponse</code>
+ */
+ public PolicyResponseStatus getPolicyResponseStatus();
+
+ /**
+ * Gets the <code>Map</code> of <code>String,String</code> which consists of ActionAdvised in this <code>PolicyResponse</code>.
+ * If there is no ActionAdvised this method must return an empty <code>Map</code>.
+ *
+ * @return the <code>Map</code> of <code>String,String</code> which consists of AdviceAttributes in <code>PolicyResponse</code>
+ */
+ public Map<String,String> getActionAdvised();
+
+ /**
+ * Gets the <code>Map</code> of <code>String,String</code> which consists of ActionTaken in this <code>PolicyResponse</code>.
+ * If there are no ActionTaken this method must return an empty <code>Map</code>.
+ *
+ * @return the <code>Map</code> of <code>String,String</code> which consists of ActionTaken in <code>PolicyResponse</code>
+ */
+ public Map<String,String> getActionTaken();
+
+ /**
+ * Gets the <code>Map</code> of <code>String,String</code> which consists of RequestAttributes in this <code>PolicyResponse</code>.
+ *
+ * @return the <code>Map</code> of <code>String,String</code> which consists of RequestAttributes from <code>PolicyResponse</code>
+ */
+ public Map<String,String> getRequestAttributes();
+
+ /**
+ * Gets the <code>String</code> of the PolicyResponseMessage from <code>PolicyResponse</code>
+ *
+ * @return the <code>String</code> which consists of PolicyResponseMessage from <code>PolicyResponse</code>
+ */
+ public String getPolicyResponseMessage();
+
+ /**
+ * Returns the <code>String</code> version of the <code>PolicyResponse</code> object.
+ *
+ * @return <code>String</code> of the <code>PolicyResponse</code> Object.
+ */
+ @Override
+ public String toString();
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyResponseStatus.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyResponseStatus.java
new file mode 100644
index 000000000..a9c329621
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyResponseStatus.java
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+/**
+ * Enumeration of PolicyResponseStatus that can be returned as a part of
+ * {@link org.openecomp.policy.api.PolicyResponse}.
+ *
+ * @version 0.2
+ */
+public enum PolicyResponseStatus {
+ /**
+ * Indicates there is no action required.
+ */
+ NO_ACTION_REQUIRED("no_action"),
+ /**
+ * Indicates that an action has been advised.
+ */
+ ACTION_ADVISED("action_advised"),
+ /**
+ * Indicates that an action has been taken.
+ */
+ ACTION_TAKEN("action_taken")
+ ;
+
+ private String name;
+ private PolicyResponseStatus(String name){
+ this.name = name;
+ }
+
+ /**
+ * Get the <code>PolicyResponseStatus</code> based on <code>String</code> representation of <code>PolicyResponse</code>
+ *
+ * @param responseStatus the <code>String</code> Response Status
+ * @return the <code>PolicyResponseStatus</code> with the name matching <code>ACTION_ADVISED</code> or <code>ACTION_TAKEN</code> or <code>NO_ACTION_REQUIRED</code>
+ */
+ public static PolicyResponseStatus getStatus(String responseStatus) {
+ if(responseStatus.equalsIgnoreCase("action_advised")) {
+ return ACTION_ADVISED;
+ }else if(responseStatus.equalsIgnoreCase("action_taken")) {
+ return ACTION_TAKEN;
+ }else {
+ return NO_ACTION_REQUIRED;
+ }
+ }
+
+ /**
+ * Returns the <code>String</code> name for this <code>PolicyResponseStatus</code>
+ *
+ * @return the <code>String</code> name for this <code>PolicyResponseStatus</code>
+ */
+ public String toString(){
+ return this.name;
+ }
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyType.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyType.java
new file mode 100644
index 000000000..b86f9521f
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyType.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+/**
+ * Enumeration of the Policy Return Types that can be returned as part of a
+ * {@link org.openecomp.policy.api.PolicyConfig}.
+ *
+ * @version 0.2
+ */
+public enum PolicyType {
+ /**
+ * Indicates the response is Properties type
+ */
+ PROPERTIES("Properties"),
+ /**
+ * Indicates the response is JSON type
+ */
+ JSON("json"),
+ /**
+ * Indicates the response is XML type
+ */
+ XML("xml"),
+ /**
+ * Indicates the response is Other type
+ */
+ OTHER("other")
+ ;
+
+ private String name;
+
+ private PolicyType(String typeName) {
+ this.name = typeName;
+ }
+
+ /**
+ * Returns the <code>String</code> format of Type for this <code>PolicyType</code>
+ * @return the <code>String</code> of the Type for this <code>PolicyType</code>
+ */
+ public String toString() {
+ return this.name;
+ }
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PushPolicyParameters.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PushPolicyParameters.java
new file mode 100644
index 000000000..8a822065b
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PushPolicyParameters.java
@@ -0,0 +1,131 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+import java.util.UUID;
+
+/**
+ * <code>PushPolicyParameters</code> defines the Policy Parameters
+ * which are required to Push a Policy to PDPGroup.
+ *
+ * @version 0.1
+ */
+public class PushPolicyParameters {
+ private String policyName;
+ private String policyType;
+ private String pdpGroup;
+ private UUID requestID;
+
+ /**
+ * Constructor with no Parameters.
+ */
+ public PushPolicyParameters(){
+ }
+
+ /**
+ * Constructor with Parameters.
+ *
+ * @param policyName the <code>String</code> format of the Policy Name
+ * @param policyType the <code>String</code> format of the Policy Type
+ * @param pdpGroup the <code>String</code> format of the PDPGroup
+ * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ */
+ public PushPolicyParameters(String policyName, String policyType, String pdpGroup, UUID requestID){
+ this.policyName = policyName;
+ this.policyType = policyType;
+ this.pdpGroup = pdpGroup;
+ this.requestID = requestID;
+ }
+
+ /**
+ * Gets the PolicyName of the Push Policy Parameters.
+ *
+ * @return policyName the <code>String</code> format of the Policy Name
+ */
+ public String getPolicyName() {
+ return policyName;
+ }
+
+ /**
+ * Sets the policyName of the Push Policy Parameters.
+ *
+ * @param policyName the <code>String</code> format of the Policy Name
+ */
+ public void setPolicyName(String policyName) {
+ this.policyName = policyName;
+ }
+
+ /**
+ * Gets the PolicyType of the Push Policy Parameters.
+ *
+ * @return policyType the <code>String</code> format of the Policy Type
+ */
+ public String getPolicyType() {
+ return policyType;
+ }
+
+ /**
+ * Sets the policyType of the Push Policy Parameters.
+ *
+ * @param policyType the <code>String</code> format of the Policy Type
+ */
+ public void setPolicyType(String policyType) {
+ this.policyType = policyType;
+ }
+
+ /**
+ * Gets the PDPGroup of the Push Policy Parameters.
+ *
+ * @return pdpGroup the <code>String</code> format of the PDPGroup
+ */
+ public String getPdpGroup() {
+ return pdpGroup;
+ }
+
+ /**
+ * Sets the PDPGroup of the Push Policy Parameters.
+ *
+ * @param pdpGroup the <code>String</code> format of the PDPGroup
+ */
+ public void setPdpGroup(String pdpGroup) {
+ this.pdpGroup = pdpGroup;
+ }
+
+ /**
+ * Gets the requestID of the Push Policy Parameters.
+ *
+ * @return unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ */
+ public UUID getRequestID() {
+ return requestID;
+ }
+
+ /**
+ * Sets the requestID of the Push Policy Parameters.
+ *
+ * @param requestID unique request ID which will be passed throughout the ECOMP components to correlate logging messages.
+ */
+ public void setRequestID(UUID requestID) {
+ this.requestID = requestID;
+ }
+
+
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/RuleProvider.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/RuleProvider.java
new file mode 100644
index 000000000..8e9218124
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/RuleProvider.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.api;
+
+/**
+ * Enumeration of the Attribute Types that is used as a part of
+ * {@link org.openecomp.policy.api.PolicyParameters}.
+ *
+ * @version 0.1
+ */
+public enum RuleProvider {
+ /**
+ * Indicates User will be defining the Rule information.
+ */
+ CUSTOM("Custom"),
+ /**
+ * Indicates AAF will be providing the Rule information.
+ */
+ AAF("AAF")
+ ;
+
+ private String name;
+
+ private RuleProvider(String typeName){
+ this.name = typeName;
+ }
+
+ /**
+ * Returns the <code>String</code> format of Type for this <code>AttributeType</code>
+ * @return the <code>String</code> of the Type for this <code>AttributeType</code>
+ */
+ public String toString() {
+ return this.name;
+ }
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/package-info.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/package-info.java
new file mode 100644
index 000000000..982dbb47c
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/package-info.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.openecomp.policy.api;
+
+/**
+ * org.openecomp.policy.api contains the API for the PolicyEngine ProtoType
+ *
+ * @version 0.9
+ *
+ * Changes:
+ * Addition of Notifications methods to the Client API.
+ * Combining Multiple results. and Minor changes to retrieve all policies.
+ * Retrieve config policy using policyFile Name and the matching conditions of the policy in the results.
+ * Addition of Decision policy call
+ *
+ *
+ */
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientEnd.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientEnd.java
new file mode 100644
index 000000000..3f4fe0c7e
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientEnd.java
@@ -0,0 +1,244 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.std;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.websocket.ClientEndpoint;
+import javax.websocket.DeploymentException;
+import javax.websocket.OnClose;
+import javax.websocket.OnError;
+import javax.websocket.OnMessage;
+import javax.websocket.OnOpen;
+import javax.websocket.Session;
+
+//import org.apache.log4j.Logger;
+import org.glassfish.tyrus.client.ClientManager;
+import org.openecomp.policy.api.NotificationHandler;
+import org.openecomp.policy.api.NotificationScheme;
+import org.openecomp.policy.api.NotificationType;
+import org.openecomp.policy.api.PDPNotification;
+import org.openecomp.policy.std.NotificationStore;
+import org.openecomp.policy.std.StdPDPNotification;
+
+import org.openecomp.policy.xacml.api.XACMLErrorConstants;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import org.openecomp.policy.common.logging.flexlogger.*;
+
+@ClientEndpoint
+public class AutoClientEnd {
+ private static StdPDPNotification notification = null;
+ private static StdPDPNotification oldNotification = null;
+ private static ClientManager client = null;
+ private static NotificationScheme scheme = null;
+ private static NotificationHandler handler = null;
+ private static String url = null;
+ private static Session session = null;
+ private static boolean status = false;
+ private static boolean stop = false;
+ private static boolean message = false;
+ private static boolean error = false;
+ private static Logger logger = FlexLogger.getLogger(AutoClientEnd.class.getName());
+
+ public static void setAuto(NotificationScheme scheme,
+ NotificationHandler handler) {
+ AutoClientEnd.scheme = scheme;
+ AutoClientEnd.handler = handler;
+ }
+
+ public static void setScheme(NotificationScheme scheme) {
+ AutoClientEnd.scheme = scheme;
+ }
+
+ public static boolean getStatus(){
+ return AutoClientEnd.status;
+ }
+
+ public static String getURL() {
+ return AutoClientEnd.url;
+ }
+
+ public static void start(String url) {
+ AutoClientEnd.url = url;
+ // Stop and Start needs to be done.
+ if (scheme != null && handler!=null) {
+ if (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS) || scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) {
+ if (AutoClientEnd.client == null) {
+ client = ClientManager.createClient();
+ if(url.contains("https")){
+ url = url.replaceAll("https", "wss");
+ }else {
+ url = url.replaceAll("http", "ws");
+ }
+ try {
+ logger.info("Starting Auto Notification with the PDP server : " + url);
+ client.connectToServer(AutoClientEnd.class, new URI(url + "notifications"));
+ status = true;
+ if(error){
+ // The URL's will be in Sync according to design Spec.
+ ManualClientEnd.start(AutoClientEnd.url);
+ StdPDPNotification notification = NotificationStore.getDeltaNotification((StdPDPNotification)ManualClientEnd.result(NotificationScheme.MANUAL_ALL_NOTIFICATIONS));
+ if(notification.getNotificationType()!=null){
+ if(oldNotification!=notification){
+ oldNotification= notification;
+ AutoClientEnd.notification = notification;
+ callHandler();
+ }
+ }
+ error = false;
+ }
+ //
+ } catch (DeploymentException | IOException | URISyntaxException e) {
+ logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
+ client = null;
+ status = false;
+ changeURL();
+ }
+ }
+ }
+ }
+ }
+
+ private static void changeURL(){
+ // Change the PDP if it is not Up.
+ StdPolicyEngine.rotateList();
+ start(StdPolicyEngine.getPDPURL());
+ }
+
+ public static void stop() {
+ if (client != null) {
+ client.shutdown();
+ if(session!=null){
+ try {
+ stop = true;
+ logger.info("\n Closing Auto Notification WebSocket Connection.. ");
+ session.close();
+ session = null;
+ } catch (IOException e) {
+ //
+ }
+ }
+ client = null;
+ status = false;
+ stop = false;
+ }
+ }
+
+ private static void callHandler() {
+ if (handler != null && scheme != null) {
+ if (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS)) {
+ boolean removed = false, updated = false;
+ if (notification.getRemovedPolicies() != null && !notification.getRemovedPolicies().isEmpty()) {
+ removed = true;
+ }
+ if (notification.getLoadedPolicies() != null && !notification.getLoadedPolicies().isEmpty()) {
+ updated = true;
+ }
+ if (removed && updated) {
+ notification.setNotificationType(NotificationType.BOTH);
+ } else if (removed) {
+ notification.setNotificationType(NotificationType.REMOVE);
+ } else if (updated) {
+ notification.setNotificationType(NotificationType.UPDATE);
+ }
+ try{
+ handler.notificationReceived(notification);
+ }catch (Exception e){
+ logger.error("Error in Clients Handler Object : " + e.getMessage());
+ }
+ } else if (scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) {
+ PDPNotification newNotification = MatchStore.checkMatch(notification);
+ if (newNotification.getNotificationType() != null) {
+ handler.notificationReceived(newNotification);
+ }
+ }
+ }
+ }
+
+ // WebSockets Code..
+ @OnOpen
+ public void onOpen(Session session) throws IOException {
+ // session.getBasicRemote().sendText("Connected to Client with Session: "
+ // + session.getId());
+ logger.debug("Auto Notification Session Started... " + session.getId());
+ if(AutoClientEnd.session == null){
+ AutoClientEnd.session = session;
+ }
+ }
+
+ @OnError
+ public void onError(Session session, Throwable e) {
+ // trying to Restart by self.
+ logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Session Error.. "+ session.getId() + "\n Error is : " + e );
+ // e.printStackTrace();
+ stop();
+ if (url != null) {
+ client = null;
+ status = false;
+ error= true;
+ start(url);
+ }
+ }
+
+ @OnClose
+ public void onClose(Session session) {
+ logger.info("Session ended with "+ session.getId());
+ if(!stop && !message){
+ // This Block of code is executed if there is any Network Failure or if the Notification is Down.
+ logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Disconnected from Notification Server");
+ client = null;
+ status = false;
+ AutoClientEnd.session=null;
+ // Try to connect Back to available PDP.
+ error = true;
+ start(url);
+ }
+ AutoClientEnd.message=false;
+ }
+
+ @OnMessage
+ public void onMessage(String message, Session session) throws JsonParseException, JsonMappingException, IOException {
+ AutoClientEnd.message = true;
+ logger.debug("Auto Notification Recieved Message " + message + " Session info is : " + session.getId());
+ try {
+ notification = NotificationUnMarshal.notificationJSON(message);
+ } catch (Exception e) {
+ logger.error("PE500 " + e);
+ }
+ if(AutoClientEnd.session == session){
+ try{
+ NotificationStore.recordNotification(notification);
+ }catch(Exception e){
+ logger.error(e);
+ }
+ if(oldNotification!=notification){
+ oldNotification= notification;
+ callHandler();
+ }
+ }else{
+ session.close();
+ }
+ AutoClientEnd.message = false;
+ }
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientUEB.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientUEB.java
new file mode 100644
index 000000000..87bb50154
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientUEB.java
@@ -0,0 +1,170 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.std;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.GeneralSecurityException;
+import java.util.List;
+import java.util.UUID;
+
+import org.openecomp.policy.api.NotificationHandler;
+import org.openecomp.policy.api.NotificationScheme;
+import org.openecomp.policy.api.NotificationType;
+import org.openecomp.policy.api.PDPNotification;
+import org.openecomp.policy.std.StdPDPNotification;
+
+import com.att.nsa.cambria.client.CambriaClientFactory;
+import com.att.nsa.cambria.client.CambriaConsumer;
+import org.openecomp.policy.common.logging.flexlogger.*;
+/**
+ * Create a UEB Consumer to receive policy update notification.
+ *
+ *
+ *
+ */
+public class AutoClientUEB implements Runnable {
+ private static StdPDPNotification notification = null;
+ private static NotificationScheme scheme = null;
+ private static NotificationHandler handler = null;
+ private static String url = null;
+ private static boolean status = false;
+ private static Logger logger = FlexLogger.getLogger(AutoClientUEB.class.getName());
+ private static String notficatioinType = null;
+ private static CambriaConsumer CConsumer = null;
+// private volatile boolean stop = false;
+ private static List<String> uebURLList = null;
+ public volatile boolean isRunning = false;
+
+
+ public AutoClientUEB(String url, List<String> uebURLList) {
+ AutoClientUEB.url = url;
+ AutoClientUEB.uebURLList = uebURLList;
+ }
+
+ public void setAuto(NotificationScheme scheme,
+ NotificationHandler handler) {
+ AutoClientUEB.scheme = scheme;
+ AutoClientUEB.handler = handler;
+ }
+
+ public static void setScheme(NotificationScheme scheme) {
+ AutoClientUEB.scheme = scheme;
+ }
+
+ public static boolean getStatus(){
+ return AutoClientUEB.status;
+ }
+
+ public static String getURL() {
+ return AutoClientUEB.url;
+ }
+
+ public static String getNotficationType(){
+ return AutoClientUEB.notficatioinType;
+ }
+
+ public synchronized boolean isRunning() {
+ return this.isRunning;
+ }
+
+ public synchronized void terminate() {
+ this.isRunning = false;
+ }
+ @SuppressWarnings("deprecation")
+ @Override
+ public void run() {
+ synchronized(this) {
+ this.isRunning = true;
+ }
+ String group = UUID.randomUUID ().toString ();
+ String id = "0";
+ String topic = null;
+ // Stop and Start needs to be done.
+ if (scheme != null && handler!=null) {
+ if (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS) || scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) {
+ //Check if the Notification Type is UEB t if (notficationType.equals("ueb")){
+ URL aURL;
+ try {
+ aURL = new URL(AutoClientUEB.url);
+ topic = aURL.getHost() + aURL.getPort();
+ } catch (MalformedURLException e) {
+ topic = AutoClientUEB.url.replace("[:/]", "");
+ }
+
+ //TODO create a loop to listen for messages from UEB cluster
+ try {
+ CConsumer = CambriaClientFactory.createConsumer ( null, uebURLList, topic, group, id, 15*1000, 1000 );
+ } catch (MalformedURLException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (GeneralSecurityException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ while (this.isRunning() )
+ {
+ try {
+ for ( String msg : CConsumer.fetch () )
+ {
+ logger.debug("Auto Notification Recieved Message " + msg + " from UEB cluster : " + uebURLList.toString());
+ notification = NotificationUnMarshal.notificationJSON(msg);
+ callHandler();
+ }
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ logger.debug("Error in processing UEB message");
+ }
+
+ }
+ logger.debug("Stopping UEB Consuer loop will not logger fetch messages from the cluser");
+ }
+ }
+ }
+
+ private static void callHandler() {
+ if (handler != null && scheme != null) {
+ if (scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS)) {
+ boolean removed = false, updated = false;
+ if (notification.getRemovedPolicies() != null && !notification.getRemovedPolicies().isEmpty()) {
+ removed = true;
+ }
+ if (notification.getLoadedPolicies() != null && !notification.getLoadedPolicies().isEmpty()) {
+ updated = true;
+ }
+ if (removed && updated) {
+ notification.setNotificationType(NotificationType.BOTH);
+ } else if (removed) {
+ notification.setNotificationType(NotificationType.REMOVE);
+ } else if (updated) {
+ notification.setNotificationType(NotificationType.UPDATE);
+ }
+ handler.notificationReceived(notification);
+ } else if (scheme.equals(NotificationScheme.AUTO_NOTIFICATIONS)) {
+ PDPNotification newNotification = MatchStore.checkMatch(notification);
+ if (newNotification.getNotificationType() != null) {
+ handler.notificationReceived(newNotification);
+ }
+ }
+ }
+ }
+
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEnd.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEnd.java
new file mode 100644
index 000000000..c006b057b
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEnd.java
@@ -0,0 +1,138 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.std;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.concurrent.CountDownLatch;
+
+import javax.websocket.ClientEndpoint;
+import javax.websocket.DeploymentException;
+import javax.websocket.OnClose;
+import javax.websocket.OnError;
+import javax.websocket.OnMessage;
+import javax.websocket.OnOpen;
+import javax.websocket.Session;
+
+//import org.apache.log4j.Logger;
+import org.glassfish.tyrus.client.ClientManager;
+import org.openecomp.policy.api.NotificationScheme;
+import org.openecomp.policy.api.NotificationType;
+import org.openecomp.policy.api.PDPNotification;
+import org.openecomp.policy.std.StdPDPNotification;
+
+import org.openecomp.policy.xacml.api.XACMLErrorConstants;
+
+import org.openecomp.policy.common.logging.flexlogger.*;
+
+@ClientEndpoint
+public class ManualClientEnd {
+ private static CountDownLatch latch;
+ private static StdPDPNotification notification = null;
+ private static String resultJson = null;
+ private static Logger logger = FlexLogger.getLogger(ManualClientEnd.class.getName());
+
+ public static void start(String url) {
+ latch = new CountDownLatch(1);
+ ClientManager client = ClientManager.createClient();
+ if(url.contains("https")){
+ url = url.replaceAll("https", "wss");
+ }else {
+ url = url.replaceAll("http", "ws");
+ }
+ try {
+ client.connectToServer(ManualClientEnd.class, new URI(url+"notifications"));
+ latch.await();
+ } catch (DeploymentException | URISyntaxException | InterruptedException e) {
+ logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
+ } catch (IOException e) {
+ logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
+ }
+ }
+
+ public static PDPNotification result(NotificationScheme scheme) {
+ if (resultJson == null || notification == null) {
+ logger.debug("No Result" );
+ return null;
+ } else {
+ if(scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)) {
+ boolean removed = false, updated = false;
+ if(notification.getRemovedPolicies()!=null && !notification.getRemovedPolicies().isEmpty()){
+ removed = true;
+ }
+ if(notification.getLoadedPolicies()!=null && !notification.getLoadedPolicies().isEmpty()){
+ updated = true;
+ }
+ if(removed && updated) {
+ notification.setNotificationType(NotificationType.BOTH);
+ }else if(removed){
+ notification.setNotificationType(NotificationType.REMOVE);
+ }else if(updated){
+ notification.setNotificationType(NotificationType.UPDATE);
+ }
+ return notification;
+ }else if(scheme.equals(NotificationScheme.MANUAL_NOTIFICATIONS)) {
+ return MatchStore.checkMatch(notification);
+ }else {
+ return null;
+ }
+ }
+ }
+
+ // WebSockets Code..
+ @OnOpen
+ public void onOpen(Session session) throws IOException {
+ logger.info("Session Started with : " + session.getId());
+ session.getBasicRemote().sendText("Manual");
+ }
+
+ @OnError
+ public void onError(Session session, Throwable e) {
+ logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error in: "+ session.getId());
+ latch.countDown();
+ }
+
+ @OnClose
+ public void onClose(Session session) {
+ logger.info("Session ended with "+ session.getId());
+ latch.countDown();
+ }
+
+ @OnMessage
+ public void onMessage(String message, Session session){
+ logger.debug(" Manual Notification Recieved Message : " + message +" Session info is : "+ session.getId());
+ resultJson = message;
+ try {
+ notification = NotificationUnMarshal.notificationJSON(message);
+ } catch (Exception e) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
+ latch.countDown();
+ }
+ try {
+ session.close();
+ } catch (IOException e) {
+ logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
+ latch.countDown();
+ } // For Manual Client..
+ latch.countDown();
+ }
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndUEB.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndUEB.java
new file mode 100644
index 000000000..b1962bc77
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndUEB.java
@@ -0,0 +1,173 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.std;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.security.GeneralSecurityException;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.CountDownLatch;
+
+//import org.apache.log4j.Logger;
+import org.json.JSONObject;
+import org.openecomp.policy.api.NotificationScheme;
+import org.openecomp.policy.api.NotificationType;
+import org.openecomp.policy.api.PDPNotification;
+import org.openecomp.policy.std.StdPDPNotification;
+
+import com.att.nsa.cambria.client.CambriaClientFactory;
+import com.att.nsa.cambria.client.CambriaConsumer;
+import com.att.nsa.cambria.client.CambriaPublisher;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import org.openecomp.policy.common.logging.flexlogger.*;
+
+
+public class ManualClientEndUEB {
+ private static StdPDPNotification notification = null;
+ private static String resultJson = null;
+ private static Logger logger = FlexLogger.getLogger(ManualClientEndUEB.class.getName());
+ private static CambriaConsumer CConsumer = null;
+ private static List<String> uebURLList = null;
+ private static boolean messageNotReceived = false;
+ private static String url = null;
+ private static String uniquID = null;
+ private static String topic = null;
+
+
+ public static PDPNotification result(NotificationScheme scheme) {
+ if (resultJson == null || notification == null) {
+ logger.debug("No Result" );
+ return null;
+ } else {
+ if(scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)) {
+ boolean removed = false, updated = false;
+ if(notification.getRemovedPolicies()!=null && !notification.getRemovedPolicies().isEmpty()){
+ removed = true;
+ }
+ if(notification.getLoadedPolicies()!=null && !notification.getLoadedPolicies().isEmpty()){
+ updated = true;
+ }
+ if(removed && updated) {
+ notification.setNotificationType(NotificationType.BOTH);
+ }else if(removed){
+ notification.setNotificationType(NotificationType.REMOVE);
+ }else if(updated){
+ notification.setNotificationType(NotificationType.UPDATE);
+ }
+ return notification;
+ }else if(scheme.equals(NotificationScheme.MANUAL_NOTIFICATIONS)) {
+ return MatchStore.checkMatch(notification);
+ }else {
+ return null;
+ }
+ }
+ }
+
+ private static void publishMessage(String pubTopic, String uniqueID , List<String> uebURLList) {
+
+ String UEBlist = uebURLList.toString();
+ UEBlist = UEBlist.substring(1,UEBlist.length()-1);
+ CambriaPublisher pub = null;
+ try {
+ pub = CambriaClientFactory.createSimplePublisher(null, UEBlist, pubTopic);
+ } catch (MalformedURLException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (GeneralSecurityException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ final JSONObject msg1 = new JSONObject ();
+
+ msg1.put ( "JSON", "UEB Update Ruest UID=" + uniqueID);
+
+ try {
+ pub.send ( "MyPartitionKey", msg1.toString () );
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ pub.close ();
+
+ }
+
+ public static void createTopic (String url, String uniquID, List<String> uebURLList){
+ URL aURL;
+ try {
+ aURL = new URL(url);
+ topic = aURL.getHost() + aURL.getPort();
+ } catch (MalformedURLException e) {
+ topic = url.replace("[:/]", "");
+ }
+
+ publishMessage(topic+ uniquID , uniquID, uebURLList);
+
+ }
+ public static void start(String url, List<String> uebURLList,
+ String uniqueID) {
+ ManualClientEndUEB.uebURLList = uebURLList;
+ ManualClientEndUEB.url = url;
+ ManualClientEndUEB.uniquID = uniqueID;
+ URL aURL;
+ try {
+ aURL = new URL(url);
+ ManualClientEndUEB.topic = aURL.getHost() + aURL.getPort();
+ } catch (MalformedURLException e) {
+ ManualClientEndUEB.topic = url.replace("[:/]", "");
+ }
+ String id = "0";
+ try {
+ CConsumer = CambriaClientFactory.createConsumer ( null, uebURLList, topic + uniquID, "clientGroup", id, 15*1000, 1000 );
+ } catch (MalformedURLException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (GeneralSecurityException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ int count = 1;
+ while (count < 4) {
+ publishMessage(topic + "UpdateRequest", uniquID, uebURLList);
+ try {
+ for ( String msg : CConsumer.fetch () )
+ {
+
+ logger.debug("Manual Notification Recieved Message " + msg + " from UEB cluster : " + uebURLList.toString());
+ resultJson = msg;
+ if (!msg.contains("UEB Update")){
+// System.out.println("Manual Notification Recieved Message " + msg + " from UEB cluster : " + uebURLList.toString());
+ notification = NotificationUnMarshal.notificationJSON(msg);
+ count = 4;
+ }
+ }
+ }catch (Exception e) {
+
+ }
+ count++;
+ }
+ }
+
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/MatchStore.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/MatchStore.java
new file mode 100644
index 000000000..2c06b9a9e
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/MatchStore.java
@@ -0,0 +1,246 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.std;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.openecomp.policy.api.LoadedPolicy;
+import org.openecomp.policy.api.NotificationType;
+import org.openecomp.policy.api.PDPNotification;
+import org.openecomp.policy.api.RemovedPolicy;
+import org.openecomp.policy.std.StdLoadedPolicy;
+import org.openecomp.policy.std.StdPDPNotification;
+import org.openecomp.policy.std.StdRemovedPolicy;
+
+import org.openecomp.policy.common.logging.flexlogger.*;
+
+public class MatchStore {
+ private static HashSet<Matches> matchStore = new HashSet<Matches>();
+ private static Logger logger = FlexLogger.getLogger(MatchStore.class.getName());
+
+ public static HashSet<Matches> getMatchStore() {
+ return matchStore;
+ }
+
+ public static void storeMatch(Matches newMatch){
+ // Initialization..
+ if(newMatch!=null){
+ if(matchStore.isEmpty()){
+ matchStore.add(newMatch);
+ }else{
+ // Check if it is a new Match
+ Boolean match = false;
+ for(Matches oldMatch: matchStore){
+ // Compare ECOMPName
+ if(oldMatch.getEcompName().equals(newMatch.getEcompName())){
+ // Compare ConfigName if it exists.
+ if(newMatch.getConfigName()!=null && oldMatch.getConfigName()!=null){
+ if(oldMatch.getConfigName().equals(newMatch.getConfigName())){
+ // Compare the Config Attributes if they exist.
+ if(newMatch.getConfigAttributes()!= null && oldMatch.getConfigAttributes()!=null) {
+ //Simple thing would be comparing their size.
+ if(newMatch.getConfigAttributes().size()==oldMatch.getConfigAttributes().size()){
+ // Now need to compare each of them..
+ int count= 0;
+ for(String oldkey: oldMatch.getConfigAttributes().keySet()){
+ boolean check = false;
+ for(String newKey: newMatch.getConfigAttributes().keySet()){
+ if(oldkey.equals(newKey)){
+ if(oldMatch.getConfigAttributes().get(oldkey).equals(newMatch.getConfigAttributes().get(newKey))){
+ check = true;
+ }
+ }
+ }
+ if(check){
+ count++;
+ }else{
+ break;
+ }
+ }
+ if(count==oldMatch.getConfigAttributes().size()){
+ match = true;
+ break;
+ }
+ }
+ }else if(newMatch.getConfigAttributes()== null && oldMatch.getConfigAttributes()==null){
+ match = true;
+ break;
+ }
+ }
+ }else if(newMatch.getConfigName()==null && oldMatch.getConfigName()==null){
+ match = true;
+ break;
+ }
+ }
+
+ }
+ // IF not a match then add it to the MatchStore
+ if(match==false){
+ matchStore.add(newMatch);
+ }
+ }
+ }
+ }
+
+ //TODO Logic changes for Requested Policies notifications..
+ public static PDPNotification checkMatch(PDPNotification oldNotification) {
+ boolean removed = false, updated = false;
+ if(oldNotification==null){
+ return null;
+ }
+ StdPDPNotification newNotification = new StdPDPNotification();
+ if(matchStore.isEmpty()) {
+ logger.debug("No Success Config Calls made yet.. ");
+ System.out.println("No success Config calls made yet. ");
+ return null;
+ }
+ if(oldNotification.getRemovedPolicies()!=null && !oldNotification.getRemovedPolicies().isEmpty()){
+ // send all removed policies to client.
+ Collection<StdRemovedPolicy> removedPolicies = new HashSet<StdRemovedPolicy>();
+ StdRemovedPolicy newRemovedPolicy;
+ for(RemovedPolicy removedPolicy: oldNotification.getRemovedPolicies()){
+ newRemovedPolicy = new StdRemovedPolicy();
+ newRemovedPolicy.setPolicyName(removedPolicy.getPolicyName());
+ newRemovedPolicy.setVersionNo(removedPolicy.getVersionNo());
+ removedPolicies.add(newRemovedPolicy);
+ }
+ newNotification.setRemovedPolicies(removedPolicies);
+ removed = true;
+ }
+ if(oldNotification.getLoadedPolicies()!=null && !oldNotification.getLoadedPolicies().isEmpty()){
+ Collection<StdLoadedPolicy> updatedPolicies = new HashSet<StdLoadedPolicy>();
+ StdLoadedPolicy newUpdatedPolicy;
+ for(LoadedPolicy updatedPolicy: oldNotification.getLoadedPolicies()){
+ // if it is config policies check their matches..
+ if(updatedPolicy.getMatches()!=null && !updatedPolicy.getMatches().isEmpty()){
+ boolean matched = false;
+ for(Matches match : matchStore){
+ matched = false;
+ // Again Better way would be comparing sizes first.
+ // Matches are different need to check if has configAttributes
+ if(match.getConfigAttributes()!=null && !match.getConfigAttributes().isEmpty()){
+ // adding ecomp and config to config-attributes.
+ int compValues = match.getConfigAttributes().size() + 2;
+ if(updatedPolicy.getMatches().size()== compValues){
+ // Comparing both the values..
+ boolean matchAttributes = false;
+ for(String newKey: updatedPolicy.getMatches().keySet()){
+ if(newKey.equals("ECOMPName")){
+ if(updatedPolicy.getMatches().get(newKey).equals(match.getEcompName())){
+ matchAttributes = true;
+ }else {
+ matchAttributes = false;
+ break;
+ }
+ }else if(newKey.equals("ConfigName")) {
+ if(updatedPolicy.getMatches().get(newKey).equals(match.getConfigName())){
+ matchAttributes = true;
+ }else{
+ matchAttributes = false;
+ break;
+ }
+ }else {
+ if(match.getConfigAttributes().containsKey(newKey)){
+ if(updatedPolicy.getMatches().get(newKey).equals(match.getConfigAttributes().get(newKey))){
+ matchAttributes = true;
+ }else{
+ matchAttributes = false;
+ break;
+ }
+ }else{
+ matchAttributes = false;
+ break;
+ }
+ }
+ }
+ if(matchAttributes){
+ // Match..
+ matched = true;
+ }else{
+ break;
+ }
+ }else {
+ break;
+ }
+ }else if(match.getConfigName()!=null){
+ // If there are no config Attributes then check if it has Config Name
+ if(updatedPolicy.getMatches().size()== 2){
+ if(updatedPolicy.getMatches().get("ECOMPName").equals(match.getEcompName())){
+ if(updatedPolicy.getMatches().get("ConfigName").equals(match.getConfigName())){
+ // Match..
+ matched = true;
+ }else{
+ break;
+ }
+ }else {
+ break;
+ }
+ }else{
+ break;
+ }
+ }else {
+ // If non exist then assuming the ECOMP Name to be there.
+ if(updatedPolicy.getMatches().size()== 1){
+ if(updatedPolicy.getMatches().get("ECOMPName").equals(match.getEcompName())){
+ // Match..
+ matched = true;
+ }else {
+ break;
+ }
+ }else{
+ break;
+ }
+ }
+ // Add logic to add the policy.
+ if(matched){
+ newUpdatedPolicy = new StdLoadedPolicy();
+ newUpdatedPolicy.setPolicyName(updatedPolicy.getPolicyName());
+ newUpdatedPolicy.setVersionNo(updatedPolicy.getVersionNo());
+ newUpdatedPolicy.setMatches(updatedPolicy.getMatches());
+ updatedPolicies.add(newUpdatedPolicy);
+ updated = true;
+ }
+ }
+
+ }else {
+ //send all non config notifications to client.
+ newUpdatedPolicy = new StdLoadedPolicy();
+ newUpdatedPolicy.setPolicyName(updatedPolicy.getPolicyName());
+ newUpdatedPolicy.setVersionNo(updatedPolicy.getVersionNo());
+ updatedPolicies.add(newUpdatedPolicy);
+ updated = true;
+ }
+ }
+ newNotification.setLoadedPolicies(updatedPolicies);
+ }
+ // Need to set the type of Update..
+ if(removed && updated) {
+ newNotification.setNotificationType(NotificationType.BOTH);
+ }else if(removed){
+ newNotification.setNotificationType(NotificationType.REMOVE);
+ }else if(updated){
+ newNotification.setNotificationType(NotificationType.UPDATE);
+ }
+ return newNotification;
+ }
+
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/Matches.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/Matches.java
new file mode 100644
index 000000000..8e6a8ee97
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/Matches.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.std;
+
+import java.util.Map;
+
+public class Matches {
+ private String ecompName = null;
+ private String configName = null;
+ private Map<String,String> configAttributes = null;
+ public String getEcompName() {
+ return ecompName;
+ }
+ public void setEcompName(String ecompName) {
+ this.ecompName = ecompName;
+ }
+ public String getConfigName() {
+ return configName;
+ }
+ public void setConfigName(String configName) {
+ this.configName = configName;
+ }
+ public Map<String,String> getConfigAttributes() {
+ return configAttributes;
+ }
+ public void setConfigAttributes(Map<String,String> configAttributes) {
+ this.configAttributes = configAttributes;
+ }
+
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/NotificationUnMarshal.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/NotificationUnMarshal.java
new file mode 100644
index 000000000..a09391baf
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/NotificationUnMarshal.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.std;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.openecomp.policy.api.LoadedPolicy;
+import org.openecomp.policy.api.RemovedPolicy;
+import org.openecomp.policy.api.UpdateType;
+import org.openecomp.policy.std.StdLoadedPolicy;
+import org.openecomp.policy.std.StdPDPNotification;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class NotificationUnMarshal {
+ private static StdPDPNotification notification;
+
+ public static StdPDPNotification notificationJSON(String json) throws Exception{
+ ObjectMapper mapper = new ObjectMapper();
+ notification = mapper.readValue(json, StdPDPNotification.class);
+ if(notification!=null){
+ if(notification.getLoadedPolicies()!=null){
+ Collection<StdLoadedPolicy> stdLoadedPolicies = new ArrayList<StdLoadedPolicy>();
+ for(LoadedPolicy loadedPolicy: notification.getLoadedPolicies()){
+ StdLoadedPolicy stdLoadedPolicy = (StdLoadedPolicy) loadedPolicy;
+ if(notification.getRemovedPolicies()!=null){
+ Boolean updated = false;
+ for(RemovedPolicy removedPolicy: notification.getRemovedPolicies()){
+ String regex = ".(\\d)*.xml";
+ if(removedPolicy.getPolicyName().replaceAll(regex, "").equals(stdLoadedPolicy.getPolicyName().replaceAll(regex, ""))){
+ updated = true;
+ break;
+ }
+ }
+ if(updated){
+ stdLoadedPolicy.setUpdateType(UpdateType.UPDATE);
+ }else{
+ stdLoadedPolicy.setUpdateType(UpdateType.NEW);
+ }
+ }else{
+ stdLoadedPolicy.setUpdateType(UpdateType.NEW);
+ }
+ stdLoadedPolicies.add(stdLoadedPolicy);
+ }
+ notification.setLoadedPolicies(stdLoadedPolicies);
+ }
+ }
+ return notification;
+ }
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdDecisionResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdDecisionResponse.java
new file mode 100644
index 000000000..1f4cf65d0
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdDecisionResponse.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.openecomp.policy.std;
+
+import org.openecomp.policy.api.DecisionResponse;
+import org.openecomp.policy.api.PolicyDecision;
+
+/**
+ * Decision Response Implementation Class.
+ *
+ * @version 0.1
+ */
+public class StdDecisionResponse implements DecisionResponse {
+
+ private PolicyDecision decision = PolicyDecision.DENY;
+ private String details;
+
+ @Override
+ public PolicyDecision getDecision() {
+ return decision;
+ }
+
+ @Override
+ public String getDetails() {
+ return details;
+ }
+
+ public void setDecision(PolicyDecision decision){
+ this.decision = decision;
+ }
+
+ public void setDetails(String details) {
+ this.details = details;
+ }
+
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyChangeResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyChangeResponse.java
new file mode 100644
index 000000000..2fec8605c
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyChangeResponse.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.std;
+
+import org.openecomp.policy.api.PolicyChangeResponse;
+
+public class StdPolicyChangeResponse implements PolicyChangeResponse{
+ private String responseMessage = null;
+ private int responseCode;
+
+ @Override
+ public String getResponseMessage() {
+ return responseMessage;
+ }
+
+ @Override
+ public int getResponseCode() {
+ return responseCode;
+ }
+
+ public void setResponseMessage(String responseMessage){
+ this.responseMessage = responseMessage;
+ }
+
+ public void setResponseCode(int responseCode){
+ this.responseCode = responseCode;
+ }
+
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyConfig.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyConfig.java
new file mode 100644
index 000000000..ec205dab2
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyConfig.java
@@ -0,0 +1,168 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.openecomp.policy.std;
+
+import java.util.Map;
+import java.util.Properties;
+
+import javax.json.JsonObject;
+
+import org.openecomp.policy.api.PolicyConfig;
+import org.openecomp.policy.api.PolicyConfigStatus;
+import org.openecomp.policy.api.PolicyType;
+import org.w3c.dom.Document;
+
+/**
+ * PolicyConfig Implementation.
+ *
+ * @version 0.3
+ *
+ */
+
+public class StdPolicyConfig implements PolicyConfig{
+ private PolicyType policyType;
+ private Properties properties;
+ private JsonObject jsonObject;
+ private Document document;
+ private String other;
+ private PolicyConfigStatus policyConfigStatus;
+ private String configStatus;
+ private String policyName;
+ private String policyVersion;
+ private Map<String,String> matchingConditions;
+ private Map<String,String> responseAttributes;
+
+ @Override
+ public PolicyType getType() {
+ return policyType;
+ }
+
+ @Override
+ public Properties toProperties() {
+ return properties;
+ }
+
+ @Override
+ public JsonObject toJSON() {
+ return jsonObject;
+ }
+
+ @Override
+ public Document toXML() {
+ return document;
+ }
+
+ @Override
+ public String toOther() {
+ return other;
+ }
+
+ @Override
+ public PolicyConfigStatus getPolicyConfigStatus() {
+ return policyConfigStatus;
+ }
+
+ @Override
+ public String getPolicyConfigMessage() {
+ return configStatus;
+ }
+
+ @Override
+ public String getPolicyName() {
+ if(policyName!=null && policyName.contains(".xml")){
+ return (policyName.substring(0, policyName.substring(0, policyName.lastIndexOf(".")).lastIndexOf(".")));
+ }
+ return policyName;
+ }
+
+ @Override
+ public String getPolicyVersion() {
+ return policyVersion;
+ }
+
+ @Override
+ public Map<String,String> getMatchingConditions(){
+ return matchingConditions;
+ }
+
+ @Override
+ public Map<String,String> getResponseAttributes(){
+ return responseAttributes;
+ }
+
+ public void setPolicyType(PolicyType policyType) {
+ this.policyType = policyType;
+ }
+
+ public void setPolicyName(String policyName) {
+ this.policyName = policyName;
+ }
+
+ public void setPolicyVersion(String policyVersion) {
+ this.policyVersion = policyVersion;
+ }
+
+ public void setProperties(Properties properties) {
+ this.properties = properties;
+ }
+
+ public void setJsonObject(JsonObject jsonObject) {
+ this.jsonObject = jsonObject;
+ }
+
+ public void setDocument(Document document) {
+ this.document = document;
+ }
+
+ public void setOther(String other) {
+ this.other = other;
+ }
+
+ public void setConfigStatus(String configStatus) {
+ this.configStatus = configStatus;
+ }
+
+ public void setPolicyConfigStatus(PolicyConfigStatus policyConfigStatus) {
+ this.policyConfigStatus = policyConfigStatus;
+ }
+
+ public void setConfigStatus(String configStatus, PolicyConfigStatus policyConfigStatus) {
+ this.configStatus = configStatus;
+ this.policyConfigStatus = policyConfigStatus;
+ }
+
+ public void setMatchingConditions(Map<String,String> matchingConditions){
+ this.matchingConditions = matchingConditions;
+ }
+
+ public void setResponseAttributes(Map<String,String> responseAttributes){
+ this.responseAttributes = responseAttributes;
+ }
+
+ @Override
+ public String toString() {
+ return "PolicyConfig [ policyConfigStatus=" + policyConfigStatus + ", policyConfigMessage=" + configStatus + ", policyName=" + policyName +
+ ""
+ + "]";
+ }
+
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyEngine.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyEngine.java
new file mode 100644
index 000000000..11e4e4f5c
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyEngine.java
@@ -0,0 +1,4227 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.openecomp.policy.std;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.StringReader;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.UUID;
+
+import javax.json.Json;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+import javax.json.JsonReader;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.http.entity.ContentType;
+//import org.apache.log4j.Logger;
+import org.json.JSONObject;
+import org.openecomp.policy.api.AttributeType;
+import org.openecomp.policy.api.ConfigRequestParameters;
+import org.openecomp.policy.api.DecisionRequestParameters;
+import org.openecomp.policy.api.DecisionResponse;
+import org.openecomp.policy.api.DeletePolicyParameters;
+import org.openecomp.policy.api.DictionaryParameters;
+import org.openecomp.policy.api.EventRequestParameters;
+import org.openecomp.policy.api.ImportParameters;
+import org.openecomp.policy.api.NotificationHandler;
+import org.openecomp.policy.api.NotificationScheme;
+import org.openecomp.policy.api.PDPNotification;
+import org.openecomp.policy.api.PolicyChangeResponse;
+import org.openecomp.policy.api.PolicyClass;
+import org.openecomp.policy.api.PolicyConfig;
+import org.openecomp.policy.api.PolicyConfigException;
+import org.openecomp.policy.api.PolicyConfigStatus;
+import org.openecomp.policy.api.PolicyConfigType;
+import org.openecomp.policy.api.PolicyDecision;
+import org.openecomp.policy.api.PolicyDecisionException;
+import org.openecomp.policy.api.PolicyEngineException;
+import org.openecomp.policy.api.PolicyEventException;
+import org.openecomp.policy.api.PolicyParameters;
+import org.openecomp.policy.api.PolicyResponse;
+import org.openecomp.policy.api.PolicyResponseStatus;
+import org.openecomp.policy.api.PolicyType;
+import org.openecomp.policy.api.PushPolicyParameters;
+import org.openecomp.policy.api.RuleProvider;
+//import org.openecomp.policy.utils.AAFPolicyClient;
+//import org.openecomp.policy.utils.AAFPolicyException;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
+
+import com.att.research.xacml.api.Advice;
+import com.att.research.xacml.api.AttributeAssignment;
+import com.att.research.xacml.api.Decision;
+import com.att.research.xacml.api.Obligation;
+import com.att.research.xacml.api.Request;
+import com.att.research.xacml.api.Response;
+import com.att.research.xacml.api.Result;
+import org.openecomp.policy.xacml.api.XACMLErrorConstants;
+import org.openecomp.policy.xacml.std.pap.StdPAPPolicy;
+import org.openecomp.policy.xacml.std.pap.StdPDPPolicy;
+
+import com.att.research.xacml.api.pap.PAPException;
+import com.att.research.xacml.api.pap.PDPPolicy;
+import com.att.research.xacml.std.json.JSONRequest;
+import com.att.research.xacml.std.json.JSONResponse;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.CharMatcher;
+
+
+
+/**
+ * PolicyEngine Implementation class
+ *
+ * @version 1.0
+ */
+public class StdPolicyEngine {
+ // Change the default Priority value here.
+ private static final int defaultPriority = 9999;
+
+ private String propertyFilePath = null;
+ private static List<String> pdps = null;
+ private static List<String> paps = null;
+ private static String environment= null;
+ private static String userName = null;
+ private static String pass = null;
+ private static List<String> encoding = null;
+ private static List<String> encodingPAP = null;
+ private List<String> pdp_default = null;
+ private List<String> pap_default = null;
+ private List<String> type_default = null;
+ private List<String> notificationType = new ArrayList<String>();
+ private List<String> uebURLList = new ArrayList<String>();
+ private NotificationScheme scheme = null;
+ private NotificationHandler handler = null;
+ private Matches match = null;
+ private Boolean decide = false;
+ private AutoClientUEB UEBClientThread = null;
+ private Thread registerUEBThread = null;
+ private boolean UEBThread = false;
+ private String policyId = null;
+ private String description = null;
+ private String pushVersion = null;
+ private boolean isValid = false;
+ private int responseCode = 0;
+ private boolean unique = false;
+ private boolean junit = false;
+ //private AAFPolicyClient aafClient = null;
+ // Backward code.
+ private String pyPDPClientFile = null;
+
+ final private static String uniqueID = UUID.randomUUID ().toString ();
+
+ private static Logger logger = FlexLogger.getLogger(StdPolicyConfig.class.getName());
+
+ /*
+ * Taking the Property file even if it null.
+ */
+ public StdPolicyEngine(String propertyFilePath)
+ throws PolicyEngineException {
+ setProperty(propertyFilePath);
+ }
+
+ /*
+ * Taking the Notification Constructor.
+ */
+ public StdPolicyEngine(String propertyFilePath, NotificationScheme scheme,
+ NotificationHandler handler) throws PolicyEngineException {
+ setProperty(propertyFilePath);
+ this.scheme = scheme;
+ this.handler = handler;
+ if (!notificationType.get(0).equals("ueb")){
+ AutoClientEnd.setAuto(scheme, handler);
+ }
+ notification(scheme, handler);
+ }
+
+ /*
+ * Taking the Notification Constructor.
+ */
+ public StdPolicyEngine(String propertyFilePath, NotificationScheme scheme)
+ throws PolicyEngineException {
+ setProperty(propertyFilePath);
+ this.scheme = scheme;
+ setScheme(scheme);
+ }
+
+ // This Call will be used by PyPDP Requests
+ public StdPolicyEngine(List<String> configURL, List<String> configPapURL, List<String> encodingPAP, List<String> encoding, NotificationScheme scheme, NotificationHandler handler, String environment, String clientProperties, Boolean isTest) {
+ StdPolicyEngine.pdps = configURL;
+ StdPolicyEngine.paps = configPapURL;
+ StdPolicyEngine.encoding = encoding;
+ StdPolicyEngine.encodingPAP = encodingPAP;
+ StdPolicyEngine.environment = environment;
+ Properties props = new Properties();
+ props.setProperty("ENVIRONMENT", environment);
+ //Not Supported for 1610 Open Source
+ /*try {
+ aafClient = AAFPolicyClient.getInstance(props);
+ } catch (AAFPolicyException e) {
+ logger.error(XACMLErrorConstants.ERROR_UNKNOWN + e.getMessage());
+ }*/
+ pyPDPClientFile = clientProperties;
+ // Default Notification Type for PyPDPServers.
+ notificationType.add("websocket");
+ if(!isTest){
+ notification(scheme, handler);
+ }
+ }
+
+ /*
+ * sendEvent API Implementation
+ */
+ public Collection<PolicyResponse> event(Map<String, String> eventAttributes, UUID requestID)
+ throws PolicyEventException {
+ Collection<PolicyResponse> policyResponse = null;
+ policyResponse = event(eventAttributes, requestID, userName, pass);
+ return policyResponse;
+ }
+
+ /*
+ * sendEvent API Implementation for eventRequestParameters
+ */
+ public Collection<PolicyResponse> event(EventRequestParameters eventRequestParameters) throws PolicyEventException{
+ Collection<PolicyResponse> response = event(eventRequestParameters.getEventAttributes(), eventRequestParameters.getRequestID());
+ return response;
+ }
+
+ /*
+ * getConfig API Implementation
+ */
+ public Collection<PolicyConfig> config(String eCOMPComponentName,
+ String configName, Map<String, String> configAttributes, UUID requestID)
+ throws PolicyConfigException {
+ Collection<PolicyConfig> policyConfig = null;
+ policyConfig = config(eCOMPComponentName, configName, configAttributes, requestID, userName, pass);
+ return policyConfig;
+ }
+
+ /*
+ * getConfig API Implementation
+ */
+ public Collection<PolicyConfig> config(String eCOMPComponentName,
+ String configName, UUID requestID) throws PolicyConfigException {
+ Collection<PolicyConfig> policyConfig = null;
+ policyConfig = config(eCOMPComponentName, configName,null, requestID, userName, pass);
+ return policyConfig;
+ }
+
+ /*
+ * getConfig API Implementation
+ */
+ public Collection<PolicyConfig> config(String eCOMPComponentName, UUID requestID)
+ throws PolicyConfigException {
+ Collection<PolicyConfig> policyConfig = null;
+ policyConfig = config(eCOMPComponentName, requestID, userName, pass);
+ return policyConfig;
+ }
+
+ /*
+ * getConfig using the PolicyFileName Implementation
+ */
+ public Collection<PolicyConfig> policyName(String policyName, UUID requestID)
+ throws PolicyConfigException {
+ Collection<PolicyConfig> policyConfig = null;
+ policyConfig = configPolicyName(policyName, requestID, userName, pass);
+ return policyConfig;
+ }
+
+ /*
+ * getConfig using configRequestParameters Implementation
+ */
+ public Collection<PolicyConfig> config(ConfigRequestParameters configRequestParameters) throws PolicyConfigException{
+ Collection<PolicyConfig> response = null;
+ response = configRequest(configRequestParameters, userName, pass);
+ return response;
+ }
+
+ /*
+ * listPolicies using configRequestParameters Implementation
+ */
+ public Collection<String> listConfig(ConfigRequestParameters listPolicyRequestParameters) throws PolicyConfigException{
+ Collection<String> policyList = new ArrayList<String>();
+ policyList = listConfigRequest(listPolicyRequestParameters, userName, pass);
+ return policyList;
+ }
+
+ /*
+ * getDecision using the decision Attributes.
+ */
+ public DecisionResponse decide(String eCOMPComponentName,
+ Map<String, String> decisionAttributes, UUID requestID)
+ throws PolicyDecisionException {
+ DecisionResponse policyDecision = policyDecide(eCOMPComponentName,
+ decisionAttributes, requestID, userName, pass);
+ return policyDecision;
+ }
+
+ /*
+ * getDecision Using decisionRequestParameters.
+ */
+ public DecisionResponse decide(DecisionRequestParameters decisionRequestParameters) throws PolicyDecisionException{
+ DecisionResponse decision = decide(decisionRequestParameters.getECOMPComponentName(), decisionRequestParameters.getDecisionAttributes(), decisionRequestParameters.getRequestID());
+ return decision;
+ }
+
+ /*
+ * PushPolicy using pushPolicyParameters.
+ */
+ public PolicyChangeResponse pushPolicy(PushPolicyParameters pushPolicyParameters) throws Exception{
+ return pushPolicy(pushPolicyParameters, userName, pass);
+ }
+
+ public PolicyChangeResponse pushPolicy(PushPolicyParameters pushPolicyParameters, String userID, String passcode) throws Exception{
+ StdPolicyChangeResponse response = new StdPolicyChangeResponse();
+ String resource= "pushPolicy";
+ if(!checkPermissions(userID, passcode, resource)){
+ logger.error(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ response.setResponseMessage(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ response.setResponseCode(401);
+ return response;
+ }
+ String plainName = null;
+ String scope = null;
+ try{
+ if(pushPolicyParameters.getPolicyName()!=null){
+ plainName = pushPolicyParameters.getPolicyName().substring(pushPolicyParameters.getPolicyName().lastIndexOf(".")+1, pushPolicyParameters.getPolicyName().length());
+ scope = pushPolicyParameters.getPolicyName().substring(0, pushPolicyParameters.getPolicyName().lastIndexOf("."));
+ logger.info("Name is "+ plainName +" scope is "+ scope);
+ }
+ }catch(Exception e){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.");
+ response.setResponseMessage(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.");
+ }
+
+ // check incoming requestID, if null then generate one here so the same id can be used for the multiple transactions for the same Push Policy request (i.e. POST, PUT)
+ UUID requestID = pushPolicyParameters.getRequestID();
+ if (requestID == null) {
+ requestID = UUID.randomUUID();
+ logger.info("Request ID was not provided from input, so sending generated ID: " + requestID.toString());
+ } else {
+ logger.info("Request ID was provided from input: " + requestID.toString());
+ }
+ // now use the local requestID field derived above to pass to the rest of the Push Policy process (below)
+ // response.setResponseMessage(pushPolicy(scope, plainName, pushPolicyParameters.getPolicyType(), pushPolicyParameters.getPdpGroup(), pushPolicyParameters.getRequestID()));
+ response.setResponseMessage(pushPolicy(scope, plainName, pushPolicyParameters.getPolicyType(), pushPolicyParameters.getPdpGroup(), requestID));
+ response.setResponseCode(responseCode);
+ return response;
+ }
+
+ /*
+ * Delete a Policy using deletePolicyParameters
+ */
+ public PolicyChangeResponse deletePolicy(DeletePolicyParameters parameters) throws Exception {
+ return deletePolicy(parameters, userName, pass);
+ }
+
+ public PolicyChangeResponse deletePolicy(DeletePolicyParameters parameters, String userID,String passcode) throws Exception {
+ StdPolicyChangeResponse response = new StdPolicyChangeResponse();
+ String resource= "deletePolicy";
+ if(!checkPermissions(userID, passcode, resource)){
+ logger.error(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ response.setResponseMessage(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ response.setResponseCode(401);
+ return response;
+ }
+ if (parameters.getPolicyComponent()!=null) {
+ if (parameters.getPolicyComponent().equalsIgnoreCase("PAP")) {
+ response.setResponseMessage(deletePolicyFromPAP(parameters));
+ } else if (parameters.getPolicyComponent().equalsIgnoreCase("PDP")) {
+ response.setResponseMessage(deletePolicyFromPDP(parameters));
+ } else {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Policy Component does not exist.");
+ response.setResponseMessage(XACMLErrorConstants.ERROR_DATA_ISSUE + "Policy Component does not exist. Please enter either PAP or PDP to delete the policy from a specified Policy Component.");
+ }
+ } else {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Component given.");
+ response.setResponseMessage(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Component given.");
+ }
+
+ response.setResponseCode(responseCode);
+ return response;
+ }
+
+ /*
+ * createDictionaryItem using dictionaryParameters.
+ */
+ public PolicyChangeResponse createDictionaryItem(DictionaryParameters parameters) throws Exception{
+ StdPolicyChangeResponse response = new StdPolicyChangeResponse();
+
+ if(parameters.getDictionaryType()!=null || parameters.getDictionaryType().equals("")){
+ if(parameters.getDictionary()!=null || parameters.getDictionary().equals("")){
+ if(parameters.getDictionaryFields()!=null){
+ logger.info("Parameters are good... start create dictionary item API...");
+
+ Map<String,String> dictionaryFields = parameters.getDictionaryFields().get(AttributeType.DICTIONARY);
+
+ StdPAPPolicy newDictionaryItem = new StdPAPPolicy(parameters.getDictionaryType().toString(), parameters.getDictionary(), dictionaryFields);
+
+ String result = (String) callPAP(newDictionaryItem, new String[] {"operation=createDictionary", "apiflag=dictionaryApi"}, parameters.getRequestID(), "dictionaryItem");
+
+ response.setResponseCode(responseCode);
+ response.setResponseMessage(result);
+
+ }else{
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Dictionary Fields given.");
+ response.setResponseMessage(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Dictionary Fields given.");
+ }
+ }else{
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Dictionary given.");
+ response.setResponseMessage(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Dictionary given.");
+ }
+ }else{
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Dictionary Type given.");
+ response.setResponseMessage(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Dictionary Type given.");
+ }
+ try{
+
+ }catch(Exception e){
+
+ }
+
+ return response;
+ }
+
+ /*
+ * createPolicy Using policyParameters.
+ */
+ public PolicyChangeResponse createPolicy(PolicyParameters policyParameters) throws Exception{
+ return createPolicy(policyParameters, userName, pass);
+ }
+
+ public PolicyChangeResponse createPolicy(PolicyParameters policyParameters, String userID, String passcode) throws Exception{
+ StdPolicyChangeResponse response = new StdPolicyChangeResponse();
+ String resource= "createPolicy";
+ if(!checkPermissions(userID, passcode, resource)){
+ logger.error(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ response.setResponseMessage(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ response.setResponseCode(401);
+ return response;
+ }
+ String plainName = null;
+ String scope = null;
+ String date = "NA";
+ if (policyParameters.getTtlDate()!=null){
+ date = ConvertDate(policyParameters.getTtlDate());
+ }
+ try{
+ if(policyParameters.getPolicyName()!=null){
+ plainName = policyParameters.getPolicyName().substring(policyParameters.getPolicyName().lastIndexOf(".")+1, policyParameters.getPolicyName().length());
+ scope = policyParameters.getPolicyName().substring(0, policyParameters.getPolicyName().lastIndexOf("."));
+ logger.info("Name is "+ plainName +" scope is "+ scope);
+ }
+ }catch(Exception e){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.");
+ response.setResponseMessage(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.");
+ }
+ if(policyParameters.getPolicyConfigType()!=null){
+ // This is Config Class Policy.
+ // Firewall
+ if(policyParameters.getPolicyConfigType().equals(PolicyConfigType.Firewall)){
+ if(policyParameters.getConfigBody()!=null){
+ JsonObject json = null;
+ try{
+ json = stringToJsonObject(policyParameters.getConfigBody());
+ }catch(Exception e){
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " improper JSON object : " + policyParameters.getConfigBody();
+ logger.error(message);
+ throw new Exception(message);
+ }
+ response.setResponseMessage(createConfigFirewallPolicy(plainName, json, scope, policyParameters.getRequestID(), userID, passcode,
+ policyParameters.getRiskLevel(), policyParameters.getRiskType(), String.valueOf(policyParameters.getGuard()), date));
+ }else{
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ "No Config Body given.";
+ logger.error(message);
+ response.setResponseMessage(message);
+ }
+ }
+ //Base
+ else if(policyParameters.getPolicyConfigType().equals(PolicyConfigType.Base)){
+ if(policyParameters.getConfigBody()!=null) {
+ if(policyParameters.getConfigBodyType()!=null){
+ response.setResponseMessage(createConfigPolicy(plainName, policyParameters.getPolicyDescription(), policyParameters.getEcompName(), policyParameters.getConfigName(),
+ policyParameters.getAttributes().get(AttributeType.MATCHING), policyParameters.getConfigBodyType().toString(), policyParameters.getConfigBody(), scope, policyParameters.getRequestID(), userID, passcode,
+ policyParameters.getRiskLevel(), policyParameters.getRiskType(), String.valueOf(policyParameters.getGuard()), date));
+ } else {
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ "No Config Body Type given.";
+ logger.error(message);
+ response.setResponseMessage(message);
+ }
+ } else {
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ "No Config Body given.";
+ logger.error(message);
+ response.setResponseMessage(message);
+ }
+ }
+ //BRMS Raw
+ else if(policyParameters.getPolicyConfigType().equals(PolicyConfigType.BRMS_RAW)){
+ if(policyParameters.getConfigBody()!=null){
+
+ /*public String createUpdateBRMSRawPolicy(String policyName, String policyDescription, Map<String,String> dyanamicFieldConfigAttributes,
+ * String brmsRawBody, String policyScope, Boolean isEdit, UUID requestID)*/
+ response.setResponseMessage(createUpdateBRMSRawPolicy(plainName, policyParameters.getPolicyDescription(),policyParameters.getAttributes(),
+ policyParameters.getConfigBody(),scope, false,
+ policyParameters.getRequestID(),policyParameters.getRiskLevel(), policyParameters.getRiskType(), String.valueOf(policyParameters.getGuard()),
+ date));
+ }else{
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " No Config Body Present";
+ logger.error(message);
+ throw new Exception(message);
+ }
+ }
+ //BRMS Param
+ else if(policyParameters.getPolicyConfigType().equals(PolicyConfigType.BRMS_PARAM)){
+ if(policyParameters.getConfigBody()!=null){
+
+ response.setResponseMessage(createUpdateBRMSParamPolicy(plainName, policyParameters.getPolicyDescription(),policyParameters.getAttributes(),
+ policyParameters.getConfigBody(),scope, false,
+ policyParameters.getRequestID(),policyParameters.getAttributes(),policyParameters.getRiskLevel(), policyParameters.getRiskType(),
+ String.valueOf(policyParameters.getGuard()), date));
+ }else{
+ response.setResponseMessage(createUpdateBRMSParamPolicy(plainName, policyParameters.getPolicyDescription(),policyParameters.getAttributes(),
+ null,scope, false,
+ policyParameters.getRequestID(),policyParameters.getAttributes(),policyParameters.getRiskLevel(), policyParameters.getRiskType(),
+ String.valueOf(policyParameters.getGuard()), date));
+ }
+ }
+ // Micro Services Policy
+ else if(policyParameters.getPolicyConfigType().equals(PolicyConfigType.MicroService)){
+ if(policyParameters.getConfigBody()!=null){
+ JsonObject json = null;
+ try{
+ json = stringToJsonObject(policyParameters.getConfigBody());
+ }catch(Exception e){
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " improper JSON object : " + policyParameters.getConfigBody();
+ logger.error(message);
+ throw new Exception(message);
+ }
+ //call Micro Services Create API here
+ response.setResponseMessage(createUpdateMicroServicesPolicy(plainName, json, policyParameters.getEcompName(),
+ scope, false, policyParameters.getRequestID(),policyParameters.getRiskLevel(), policyParameters.getRiskType(),
+ String.valueOf(policyParameters.getGuard()), date));
+
+ }else{
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " No Micro Service or Attributes Config Body Present";
+ logger.error(message);
+ throw new Exception(message);
+ }
+ }
+ // ClosedLoop_Fault Policy
+ else if(policyParameters.getPolicyConfigType().equals(PolicyConfigType.ClosedLoop_Fault)){
+ if(policyParameters.getConfigBody()!=null){
+ JsonObject json = null;
+ try{
+ if(validateNONASCIICharactersAndAllowSpaces(policyParameters.getConfigBody())){
+ json = stringToJsonObject(policyParameters.getConfigBody());
+ } else {
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ "The ClosedLoop JSON Contains Non ASCII Characters.";
+ logger.error(message);
+ response.setResponseCode(400);
+ response.setResponseMessage(message);
+ return response;
+ }
+
+ }catch(Exception e){
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " improper JSON object : " + policyParameters.getConfigBody();
+ logger.error(message);
+ response.setResponseCode(400);
+ response.setResponseMessage(message);
+ return response;
+
+ }
+ //call ClosedLoop_Fault Create API here
+ response.setResponseMessage(createUpdateClosedLoopPolicy(plainName, json, policyParameters.getPolicyDescription(),
+ scope, false, policyParameters.getRequestID(),policyParameters.getRiskLevel(), policyParameters.getRiskType(),
+ String.valueOf(policyParameters.getGuard()), date));
+
+ }else{
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " No Config Body Present";
+ logger.error(message);
+ response.setResponseMessage(message);
+ response.setResponseCode(400);
+ return response;
+ }
+ }
+ // ClosedLoop_PM Policy
+ else if(policyParameters.getPolicyConfigType().equals(PolicyConfigType.ClosedLoop_PM)){
+ if(policyParameters.getConfigBody()!=null){
+ JsonObject json = null;
+ try{
+ if(validateNONASCIICharactersAndAllowSpaces(policyParameters.getConfigBody())){
+ json = stringToJsonObject(policyParameters.getConfigBody());
+ } else {
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ "The ClosedLoop PM JSON Contains Non ASCII Characters.";
+ logger.error(message);
+ response.setResponseMessage(message);
+ response.setResponseCode(400);
+ return response;
+
+ }
+
+ }catch(Exception e){
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " improper JSON object : " + policyParameters.getConfigBody();
+ logger.error(message);
+ response.setResponseMessage(message);
+ response.setResponseCode(400);
+ return response;
+
+ }
+ //call ClosedLoop_Fault Create API here
+ response.setResponseMessage(createUpdateClosedLoopPmPolicy(plainName, json, policyParameters.getPolicyDescription(),
+ scope, false, policyParameters.getRequestID(),policyParameters.getRiskLevel(), policyParameters.getRiskType(),
+ String.valueOf(policyParameters.getGuard()), date));
+
+ }else{
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " No Config Body Present";
+ logger.error(message);
+ response.setResponseMessage(message);
+ response.setResponseCode(400);
+ return response;
+
+ }
+ }
+
+ } else if (policyParameters.getPolicyClass()!=null){
+ if(policyParameters.getPolicyClass().equals(PolicyClass.Action)){
+ // call Action Create API here.
+ response.setResponseMessage(createUpdateActionPolicy(plainName, policyParameters.getPolicyDescription(), policyParameters.getAttributes().get(AttributeType.MATCHING),
+ policyParameters.getDynamicRuleAlgorithmLabels(), policyParameters.getDynamicRuleAlgorithmField1(), policyParameters.getDynamicRuleAlgorithmFunctions(), policyParameters.getDynamicRuleAlgorithmField2(),
+ policyParameters.getActionPerformer(), policyParameters.getActionAttribute(), scope, false, policyParameters.getRequestID()));
+ }else if(policyParameters.getPolicyClass().equals(PolicyClass.Decision)){
+ // Call Decision Create API here.
+ if (policyParameters.getAttributes()!=null && policyParameters.getAttributes().containsKey(AttributeType.MATCHING) && policyParameters.getAttributes().containsKey(AttributeType.SETTINGS)) {
+ response.setResponseMessage(createUpdateDecisionPolicy(plainName, policyParameters.getPolicyDescription(), policyParameters.getEcompName(), policyParameters.getRuleProvider(),
+ policyParameters.getAttributes().get(AttributeType.MATCHING), policyParameters.getAttributes().get(AttributeType.SETTINGS), policyParameters.getDynamicRuleAlgorithmLabels(),
+ policyParameters.getDynamicRuleAlgorithmField1(), policyParameters.getDynamicRuleAlgorithmFunctions(), policyParameters.getDynamicRuleAlgorithmField2(),
+ scope, false, policyParameters.getRequestID()));
+ }else if(policyParameters.getAttributes()!=null && !policyParameters.getAttributes().containsKey(AttributeType.MATCHING) && policyParameters.getAttributes().containsKey(AttributeType.SETTINGS)){
+ response.setResponseMessage(createUpdateDecisionPolicy(plainName, policyParameters.getPolicyDescription(), policyParameters.getEcompName(), policyParameters.getRuleProvider(),
+ null, policyParameters.getAttributes().get(AttributeType.SETTINGS), policyParameters.getDynamicRuleAlgorithmLabels(),
+ policyParameters.getDynamicRuleAlgorithmField1(), policyParameters.getDynamicRuleAlgorithmFunctions(), policyParameters.getDynamicRuleAlgorithmField2(),
+ scope, false, policyParameters.getRequestID()));
+ }else if(policyParameters.getAttributes()!=null && policyParameters.getAttributes().containsKey(AttributeType.MATCHING) && !policyParameters.getAttributes().containsKey(AttributeType.SETTINGS)){
+ response.setResponseMessage(createUpdateDecisionPolicy(plainName, policyParameters.getPolicyDescription(), policyParameters.getEcompName(), policyParameters.getRuleProvider(),
+ policyParameters.getAttributes().get(AttributeType.MATCHING), null, policyParameters.getDynamicRuleAlgorithmLabels(),
+ policyParameters.getDynamicRuleAlgorithmField1(), policyParameters.getDynamicRuleAlgorithmFunctions(), policyParameters.getDynamicRuleAlgorithmField2(),
+ scope, false, policyParameters.getRequestID()));
+ }else{
+ response.setResponseMessage(createUpdateDecisionPolicy(plainName, policyParameters.getPolicyDescription(), policyParameters.getEcompName(), policyParameters.getRuleProvider(),
+ null, null, policyParameters.getDynamicRuleAlgorithmLabels(),
+ policyParameters.getDynamicRuleAlgorithmField1(), policyParameters.getDynamicRuleAlgorithmFunctions(), policyParameters.getDynamicRuleAlgorithmField2(),
+ scope, false, policyParameters.getRequestID()));
+ }
+ }
+ } else {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Class found.");
+ response.setResponseMessage(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Class found.");
+ }
+ response.setResponseCode(responseCode);
+ return response;
+ }
+
+ /*
+ * updatePolicy using policyParameters.
+ */
+ public PolicyChangeResponse updatePolicy(PolicyParameters policyParameters) throws Exception{
+ return updatePolicy(policyParameters, userName, pass);
+ }
+
+ public PolicyChangeResponse updatePolicy(PolicyParameters policyParameters,String userID, String passcode) throws Exception{
+ StdPolicyChangeResponse response = new StdPolicyChangeResponse();
+ String resource= "updatePolicy";
+ if(!checkPermissions(userID, passcode, resource)){
+ logger.error(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ response.setResponseMessage(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ response.setResponseCode(401);
+ return response;
+ }
+ String plainName = null;
+ String scope = null;
+ String date = "NA";
+ if (policyParameters.getTtlDate()!=null){
+ date = ConvertDate(policyParameters.getTtlDate());
+ }
+ try{
+ if(policyParameters.getPolicyName()!=null){
+ plainName = policyParameters.getPolicyName().substring(policyParameters.getPolicyName().lastIndexOf(".")+1, policyParameters.getPolicyName().length());
+ scope = policyParameters.getPolicyName().substring(0, policyParameters.getPolicyName().lastIndexOf("."));
+ logger.info("Name is "+ plainName +" scope is "+ scope);
+ }
+ }catch(Exception e){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.");
+ response.setResponseMessage(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.");
+ }
+ if(policyParameters.getPolicyConfigType()!=null){
+ // This is Config Class Policy.
+ //Firewall
+ if(policyParameters.getPolicyConfigType().equals(PolicyConfigType.Firewall)){
+ if(policyParameters.getConfigBody()!=null){
+ JsonObject json = null;
+ try{
+ json = stringToJsonObject(policyParameters.getConfigBody());
+ }catch(Exception e){
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " improper JSON object : " + policyParameters.getConfigBody();
+ logger.error(message);
+ throw new Exception(message);
+ }
+ response.setResponseMessage(updateConfigFirewallPolicy(plainName, json, scope, policyParameters.getRequestID(), userID, passcode,policyParameters.getRiskLevel(),
+ policyParameters.getRiskType(), String.valueOf(policyParameters.getGuard()), date));
+ }else{
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ "No Config Body given.";
+ logger.error(message);
+ response.setResponseMessage(message);
+ }
+ }
+ //Base Policy
+ else if(policyParameters.getPolicyConfigType().equals(PolicyConfigType.Base)){
+ if(policyParameters.getConfigBody()!=null) {
+ if(policyParameters.getConfigBodyType()!=null){
+ response.setResponseMessage(updateConfigPolicy(plainName, policyParameters.getPolicyDescription(), policyParameters.getEcompName(), policyParameters.getConfigName(),
+ policyParameters.getAttributes().get(AttributeType.MATCHING), policyParameters.getConfigBodyType().toString(), policyParameters.getConfigBody(), scope,
+ policyParameters.getRequestID(), userID, passcode, policyParameters.getRiskLevel(), policyParameters.getRiskType(), String.valueOf(policyParameters.getGuard()), date));
+ } else {
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ "No Config Body Type given.";
+ logger.error(message);
+ response.setResponseMessage(message);
+ }
+ } else {
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ "No Config Body given.";
+ logger.error(message);
+ response.setResponseMessage(message);
+ }
+ }
+ //BRMS Raw
+ else if(policyParameters.getPolicyConfigType().equals(PolicyConfigType.BRMS_RAW)){
+ if(policyParameters.getConfigBody()!=null){
+ /*public String createUpdateBRMSRawPolicy(String policyName, String policyDescription, Map<String,String> dyanamicFieldConfigAttributes,
+ * String brmsRawBody, String policyScope, Boolean isEdit, UUID requestID)*/
+ response.setResponseMessage(createUpdateBRMSRawPolicy(plainName, policyParameters.getPolicyDescription(),policyParameters.getAttributes(),
+ policyParameters.getConfigBody(),scope, true,
+ policyParameters.getRequestID(),policyParameters.getRiskLevel(), policyParameters.getRiskType(), String.valueOf(policyParameters.getGuard()), date));
+ }else{
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " No Config Body Present";
+ logger.error(message);
+ throw new Exception(message);
+ }
+ }
+ //BRMS Param
+ else if(policyParameters.getPolicyConfigType().equals(PolicyConfigType.BRMS_PARAM)){
+ if(policyParameters.getConfigBody()!=null){
+
+ /* public String createUpdateBRMSParamPolicy(String policyName, String policyDescription, Map<AttributeType, Map<String, String>> dyanamicFieldConfigAttributes,
+ String brmsRawBody, String policyScope, Boolean isEdit,
+ UUID requestID,Map<String,String> drlRuleAndUIParams)*/
+ response.setResponseMessage(createUpdateBRMSParamPolicy(plainName, policyParameters.getPolicyDescription(),policyParameters.getAttributes(),
+ policyParameters.getConfigBody(),scope, true,
+ policyParameters.getRequestID(),policyParameters.getAttributes(),policyParameters.getRiskLevel(), policyParameters.getRiskType(), String.valueOf(policyParameters.getGuard()), date));
+ }else{
+ response.setResponseMessage(createUpdateBRMSParamPolicy(plainName, policyParameters.getPolicyDescription(),policyParameters.getAttributes(),
+ null,scope, true,
+ policyParameters.getRequestID(),policyParameters.getAttributes(),policyParameters.getRiskLevel(), policyParameters.getRiskType(), String.valueOf(policyParameters.getGuard()), date));
+ }
+ }
+ // Micro Services Policy
+ else if(policyParameters.getPolicyConfigType().equals(PolicyConfigType.MicroService)){
+ if(policyParameters.getConfigBody()!=null){
+ JsonObject json = null;
+ try{
+ json = stringToJsonObject(policyParameters.getConfigBody());
+ }catch(Exception e){
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " improper JSON object : " + policyParameters.getConfigBody();
+ logger.error(message);
+ throw new Exception(message);
+ }
+ //call Micro Services Create API here
+ response.setResponseMessage(createUpdateMicroServicesPolicy(plainName, json, policyParameters.getEcompName(),
+ scope, true, policyParameters.getRequestID(),policyParameters.getRiskLevel(), policyParameters.getRiskType(), String.valueOf(policyParameters.getGuard()), date));
+
+ }else{
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " No Micro Service or Attributes Config Body Present";
+ logger.error(message);
+ throw new Exception(message);
+ }
+ }
+ // ClosedLoop_Fault Policy
+ else if(policyParameters.getPolicyConfigType().equals(PolicyConfigType.ClosedLoop_Fault)){
+ if(policyParameters.getConfigBody()!=null){
+ JsonObject json = null;
+ try{
+ if(validateNONASCIICharactersAndAllowSpaces(policyParameters.getConfigBody())){
+ json = stringToJsonObject(policyParameters.getConfigBody());
+ } else {
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ "The ClosedLoop JSON Contains Non ASCII Characters.";
+ logger.error(message);
+ response.setResponseMessage(message);
+ return response;
+ }
+
+ }catch(Exception e){
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " improper JSON object : " + policyParameters.getConfigBody();
+ logger.error(message);
+ response.setResponseMessage(message);
+ return response;
+ }
+ //call ClosedLoop_Fault Create API here
+ response.setResponseMessage(createUpdateClosedLoopPolicy(plainName, json, policyParameters.getPolicyDescription(),
+ scope, true, policyParameters.getRequestID(),policyParameters.getRiskLevel(), policyParameters.getRiskType(), String.valueOf(policyParameters.getGuard()), date));
+
+ }else{
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " No Config Body Present";
+ logger.error(message);
+ response.setResponseMessage(message);
+ }
+ }
+ // ClosedLoop_PM Policy
+ else if(policyParameters.getPolicyConfigType().equals(PolicyConfigType.ClosedLoop_PM)){
+ if(policyParameters.getConfigBody()!=null){
+ JsonObject json = null;
+ try{
+ if(validateNONASCIICharactersAndAllowSpaces(policyParameters.getConfigBody())){
+ json = stringToJsonObject(policyParameters.getConfigBody());
+ } else {
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ "The ClosedLoop PM JSON Contains Non ASCII Characters.";
+ logger.error(message);
+ response.setResponseMessage(message);
+ return response;
+ }
+
+ }catch(Exception e){
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " improper JSON object : " + policyParameters.getConfigBody();
+ logger.error(message);
+ response.setResponseMessage(message);
+ return response;
+ }
+ //call ClosedLoop_Fault Create API here
+ response.setResponseMessage(createUpdateClosedLoopPmPolicy(plainName, json, policyParameters.getPolicyDescription(),
+ scope, true, policyParameters.getRequestID(),policyParameters.getRiskLevel(), policyParameters.getRiskType(),
+ String.valueOf(policyParameters.getGuard()), date));
+
+ }else{
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " No Config Body Present";
+ logger.error(message);
+ response.setResponseMessage(message);
+ }
+ }
+
+ }else{
+
+ if(policyParameters.getPolicyClass().equals(PolicyClass.Action)){
+ // call Action Update API here.
+ response.setResponseMessage(createUpdateActionPolicy(plainName, policyParameters.getPolicyDescription(), policyParameters.getAttributes().get(AttributeType.MATCHING),
+ policyParameters.getDynamicRuleAlgorithmLabels(), policyParameters.getDynamicRuleAlgorithmField1(), policyParameters.getDynamicRuleAlgorithmFunctions(), policyParameters.getDynamicRuleAlgorithmField2(),
+ policyParameters.getActionPerformer(), policyParameters.getActionAttribute(), scope, true, policyParameters.getRequestID()));
+
+ }else if(policyParameters.getPolicyClass().equals(PolicyClass.Decision)){
+ // Call Decision Create API here.
+ if (policyParameters.getAttributes()!=null && policyParameters.getAttributes().containsKey(AttributeType.MATCHING) && policyParameters.getAttributes().containsKey(AttributeType.SETTINGS)) {
+ response.setResponseMessage(createUpdateDecisionPolicy(plainName, policyParameters.getPolicyDescription(), policyParameters.getEcompName(), policyParameters.getRuleProvider(),
+ policyParameters.getAttributes().get(AttributeType.MATCHING), policyParameters.getAttributes().get(AttributeType.SETTINGS), policyParameters.getDynamicRuleAlgorithmLabels(),
+ policyParameters.getDynamicRuleAlgorithmField1(), policyParameters.getDynamicRuleAlgorithmFunctions(), policyParameters.getDynamicRuleAlgorithmField2(),
+ scope, true, policyParameters.getRequestID()));
+ }else if(policyParameters.getAttributes()!=null && !policyParameters.getAttributes().containsKey(AttributeType.MATCHING) && policyParameters.getAttributes().containsKey(AttributeType.SETTINGS)){
+ response.setResponseMessage(createUpdateDecisionPolicy(plainName, policyParameters.getPolicyDescription(), policyParameters.getEcompName(), policyParameters.getRuleProvider(),
+ null, policyParameters.getAttributes().get(AttributeType.SETTINGS), policyParameters.getDynamicRuleAlgorithmLabels(),
+ policyParameters.getDynamicRuleAlgorithmField1(), policyParameters.getDynamicRuleAlgorithmFunctions(), policyParameters.getDynamicRuleAlgorithmField2(),
+ scope, true, policyParameters.getRequestID()));
+ }else if(policyParameters.getAttributes()!=null && policyParameters.getAttributes().containsKey(AttributeType.MATCHING) && !policyParameters.getAttributes().containsKey(AttributeType.SETTINGS)){
+ response.setResponseMessage(createUpdateDecisionPolicy(plainName, policyParameters.getPolicyDescription(), policyParameters.getEcompName(), policyParameters.getRuleProvider(),
+ policyParameters.getAttributes().get(AttributeType.MATCHING), null, policyParameters.getDynamicRuleAlgorithmLabels(),
+ policyParameters.getDynamicRuleAlgorithmField1(), policyParameters.getDynamicRuleAlgorithmFunctions(), policyParameters.getDynamicRuleAlgorithmField2(),
+ scope, true, policyParameters.getRequestID()));
+ }else{
+ response.setResponseMessage(createUpdateDecisionPolicy(plainName, policyParameters.getPolicyDescription(), policyParameters.getEcompName(), policyParameters.getRuleProvider(),
+ null, null, policyParameters.getDynamicRuleAlgorithmLabels(),
+ policyParameters.getDynamicRuleAlgorithmField1(), policyParameters.getDynamicRuleAlgorithmFunctions(), policyParameters.getDynamicRuleAlgorithmField2(),
+ scope, true, policyParameters.getRequestID()));
+ }
+ }
+ }
+ response.setResponseCode(responseCode);
+ return response;
+ }
+
+ public DecisionResponse policyDecide(String eCOMPComponentName,
+ Map<String, String> decisionAttributes, UUID requestID, String userID, String passcode)
+ throws PolicyDecisionException {
+ String resource= "getDecision";
+ if(!checkPermissions(userID, passcode, resource)){
+ logger.error(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ throw new PolicyDecisionException(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ }
+ DecisionResponse policyDecision;
+ if (eCOMPComponentName == null || eCOMPComponentName.isEmpty()) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No eCOMPComponentName given : " + eCOMPComponentName);
+ throw new PolicyDecisionException(XACMLErrorConstants.ERROR_DATA_ISSUE + "No eCOMPComponentName given.");
+ }
+ if (decisionAttributes != null && !decisionAttributes.isEmpty()) {
+ JsonArrayBuilder resourceArray = Json.createArrayBuilder();
+ for (String key : decisionAttributes.keySet()) {
+ if (key.isEmpty()) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot have an Empty Key");
+ throw new PolicyDecisionException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot have an empty Key");
+ }
+ JsonObjectBuilder resourceBuilder = Json.createObjectBuilder();
+ if (decisionAttributes.get(key).matches("[0-9]+")) {
+ int val = Integer.parseInt(decisionAttributes.get(key));
+ resourceBuilder.add("Value", val);
+ } else {
+ resourceBuilder.add("Value", decisionAttributes.get(key));
+ }
+ resourceBuilder.add("AttributeId", key);
+ resourceArray.add(resourceBuilder);
+ }
+ JsonObject model = Json
+ .createObjectBuilder()
+ .add("Request",
+ Json.createObjectBuilder()
+ .add("AccessSubject",
+ Json.createObjectBuilder()
+ .add("Attribute",
+ Json.createObjectBuilder()
+ .add("Value",
+ eCOMPComponentName)
+ .add("AttributeId",
+ "ECOMPName")))
+ .add("Resource",
+ Json.createObjectBuilder().add(
+ "Attribute", resourceArray))
+ .add("Action",
+ Json.createObjectBuilder()
+ .add("Attribute",
+ Json.createObjectBuilder()
+ .add("Value",
+ "DECIDE")
+ .add("AttributeId",
+ "urn:oasis:names:tc:xacml:1.0:action:action-id"))))
+ .build();
+ try {
+ decide = true;
+ policyDecision = decisionResult(generateRequest(model
+ .toString(), requestID));
+ } catch (Exception e) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
+ decide = false;
+ throw new PolicyDecisionException(e);
+ }
+ } else {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Decision Attributes Given. ");
+ throw new PolicyDecisionException(XACMLErrorConstants.ERROR_DATA_ISSUE +"No DecisionAttributes Given.");
+ }
+ decide = false;
+ return policyDecision;
+ }
+
+ public Collection<PolicyConfig> configPolicyName(String policyName, UUID requestID, String userID, String passcode)
+ throws PolicyConfigException {
+ String resource= "getConfigByPolicyName";
+ if(!checkPermissions(userID, passcode, resource)){
+ logger.error(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ }
+ Collection<PolicyConfig> policyConfig = null;
+ if (policyName == null || policyName.isEmpty()) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+ "No Policy FileName specified!! : " + policyName);
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_DATA_ISSUE+"No Policy FileName specified!!");
+ }
+ if(policyName!= null && !policyName.trim().equals("") && !policyName.endsWith("xml")){
+ policyName = policyName + ".[\\d].*";
+ }
+ JsonObject model = Json
+ .createObjectBuilder()
+ .add("Request",
+ Json.createObjectBuilder()
+ .add("AccessSubject",
+ Json.createObjectBuilder().add(
+ "Attribute",
+ Json.createObjectBuilder()
+ .add("Value",
+ policyName)
+ .add("AttributeId",
+ "PolicyName")))
+ .add("Action",
+ Json.createObjectBuilder()
+ .add("Attribute",
+ Json.createObjectBuilder()
+ .add("Value",
+ "ACCESS")
+ .add("AttributeId",
+ "urn:oasis:names:tc:xacml:1.0:action:action-id")))
+ .add("Resource",
+ Json.createObjectBuilder()
+ .add("Attribute",
+ Json.createObjectBuilder()
+ .add("Value",
+ "Config")
+ .add("AttributeId",
+ "urn:oasis:names:tc:xacml:1.0:resource:resource-id"))))
+ .build();
+ try {
+ policyConfig = configResult(generateRequest(model.toString(), requestID));
+ } catch (Exception e) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_DATA_ISSUE +e);
+ }
+ return policyConfig;
+ }
+
+ public Collection<PolicyConfig> config(String eCOMPComponentName, UUID requestID, String userID, String passcode)
+ throws PolicyConfigException {
+ String resource= "getConfig";
+ if(!checkPermissions(userID, passcode, resource)){
+ logger.error(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ }
+ Collection<PolicyConfig> policyConfig = null;
+ if (eCOMPComponentName == null || eCOMPComponentName.isEmpty()) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No eCOMPComponentName given : " + eCOMPComponentName);
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_DATA_ISSUE + "No eCOMPComponentName given.");
+ }
+ JsonObject model = Json
+ .createObjectBuilder()
+ .add("Request",
+ Json.createObjectBuilder()
+ .add("AccessSubject",
+ Json.createObjectBuilder()
+ .add("Attribute",
+ Json.createObjectBuilder()
+ .add("Value",
+ eCOMPComponentName)
+ .add("AttributeId",
+ "ECOMPName")))
+ .add("Action",
+ Json.createObjectBuilder()
+ .add("Attribute",
+ Json.createObjectBuilder()
+ .add("Value",
+ "ACCESS")
+ .add("AttributeId",
+ "urn:oasis:names:tc:xacml:1.0:action:action-id")))
+ .add("Resource",
+ Json.createObjectBuilder()
+ .add("Attribute",
+ Json.createObjectBuilder()
+ .add("Value",
+ "Config")
+ .add("AttributeId",
+ "urn:oasis:names:tc:xacml:1.0:resource:resource-id"))))
+ .build();
+ try {
+ policyConfig = configResult(generateRequest(model.toString(), requestID));
+ } catch (Exception e) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_DATA_ISSUE +e);
+ }
+ return policyConfig;
+ }
+
+ public Collection<PolicyConfig> config(String eCOMPComponentName,
+ String configName, UUID requestID, String userID, String passcode) throws PolicyConfigException {
+ String resource= "getConfig";
+ if(!checkPermissions(userID, passcode, resource)){
+ logger.error(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ }
+ Collection<PolicyConfig> policyConfig = null;
+ if (eCOMPComponentName == null || eCOMPComponentName.isEmpty()) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No eCOMPComponentName given : " + eCOMPComponentName);
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_DATA_ISSUE + "No eCOMPComponentName given.");
+ }
+ if (configName == null || configName.isEmpty()) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No configName given : " + configName);
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_DATA_ISSUE +"No configName given.");
+ }
+ JsonObject model = Json
+ .createObjectBuilder()
+ .add("Request",
+ Json.createObjectBuilder()
+ .add("AccessSubject",
+ Json.createObjectBuilder()
+ .add("Attribute",
+ Json.createArrayBuilder()
+ .add(Json
+ .createObjectBuilder()
+ .add("Value",
+ eCOMPComponentName)
+ .add("AttributeId",
+ "ECOMPName"))
+ .add(Json
+ .createObjectBuilder()
+ .add("Value",
+ configName)
+ .add("AttributeId",
+ "ConfigName"))))
+ .add("Action",
+ Json.createObjectBuilder()
+ .add("Attribute",
+ Json.createObjectBuilder()
+ .add("Value",
+ "ACCESS")
+ .add("AttributeId",
+ "urn:oasis:names:tc:xacml:1.0:action:action-id")))
+ .add("Resource",
+ Json.createObjectBuilder()
+ .add("Attribute",
+ Json.createObjectBuilder()
+ .add("Value",
+ "Config")
+ .add("AttributeId",
+ "urn:oasis:names:tc:xacml:1.0:resource:resource-id"))))
+ .build();
+ try {
+ policyConfig = configResult(generateRequest(model.toString(), requestID));
+ } catch (Exception e) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_DATA_ISSUE +e);
+ }
+
+ return policyConfig;
+ }
+
+ public Collection<PolicyConfig> config(String eCOMPComponentName,
+ String configName, Map<String, String> configAttributes, UUID requestID, String userID, String passcode)
+ throws PolicyConfigException {
+ String resource= "getConfig";
+ if(!checkPermissions(userID, passcode, resource)){
+ logger.error(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ }
+ Collection<PolicyConfig> policyConfig = null;
+ if (eCOMPComponentName == null || eCOMPComponentName.isEmpty()) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No eCOMPComponentName given : " + eCOMPComponentName);
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_DATA_ISSUE + "No eCOMPComponentName given.");
+ }
+ if (configName == null || configName.isEmpty()) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No configName given : " + configName);
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_DATA_ISSUE +"No configName given.");
+ }
+ if (configAttributes != null && !configAttributes.isEmpty()) {
+ if(!configAttributes.containsKey("RiskType")){
+ configAttributes.put("RiskType", ".*");
+ }
+ if(!configAttributes.containsKey("RiskLevel")){
+ configAttributes.put("RiskLevel", ".*");
+ }
+ if(!configAttributes.containsKey("guard")){
+ configAttributes.put("guard", ".*");
+ }
+ if(!configAttributes.containsKey("TTLDate")){
+ configAttributes.put("TTLDate", ".*");
+ }
+ }else{
+ // ConfigAttributes is Null. So add basic values.
+ configAttributes = new HashMap<String,String>();
+ configAttributes.put("RiskType", ".*");
+ configAttributes.put("RiskLevel", ".*");
+ configAttributes.put("guard", ".*");
+ configAttributes.put("TTLDate", ".*");
+ }
+ JsonArrayBuilder resourceArray = Json.createArrayBuilder();
+ for (String key : configAttributes.keySet()) {
+ if (key.isEmpty()) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot have an empty Key");
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_DATA_ISSUE +"Cannot have an empty Key");
+ }
+ JsonObjectBuilder resourceBuilder = Json.createObjectBuilder();
+ /*if (configAttributes.get(key).matches("[0-9]+")) {
+ int val = Integer.parseInt(configAttributes.get(key));
+ resourceBuilder.add("Value", val);
+ } else {*/
+ resourceBuilder.add("Value", configAttributes.get(key));
+ resourceBuilder.add("AttributeId", key);
+ resourceArray.add(resourceBuilder);
+ }
+ JsonObject model = Json
+ .createObjectBuilder()
+ .add("Request",
+ Json.createObjectBuilder()
+ .add("AccessSubject",
+ Json.createObjectBuilder()
+ .add("Attribute",
+ Json.createArrayBuilder()
+ .add(Json
+ .createObjectBuilder()
+ .add("Value",
+ eCOMPComponentName)
+ .add("AttributeId",
+ "ECOMPName"))
+ .add(Json
+ .createObjectBuilder()
+ .add("Value",
+ configName)
+ .add("AttributeId",
+ "ConfigName"))))
+ .add("Action",
+ Json.createObjectBuilder()
+ .add("Attribute",
+ Json.createObjectBuilder()
+ .add("Value",
+ "ACCESS")
+ .add("AttributeId",
+ "urn:oasis:names:tc:xacml:1.0:action:action-id")))
+ .add("Resource",
+ Json.createObjectBuilder()
+ .add("Attribute",
+ resourceArray
+ .add(Json.createObjectBuilder()
+ .add("Value",
+ "Config")
+ .add("AttributeId",
+ "urn:oasis:names:tc:xacml:1.0:resource:resource-id")))))
+ .build();
+ try {
+ policyConfig = configResult(generateRequest(model.toString(), requestID));
+ } catch (Exception e) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_DATA_ISSUE +e);
+ }
+ return policyConfig;
+ }
+
+ public Collection<PolicyConfig> configRequest(ConfigRequestParameters configRequestParameters, String userID, String passcode) throws PolicyConfigException{
+ String resource= "getConfig";
+ if(!checkPermissions(userID, passcode, resource)){
+ logger.error(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ }
+ Collection<PolicyConfig> policyConfig = null;
+ unique = false;
+ if(configRequestParameters==null){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No config Request Parameters given ");
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_DATA_ISSUE + "No config Request Parameters given.");
+ }
+ if(configRequestParameters.getEcompName() == null && configRequestParameters.getPolicyName() == null){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot proceed without eCOMPComponentName or PolicyName");
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_DATA_ISSUE + "No eCOMPComponentName or PolicyName given.");
+ }
+ String policyName = configRequestParameters.getPolicyName();
+ if(policyName!= null && !policyName.trim().equals("") && !policyName.endsWith("xml")){
+ policyName = policyName + ".[\\d].*";
+ }
+ JsonArrayBuilder subjectArray = Json.createArrayBuilder();
+ JsonArrayBuilder resourceArray = Json.createArrayBuilder();
+ if(configRequestParameters.getPolicyName()!=null){
+ JsonObjectBuilder subjectBuilder = Json.createObjectBuilder();
+ subjectBuilder.add("Value", policyName);
+ subjectBuilder.add("AttributeId", "PolicyName");
+ subjectArray.add(subjectBuilder);
+ }else{
+ logger.info("PolicyName values are not given. ");
+ }
+ if(configRequestParameters.getEcompName()!=null){
+ JsonObjectBuilder subjectBuilder = Json.createObjectBuilder();
+ subjectBuilder.add("Value", configRequestParameters.getEcompName());
+ subjectBuilder.add("AttributeId", "ECOMPName");
+ subjectArray.add(subjectBuilder);
+ if(configRequestParameters.getConfigName()!=null){
+ subjectBuilder = Json.createObjectBuilder();
+ subjectBuilder.add("Value", configRequestParameters.getConfigName());
+ subjectBuilder.add("AttributeId", "ConfigName");
+ subjectArray.add(subjectBuilder);
+ Map<String,String> configAttributes = configRequestParameters.getConfigAttributes();
+ if (configAttributes != null && !configAttributes.isEmpty()) {
+ if(!configAttributes.containsKey("RiskType")){
+ configAttributes.put("RiskType", ".*");
+ }
+ if(!configAttributes.containsKey("RiskLevel")){
+ configAttributes.put("RiskLevel", ".*");
+ }
+ if(!configAttributes.containsKey("guard")){
+ configAttributes.put("guard", ".*");
+ }
+ if(!configAttributes.containsKey("TTLDate")){
+ configAttributes.put("TTLDate", ".*");
+ }
+ }else{
+ // ConfigAttributes is Null. So add basic values.
+ configAttributes = new HashMap<String,String>();
+ configAttributes.put("RiskType", ".*");
+ configAttributes.put("RiskLevel", ".*");
+ configAttributes.put("guard", ".*");
+ configAttributes.put("TTLDate", ".*");
+ }
+ for (String key : configAttributes.keySet()) {
+ if (key.isEmpty()) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot have an empty Key");
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_DATA_ISSUE +"Cannot have an empty Key");
+ }
+ JsonObjectBuilder resourceBuilder = Json.createObjectBuilder();
+ /*if (configAttributes.get(key).matches("[0-9]+")) {
+ int val = Integer.parseInt(configAttributes.get(key));
+ resourceBuilder.add("Value", val);
+ } else {*/
+ resourceBuilder.add("Value", configAttributes.get(key));
+ resourceBuilder.add("AttributeId", key);
+ resourceArray.add(resourceBuilder);
+ }
+ }else{
+ logger.info("Config Name is not given. ");
+ }
+ }else{
+ logger.info("Ecomp Name is not given. ");
+ }
+ JsonObject model = Json
+ .createObjectBuilder()
+ .add("Request",
+ Json.createObjectBuilder()
+ .add("AccessSubject",
+ Json.createObjectBuilder()
+ .add("Attribute",subjectArray))
+ .add("Action",
+ Json.createObjectBuilder()
+ .add("Attribute",
+ Json.createObjectBuilder()
+ .add("Value",
+ "ACCESS")
+ .add("AttributeId",
+ "urn:oasis:names:tc:xacml:1.0:action:action-id")))
+ .add("Resource",
+ Json.createObjectBuilder()
+ .add("Attribute",
+ resourceArray
+ .add(Json
+ .createObjectBuilder()
+ .add("Value",
+ "Config")
+ .add("AttributeId",
+ "urn:oasis:names:tc:xacml:1.0:resource:resource-id")))))
+ .build();
+ logger.debug("Generated JSON Request is: " + model.toString());
+ if(configRequestParameters.getUnique()){
+ logger.info("Requested for Unique Result only. ");
+ unique = true;
+ }
+ try {
+ policyConfig = configResult(generateRequest(model.toString(), configRequestParameters.getRequestID()));
+ } catch (Exception e) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_DATA_ISSUE +e);
+ }
+ return policyConfig;
+ }
+
+ public Collection<String> listConfigRequest(ConfigRequestParameters listRequestParameters, String userID, String passcode) throws PolicyConfigException{
+ String resource= "listConfig";
+ if(!checkPermissions(userID, passcode, resource)){
+ logger.error(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ }
+ Collection<PolicyConfig> policyConfig = null;
+ Collection<String> policyList = new ArrayList<String>();
+
+ unique = false;
+ if(listRequestParameters==null){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Request Parameters given ");
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Request Parameters given.");
+ }
+
+ if (junit){
+ policyList.add("Policy Name: listConfigTest");
+ return policyList;
+ }
+
+ String policyName = listRequestParameters.getPolicyName();
+ if(policyName!= null && !policyName.trim().equals("") && !policyName.endsWith("xml")){
+ policyName = policyName + ".[\\d].*";
+ }
+ JsonArrayBuilder subjectArray = Json.createArrayBuilder();
+ JsonArrayBuilder resourceArray = Json.createArrayBuilder();
+ if(listRequestParameters.getPolicyName()!=null){
+ JsonObjectBuilder subjectBuilder = Json.createObjectBuilder();
+ subjectBuilder.add("Value", policyName);
+ subjectBuilder.add("AttributeId", "PolicyName");
+ subjectArray.add(subjectBuilder);
+ }else{
+ logger.info("PolicyName values are not given. ");
+ }
+ if(listRequestParameters.getEcompName()!=null){
+ JsonObjectBuilder subjectBuilder = Json.createObjectBuilder();
+ subjectBuilder.add("Value", listRequestParameters.getEcompName());
+ subjectBuilder.add("AttributeId", "ECOMPName");
+ subjectArray.add(subjectBuilder);
+ if(listRequestParameters.getConfigName()!=null){
+ subjectBuilder = Json.createObjectBuilder();
+ subjectBuilder.add("Value", listRequestParameters.getConfigName());
+ subjectBuilder.add("AttributeId", "ConfigName");
+ subjectArray.add(subjectBuilder);
+ Map<String,String> configAttributes = listRequestParameters.getConfigAttributes();
+ if (configAttributes != null && !configAttributes.isEmpty()) {
+ if(!configAttributes.containsKey("RiskType")){
+ configAttributes.put("RiskType", ".*");
+ }
+ if(!configAttributes.containsKey("RiskLevel")){
+ configAttributes.put("RiskLevel", ".*");
+ }
+ if(!configAttributes.containsKey("guard")){
+ configAttributes.put("guard", ".*");
+ }
+ if(!configAttributes.containsKey("TTLDate")){
+ configAttributes.put("TTLDate", ".*");
+ }
+ }else{
+ // ConfigAttributes is Null. So add basic values.
+ configAttributes = new HashMap<String,String>();
+ configAttributes.put("RiskType", ".*");
+ configAttributes.put("RiskLevel", ".*");
+ configAttributes.put("guard", ".*");
+ configAttributes.put("TTLDate", ".*");
+ }
+ for (String key : configAttributes.keySet()) {
+ if (key.isEmpty()) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot have an empty Key");
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_DATA_ISSUE +"Cannot have an empty Key");
+ }
+ JsonObjectBuilder resourceBuilder = Json.createObjectBuilder();
+ /*if (configAttributes.get(key).matches("[0-9]+")) {
+ int val = Integer.parseInt(configAttributes.get(key));
+ resourceBuilder.add("Value", val);
+ } else {*/
+ resourceBuilder.add("Value", configAttributes.get(key));
+ resourceBuilder.add("AttributeId", key);
+ resourceArray.add(resourceBuilder);
+ }
+ }else{
+ logger.info("Config Name is not given. ");
+ }
+ }else{
+ logger.info("Ecomp Name is not given. ");
+ }
+ JsonObject model = Json
+ .createObjectBuilder()
+ .add("Request",
+ Json.createObjectBuilder()
+ .add("AccessSubject",
+ Json.createObjectBuilder()
+ .add("Attribute",subjectArray))
+ .add("Action",
+ Json.createObjectBuilder()
+ .add("Attribute",
+ Json.createObjectBuilder()
+ .add("Value",
+ "ACCESS")
+ .add("AttributeId",
+ "urn:oasis:names:tc:xacml:1.0:action:action-id")))
+ .add("Resource",
+ Json.createObjectBuilder()
+ .add("Attribute",
+ resourceArray
+ .add(Json
+ .createObjectBuilder()
+ .add("Value",
+ "Config")
+ .add("AttributeId",
+ "urn:oasis:names:tc:xacml:1.0:resource:resource-id")))))
+ .build();
+ logger.debug("Generated JSON Request is: " + model.toString());
+ if(listRequestParameters.getUnique()){
+ logger.info("Requested for Unique Result only. ");
+ unique = true;
+ }
+ try {
+ policyConfig = configResult(generateRequest(model.toString(), listRequestParameters.getRequestID()));
+ } catch (Exception e) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
+ throw new PolicyConfigException(XACMLErrorConstants.ERROR_DATA_ISSUE +e);
+ }
+ for(PolicyConfig policy : policyConfig){
+ if(policy.getPolicyConfigMessage()!=null && policy.getPolicyConfigMessage().contains("PE300")){
+ policyList.add(policy.getPolicyConfigMessage());
+ } else {
+ policyList.add("Policy Name: " + policy.getPolicyName());
+ }
+ }
+ return policyList;
+ }
+
+
+
+ public Collection<PolicyResponse> event(Map<String, String> eventAttributes, UUID requestID, String userID, String passcode)
+ throws PolicyEventException {
+ String resource= "sendEvent";
+ if(!checkPermissions(userID, passcode, resource)){
+ logger.error(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ throw new PolicyEventException(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ }
+ Collection<PolicyResponse> policyResponse = null;
+ if (eventAttributes != null && !eventAttributes.isEmpty()) {
+ JsonArrayBuilder resourceArray = Json.createArrayBuilder();
+ for (String key : eventAttributes.keySet()) {
+ if (key.isEmpty()) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot have an Empty Key");
+ throw new PolicyEventException(XACMLErrorConstants.ERROR_DATA_ISSUE +"Cannot have an empty Key");
+ }
+ JsonObjectBuilder resourceBuilder = Json.createObjectBuilder();
+ if (eventAttributes.get(key).matches("[0-9]+")) {
+ int val = Integer.parseInt(eventAttributes.get(key));
+ resourceBuilder.add("Value", val);
+ } else {
+ resourceBuilder.add("Value", eventAttributes.get(key));
+ }
+ resourceBuilder.add("AttributeId", key);
+ resourceArray.add(resourceBuilder);
+ }
+ JsonObject model = Json
+ .createObjectBuilder()
+ .add("Request",
+ Json.createObjectBuilder().add(
+ "Resource",
+ Json.createObjectBuilder().add("Attribute",
+ resourceArray))).build();
+ // Removed Part can be Useful in Future.
+ /*
+ * .add("AccessSubject",Json.createObjectBuilder() .add("Attribute",
+ * subjectArray)) .add("Action", Json.createObjectBuilder()
+ * .add("Attribute", actionArray))
+ */
+ // System.out.println(model.toString());
+ try {
+ // StdPolicyResponse stdPolicyResponse =
+ // generateRequest(model.toString());
+ // stdPolicyResponse.setRequestAttributes(eventAttributes);
+ policyResponse = eventResult(generateRequest(model.toString(), requestID),
+ eventAttributes);
+ } catch (Exception e) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
+ throw new PolicyEventException(XACMLErrorConstants.ERROR_DATA_ISSUE +e);
+ }
+ } else {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No event Attributes Given. ");
+ throw new PolicyEventException(XACMLErrorConstants.ERROR_DATA_ISSUE +"No EventAttributes Given.");
+ }
+ return policyResponse;
+ }
+
+ private Collection<StdStatus> generateRequest(String Json, UUID requestID) throws Exception {
+ Collection<StdStatus> results = null;
+
+ Response response = null;
+ // Create Request. We need XACML API here.
+ try {
+ Request request = JSONRequest.load(Json);
+ String jRequest = JSONRequest.toString(request);
+
+ // Call the PDP
+ logger.debug("--- Generating Request: ---\n" + jRequest );
+ response = callPDP(new ByteArrayInputStream(jRequest.getBytes()), requestID);
+
+ } catch (Exception e) {
+ logger.error(XACMLErrorConstants.ERROR_SCHEMA_INVALID + e);
+ StdStatus stdStatus = new StdStatus();
+ results = new HashSet<StdStatus>();
+ stdStatus.setStatus("Unable to Call PDP. Error with the URL",
+ PolicyResponseStatus.NO_ACTION_REQUIRED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ results.add(stdStatus);
+ throw new Exception(e);
+ }
+
+ if(this.UEBThread){
+ this.UEBThread = registerUEBThread.isAlive();
+ }
+ if (response != null) {
+ results = checkResponse(response);
+ // TODO Starting Auto Client Here.
+ if (notificationType.get(0).equals("ueb") && !this.UEBThread){
+ this.UEBClientThread = new AutoClientUEB(pdps.get(0), uebURLList);
+ this.registerUEBThread = new Thread(this.UEBClientThread);
+ this.registerUEBThread.start();
+ this.UEBThread = true;
+
+ }else {
+ if(AutoClientEnd.getURL()==null){
+ AutoClientEnd.start(pdps.get(0));
+ }else if(AutoClientEnd.getURL()!=pdps.get(0)){
+ AutoClientEnd.stop();
+ AutoClientEnd.start(pdps.get(0));
+ }
+ }
+ } else {
+ logger.debug("No Response Received from PDP");
+ StdStatus stdStatus = new StdStatus();
+ results = new HashSet<StdStatus>();
+ stdStatus.setStatus("No Response Received",
+ PolicyResponseStatus.NO_ACTION_REQUIRED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ results.add(stdStatus);
+ }
+
+ return results;
+ }
+
+ private Response callPDP(ByteArrayInputStream input, UUID requestID) throws Exception {
+ Response response = null;
+ HttpURLConnection connection = null;
+ responseCode = 0;
+ // Checking for the available PDPs is done during the first Request and
+ // the List is going to have the connected PDP as first element.
+ // This makes it Real-Time to change the list depending on their
+ // availability.
+ if (pdps == null || pdps.isEmpty()) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "PDPs List is Empty.");
+ throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE +"PDPs List is empty.");
+ } else {
+ int pdpsCount = 0;
+ boolean connected = false;
+ while (pdpsCount < pdps.size()) {
+ input.reset();
+ try {
+ String urlValue = pdps.get(0);
+ URL url = new URL(urlValue);
+ logger.debug("--- Sending Request to PDP : "+ url.toString() + " ---");
+ connection = (HttpURLConnection) url.openConnection();
+ // Setting Content-Type
+ connection.setRequestProperty("Content-Type","application/json");
+ // Adding Authorization
+ connection.setRequestProperty("Authorization", "Basic " + encoding.get(0));
+ // Adding Environment.
+ connection.setRequestProperty("Environment", environment);
+ // Adding RequestID
+ if (requestID == null) {
+ requestID = UUID.randomUUID();
+ logger.info("No request ID provided, sending generated ID: " + requestID.toString());
+ } else {
+ logger.info("Using provided request ID: " + requestID.toString());
+ }
+ connection.setRequestProperty("X-ECOMP-RequestID", requestID.toString());
+ // Setting up connection method and headers.
+ connection.setRequestMethod("POST");
+ connection.setUseCaches(false);
+ connection.setInstanceFollowRedirects(false);
+ connection.setDoOutput(true);
+ connection.setDoInput(true);
+ OutputStream os = connection.getOutputStream();
+ IOUtils.copy(input, os);
+
+
+ connection.connect();
+ responseCode = connection.getResponseCode();
+ // If Connected to a PDP Then break from the loop and
+ // continue with the Request.
+ if (connection.getResponseCode() == 200 || junit) {
+ connected = true;
+ break;
+ } else {
+ logger.debug(XACMLErrorConstants.ERROR_PERMISSIONS+ "PDP Response Code : " + connection.getResponseCode());
+ Collections.rotate(pdps, -1);
+ Collections.rotate(encoding, -1);
+ }
+ } catch (Exception e) {
+ // This means that the PDP is not working and needs to
+ // Re-Order our List and Connect to the next one.
+ logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "PDP connection Error : " + e);
+ Collections.rotate(pdps, -1);
+ Collections.rotate(encoding, -1);
+ }
+ pdpsCount++;
+ }
+ if (connected) {
+ // Read the Response
+ // System.out.println("connected to PDP : " + pdps.get(0));
+ logger.debug("connected to PDP : " + pdps.get(0));
+ logger.debug("--- Response: ---");
+ Map<String,List<String>> headers = connection.getHeaderFields();
+ for(String key : headers.keySet()){
+ logger.debug("Header : " + key + " Value: " + headers.get(key));
+ }
+ try {
+ if (connection.getResponseCode() == 200 || junit) {
+ // Read the Response
+ ContentType contentType = null;
+ try {
+ contentType = ContentType.parse(connection
+ .getContentType());
+ if (contentType.getMimeType().equalsIgnoreCase(
+ ContentType.APPLICATION_JSON.getMimeType())) {
+ if(junit){
+ response = JSONResponse.load(getJsonResponseString());
+ } else {
+ response = JSONResponse.load(connection.getInputStream());
+ }
+ logger.debug(response + "\n---");
+ } else {
+ logger.error(XACMLErrorConstants.ERROR_SCHEMA_INVALID + "Unknown Content-Type: "
+ + contentType);
+ throw new Exception(XACMLErrorConstants.ERROR_SCHEMA_INVALID + "Unknown Content-Type: "
+ + contentType);
+ }
+ } catch (Exception e) {
+ String message = XACMLErrorConstants.ERROR_SCHEMA_INVALID + "Parsing Content-Type: "
+ + connection.getContentType() + ", error="
+ + e;
+ logger.error(XACMLErrorConstants.ERROR_SCHEMA_INVALID + e);
+ throw new Exception(message, e);
+ }
+ } else {
+ throw new Exception(XACMLErrorConstants.ERROR_PERMISSIONS+ "ERROR response code of the URL " + pdps.get(0) + " is "
+ + connection.getResponseCode());
+ }
+ } catch (IOException e) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
+ throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE +"Error in Connecting to the PDP ", e);
+ }
+ return response;
+ } else {
+ if(junit){
+ response = JSONResponse.load(getJsonResponseString());
+ return response;
+ }
+ throw new Exception(XACMLErrorConstants.ERROR_PERMISSIONS+ "Unable to get valid Response from PDP(s) " + pdps);
+ }
+ }
+ }
+
+ private Collection<StdStatus> checkResponse(Response response)
+ throws Exception {
+
+ String pdpConfigURL = null;
+
+ Collection<StdStatus> combinedResult = new HashSet<StdStatus>();
+ int priority = defaultPriority;
+ Map<Integer, StdStatus> uniqueResult = new HashMap<Integer, StdStatus>();
+ for (Result result : response.getResults()) {
+ if (!result.getDecision().equals(Decision.PERMIT)) {
+ logger.debug("Decision not a Permit. " + result.getDecision().toString());
+ StdStatus stdStatus = new StdStatus();
+ if (decide) {
+ stdStatus.setDecision(PolicyDecision.DENY);
+ for(Advice advice: result.getAssociatedAdvice()){
+ for(AttributeAssignment attribute: advice.getAttributeAssignments()){
+ stdStatus.setDetails(attribute.getAttributeValue().getValue().toString());
+ break;
+ }
+ }
+ combinedResult.add(stdStatus);
+ return combinedResult;
+ }
+ stdStatus.setStatus(XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Params passed: Decision not a Permit.",PolicyResponseStatus.NO_ACTION_REQUIRED,PolicyConfigStatus.CONFIG_NOT_FOUND);
+ combinedResult.add(stdStatus);
+ return combinedResult;
+ } else {
+ if (decide) {
+ // check for Decision for decision based calls.
+ StdStatus stdStatus = new StdStatus();
+ stdStatus.setDecision(PolicyDecision.PERMIT);
+ stdStatus.setDetails("Decision Permit. OK!");
+ combinedResult.add(stdStatus);
+ return combinedResult;
+ }
+ if (!result.getAssociatedAdvice().isEmpty()) {
+ // @ TODO Add advice actions
+ // Configurations should be in advice. + Also PDP took
+ // actions could be here.
+ for (Advice advice : result.getAssociatedAdvice()) {
+ int config = 0, uri = 0;
+ String configURL = null;
+ String policyName = null;
+ String policyVersion = null;
+ Map<String, String> matchingConditions = new HashMap<String, String>();
+ match = new Matches();
+ Map<String, String> configAttributes = new HashMap<String, String>();
+ Map<String, String> responseAttributes = new HashMap<String,String>();
+ Map<String, String> actionTaken = new HashMap<String, String>();
+ StdStatus stdStatus = new StdStatus();
+ Map<String, String> adviseAttributes = new HashMap<String, String>();
+ for (AttributeAssignment attribute : advice.getAttributeAssignments()) {
+ adviseAttributes.put(attribute.getAttributeId().stringValue(), attribute.getAttributeValue().getValue().toString());
+ if (attribute.getAttributeValue().getValue().toString().equalsIgnoreCase("CONFIGURATION")) {
+ config++;
+ } else if (attribute.getDataTypeId().stringValue().endsWith("anyURI")) {
+ uri++;
+ if (uri == 1) {
+ configURL = attribute.getAttributeValue().getValue().toString();
+ String currentUsedPDP = pdps.get(0);
+ int pos = (pdps.get(0)).lastIndexOf("/");
+ String configURLPath = currentUsedPDP.substring(0, pos);
+ int pos1 = configURLPath.lastIndexOf("/");
+ String pdpConfigURLPath = configURLPath.substring(0, pos1 + 1);
+ pdpConfigURL = configURL.replace("$URL", pdpConfigURLPath);
+ } else {
+ if (!(attribute.getIssuer().equalsIgnoreCase("PDP"))) {
+ throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE + "Error having multiple URI in the Policy");
+ }
+ }
+ } else if (attribute.getAttributeId().stringValue()
+ .equalsIgnoreCase("PolicyName")) {
+ policyName = attribute.getAttributeValue()
+ .getValue().toString();
+ } else if (attribute.getAttributeId().stringValue()
+ .equalsIgnoreCase("VersionNumber")) {
+ policyVersion = attribute.getAttributeValue()
+ .getValue().toString();
+ } else if (attribute.getAttributeId().stringValue().equalsIgnoreCase("Priority")){
+ try{
+ priority = Integer.parseInt(attribute.getAttributeValue().getValue().toString());
+ } catch(Exception e){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+ "Unable to Parse Integer for Priority. Setting to default value");
+ priority = defaultPriority;
+ }
+ } else if (attribute.getAttributeId().stringValue()
+ .startsWith("matching")) {
+ matchingConditions.put(attribute
+ .getAttributeId().stringValue()
+ .replaceFirst("(matching).", ""),
+ attribute.getAttributeValue()
+ .getValue().toString());
+ if (attribute.getAttributeId().stringValue()
+ .replaceFirst("(matching).", "")
+ .equals("ECOMPName")) {
+ match.setEcompName(attribute
+ .getAttributeValue().getValue()
+ .toString());
+ } else if (attribute.getAttributeId()
+ .stringValue()
+ .replaceFirst("(matching).", "")
+ .equals("ConfigName")) {
+ match.setConfigName(attribute
+ .getAttributeValue().getValue()
+ .toString());
+ } else {
+ configAttributes.put(attribute
+ .getAttributeId().stringValue()
+ .replaceFirst("(matching).", ""),
+ attribute.getAttributeValue()
+ .getValue().toString());
+ }
+ } else if (attribute.getAttributeId().stringValue().startsWith("key:")) {
+ responseAttributes.put(attribute
+ .getAttributeId().stringValue()
+ .replaceFirst("(key).", ""),
+ attribute.getAttributeValue()
+ .getValue().toString());
+ }
+ }
+ if (!configAttributes.isEmpty()) {
+ match.setConfigAttributes(configAttributes);
+ }
+ if ((config == 1) && (uri == 1)) {
+ // If there is a configuration.
+ try {
+ logger.debug("Configuration Call to : "
+ + configURL);
+ stdStatus = ConfigCall(pdpConfigURL);
+ } catch (Exception e) {
+ logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW+ e);
+ stdStatus
+ .setStatus(
+ "Error in Calling the Configuration URL "
+ + e,
+ PolicyResponseStatus.NO_ACTION_REQUIRED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ }
+ stdStatus.setPolicyName(policyName);
+ stdStatus.setPolicyVersion(policyVersion);
+ stdStatus.setMatchingConditions(matchingConditions);
+ stdStatus.setResposneAttributes(responseAttributes);
+ if(!unique){
+ combinedResult.add(stdStatus);
+ }else{
+ if(!uniqueResult.isEmpty()){
+ if(uniqueResult.containsKey(priority)){
+ // Not any more unique, check the matching conditions size
+ int oldSize = uniqueResult.get(priority).getMatchingConditions().size();
+ int newSize = matchingConditions.size();
+ if(oldSize < newSize){
+ uniqueResult.put(priority, stdStatus);
+ }else if(oldSize == newSize){
+ stdStatus = new StdStatus();
+ stdStatus.setStatus("Two/more Policies have Same Priority and matching conditions, Please correct your policies.", PolicyResponseStatus.NO_ACTION_REQUIRED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ combinedResult.add(stdStatus);
+ unique = false;
+ return combinedResult;
+ }
+ }else{
+ uniqueResult.put(priority, stdStatus);
+ }
+ }else{
+ uniqueResult.put(priority, stdStatus);
+ }
+ }
+ } else {
+ // Else it is Action Taken.
+ logger.info("Action Taken by PDP. ");
+ actionTaken.putAll(adviseAttributes);
+ stdStatus.setActionTaken(actionTaken);
+ stdStatus.setPolicyResponseStatus(
+ "Action Taken by the PDP",
+ PolicyResponseStatus.ACTION_TAKEN);
+ combinedResult.add(stdStatus);
+ }
+ }
+ }
+ if (!result.getObligations().isEmpty()) {
+ // @ TODO add Obligation actions
+ // Action advised should be in obligations.
+ for (Obligation obligation : result.getObligations()) {
+ Map<String, String> actionAdvised = new HashMap<String, String>();
+ StdStatus stdStatus = new StdStatus();
+ for (AttributeAssignment attribute : obligation
+ .getAttributeAssignments()) {
+ actionAdvised.put(attribute.getAttributeId()
+ .stringValue(), attribute
+ .getAttributeValue().getValue().toString());
+ }
+ stdStatus.setActionAdvised(actionAdvised);
+ stdStatus.setPolicyResponseStatus(
+ "Action has been Advised ",
+ PolicyResponseStatus.ACTION_ADVISED);
+ combinedResult.add(stdStatus);
+ }
+ }
+ }
+ }
+ if(unique){
+ // Select Unique policy.
+ int minNum = defaultPriority;
+ for(int num: uniqueResult.keySet()){
+ if(num < minNum){
+ minNum = num;
+ }
+ }
+ combinedResult.add(uniqueResult.get(minNum));
+ // Turn off Unique
+ unique = false;
+ }
+
+ return combinedResult;
+ }
+
+ private StdStatus ConfigCall(String stringURL) throws Exception {
+ StdStatus stdStatus = new StdStatus();
+ try {
+ URL configURL = new URL(stringURL);
+ URLConnection connection = null;
+ try {
+ connection = configURL.openConnection();
+ if (stringURL.endsWith("json")) {
+ stdStatus.setPolicyType(PolicyType.JSON);
+ JsonReader jsonReader = Json.createReader(connection
+ .getInputStream());
+ stdStatus.setJsonObject(jsonReader.readObject());
+ jsonReader.close();
+ logger.info("config Retrieved ");
+ stdStatus.setStatus("Config Retrieved from: " + configURL,
+ PolicyResponseStatus.NO_ACTION_REQUIRED,
+ PolicyConfigStatus.CONFIG_RETRIEVED);
+ try {
+ MatchStore.storeMatch(match);
+ } catch (Exception e) {
+ logger.info("StoreMatch failed for Ecomp:"
+ + match.getEcompName() + " Config: "
+ + match.getConfigName());
+ }
+ return stdStatus;
+ } else if (stringURL.endsWith("xml")) {
+ stdStatus.setPolicyType(PolicyType.XML);
+ DocumentBuilderFactory dbf = DocumentBuilderFactory
+ .newInstance();
+ DocumentBuilder db = null;
+ try {
+ db = dbf.newDocumentBuilder();
+ Document config = db.parse(connection.getInputStream());
+ stdStatus.setDocument(config);
+ } catch (ParserConfigurationException e) {
+ logger.error(XACMLErrorConstants.ERROR_SCHEMA_INVALID + e);
+ throw new Exception(XACMLErrorConstants.ERROR_SCHEMA_INVALID + "Unable to create Document Object",
+ e);
+ } catch (SAXException e) {
+ logger.error(XACMLErrorConstants.ERROR_SCHEMA_INVALID+ e);
+ throw new Exception(XACMLErrorConstants.ERROR_SCHEMA_INVALID+ "Unable to parse the XML config", e);
+ }
+ logger.info("config Retrieved ");
+ stdStatus.setStatus("Config Retrieved from: " + configURL,
+ PolicyResponseStatus.NO_ACTION_REQUIRED,
+ PolicyConfigStatus.CONFIG_RETRIEVED);
+ try {
+ MatchStore.storeMatch(match);
+ } catch (Exception e) {
+ logger.info("StoreMatch failed for Ecomp:"
+ + match.getEcompName() + " Config: "
+ + match.getConfigName());
+ }
+ return stdStatus;
+ } else if (stringURL.endsWith("properties")) {
+ stdStatus.setPolicyType(PolicyType.PROPERTIES);
+ Properties configProp = new Properties();
+ configProp.load(connection.getInputStream());
+ stdStatus.setProperties(configProp);
+ logger.info("config Retrieved ");
+ stdStatus.setStatus("Config Retrieved from: " + configURL,
+ PolicyResponseStatus.NO_ACTION_REQUIRED,
+ PolicyConfigStatus.CONFIG_RETRIEVED);
+ try {
+ MatchStore.storeMatch(match);
+ } catch (Exception e) {
+ logger.info("StoreMatch failed for Ecomp:"
+ + match.getEcompName() + " Config: "
+ + match.getConfigName());
+ }
+ return stdStatus;
+ } else if (stringURL.endsWith("txt")) {
+ stdStatus.setPolicyType(PolicyType.OTHER);
+ InputStream in = connection.getInputStream();
+ String other = IOUtils.toString(in);
+ IOUtils.closeQuietly(in);
+ stdStatus.setOther(other);
+ logger.info("config Retrieved ");
+ stdStatus.setStatus("Config Retrieved from: " + configURL,
+ PolicyResponseStatus.NO_ACTION_REQUIRED,
+ PolicyConfigStatus.CONFIG_RETRIEVED);
+ try {
+ MatchStore.storeMatch(match);
+ } catch (Exception e) {
+ logger.info("StoreMatch failed for Ecomp:"
+ + match.getEcompName() + " Config: "
+ + match.getConfigName());
+ }
+ return stdStatus;
+ } else {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Config Not Found");
+ stdStatus
+ .setPolicyConfigStatus(PolicyConfigStatus.CONFIG_NOT_FOUND);
+ stdStatus
+ .setConfigStatus("Illegal form of Configuration Type Found.");
+ return stdStatus;
+ }
+ } catch (IOException e) {
+ logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
+ throw new Exception(XACMLErrorConstants.ERROR_PROCESS_FLOW +
+ "Cannot open a connection to the configURL", e);
+ }
+ } catch (MalformedURLException e) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
+ throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE + "Error in ConfigURL", e);
+ }
+ }
+
+ private void setProperty(String propertyFilePath)
+ throws PolicyEngineException {
+ this.propertyFilePath = propertyFilePath;
+ if (this.propertyFilePath == null) {
+ // This is only for testing purpose. Or We will add a default PDP
+ // address here.
+ // url_default = "http://localhost:8080/pdp/";
+ // The General Error Message is Below.
+ throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Error NO PropertyFile Path provided");
+ } else {
+ // Adding logic for remote Properties file.
+ Properties prop = new Properties();
+ if (propertyFilePath.startsWith("http")) {
+ URL configURL;
+ try {
+ configURL = new URL(propertyFilePath);
+ URLConnection connection = null;
+ connection = configURL.openConnection();
+ prop.load(connection.getInputStream());
+ } catch (IOException e) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
+ throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Maformed property URL "+ e.getMessage());
+ }
+ } else {
+ Path file = Paths.get(propertyFilePath);
+ if (Files.notExists(file)) {
+ throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "File doesn't exist in the specified Path " + file.toString());
+ }
+ if (file.toString().endsWith(".properties")) {
+ InputStream in;
+ prop = new Properties();
+ try {
+ in = new FileInputStream(file.toFile());
+ prop.load(in);
+ } catch (IOException e) {
+ logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
+ throw new PolicyEngineException(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Cannot Load the Properties file", e);
+ }
+ } else {
+ logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Not a .properties file " + propertyFilePath);
+ throw new PolicyEngineException(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Not a .properties file");
+ }
+ }
+ // UEB Settings
+ String check_type = prop.getProperty("NOTIFICATION_TYPE");
+ String serverList = prop.getProperty("NOTIFICATION_UEB_SERVERS");
+ if(check_type==null) {
+ notificationType.add("websocket");
+ logger.info("Properties file doesn't have the NOTIFICATION_TYPE parameter system will use defualt websockets");
+ }else{
+ if(check_type.contains(",")) {
+ type_default = new ArrayList<String>(Arrays.asList(prop.getProperty("NOTIFICATION_TYPE").split(",")));
+ notificationType = type_default;
+ } else {
+ notificationType = new ArrayList<String>();
+ notificationType.add(check_type);
+ }
+ }
+ if(serverList==null) {
+ notificationType.clear();
+ notificationType.add("websocket");
+ logger.info("Properties file doesn't have the NOTIFICATION_UEB_SERVERS parameter system will use defualt websockets");
+ }else{
+ if(serverList.contains(",")) {
+ uebURLList = new ArrayList<String>(Arrays.asList(prop.getProperty("NOTIFICATION_UEB_SERVERS").split(",")));
+ } else {
+ uebURLList = new ArrayList<String>();
+ uebURLList.add(serverList);
+ }
+ }
+ // Client ID Authorization Settings.
+ String clientID = prop.getProperty("CLIENT_ID");
+ String clientKey = prop.getProperty("CLIENT_KEY");
+ userName = clientID;
+ pass = clientKey;
+ pyPDPClientFile = prop.getProperty("CLIENT_FILE");
+ environment = prop.getProperty("ENVIRONMENT", "DEVL");
+ /*try {
+ aafClient = AAFPolicyClient.getInstance(prop);
+ } catch (AAFPolicyException e) {
+ logger.error(XACMLErrorConstants.ERROR_UNKNOWN + e.getMessage());
+ throw new PolicyEngineException(XACMLErrorConstants.ERROR_UNKNOWN + e);
+ }*/
+ // Initializing the values.
+ pdps = new ArrayList<String>();
+ paps = new ArrayList<String>();
+ encoding = new ArrayList<String>();
+ encodingPAP = new ArrayList<String>();
+ // Check the Keys for PDP_URLs
+ Collection<Object> unsorted = prop.keySet();
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ List<String> sorted = new ArrayList(unsorted);
+ Collections.sort(sorted);
+ for (String propKey : sorted) {
+ if (propKey.startsWith("PDP_URL")) {
+ String check_val = prop.getProperty(propKey);
+ if (check_val == null) {
+ throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Properties file doesn't have the PDP_URL parameter");
+ }
+ if (check_val.contains(";")) {
+ pdp_default = new ArrayList<String>(Arrays.asList(check_val.split("\\s*;\\s*")));
+ int pdpCount = 0;
+ while (pdpCount < pdp_default.size()) {
+ String pdpVal = pdp_default.get(pdpCount);
+ readPDPParam(pdpVal);
+ pdpCount++;
+ }
+ } else {
+ readPDPParam(check_val);
+ }
+ } else if (propKey.startsWith("PAP_URL")) {
+ String check_val = prop.getProperty(propKey);
+ if (check_val == null) {
+ throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Properties file doesn't have the PAP_URL parameter");
+ }
+ if (check_val.contains(";")) {
+ pap_default = new ArrayList<String>(Arrays.asList(check_val.split("\\s*;\\s*")));
+ int papCount = 0;
+ while (papCount < pap_default.size()) {
+ String papVal = pap_default.get(papCount);
+ readPAPParam(papVal);
+ papCount++;
+ }
+ } else {
+ readPAPParam(check_val);
+ }
+ }
+ }
+ if (pdps == null || pdps.isEmpty()) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot Proceed without PDP_URLs");
+ throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot Proceed without PDP_URLs");
+ }
+
+ if (paps == null || paps.isEmpty()) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot Proceed without PAP_URLs");
+ throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot Proceed with out PAP_URLs");
+ }
+
+ // Get JUNIT property from properties file when running tests
+ String junit = prop.getProperty("JUNIT");
+ if(junit == null || junit.isEmpty()){
+ logger.info("No JUNIT property provided, this will not be executed as a test.");
+ }else{
+ if(junit.equals("test")){
+ this.junit = true;
+ } else {
+ this.junit = false;
+ }
+ }
+ }
+ }
+
+ /*
+ * Read the PDP_URL parameter
+ */
+ private void readPDPParam(String pdpVal) throws PolicyEngineException{
+ if(pdpVal.contains(",")){
+ List<String> pdpValues = new ArrayList<String>(Arrays.asList(pdpVal.split("\\s*,\\s*")));
+ if(pdpValues.size()==3){
+ // 0 - PDPURL
+ pdps.add(pdpValues.get(0));
+ // 1:2 will be UserID:Password
+ String userID = pdpValues.get(1);
+ String pass = pdpValues.get(2);
+ Base64.Encoder encoder = Base64.getEncoder();
+ encoding.add(encoder.encodeToString((userID+":"+pass).getBytes(StandardCharsets.UTF_8)));
+ }else{
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Credentials to send Request: " + pdpValues);
+ throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "No enough Credentials to send Request. " + pdpValues);
+ }
+ }else{
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "PDP value is improper/missing required values: " + pdpVal);
+ throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "PDP value is improper/missing required values.");
+ }
+ }
+
+ /*
+ * Read the PAP_URL parameter
+ */
+ private void readPAPParam(String papVal) throws PolicyEngineException{
+ if(papVal.contains(",")){
+ List<String> papValues = new ArrayList<String>(Arrays.asList(papVal.split("\\s*,\\s*")));
+ if(papValues.size()==3){
+ // 0 - PAPURL
+ paps.add(papValues.get(0));
+ // 1:2 will be UserID:Password
+ String userID = papValues.get(1);
+ String pass = papValues.get(2);
+ Base64.Encoder encoder = Base64.getEncoder();
+ encodingPAP.add(encoder.encodeToString((userID+":"+pass).getBytes(StandardCharsets.UTF_8)));
+ }else{
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Credentials to send Request: " + papValues);
+ throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "No enough Credentials to send Request. " + papValues);
+ }
+ }else{
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Credentials to send Request: " + papVal);
+ throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "No enough Credentials to send Request.");
+ }
+ }
+ /*
+ * Allowing changes to the scheme and Handler.
+ */
+ public void notification(NotificationScheme scheme, NotificationHandler handler) {
+ this.scheme = scheme;
+ this.handler = handler;
+ logger.debug("Scheme is : " + scheme.toString());
+ logger.debug("Handler is : " + handler.getClass().getName());
+ if (!notificationType.get(0).equals("ueb")){
+ AutoClientEnd.setAuto(scheme, handler);
+ }else {
+ if (this.UEBThread){
+ UEBClientThread.setAuto(scheme, handler);
+ this.UEBThread = registerUEBThread.isAlive();
+ }
+ }
+
+ //TODO This could also be a Start point for Auto Notifications..
+ if(pdps!=null){
+ if (notificationType.get(0).equals("ueb") && !this.UEBThread){
+ this.UEBClientThread = new AutoClientUEB(pdps.get(0), uebURLList);
+ this.UEBClientThread.setAuto(scheme, handler);
+ this.registerUEBThread = new Thread(this.UEBClientThread);
+ this.registerUEBThread.start();
+ this.UEBThread = true;
+ }
+ if (!notificationType.get(0).equals("ueb")){
+ if(pdps.get(0)!=null){
+ if(AutoClientEnd.getURL()==null){
+ AutoClientEnd.start(pdps.get(0));
+ }else {
+ AutoClientEnd.stop();
+ AutoClientEnd.start(pdps.get(0));
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * Gets the Notification if one exists. Used only for Manual Polling
+ * purposes.
+ */
+ public PDPNotification getNotification(){
+ //TODO manual Polling
+ //Check if there is proper scheme..
+ PDPNotification notification = null;
+ if(this.scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS) || this.scheme.equals(NotificationScheme.MANUAL_NOTIFICATIONS)) {
+ if (notificationType.get(0).equals("ueb")){
+ ManualClientEndUEB.start(pdps.get(0), uebURLList, uniqueID);
+ notification = ManualClientEndUEB.result(scheme);
+ }else{
+ ManualClientEnd.start(pdps.get(0));
+ logger.debug("manual notification requested.. : " + scheme.toString());
+ notification = ManualClientEnd.result(scheme);
+ }
+
+ if (notification == null){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Notification yet..");
+ return null;
+ } else {
+ return notification;
+ }
+
+ }else {
+ return null;
+ }
+ }
+
+ /*
+ * Setting the Scheme.
+ */
+ public void setScheme(NotificationScheme scheme) {
+ this.scheme = scheme;
+ if (notificationType.get(0).equals("ueb")){
+ AutoClientUEB.setScheme(this.scheme);
+ if (this.scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)){
+ ManualClientEndUEB.createTopic(pdps.get(0), uniqueID, uebURLList);
+ }
+ }else{
+ AutoClientEnd.setScheme(this.scheme);
+ }
+ }
+
+ /*
+ * Returns the Scheme
+ */
+ public NotificationScheme getScheme() {
+ return this.scheme;
+ }
+
+ /*
+ * Returns the NotificationHandler
+ */
+ public NotificationHandler getNotificationHandler() {
+ return this.handler;
+ }
+
+ private Collection<PolicyConfig> configResult(
+ Collection<StdStatus> generateRequest) {
+ Collection<PolicyConfig> result = new HashSet<PolicyConfig>();
+ if (generateRequest == null) {
+ return null;
+ }
+ if (!generateRequest.isEmpty()) {
+ for (StdStatus stdStatus : generateRequest) {
+ PolicyConfig policyConfig = new StdPolicyConfig();
+ policyConfig = stdStatus;
+ result.add(policyConfig);
+ }
+ }
+ return result;
+ }
+
+ private Collection<PolicyResponse> eventResult(
+ Collection<StdStatus> generateRequest,
+ Map<String, String> eventAttributes) {
+ Collection<PolicyResponse> result = new HashSet<PolicyResponse>();
+ if (generateRequest == null) {
+ return null;
+ }
+ if (!generateRequest.isEmpty()) {
+ for (StdStatus stdStatus : generateRequest) {
+ StdPolicyResponse policyResponse = new StdPolicyResponse();
+ policyResponse = stdStatus;
+ policyResponse.setRequestAttributes(eventAttributes);
+ result.add(policyResponse);
+ }
+ }
+ return result;
+ }
+
+ private DecisionResponse decisionResult(Collection<StdStatus> generateRequest) {
+ StdDecisionResponse policyDecision = new StdDecisionResponse();
+ if (generateRequest == null) {
+ return policyDecision;
+ }
+ if (!generateRequest.isEmpty()) {
+ for (StdStatus stdStatus : generateRequest) {
+ policyDecision.setDecision(stdStatus.getDecision());
+ policyDecision.setDetails(stdStatus.getDetails());
+ }
+ }
+ return policyDecision;
+ }
+
+ /*
+ * Stop the Notification Service if its running.
+ */
+ public void stopNotification() {
+ if (this.scheme != null && this.handler != null) {
+ if (this.scheme.equals(NotificationScheme.AUTO_ALL_NOTIFICATIONS)
+ || this.scheme
+ .equals(NotificationScheme.AUTO_NOTIFICATIONS)) {
+ logger.info("Clear Notification called.. ");
+ if (notificationType.get(0).equals("ueb")){
+ this.UEBClientThread.terminate();
+ this.UEBThread = false;
+ }else{
+ AutoClientEnd.stop();
+ }
+ }
+ }
+ }
+
+ /*
+ * Create Config Policy API Implementation
+ */
+ public String createConfigPolicy(String policyName, String policyDescription, String ecompName, String configName,
+ Map<String, String> configAttributes, String configType, String body, String policyScope, UUID requestID,
+ String riskLevel, String riskType, String guard, String ttlDate) throws Exception {
+ return createConfigPolicy(policyName,policyDescription, ecompName, configName,
+ configAttributes, configType, body, policyScope, requestID, userName , pass, riskLevel, riskType, guard, ttlDate);
+ }
+
+ public String createConfigPolicy(String policyName, String policyDescription, String ecompName, String configName,
+ Map<String, String> configAttributes, String configType, String body, String policyScope, UUID requestID, String userID, String passcode,
+ String riskLevel, String riskType, String guard, String ttlDate) throws Exception {
+
+ String response = null;
+ String configBody = null;
+ String resource= "createPolicy";
+ if(!checkPermissions(userID, passcode, resource)){
+ logger.error(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ response = XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource;
+ return response;
+ }
+
+ //check body for JSON form and remove single quotes if present
+ if (configType.equalsIgnoreCase("JSON")) {
+ if (body.contains("'")) {
+ configBody = body.replace("'", "\"");
+ } else {
+ configBody = body;
+ }
+ } else {
+ configBody = body;
+ }
+
+ boolean levelCheck = isNumeric(riskLevel);
+
+ if (policyName==null||policyName.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.";
+ } else if (ecompName==null||ecompName.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No ECOMP Name given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No ECOMP Name given.";
+ } else if (configName==null||configName.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Config Name given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Config Name given.";
+ } else if (policyScope==null||policyScope.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.";
+ } else if (!levelCheck){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.";
+ }else {
+
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy("Base", policyName, policyDescription, ecompName, configName, configAttributes, configType,
+ configBody, false, policyScope,0, riskLevel, riskType, guard, ttlDate);
+
+ //send JSON object to PAP
+ response = (String) callPAP(newPAPPolicy, new String[] {"operation=create", "apiflag=api", "policyType=Config"}, requestID, "Config");
+ }
+ return response;
+
+ }
+
+ /*
+ * Create Config Policy API Implementation
+ */
+ public String updateConfigPolicy(String policyName, String policyDescription, String ecompName, String configName,
+ Map<String, String> configAttributes, String configType, String body, String policyScope, UUID requestID,
+ String riskLevel, String riskType, String guard, String ttlDate) throws Exception {
+ return updateConfigPolicy(policyName, policyDescription, ecompName, configName,
+ configAttributes, configType, body, policyScope, requestID, userName, pass, riskLevel, riskType, guard, ttlDate);
+ }
+
+ public String updateConfigPolicy(String policyName, String policyDescription, String ecompName, String configName,
+ Map<String, String> configAttributes, String configType, String body, String policyScope,
+ UUID requestID, String userID, String passcode,String riskLevel, String riskType, String guard,
+ String ttlDate) throws Exception {
+
+ String response = null;
+ String configBody = null;
+ String resource= "updatePolicy";
+ if(!checkPermissions(userID, passcode, resource)){
+ logger.error(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ response = XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource;
+ return response;
+ }
+ //check body for JSON form and remove single quotes if present
+ if (configType.equalsIgnoreCase("JSON")) {
+ if (body.contains("'")) {
+ configBody = body.replace("'", "\"");
+ } else {
+ configBody = body;
+ }
+ } else {
+ configBody = body;
+ }
+
+ boolean levelCheck = isNumeric(riskLevel);
+
+ if (policyName==null||policyName.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.";
+ } else if (ecompName==null||ecompName.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No ECOMP Name given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No ECOMP Name given.";
+ } else if (configName==null||configName.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Config Name given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Config Name given.";
+ } else if (policyScope==null||policyScope.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.";
+ } else if (!levelCheck){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.";
+ } else {
+
+ //set values for basic policy information
+ String policyType = "Config";
+ String configPolicyType = "base";
+
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy(configPolicyType, policyName, policyDescription, ecompName, configName, configAttributes, configType,
+ configBody, true, policyScope,0, riskLevel, riskType, guard, ttlDate);
+
+ //send JSON object to PAP
+ response = (String) callPAP(newPAPPolicy, new String[] {"operation=update", "apiflag=api", "policyType=" + policyType}, requestID, "Config");
+
+ }
+ return response;
+
+ }
+
+
+ /*
+ * Create Config Firewall Policy API implementation
+ */
+ public String createConfigFirewallPolicy(String policyName, JsonObject firewallJson, String policyScope, UUID requestID,
+ String riskLevel, String riskType, String guard, String ttlDate) throws Exception {
+ return createConfigFirewallPolicy(policyName, firewallJson, policyScope, requestID, userName, pass, riskLevel, riskType, guard, ttlDate);
+ }
+
+ public String createConfigFirewallPolicy(String policyName, JsonObject firewallJson, String policyScope, UUID requestID, String userID, String passcode,
+ String riskLevel, String riskType, String guard, String ttlDate) throws Exception {
+
+ String response = null;
+ String resource= "createPolicy";
+ if(!checkPermissions(userID, passcode, resource)){
+ logger.error(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ response = XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource;
+ return response;
+ }
+
+ //set values for basic policy information
+ String configName = firewallJson.get("configName").toString();
+ //String configDescription = firewallJson.get("configDescription").toString();
+ String configDescription = "";
+ String json = firewallJson.toString();
+
+ boolean levelCheck = isNumeric(riskLevel);
+
+ if (!isJSONValid(json)) {
+ logger.error(XACMLErrorConstants.ERROR_SCHEMA_INVALID + "Invalid JSON for firewallJson: " + json);
+ throw new PolicyDecisionException(XACMLErrorConstants.ERROR_SCHEMA_INVALID + "Invalid JSON for firewallJson: " + json);
+ }
+
+ if (policyName==null||policyName.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.";
+ } else if (policyScope==null||policyScope.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.";
+ } else if (!levelCheck){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.";
+ } else {
+
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy("Firewall Config", policyName, configDescription, configName, false, policyScope, json, 0,
+ riskLevel, riskType, guard, ttlDate);
+
+ //send JSON object to PAP
+ response = (String) callPAP(newPAPPolicy, new String[] {"operation=create", "apiflag=api", "policyType=Config"}, requestID, "ConfigFirewall");
+ }
+
+ return response;
+ }
+
+ /*
+ * Update Config Firewall Policy API implementation
+ */
+ public String updateConfigFirewallPolicy(String policyName, JsonObject firewallJson, String policyScope, UUID requestID, String riskLevel, String riskType,
+ String guard, String ttlDate) throws Exception {
+ return updateConfigFirewallPolicy(policyName, firewallJson, policyScope, requestID, userName, pass, riskLevel, riskType, guard, ttlDate);
+ }
+
+ public String updateConfigFirewallPolicy(String policyName, JsonObject firewallJson, String policyScope, UUID requestID, String userID, String passcode,
+ String riskLevel, String riskType, String guard, String ttlDate) throws Exception {
+
+ String response = null;
+ String resource= "updatePolicy";
+ if(!checkPermissions(userID, passcode, resource)){
+ logger.error(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ response = XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource;
+ return response;
+ }
+ String configName = firewallJson.get("configName").toString();
+ //String configDescription = firewallJson.get("configDescription").toString();
+ String configDescription = ""; //ASK Lak about this...****
+ String json = firewallJson.toString();
+ boolean levelCheck = isNumeric(riskLevel);
+
+ if (policyName==null||policyName.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.";
+ } else if (policyScope==null||policyScope.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.";
+ } else if (!levelCheck){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.";
+ } else {
+
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy("Firewall Config", policyName, configDescription, configName, true, policyScope, json, 0,
+ riskLevel, riskType, guard, ttlDate);
+
+ //send JSON object to PAP
+ response = (String) callPAP(newPAPPolicy, new String[] {"operation=update", "apiflag=api", "policyType=Config"}, requestID, "ConfigFirewall");
+ }
+
+ return response;
+ }
+
+ /*
+ * Create or Update BRMS Raw Config Policy API implementation
+ */
+ public String createUpdateBRMSRawPolicy(String policyName,
+ String policyDescription,
+ Map<AttributeType, Map<String, String>> dyanamicFieldConfigAttributes,
+ String brmsRawBody,
+ String policyScope,
+ Boolean isEdit,
+ UUID requestID,
+ String riskLevel,
+ String riskType,
+ String guard,
+ String ttlDate) {
+
+ String response = null;
+ String operation = null;
+
+
+ if (isEdit){
+ operation = "update";
+ } else {
+ operation = "create";
+ }
+
+ boolean levelCheck = isNumeric(riskLevel);
+
+ if (policyName==null||policyName.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.";
+ } else if(policyDescription==null || policyDescription.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No policyDescription given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No policyDescription given.";
+ } else if (policyScope==null||policyScope.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.";
+ } else if (brmsRawBody==null ||brmsRawBody.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No rule body given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No rule body given.";
+ } else if (!levelCheck){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.";
+ } else {
+ /*String configPolicyType, String policyName, String description,
+ String configName, Boolean editPolicy, String domain,
+ Map<String,String> dyanamicFieldConfigAttributes, Integer highestVersion, String eCompName,
+ String configBodyData*/
+
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy("BRMS_Raw",policyName,policyDescription,
+ "BRMS_RAW_RULE",isEdit,policyScope,
+ dyanamicFieldConfigAttributes.get(AttributeType.RULE), 0, "DROOLS",
+ brmsRawBody, riskLevel, riskType, guard, ttlDate);
+
+ //send JSON object to PAP
+ try {
+ response = (String) callPAP(newPAPPolicy, new String[] {"operation="+operation, "apiflag=api", "policyType=Config"}, requestID, "ConfigBrmsRaw");
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ return response;
+ }
+
+ /*
+ * Create or Update BRMS Param Config Policy API implementation
+ */
+ public String createUpdateBRMSParamPolicy(String policyName,
+ String policyDescription,
+ Map<AttributeType, Map<String, String>> dyanamicFieldConfigAttributes,
+ String brmsRawBody,
+ String policyScope,
+ Boolean isEdit,
+ UUID requestID,
+ Map<AttributeType, Map<String, String>> drlRuleAndUIParams,
+ String riskLevel, String riskType, String guard, String ttlDate) {
+
+ String response = null;
+ String operation = null;
+
+
+ if (isEdit){
+ operation = "update";
+ } else {
+ operation = "create";
+ }
+
+ boolean levelCheck = isNumeric(riskLevel);
+
+ if (policyName==null||policyName.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.";
+ } else if(policyDescription==null || policyDescription.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No policyDescription given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No policyDescription given.";
+ } else if (policyScope==null||policyScope.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.";
+ } else if ((dyanamicFieldConfigAttributes==null)){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Rule Attributes given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Rule Attributes given.";
+ } else if (!levelCheck){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.";
+ }else {
+ /*public StdPAPPolicy (String configPolicyType, String policyName, String description,
+ String configName, Boolean editPolicy, String domain,
+ Map<String,String> dyanamicFieldConfigAttributes, Integer highestVersion, String eCompName,
+ String configBodyData,Map<String,String> drlRuleAndUIParams) */
+
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy("BRMS_Param",policyName,policyDescription,
+ "BRMS_PARAM_RULE",isEdit,policyScope,
+ drlRuleAndUIParams.get(AttributeType.MATCHING), 0, "DROOLS",
+ brmsRawBody, drlRuleAndUIParams.get(AttributeType.RULE), riskLevel, riskType, guard, ttlDate);
+
+ //send JSON object to PAP
+ try {
+ response = (String) callPAP(newPAPPolicy, new String[] {"operation="+operation, "apiflag=api", "policyType=Config"}, requestID, "ConfigBrmsParam");
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ return response;
+ }
+
+ /*
+ * Create or Update Action Policy API implementation
+ */
+ public String createUpdateActionPolicy(String policyName, String policyDescription, Map<String,String> componentAttributes, List<String> dynamicRuleAlgorithmLabels,
+ List<String> dynamicRuleAlgorithmField1, List<String> dynamicRuleAlgorithmFunctions, List<String> dynamicRuleAlgorithmField2,
+ String actionPerformer, String actionAttribute, String policyScope, Boolean isEdit, UUID requestID) {
+
+ String response = null;
+ String operation = null;
+
+ if (isEdit){
+ operation = "update";
+ } else {
+ operation = "create";
+ }
+
+ if (policyName==null||policyName.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.";
+ return response;
+ } else if (componentAttributes==null||componentAttributes.equals("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Component Attributes given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Component Attributes given.";
+ return response;
+ } else if (actionAttribute==null||actionAttribute.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Action Attribute given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Action Attribute given.";
+ return response;
+ } else if (policyScope==null||policyScope.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.";
+ return response;
+ } else if (actionPerformer==null||actionPerformer.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Action Performer given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Action Performer given.";
+ return response;
+ } else if (!actionPerformer.equals("PEP")) {
+ if (!actionPerformer.equals("PDP")) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Action Performer given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Action Performer given.";
+ return response;
+ }
+ }
+
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy(policyName, policyDescription, componentAttributes, dynamicRuleAlgorithmLabels, dynamicRuleAlgorithmFunctions,
+ dynamicRuleAlgorithmField1, dynamicRuleAlgorithmField2, actionPerformer, actionAttribute, isEdit, policyScope, 0);
+
+ //send JSON object to PAP
+ try {
+ response = (String) callPAP(newPAPPolicy, new String[] {"operation="+operation, "apiflag=api", "policyType=Action"}, requestID, "Action");
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return response;
+
+ }
+
+ /*
+ * Create or Update Decision Policy implementation
+ */
+ private String createUpdateDecisionPolicy(String policyName, String policyDescription, String ecompName, RuleProvider ruleProvider, Map<String,String> componentAttributes, Map<String,String> settings,
+ List<String> dynamicRuleAlgorithmLabels, List<String> dynamicRuleAlgorithmField1, List<String> dynamicRuleAlgorithmFunctions, List<String> dynamicRuleAlgorithmField2,
+ String policyScope, Boolean isEdit, UUID requestID) {
+
+ String response = null;
+ String operation = null;
+
+ if (isEdit){
+ operation = "update";
+ } else {
+ operation = "create";
+ }
+
+ if (policyName==null||policyName.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.";
+ } else if (ecompName==null||ecompName.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No ECOMP Name given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No ECOMP Name given.";
+ } else if (policyScope==null||policyScope.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.";
+ } else {
+
+ if (ruleProvider==null) {
+ ruleProvider = RuleProvider.CUSTOM ;
+ }
+
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy(policyName, policyDescription, ecompName, ruleProvider.toString(), componentAttributes, settings, dynamicRuleAlgorithmLabels, dynamicRuleAlgorithmFunctions,
+ dynamicRuleAlgorithmField1, dynamicRuleAlgorithmField2, null, null, null, isEdit, policyScope, 0);
+
+ //send JSON object to PAP
+ try {
+ response = (String) callPAP(newPAPPolicy, new String[] {"operation="+operation, "apiflag=api", "policyType=Decision"}, requestID, "Decision");
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ return response;
+ }
+
+ /*
+ * Create or Update ClosedLoop_Fault policy implementation
+ */
+ private String createUpdateClosedLoopPolicy(String policyName, JsonObject configBody, String policyDescription, String policyScope, Boolean isEdit,
+ UUID requestID,String riskLevel, String riskType, String guard, String ttlDate) {
+
+ String response = null;
+ String operation = null;
+ String oldPolicyName = null;
+
+ if (isEdit){
+ operation = "update";
+ if (policyName.endsWith("_Draft")) {
+ oldPolicyName = policyName + "_Draft.1";
+ }
+ } else {
+ operation = "create";
+ }
+
+ boolean levelCheck = isNumeric(riskLevel);
+
+ // get values and attributes from the JsonObject
+ String ecompName = configBody.get("ecompname").toString().replace("\"", "");
+ String jsonBody = configBody.toString();
+
+
+ if (policyName==null||policyName.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.";
+ } else if (ecompName==null||ecompName.equals("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Ecomp Name given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Ecomp Name given.";
+ } else if (policyScope==null||policyScope.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.";
+ } else if (!levelCheck){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.";
+ } else {
+
+
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy("ClosedLoop_Fault", policyName, policyDescription, ecompName,
+ jsonBody, false, oldPolicyName, null, isEdit, policyScope, 0, riskLevel, riskType, guard, ttlDate);
+
+ //send JSON object to PAP
+ try {
+ response = (String) callPAP(newPAPPolicy, new String[] {"operation="+operation, "apiflag=api", "policyType=Config"}, requestID, "ConfigClosedLoop");
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ return response;
+
+ }
+
+ private String createUpdateClosedLoopPmPolicy(String policyName, JsonObject configBody, String policyDescription, String policyScope, Boolean isEdit,
+ UUID requestID, String riskLevel, String riskType, String guard, String ttlDate) {
+
+ String response = null;
+ String operation = null;
+ String oldPolicyName = null;
+
+ if (isEdit){
+ operation = "update";
+ } else {
+ operation = "create";
+ }
+
+ boolean levelCheck = isNumeric(riskLevel);
+
+ // get values and attributes from the JsonObject
+ String ecompName = configBody.get("ecompname").toString().replace("\"", "");
+ String serviceType = configBody.get("serviceTypePolicyName").toString().replace("\"", "");
+ String jsonBody = configBody.toString();
+
+
+ if (policyName==null||policyName.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.";
+ } else if (ecompName==null||ecompName.equals("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Ecomp Name given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Ecomp Name given.";
+ } else if (policyScope==null||policyScope.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.";
+ } else if (!levelCheck){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.";
+ } else {
+
+
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy("ClosedLoop_PM", policyName, policyDescription, ecompName,
+ jsonBody, false, oldPolicyName, serviceType, isEdit, policyScope, 0, riskLevel, riskType, guard, ttlDate);
+
+ //send JSON object to PAP
+ try {
+ response = (String) callPAP(newPAPPolicy, new String[] {"operation="+operation, "apiflag=api", "policyType=Config"}, requestID, "ConfigClosedLoop");
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ return response;
+
+ }
+
+ public Boolean validateNONASCIICharactersAndAllowSpaces(Object json){
+ Boolean isValidForm = false;
+ if (json instanceof String) {
+ String jsonString = (String)json;
+ if (jsonString.isEmpty()) {
+ logger.info("JSON String is empty so cannot validate NON ACSII Characters.");
+ } else {
+ if(CharMatcher.ASCII.matchesAllOf((CharSequence) jsonString)){
+ logger.info("The Value does not contain ASCII Characters");
+ isValidForm = true;
+ }else{
+ logger.error("The Value Contains Non ASCII Characters");
+ isValidForm = false;
+ }
+ }
+ } else if (json instanceof JsonObject) {
+ JsonObject jsonObj = (JsonObject)json;
+ if (jsonObj.isEmpty()){
+ logger.info("JSON object is empty so cannot validate NON ACSII Characters.");
+ } else {
+ if(CharMatcher.ASCII.matchesAllOf((CharSequence) jsonObj.toString())){
+ logger.info("The Value does not contain ASCII Characters");
+ isValidForm = true;
+ }else{
+ logger.error("The Value Contains Non ASCII Characters");
+ isValidForm = false;
+ }
+ }
+
+ }
+
+ return isValidForm;
+ }
+
+ private String createUpdateMicroServicesPolicy(String policyName, JsonObject microServiceAttributes, String ecompName, String policyScope, Boolean isEdit, UUID requestID,
+ String riskLevel, String riskType, String guard, String ttlDate) {
+
+ String response = null;
+ String operation = null;
+
+ if (isEdit){
+ operation = "update";
+ } else {
+ operation = "create";
+ }
+
+ boolean levelCheck = isNumeric(riskLevel);
+
+ // get values and attributes from the JsonObject
+ String microService = microServiceAttributes.get("service").toString().replace("\"", "");
+ String uuid = microServiceAttributes.get("uuid").toString().replace("\"", "");
+ String msLocation = microServiceAttributes.get("location").toString().replace("\"", "");;
+ String policyDescription = microServiceAttributes.get("description").toString().replace("\"", "");
+ String configName = microServiceAttributes.get("configName").toString().replace("\"", "");
+ String priority = microServiceAttributes.get("priority").toString().replace("\"", "");
+ String version = microServiceAttributes.get("version").toString().replace("\"", "");
+
+
+ if (policyName==null||policyName.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.";
+ } else if (ecompName==null||ecompName.equals("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Ecomp Name given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Ecomp Name given.";
+ } else if (configName==null||configName.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Configuration Name given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Configuration Name given.";
+ } else if (policyScope==null||policyScope.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.";
+ } else if (!levelCheck){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.";
+ } else {
+
+
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy("DCAE Micro Service", policyName, policyDescription, ecompName,
+ configName, microService, uuid, msLocation, microServiceAttributes.toString(), priority,
+ version, isEdit, policyScope, 0, riskLevel, riskType, guard, ttlDate);
+
+ //send JSON object to PAP
+ try {
+ response = (String) callPAP(newPAPPolicy, new String[] {"operation="+operation, "apiflag=api", "policyType=Config"}, requestID, "ConfigMS");
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ return response;
+
+ }
+
+
+ /*
+ * Push a policy to the PDP API implementation
+ */
+ public String pushPolicy(String policyScope, String policyName, String policyType, String pdpGroup, UUID requestID) throws Exception {
+ return pushPolicy(policyScope, policyName, policyType, pdpGroup, requestID, userName, pass);
+ }
+
+ public String pushPolicy(String policyScope, String policyName, String policyType, String pdpGroup, UUID requestID, String userID, String passcode) throws Exception {
+ String resource= "pushPolicy";
+ if(!checkPermissions(userID, passcode, resource)){
+ logger.error(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ return (XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ }
+ String response = null;
+ String filePrefix = null;
+ String clientScope = null;
+ String activeVersion = null;
+
+ //get the client scope based policy type
+ if (policyType.equalsIgnoreCase("Firewall")){
+ clientScope = "ConfigFirewall";
+ filePrefix = "Config_FW_";
+ } else if (policyType.equalsIgnoreCase("Action")) {
+ clientScope = "Action";
+ filePrefix = "Action_";
+ } else if (policyType.equalsIgnoreCase("Decision")){
+ clientScope = "Decision";
+ filePrefix = "Decision_";
+ } else if (policyType.equalsIgnoreCase("Base")){
+ clientScope = "Config";
+ filePrefix = "Config_";
+ } else if (policyType.equalsIgnoreCase("ClosedLoop_Fault")){
+ clientScope = "ConfigClosedLoop";
+ filePrefix = "Config_Fault_";
+ } else if (policyType.equalsIgnoreCase("ClosedLoop_PM")){
+ clientScope = "ConfigClosedLoop";
+ filePrefix = "Config_PM_";
+ } else if (policyType.equalsIgnoreCase("MicroService")) {
+ clientScope = "ConfigMS";
+ filePrefix = "Config_MS_";
+ }else if (policyType.equalsIgnoreCase("BRMS_RAW")){
+ clientScope = "ConfigBrmsRaw";
+ filePrefix = "Config_BRMS_Raw_";
+ } else if (policyType.equalsIgnoreCase("BRMS_PARAM")){
+ clientScope = "ConfigBrmsParam";
+ filePrefix = "Config_BRMS_Param_";
+ } else {
+ clientScope = null;
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + policyType + " is not a valid Policy Type.");
+ return XACMLErrorConstants.ERROR_DATA_ISSUE + policyType + " is not a valid Policy Type.";
+ }
+
+ logger.debug("clientScope is " + clientScope);
+ logger.debug("filePrefix is " + filePrefix);
+
+ if (pdpGroup == null) {
+ pdpGroup = "default";
+ }
+
+ if (policyName==null||policyName.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.";
+ } else if (policyScope==null||policyScope.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given.";
+ } else if (policyType==null||policyType.equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Type given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Type given.";
+ } else {
+ // requestID null check.
+ if(requestID==null){
+ requestID = UUID.randomUUID();
+ logger.debug("Request ID not provided. Generating request ID " + requestID.toString());
+ }
+
+ // change call to getActiveVersion to pass requestID for PAP to receive on the GET process so PAP won't generate another
+ // activeVersion = getActiveVersion(policyScope, filePrefix, policyName, clientScope);
+ activeVersion = getActiveVersion(policyScope, filePrefix, policyName, clientScope, requestID);
+ logger.debug("The active version of " + policyScope + File.separator + filePrefix + policyName + " is " + activeVersion);
+
+ String id = null;
+ if (activeVersion.equalsIgnoreCase("pe100")) {
+ logger.error(XACMLErrorConstants.ERROR_PERMISSIONS + "response code of the URL is 403. PEP is not Authorized for making this Request!! "
+ + "\n Contact Administrator for this Scope. ");
+ return XACMLErrorConstants.ERROR_PERMISSIONS + "response code of the URL is 403. PEP is not Authorized for making this Request!! "
+ + "Contact Administrator for this Scope. ";
+
+ } else if (activeVersion.equalsIgnoreCase("pe300")) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "response code of the URL is 404. "
+ + "This indicates a problem with getting the version from the PAP or the policy does not exist.");
+ return XACMLErrorConstants.ERROR_DATA_ISSUE + "response code of the URL is 404. "
+ + "This indicates a problem with getting the version from the PAP or the policy does not exist.";
+ }
+
+
+ if (!activeVersion.equalsIgnoreCase("0")) {
+ id = policyScope + "." + filePrefix + policyName + "." + activeVersion + ".xml";
+ logger.debug("The policyId is " + id);
+ } else {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "could not retrieve the activeVersion for this policy. "
+ + "This indicates the policy does not exist, please verify the policy exists.");
+ return XACMLErrorConstants.ERROR_DATA_ISSUE + "could not retrieve the activeVersion for this policy. could not retrieve the activeVersion for this policy. "
+ + "This indicates the policy does not exist, please verify the policy exists.";
+ }
+
+ // change call to getgitPath to pass requestID for PAP to receive on the GET process so PAP won't generate another
+ // String gitPath = getGitPath(policyScope, filePrefix, policyName, activeVersion, clientScope);
+ String gitPath = getGitPath(policyScope, filePrefix, policyName, activeVersion, clientScope, requestID);
+ logger.debug("Full gitPath policy xml file: " + gitPath);
+
+ // change call to getSelectedURI to pass requestID for PAP to receive on the GET process so PAP won't generate another
+ // URI selectedURI = getSelectedURI(gitPath, clientScope);
+ URI selectedURI = getSelectedURI(gitPath, clientScope, requestID);
+
+ logger.debug("The selectedURI is : " + selectedURI.toString());
+ String name = filePrefix+policyName;
+
+ StdPDPPolicy selectedPolicy = new StdPDPPolicy(id, true, name, selectedURI, isValid, policyId, description, pushVersion);
+
+ logger.debug("StdPDPPolicy object contains: " + selectedPolicy.getId() + ", " + selectedPolicy.getName() + ", " + selectedPolicy.getLocation().toString());
+
+ response = copyPolicy(selectedPolicy, pdpGroup, clientScope, requestID);
+
+ logger.debug("copyPolicy response: " + response);
+
+ if(response.contains("successfully")){
+ response = (String) callPAP(selectedPolicy, new String[]{"groupId=" + pdpGroup, "policyId="+id, "apiflag=addPolicyToGroup", "operation=PUT"}, requestID, clientScope);
+ }
+
+ logger.debug("Final API response: " + response);
+ }
+
+ return response;
+
+ }
+
+ private String deletePolicyFromPAP(DeletePolicyParameters parameters) {
+ String response = null;
+ String clientScope = null;
+ String pdpGroup = parameters.getPdpGroup();
+
+ if (pdpGroup==null){
+ pdpGroup="NA";
+ }
+
+ //get the client scope based policy type
+ if (parameters.getPolicyName().contains("Config_FW")){
+ clientScope = "ConfigFirewall";
+ } else if (parameters.getPolicyName().contains("Action")) {
+ clientScope = "Action";
+ } else if (parameters.getPolicyName().contains("Decision")){
+ clientScope = "Decision";
+ } else if (parameters.getPolicyName().contains("Config_Fault")){
+ clientScope = "ConfigClosedLoop";
+ } else if (parameters.getPolicyName().contains("Config_PM")){
+ clientScope = "ConfigClosedLoop";
+ } else if (parameters.getPolicyName().contains("Config_MS")){
+ clientScope = "ConfigMS";
+ } else if (parameters.getPolicyName().contains("Config_BRMS_Raw")){
+ clientScope = "ConfigBrmsRaw";
+ } else if (parameters.getPolicyName().contains("Config_BRMS_Param")){
+ clientScope = "ConfigBrmsParam";
+ } else {
+ clientScope = "Config";
+ }
+
+ logger.debug("clientScope is " + clientScope);
+
+ if (clientScope==null||clientScope.equals("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + parameters.getPolicyName() + " is not a valid Policy Name.");
+ return XACMLErrorConstants.ERROR_DATA_ISSUE + parameters.getPolicyName() + " is not a valid Policy Name.";
+ }
+
+ if (parameters.getPolicyName()==null||parameters.getPolicyName().equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.";
+ } else if (parameters.getDeleteCondition()==null||parameters.getDeleteCondition().equals("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Delete Condition given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Delete Condition given.";
+ } else {
+
+ StdPAPPolicy deletePapPolicy = new StdPAPPolicy(parameters.getPolicyName(), parameters.getDeleteCondition().toString());
+
+ //send JSON object to PAP
+ try {
+ response = (String) callPAP(deletePapPolicy, new String[] {"groupId="+pdpGroup, "apiflag=deletePapApi", "operation=delete" }, parameters.getRequestID(), clientScope);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ return response;
+ }
+
+ private String deletePolicyFromPDP(DeletePolicyParameters parameters) {
+ String response = null;
+ String clientScope = null;
+ String pdpGroup = parameters.getPdpGroup();
+
+ if (pdpGroup==null){
+ pdpGroup="NA";
+ }
+
+ //get the client scope based policy type
+ if (parameters.getPolicyName().contains("Config_FW")){
+ clientScope = "ConfigFirewall";
+ } else if (parameters.getPolicyName().contains("Action")) {
+ clientScope = "Action";
+ } else if (parameters.getPolicyName().contains("Decision")){
+ clientScope = "Decision";
+ } else if (parameters.getPolicyName().contains("Config_Fault")){
+ clientScope = "ConfigClosedLoop";
+ } else if (parameters.getPolicyName().contains("Config_PM")){
+ clientScope = "ConfigClosedLoop";
+ } else if (parameters.getPolicyName().contains("Config_MS")){
+ clientScope = "ConfigMS";
+ }else if (parameters.getPolicyName().contains("Config_BRMS_Raw")){
+ clientScope = "ConfigBrmsRaw";
+ } else if (parameters.getPolicyName().contains("Config_BRMS_Param")){
+ clientScope = "ConfigBrmsParam";
+ } else {
+ clientScope = "Config";
+ }
+
+ logger.debug("clientScope is " + clientScope);
+
+ if (clientScope==null||clientScope.equals("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + parameters.getPolicyName() + " is not a valid Policy Name.");
+ return XACMLErrorConstants.ERROR_DATA_ISSUE + parameters.getPolicyName() + " is not a valid Policy Name.";
+ }
+
+ if (parameters.getPolicyName()==null||parameters.getPolicyName().equalsIgnoreCase("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Name given.";
+ } else if (parameters.getPdpGroup()==null||parameters.getPdpGroup().equals("")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "No PDP Group given.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "No PDP Group given.";
+ } else {
+
+ //send JSON object to PAP
+ try {
+ response = (String) callPAP(null, new String[] {"policyName="+parameters.getPolicyName(), "groupId="+pdpGroup, "apiflag=deletePdpApi", "operation=delete" }, parameters.getRequestID(), clientScope);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ return response;
+ }
+
+ /*
+ * Copy a single Policy file from the input stream to the PAP Servlet.
+ * Either this works (silently) or it throws an exception.
+ *
+ */
+ public String copyFile(String policyId, String group, StdPAPPolicy location, String clientScope, UUID requestID) throws PAPException {
+ String response = null;
+ //String clientScope = null;
+
+ // send the policy file to the PAP Servlet
+ try {
+ response = (String) callPAP(location, new String[] {"groupId=" + group, "policyId="+policyId, "apiflag=api", "operation=post"}, requestID, clientScope);
+ } catch (Exception e) {
+ String message = "Unable to PUT policy '" + policyId + "', e:" + e;
+ logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + message, e);
+ throw new PAPException(message);
+ }
+
+ return response;
+ }
+
+ public String copyPolicy(PDPPolicy policy, String group, String policyType, UUID requestID) throws PAPException {
+ String response = null;
+
+ if (policy == null || group == null) {
+ throw new PAPException("Null input policy="+policy+" group="+group);
+ }
+ try {
+ StdPAPPolicy location = new StdPAPPolicy(policy.getLocation());
+ response = copyFile(policy.getId(), group, location, policyType, requestID);
+ } catch (Exception e) {
+ String message = "Unable to PUT policy '" + policy.getId() + "', e:" + e;
+ logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + message, e);
+ throw new PAPException(message);
+ }
+
+ return response;
+ }
+
+ public Object callPAP(Object content, String[] parameters, UUID requestID, String clientScope) throws Exception {
+ String response = null;
+ HttpURLConnection connection = null;
+ String requestMethod = null;
+ String operation = null;
+ responseCode = 0;
+ // Checking for the available PDPs is done during the first Request and the List is going to have the connected PDP as first element.
+ // This makes it Real-Time to change the list depending on their availability.
+ if (paps == null || paps.isEmpty()) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "PAPs List is Empty.");
+ throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE +"PAPs List is empty.");
+ }else {
+ int papsCount = 0;
+ boolean connected = false;
+ while (papsCount < paps.size()) {
+ try {
+ String fullURL = paps.get(0);
+ if (parameters != null && parameters.length > 0) {
+ String queryString = "";
+ for (String p : parameters) {
+ queryString += "&" + p;
+ if (p.equalsIgnoreCase("operation=post")){
+ requestMethod = "POST";
+ } else if (p.equalsIgnoreCase("operation=delete")){
+ requestMethod = "DELETE";
+ operation = "delete";
+ } else {
+ requestMethod = "PUT";
+ if (p.equalsIgnoreCase("operation=create")){
+ operation = "create";
+ } else if (p.equalsIgnoreCase("operation=update")){
+ operation = "update";
+ } else if (p.equalsIgnoreCase("operation=createDictionary")){
+ operation = "createDictionary";
+ }
+ }
+ }
+ fullURL += "?" + queryString.substring(1);
+ }
+
+ URL url = new URL (fullURL);
+
+ //Open the connection
+ connection = (HttpURLConnection)url.openConnection();
+
+ // Setting Content-Type
+ connection.setRequestProperty("Content-Type",
+ "application/json");
+
+ // Adding Authorization
+ connection.setRequestProperty("Authorization", "Basic "
+ + encodingPAP.get(0));
+
+ connection.setRequestProperty("Environment", environment);
+ connection.setRequestProperty("ClientScope", clientScope);
+
+ //set the method and headers
+ connection.setRequestMethod(requestMethod);
+ connection.setUseCaches(false);
+ connection.setInstanceFollowRedirects(false);
+ connection.setDoOutput(true);
+ connection.setDoInput(true);
+ // Adding RequestID
+ if (requestID == null) {
+ requestID = UUID.randomUUID();
+ logger.info("No request ID provided, sending generated ID: " + requestID.toString());
+ } else {
+ logger.info("Using provided request ID: " + requestID.toString());
+ }
+ connection.setRequestProperty("X-ECOMP-RequestID", requestID.toString());
+
+ if (content != null) {
+ if (content instanceof InputStream) {
+ try {
+ //send current configuration
+ try (OutputStream os = connection.getOutputStream()) {
+ int count = IOUtils.copy((InputStream)content, os);
+ if (logger.isDebugEnabled()) {
+ logger.debug("copied to output, bytes=" + count);
+ }
+ }
+ } catch (Exception e) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Failed to write content in 'PUT'", e);
+ throw e;
+ }
+ } else {
+ // the content is an object to be encoded in JSON
+ ObjectMapper mapper = new ObjectMapper();
+ if(!junit){
+ mapper.writeValue(connection.getOutputStream(), content);
+ }
+ }
+ }
+
+ //DO the connect
+ connection.connect();
+ responseCode = connection.getResponseCode();
+ // If Connected to PAP then break from the loop and continue with the Request
+ if (connection.getResponseCode() > 0 || junit) {
+ connected = true;
+ break;
+
+ } else {
+ logger.debug(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "PAP connection Error");
+ }
+ } catch (Exception e) {
+ // This means that the PAP is not working
+ if (junit) {
+ connected = true;
+ break;
+ }
+ logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "PAP connection Error : " + e);
+ }
+ papsCount++;
+ }
+
+ if (connected) {
+ //Read the Response
+ logger.debug("connected to the PAP : " + paps.get(0));
+ logger.debug("--- Response: ---");
+ Map<String, List<String>> headers = connection.getHeaderFields();
+ for (String key : headers.keySet()) {
+ logger.debug("Header :" + key + " Value: " + headers.get(key));
+ }
+ try {
+ if (responseCode == 200 || junit) {
+
+ // Check for successful creation of policy
+ String isSuccess = null;
+ if(!junit){ //is this a junit test?
+ isSuccess = connection.getHeaderField("successMapKey");
+ operation = connection.getHeaderField("operation");
+ } else {
+ isSuccess = "success";
+ }
+
+ if (isSuccess.equals("success")) {
+ if (operation.equals("update")) {
+ logger.info("Transaction ID: " + requestID + " --Policy Updated Successfully!" );
+ response = "Transaction ID: " + requestID + " --Policy with the name " + connection.getHeaderField("policyName") + " was successfully updated.";
+ } else if (operation.equals("delete")) {
+ logger.info("Transaction ID: " + requestID + " --Policy Deleted Successfully!");
+ response = "Transaction ID: " + requestID + " --The policy was successfully deleted.";
+ } else if (operation.equals("import")) {
+ logger.info("Transaction ID: " + requestID + " --Policy Engine Import Successful!");
+ response = "Transaction ID: " + requestID + " --The policy engine import for " + connection.getHeaderField("service") + " was successfull.";
+ }else {
+ logger.info("Transaction ID: " + requestID + " --Policy Created Successfully!" );
+ response = "Transaction ID: " + requestID + " --Policy with the name " + connection.getHeaderField("policyName") + " was successfully created.";
+ }
+
+ } else {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Unable to Create/Update the Policy!");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "Unable to Create/Update the Policy!";
+ }
+ } else if (connection.getResponseCode() == 202) {
+ if (connection.getHeaderField("operation")!=null && connection.getHeaderField("operation").equalsIgnoreCase("delete")){
+ if (connection.getHeaderField("lockdown")!=null && connection.getHeaderField("lockdown").equals("true")){
+ logger.warn("Transaction ID: " + requestID + "Policies are locked down.");
+ response = "Transaction ID: " + requestID + " --Policies are locked down, please try again later.";
+ }
+ }
+ } else if (connection.getResponseCode() == 204) {
+ if (connection.getHeaderField("operation")!=null && connection.getHeaderField("operation").equals("push")){
+ logger.info("Transaction ID: " + requestID + " --Policy '" + connection.getHeaderField("policyId") +
+ "' was successfully pushed to the PDP group '" + connection.getHeaderField("groupId") + "'.");
+ response = "Transaction ID: " + requestID + " --Policy '" + connection.getHeaderField("policyId") +
+ "' was successfully pushed to the PDP group '" + connection.getHeaderField("groupId") + "'.";
+ }
+ } else if (connection.getResponseCode() == 400 && connection.getHeaderField("error")!=null){
+ if (connection.getHeaderField("error").equals("noPolicyExist")) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Policy does not exist on the PDP.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "Policy does not exist on the PDP.";
+ } else if (connection.getHeaderField("error").equals("invalidPolicyName")) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid policyName... "
+ + "policyName must be the full name of the file to be deleted including version and extension");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid policyName... "
+ + "policyName must be the full name of the file to be deleted including version and extension";
+ } else if (connection.getHeaderField("error").equals("actionPolicyDB")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Could not find " + connection.getHeaderField("actionAttribute") + " in the ActionPolicyDict table.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid actionAttribute given.";
+ } else if (connection.getHeaderField("error").equals("serviceModelDB")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Service or Version. The Service Model, "
+ + connection.getHeaderField("modelName") + " of version " + connection.getHeaderField("modelVersion")
+ + " was not found in the dictionary.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Service or Version. The Service Model, "
+ + connection.getHeaderField("modelName") + " of version " + connection.getHeaderField("modelVersion")
+ + " was not found in the dictionary.";
+ } else if (connection.getHeaderField("error").equals("FWDBError")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Error when inserting Firewall ConfigBody data into database.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "Error when inserting Firewall ConfigBody data into the database.";
+ } else if (connection.getHeaderField("error").equals("savePolicy")){
+ logger.error(connection.getHeaderField("message"));
+ response = connection.getHeaderField("message");
+ }
+ } else if (connection.getResponseCode() == 403) {
+ logger.error(XACMLErrorConstants.ERROR_PERMISSIONS + "response code of the URL is "
+ + connection.getResponseCode() + ". PEP is not Authorized for making this Request!! \n Contact Administrator for this Scope. ");
+ response = XACMLErrorConstants.ERROR_PERMISSIONS + "response code of the URL is "
+ + connection.getResponseCode() + ". PEP is not Authorized for making this Request!! \n Contact Administrator for this Scope. ";
+ } else if (connection.getResponseCode() == 404 && connection.getHeaderField("error")!=null) {
+ if (connection.getHeaderField("error").equals("unknownGroupId")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + connection.getHeaderField("message"));
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + connection.getHeaderField("message") +
+ " Please check the pdpGroup you are requesting to move the policy to.";
+ }
+ } else if (connection.getResponseCode() == 409 && connection.getHeaderField("error")!=null) {
+ if (connection.getHeaderField("error").equals("modelExistsDB")) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Import Value Exist Error");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "Import Value Exist Error: The import value "+connection.getHeaderField("service")+" already exist on the PAP. "
+ + "Please create a new import value.";
+ }else if (connection.getHeaderField("error").equals("policyExists")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Policy Exist Error");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "Policy Exist Error: The Policy "+connection.getHeaderField("policyName")+" already exist on the PAP. "
+ + "Please create a new policy or use the update API to modify the existing one.";
+ }
+ } else if (connection.getResponseCode() == 500 && connection.getHeaderField("error")!=null) {
+ if (connection.getHeaderField("error").equals("jpautils")){
+ logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Could not create JPAUtils instance on the PAP");
+ response = XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Could not create JPAUtils instance on the PAP";
+ } else if (connection.getHeaderField("error").equals("deleteDB")){
+ logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Failed to delete Policy from database.");
+ response = XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Failed to delete Policy from database.";
+ } else if (connection.getHeaderField("error").equals("deleteFile")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot delete the policy file.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot delete the policy file";
+ } else if (connection.getHeaderField("error").equals("groupUpdate")){
+ logger.error(connection.getHeaderField("message"));
+ response = connection.getHeaderField("message");
+ }else if (connection.getHeaderField("error").equals("unknown")){
+ logger.error(XACMLErrorConstants.ERROR_UNKNOWN + "Failed to delete the policy for an unknown reason. Check the file system and other logs for further information.");
+ response = XACMLErrorConstants.ERROR_UNKNOWN + "Failed to delete the policy for an unknown reason. Check the file system and other logs for further information.";
+ } else if (connection.getHeaderField("error").equals("deleteConfig")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot delete the configuration or action body file in specified location");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot delete the configuration or action body file in specified location.";
+ }else if (connection.getHeaderField("error").equals("missing")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Failed to create value in database because service does match a value in file");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "Failed to create value in database because service does match a value in file";
+ }else if (connection.getHeaderField("error").equals("importDB")){
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Database errors during policy engine import");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "Database errors during policy engine import";
+ }else if (connection.getHeaderField("error").equals("policyCopyError")){
+ logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + connection.getHeaderField("message"));
+ response = XACMLErrorConstants.ERROR_PROCESS_FLOW + connection.getHeaderField("message");
+ }else if (connection.getHeaderField("error").equals("addGroupError")){
+ logger.error(connection.getHeaderField("message"));
+ response = connection.getHeaderField("message");
+ }else if (connection.getHeaderField("error").equals("error")){
+ logger.error(XACMLErrorConstants.ERROR_UNKNOWN + "Could not create or update the policy for and unknown reason");
+ response = XACMLErrorConstants.ERROR_UNKNOWN + "Could not create or update the policy for and unknown reason";
+ }
+ } else {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "BAD REQUEST: Error occured while attempting perform this operation.. the request may be incorrect.");
+ response = XACMLErrorConstants.ERROR_DATA_ISSUE + "BAD REQUEST: Error occured while attempting perform this operation.. the request may be incorrect.";
+ }
+ } catch (IOException e) {
+ logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
+ response = XACMLErrorConstants.ERROR_SYSTEM_ERROR + e;
+ throw new Exception(XACMLErrorConstants.ERROR_SYSTEM_ERROR +"ERROR in connecting to the PAP ", e);
+ }
+
+ if (junit){
+ response = "success";
+ }
+ return response;
+
+ } else {
+ response = XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Unable to get valid response from PAP(s) " + paps;
+ return response;
+ }
+ }
+
+ }
+
+ // change getSelectedURI method to receive requestID to be used to send to PAP on the GET request so PAP won't generate another
+ // private URI getSelectedURI(String gitPath, String clientScope){
+ private URI getSelectedURI(String gitPath, String clientScope, UUID requestID){
+ //Connect to the PAP
+ URI selectedURI = null;
+ HttpURLConnection connection = null;
+ String [] parameters = {"apiflag=uri", "gitPath="+gitPath};
+
+
+ // Checking for the available PDPs is done during the first Request and the List is going to have the connected PDP as first element.
+ // This makes it Real-Time to change the list depending on their availability.
+ if (paps == null || paps.isEmpty()) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "PAPs List is Empty.");
+ try {
+ throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE +"PAPs List is empty.");
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ }
+ }else {
+ int papsCount = 0;
+ boolean connected = false;
+ while (papsCount < paps.size()) {
+ try {
+ String fullURL = paps.get(0);
+ if (parameters != null && parameters.length > 0) {
+ String queryString = "";
+ for (String p : parameters) {
+ queryString += "&" + p;
+ }
+ fullURL += "?" + queryString.substring(1);
+ }
+
+ URL url = new URL (fullURL);
+
+ //Open the connection
+ connection = (HttpURLConnection)url.openConnection();
+
+ // Setting Content-Type
+ connection.setRequestProperty("Content-Type",
+ "application/json");
+
+ // Adding Authorization
+ connection.setRequestProperty("Authorization", "Basic "
+ + encodingPAP.get(0));
+
+ connection.setRequestProperty("Environment", environment);
+ connection.setRequestProperty("ClientScope", clientScope);
+
+ //set the method and headers
+ connection.setRequestMethod("GET");
+ connection.setUseCaches(false);
+ connection.setInstanceFollowRedirects(false);
+ connection.setDoOutput(true);
+ connection.setDoInput(true);
+
+ // set requestID in header properties to be used to send to PAP on the GET request so PAP won't generate another
+ connection.setRequestProperty("X-ECOMP-RequestID", requestID.toString());
+
+ //DO the connect
+ connection.connect();
+ responseCode = connection.getResponseCode();
+ // If Connected to PAP then break from the loop and continue with the Request
+ if (connection.getResponseCode() > 0) {
+ connected = true;
+ break;
+
+ } else {
+ logger.debug(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "PAP connection Error");
+ }
+ } catch (Exception e) {
+ // This means that the PAP is not working
+ logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "PAP connection Error : " + e);
+ }
+ papsCount++;
+ }
+
+ if (connected) {
+ //Read the Response
+ logger.debug("connected to the PAP : " + paps.get(0));
+ logger.debug("--- Response: ---");
+ Map<String, List<String>> headers = connection.getHeaderFields();
+ for (String key : headers.keySet()) {
+ logger.debug("Header :" + key + " Value: " + headers.get(key));
+ }
+ try {
+ if (connection.getResponseCode() == 200) {
+ // Check for successful creation of policy
+ String uri = connection.getHeaderField("selectedURI");
+ logger.debug("URI from Header: " + uri);
+ if (uri != null && !uri.equalsIgnoreCase("")) {
+ selectedURI = URI.create(uri);
+ return selectedURI;
+ } else {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "could not retrieve the gitPath from the PAP");
+ }
+ } else if (connection.getResponseCode() == 404) {
+ logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "response code of the URL is "
+ + connection.getResponseCode() + ". This indicates a problem with getting the gitPath from the PAP");
+ } else {
+ logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "BAD REQUEST: Error occured while getting the gitPath from the PAP. The request may be incorrect.");
+ }
+ } catch (IOException e) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
+ try {
+ throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE +"ERROR in connecting to the PAP ", e);
+ } catch (Exception e1) {
+ logger.error(e1.getMessage());
+ }
+ }
+
+ } else {
+ logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Unable to get valid response from PAP(s) " + paps);
+ try {
+ throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE +"ERROR in connecting to the PAP ");
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ }
+ }
+ }
+ return selectedURI;
+
+ }
+
+ // Make a call to the PAP to get the gitPath
+ // change getGitPath method to receive requestID to be used to send to PAP on the GET request so PAP won't generate another
+ // private String getGitPath(String policyScope, String filePrefix, String policyName, String activeVersion, String clientScope){
+ private String getGitPath(String policyScope, String filePrefix, String policyName, String activeVersion, String clientScope, UUID requestID){
+
+ //Connect to the PAP
+ String gitPath = null;
+ HttpURLConnection connection = null;
+ String [] parameters = {"apiflag=gitPath", "policyScope="+policyScope, "filePrefix="+filePrefix,
+ "policyName="+policyName, "activeVersion="+activeVersion};
+
+
+ // Checking for the available PDPs is done during the first Request and the List is going to have the connected PDP as first element.
+ // This makes it Real-Time to change the list depending on their availability.
+ if (paps == null || paps.isEmpty()) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "PAPs List is Empty.");
+ try {
+ throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE +"PAPs List is empty.");
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ }
+ }else {
+ int papsCount = 0;
+ boolean connected = false;
+ while (papsCount < paps.size()) {
+ try {
+ String fullURL = paps.get(0);
+ if (parameters != null && parameters.length > 0) {
+ String queryString = "";
+ for (String p : parameters) {
+ queryString += "&" + p;
+ }
+ fullURL += "?" + queryString.substring(1);
+ }
+
+ URL url = new URL (fullURL);
+
+ //Open the connection
+ connection = (HttpURLConnection)url.openConnection();
+
+ // Setting Content-Type
+ connection.setRequestProperty("Content-Type",
+ "application/json");
+
+ // Adding Authorization
+ connection.setRequestProperty("Authorization", "Basic "
+ + encodingPAP.get(0));
+
+ connection.setRequestProperty("Environment", environment);
+ connection.setRequestProperty("ClientScope", clientScope);
+
+ //set the method and headers
+ connection.setRequestMethod("GET");
+ connection.setUseCaches(false);
+ connection.setInstanceFollowRedirects(false);
+ connection.setDoOutput(true);
+ connection.setDoInput(true);
+
+ // set requestID in header properties to be used to send to PAP on the GET request so PAP won't generate another
+ connection.setRequestProperty("X-ECOMP-RequestID", requestID.toString());
+
+ //DO the connect
+ connection.connect();
+
+ // If Connected to PAP then break from the loop and continue with the Request
+ if (connection.getResponseCode() > 0) {
+ connected = true;
+ break;
+
+ } else {
+ logger.debug(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "PAP connection Error");
+ }
+ } catch (Exception e) {
+ // This means that the PAP is not working
+ logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "PAP connection Error : " + e);
+ }
+ papsCount++;
+ }
+
+ if (connected) {
+ //Read the Response
+ logger.debug("connected to the PAP : " + paps.get(0));
+ logger.debug("--- Response: ---");
+ Map<String, List<String>> headers = connection.getHeaderFields();
+ for (String key : headers.keySet()) {
+ logger.debug("Header :" + key + " Value: " + headers.get(key));
+ }
+ try {
+ if (connection.getResponseCode() == 200) {
+ // Check for successful creation of policy
+ gitPath = connection.getHeaderField("gitPath");
+ this.policyId = connection.getHeaderField("policyId");
+ this.description = connection.getHeaderField("description");
+ this.pushVersion = connection.getHeaderField("version");
+ String isValid = connection.getHeaderField("isValid");
+ this.isValid = Boolean.parseBoolean(isValid);
+
+ logger.debug("GitPath from Header: " + gitPath);
+ logger.debug("policyId from Header: " + policyId);
+ logger.debug("description from Header: " + description);
+ logger.debug("version from Header: " + pushVersion);
+ logger.debug("isValid from Header: " + isValid);
+
+ if (gitPath != null && !gitPath.equalsIgnoreCase("")) {
+ return gitPath;
+ } else {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "could not retrieve the gitPath from the PAP");
+ }
+ } else if (connection.getResponseCode() == 404) {
+ logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "response code of the URL is "
+ + connection.getResponseCode() + ". This indicates a problem with getting the gitPath from the PAP");
+ } else {
+ logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "BAD REQUEST: Error occured while getting the gitPath from the PAP. The request may be incorrect.");
+ }
+ } catch (IOException e) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
+ try {
+ throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE +"ERROR in connecting to the PAP ", e);
+ } catch (Exception e1) {
+ logger.error(e1.getMessage());
+ }
+ }
+
+ } else {
+ logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Unable to get valid response from PAP(s) " + paps);
+ try {
+ throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE +"ERROR in connecting to the PAP ");
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ }
+ }
+ }
+ return gitPath;
+
+ }
+
+ // change getActiveVersion method to receive requestID to be used to send to PAP on the GET request so PAP won't generate another
+// private String getActiveVersion(String policyScope, String filePrefix, String policyName, String clientScope) {
+ private String getActiveVersion(String policyScope, String filePrefix, String policyName, String clientScope, UUID requestID) {
+
+ //Connect to the PAP
+ String version = null;
+ HttpURLConnection connection = null;
+ String [] parameters = {"apiflag=version","policyScope="+policyScope, "filePrefix="+filePrefix, "policyName="+policyName};
+
+
+ // Checking for the available PDPs is done during the first Request and the List is going to have the connected PDP as first element.
+ // This makes it Real-Time to change the list depending on their availability.
+ if (paps == null || paps.isEmpty()) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "PAPs List is Empty.");
+ try {
+ throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE +"PAPs List is empty.");
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ }
+ }else {
+ int papsCount = 0;
+ boolean connected = false;
+ while (papsCount < paps.size()) {
+ try {
+ String fullURL = paps.get(0);
+ if (parameters != null && parameters.length > 0) {
+ String queryString = "";
+ for (String p : parameters) {
+ queryString += "&" + p;
+ }
+ fullURL += "?" + queryString.substring(1);
+ }
+
+ URL url = new URL (fullURL);
+
+ //Open the connection
+ connection = (HttpURLConnection)url.openConnection();
+
+ // Setting Content-Type
+ connection.setRequestProperty("Content-Type",
+ "application/json");
+
+ // Adding Authorization
+ connection.setRequestProperty("Authorization", "Basic "
+ + encodingPAP.get(0));
+
+ connection.setRequestProperty("Environment", environment);
+ connection.setRequestProperty("ClientScope", clientScope);
+
+
+ //set the method and headers
+ connection.setRequestMethod("GET");
+ connection.setUseCaches(false);
+ connection.setInstanceFollowRedirects(false);
+ connection.setDoOutput(true);
+ connection.setDoInput(true);
+
+ // set requestID in header properties to be used to send to PAP on the GET request so PAP won't generate another
+ connection.setRequestProperty("X-ECOMP-RequestID", requestID.toString());
+
+ //DO the connect
+ connection.connect();
+
+ // If Connected to PAP then break from the loop and continue with the Request
+ if (connection.getResponseCode() > 0) {
+ connected = true;
+ break;
+
+ } else {
+ logger.debug(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "PAP connection Error");
+ }
+ } catch (Exception e) {
+ // This means that the PAP is not working
+ logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "PAP connection Error : " + e);
+ }
+ papsCount++;
+ }
+
+ if (connected) {
+ //Read the Response
+ logger.debug("connected to the PAP : " + paps.get(0));
+ logger.debug("--- Response: ---");
+ Map<String, List<String>> headers = connection.getHeaderFields();
+ for (String key : headers.keySet()) {
+ logger.debug("Header :" + key + " Value: " + headers.get(key));
+ }
+ try {
+ if (connection.getResponseCode() == 200) {
+ // Check for successful creation of policy
+ version = connection.getHeaderField("version");
+ logger.debug("ActiveVersion from the Header: " + version);
+ } else if (connection.getResponseCode() == 403) {
+ logger.error(XACMLErrorConstants.ERROR_PERMISSIONS + "response code of the URL is "
+ + connection.getResponseCode() + ". PEP is not Authorized for making this Request!! \n Contact Administrator for this Scope. ");
+ version = "pe100";
+ } else if (connection.getResponseCode() == 404) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "response code of the URL is "
+ + connection.getResponseCode() + ". This indicates a problem with getting the version from the PAP");
+ version = "pe300";
+ } else {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "BAD REQUEST: Error occured while getting the version from the PAP. The request may be incorrect.");
+ }
+ } catch (IOException e) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
+ try {
+ throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE +"ERROR in connecting to the PAP ", e);
+ } catch (Exception e1) {
+ logger.error(e1.getMessage());
+ }
+ }
+
+ } else {
+ logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Unable to get valid response from PAP(s) " + paps);
+ try {
+ throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE +"ERROR in connecting to the PAP ");
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ }
+ }
+ }
+ return version;
+ }
+
+ // Validation for json inputs
+ public static boolean isJSONValid(String data) {
+ try {
+ new JSONObject(data);
+ InputStream stream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));
+ JsonReader jsonReader = Json.createReader(stream);
+ logger.debug("Json Value is: " + jsonReader.read().toString() );
+ } catch (Exception e) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * Rotate the PDP list upon WEBsocket Failures
+ */
+ public static void rotateList() {
+ Collections.rotate(pdps, -1);
+ Collections.rotate(encoding, -1);
+ /* not required for 1510. //TODO uncomment when PAP API has been implemented
+ * This Broke the PyPDP :( Since there is no PAP LIST yet.
+ Collections.rotate(paps, -1);
+ Collections.rotate(encodingPAP, -1);
+ */
+ }
+
+ /*
+ * Get the latest PDP
+ */
+ public static String getPDPURL() {
+ return pdps.get(0);
+ }
+
+ /*
+ * Get the latest PAP
+ */
+ public static String getPAPURL() {
+ return paps.get(0);
+ }
+
+ private JsonObject stringToJsonObject(String value) throws Exception{
+ JsonReader jsonReader = Json.createReader(new StringReader(value));
+ JsonObject object = jsonReader.readObject();
+ jsonReader.close();
+ return object;
+ }
+
+ private String getJsonResponseString() {
+ String jsonString = "{\"Response\":[{\"Status\":{\"StatusCode\":{\"Value\":\"urn:oasis:names:tc:xacml:1.0:status:ok\"}},"
+ + "\"AssociatedAdvice\":[{\"AttributeAssignment\":[{\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\","
+ + "\"Issuer\":\"\",\"AttributeId\":\"type\",\"Value\":\"Configuration\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\"},"
+ + "{\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"Issuer\":\"\",\"AttributeId\":\"URLID\",\"Value\":"
+ + "\"$URL/Config/JunitTest.Config_testing.1.json\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#anyURI\"},{\"Category\":"
+ + "\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"Issuer\":\"\",\"AttributeId\":\"PolicyName\",\"Value\":"
+ + "\"JunitTest.Config_testing.1.xml\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\"},{\"Category\":"
+ + "\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"Issuer\":\"\",\"AttributeId\":\"VersionNumber\",\"Value\":"
+ + "\"1\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\"},{\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\","
+ + "\"Issuer\":\"\",\"AttributeId\":\"matching:ECOMPName\",\"Value\":\"test\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\"},"
+ + "{\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"Issuer\":\"\",\"AttributeId\":\"matching:ConfigName\","
+ + "\"Value\":\"TestName\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\"},{\"Category\":"
+ + "\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"Issuer\":\"\",\"AttributeId\":\"matching:service\","
+ + "\"Value\":\"ControllerServiceOpendcaeCapsuleServiceInstance\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\"},"
+ + "{\"Category\":\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"Issuer\":\"\",\"AttributeId\":\"matching:uuid\","
+ + "\"Value\":\"TestUUID\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\"},{\"Category\":"
+ + "\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"Issuer\":\"\",\"AttributeId\":\"matching:Location\","
+ + "\"Value\":\"Edge\",\"DataType\":\"http://www.w3.org/2001/XMLSchema#string\"},{\"Category\":"
+ + "\"urn:oasis:names:tc:xacml:3.0:attribute-category:resource\",\"Issuer\":\"\",\"AttributeId\":\"Priority\",\"Value\":\"1\",\"DataType\":"
+ + "\"http://www.w3.org/2001/XMLSchema#string\"}],\"Id\":\"MSID\"}],\"Decision\":\"Permit\"}]}";
+
+ return jsonString;
+ }
+
+ public PolicyChangeResponse policyEngineImport(ImportParameters importParameters) throws Exception {
+ return policyEngineImport(importParameters, userName, pass);
+ }
+
+ public PolicyChangeResponse policyEngineImport(ImportParameters importParameters, String userID, String passcode) throws Exception {
+ StdPolicyChangeResponse response = new StdPolicyChangeResponse();
+ String resource= "policyEngineImport";
+ if(!checkPermissions(userID, passcode, resource)){
+ logger.error(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ response.setResponseMessage(XACMLErrorConstants.ERROR_PERMISSIONS + "You are not allowed to Make this Request. Please contact PolicyAdmin to give access to:" + resource);
+ response.setResponseCode(401);
+ return response;
+ }
+ InputStream targetStream = null;
+ if(importParameters.getServiceName()!=null && importParameters.getVersion()!=null && importParameters.getServiceType()!=null){
+ // This is Config Class Policy.
+ if(importParameters.getFilePath()!=null){
+ File input = new File(importParameters.getFilePath());
+ if (input.getName().endsWith(".xmi") || input.getName().endsWith(".zip")){
+ try {
+ if (input.exists()){
+ targetStream = new FileInputStream(input);
+ }else {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "File provided in ImportParameters does not exists.");
+ response.setResponseMessage(XACMLErrorConstants.ERROR_DATA_ISSUE + "File provided in ImportParameters does not exist.");
+ return response;
+ }
+ } catch (Exception e) {
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Error reading in File");
+ response.setResponseMessage(XACMLErrorConstants.ERROR_DATA_ISSUE + "Error in reading in the file provided");
+ }
+ }else{
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect File Data type.");
+ response.setResponseMessage(XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect File Type Given. Please use a file of type .xmi or .zip.");
+ return response;
+ }
+ String[] parameters = new String[] {"importService=" + importParameters.getServiceType(), "serviceName="
+ + importParameters.getServiceName(), "fileName=" + input.getName(), "version=" + importParameters.getVersion()};
+ String responseMessage = (String) callPAP(targetStream, parameters, importParameters.getRequestID(), "importMS");
+ response.setResponseMessage(responseMessage);
+ }else{
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Missing required ImportParameters value.");
+ response.setResponseMessage(XACMLErrorConstants.ERROR_DATA_ISSUE + "Missing required ImportParameters value.");
+ }
+ }else{
+ logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Missing required ImportParameters value.");
+ response.setResponseMessage(XACMLErrorConstants.ERROR_DATA_ISSUE + "Missing required ImportParameters value.");
+ }
+ return response;
+ }
+
+ /*
+ * Give userID, Passcode and the Resoruce they are requesting for.
+ */
+ private boolean checkPermissions(String userID, String passcode, String resource){
+ Boolean result = false;
+ if(pyPDPClientFile!=null){
+ // Backward compatible pyPDP called us. So validate the user names and scope.
+ Path clientPath = Paths.get(pyPDPClientFile);
+ if (Files.notExists(clientPath)) {
+ result = false;
+ }else if(clientPath.toString().endsWith(".properties")) {
+ try {
+ HashMap<String, ArrayList<String>> clientMap = readProps(clientPath);
+ if (clientMap.containsKey(userID) && clientMap.get(userID).get(0).equals(passcode)) {
+ result= true;
+ }
+ } catch (Exception e) {
+ result = false;
+ }
+ }
+ }else{
+ //Allowing Every Client who ever don't have access for AAF and Backup Client file
+ result = true;
+ }
+ return result;
+ }
+
+ private HashMap<String, ArrayList<String>> readProps(Path clientPath) throws Exception{
+ InputStream in;
+ Properties clientProp = new Properties();
+ try {
+ in = new FileInputStream(clientPath.toFile());
+ clientProp.load(in);
+ } catch (IOException e) {
+ logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
+ throw new Exception(XACMLErrorConstants.ERROR_SYSTEM_ERROR +"Cannot Load the Properties file", e);
+ }
+ // Read the Properties and Load the Clients and their scopes.
+ HashMap<String, ArrayList<String>>clientMap = new HashMap<String, ArrayList<String>>();
+ //
+ for (Object propKey : clientProp.keySet()) {
+ String clientID = (String)propKey;
+ String clientValue = clientProp.getProperty(clientID);
+ if (clientValue != null) {
+ if (clientValue.contains(",")) {
+ ArrayList<String> clientValues = new ArrayList<String>(Arrays.asList(clientValue.split("\\s*,\\s*")));
+ if(clientValues.get(0)!=null || clientValues.get(1)!=null || clientValues.get(0).isEmpty() || clientValues.get(1).isEmpty()){
+ clientMap.put(clientID, clientValues);
+ }
+ }
+ }
+ }
+ if (clientMap == null || clientMap.isEmpty()) {
+ logger.debug(XACMLErrorConstants.ERROR_PERMISSIONS + "No Clients ID , Client Key and Scopes are available. Cannot serve any Clients !!");
+ throw new Exception("Empty Client file");
+ }
+ return clientMap;
+ }
+
+ protected boolean isNumeric(String str)
+ {
+ for (char c : str.toCharArray())
+ {
+ if (!Character.isDigit(c)) return false;
+ }
+ return true;
+ }
+
+ private String ConvertDate(Date date){
+ String strDate = null;
+ if (date!=null)
+ {
+ SimpleDateFormat dateformatJava = new SimpleDateFormat("dd-MM-yyyy");
+ strDate = dateformatJava.format(date);
+ }
+
+ return strDate;
+ }
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyResponse.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyResponse.java
new file mode 100644
index 000000000..eed40ba2e
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyResponse.java
@@ -0,0 +1,98 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.openecomp.policy.std;
+
+import java.util.Map;
+
+import org.openecomp.policy.api.PolicyResponse;
+import org.openecomp.policy.api.PolicyResponseStatus;
+
+/**
+ * PolicyResponse Implementation class.
+ *
+ * @version 0.1
+ *
+ */
+public class StdPolicyResponse implements PolicyResponse{
+ private PolicyResponseStatus policyResponseStatus;
+ private Map<String,String> actionAdvised;
+ private Map<String,String> actionTaken;
+ private Map<String,String> requestAttributes;
+ private String policyResponseMessage;
+
+ @Override
+ public PolicyResponseStatus getPolicyResponseStatus() {
+ return policyResponseStatus;
+ }
+
+ @Override
+ public Map<String, String> getActionAdvised() {
+ return actionAdvised;
+ }
+
+ @Override
+ public Map<String, String> getActionTaken() {
+ return actionTaken;
+ }
+
+ @Override
+ public Map<String, String> getRequestAttributes() {
+ return requestAttributes;
+ }
+
+ @Override
+ public String getPolicyResponseMessage() {
+ return policyResponseMessage;
+ }
+
+ public void setPolicyResponseStatus(PolicyResponseStatus policyResponseStatus) {
+ this.policyResponseStatus = policyResponseStatus;
+ }
+
+ public void setActionAdvised(Map<String, String> actionAdvised) {
+ this.actionAdvised = actionAdvised;
+ }
+
+ public void setActionTaken(Map<String, String> actionTaken) {
+ this.actionTaken = actionTaken;
+ }
+
+ public void setRequestAttributes(Map<String, String> requestAttributes) {
+ this.requestAttributes = requestAttributes;
+ }
+
+ public void setPolicyResponseMessage(String policyResponseMessage) {
+ this.policyResponseMessage = policyResponseMessage;
+ }
+
+ public void setPolicyResponseStatus(String policyResponseMessage, PolicyResponseStatus policyResponseStatus) {
+ this.policyResponseMessage = policyResponseMessage;
+ this.policyResponseStatus = policyResponseStatus;
+ }
+
+ @Override
+ public String toString() {
+ return "PolicyResponse [ policyResponseStatus=" + policyResponseStatus + ", policyResponseMessage=" + policyResponseMessage + ", " +
+ ""
+ + "]";
+ }
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdStatus.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdStatus.java
new file mode 100644
index 000000000..a7d22b7cb
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdStatus.java
@@ -0,0 +1,235 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.openecomp.policy.std;
+
+import java.util.Map;
+import java.util.Properties;
+
+import javax.json.JsonObject;
+
+import org.openecomp.policy.api.DecisionResponse;
+import org.openecomp.policy.api.PolicyConfig;
+import org.openecomp.policy.api.PolicyConfigStatus;
+import org.openecomp.policy.api.PolicyDecision;
+import org.openecomp.policy.api.PolicyResponse;
+import org.openecomp.policy.api.PolicyResponseStatus;
+import org.openecomp.policy.api.PolicyType;
+import org.w3c.dom.Document;
+
+public class StdStatus extends StdPolicyResponse implements PolicyConfig, PolicyResponse, DecisionResponse{
+ private PolicyType policyType;
+ private Properties properties;
+ private JsonObject jsonObject;
+ private Document document;
+ private String other;
+ private PolicyConfigStatus policyConfigStatus;
+ private String configStatus;
+ private PolicyResponseStatus policyResponseStatus;
+ private Map<String,String> actionAdvised;
+ private Map<String,String> actionTaken;
+ private Map<String,String> requestAttributes;
+ private String policyResponseMessage;
+ private String policyName;
+ private String policyVersion;
+ private Map<String,String> matchingConditions;
+ private Map<String,String> responseAttributes;
+ private PolicyDecision policyDecision;
+ private String details;
+
+ public void setStatus(String message, PolicyResponseStatus policyResponseStatus, PolicyConfigStatus policyConfigStatus) {
+ this.configStatus = message;
+ this.policyResponseMessage = message;
+ this.policyResponseStatus = policyResponseStatus;
+ this.policyConfigStatus = policyConfigStatus;
+ }
+ @Override
+ public PolicyResponseStatus getPolicyResponseStatus() {
+ return policyResponseStatus;
+ }
+
+ @Override
+ public Map<String, String> getActionAdvised() {
+ return actionAdvised;
+ }
+
+ @Override
+ public Map<String, String> getActionTaken() {
+ return actionTaken;
+ }
+
+ @Override
+ public Map<String, String> getRequestAttributes() {
+ return requestAttributes;
+ }
+
+ @Override
+ public String getPolicyResponseMessage() {
+ return policyResponseMessage;
+ }
+
+ public void setPolicyResponseStatus(PolicyResponseStatus policyResponseStatus) {
+ this.policyResponseStatus = policyResponseStatus;
+ }
+
+ public void setActionAdvised(Map<String, String> actionAdvised) {
+ this.actionAdvised = actionAdvised;
+ }
+
+ public void setActionTaken(Map<String, String> actionTaken) {
+ this.actionTaken = actionTaken;
+ }
+
+ public void setRequestAttributes(Map<String, String> requestAttributes) {
+ this.requestAttributes = requestAttributes;
+ }
+
+ public void setPolicyResponseMessage(String policyResponseMessage) {
+ this.policyResponseMessage = policyResponseMessage;
+ }
+
+ public void setPolicyResponseStatus(String policyResponseMessage, PolicyResponseStatus policyResponseStatus) {
+ this.policyResponseMessage = policyResponseMessage;
+ this.policyResponseStatus = policyResponseStatus;
+ }
+
+ @Override
+ public PolicyType getType() {
+ return policyType;
+ }
+
+ @Override
+ public Properties toProperties() {
+ return properties;
+ }
+
+ @Override
+ public JsonObject toJSON() {
+ return jsonObject;
+ }
+
+ @Override
+ public Document toXML() {
+ return document;
+ }
+
+ @Override
+ public PolicyConfigStatus getPolicyConfigStatus() {
+ return policyConfigStatus;
+ }
+
+ @Override
+ public String getPolicyConfigMessage() {
+ return configStatus;
+ }
+
+ @Override
+ public String getPolicyName() {
+ if(policyName!=null && policyName.contains(".xml")){
+ return (policyName.substring(0, policyName.substring(0, policyName.lastIndexOf(".")).lastIndexOf(".")));
+ }
+ return policyName;
+ }
+
+ @Override
+ public String getPolicyVersion() {
+ return policyVersion;
+ }
+
+ @Override
+ public Map<String,String> getMatchingConditions(){
+ return matchingConditions;
+ }
+
+ @Override
+ public Map<String,String> getResponseAttributes(){
+ return responseAttributes;
+ }
+
+ public void setPolicyType(PolicyType policyType) {
+ this.policyType = policyType;
+ }
+
+ public void setProperties(Properties properties) {
+ this.properties = properties;
+ }
+
+ public void setJsonObject(JsonObject jsonObject) {
+ this.jsonObject = jsonObject;
+ }
+
+ public void setDocument(Document document) {
+ this.document = document;
+ }
+
+ public void setConfigStatus(String configStatus) {
+ this.configStatus = configStatus;
+ }
+
+ public void setPolicyName(String policyName) {
+ this.policyName = policyName;
+ }
+
+ public void setPolicyVersion(String policyVersion) {
+ this.policyVersion = policyVersion;
+ }
+
+ public void setMatchingConditions(Map<String,String> matchingConditions){
+ this.matchingConditions = matchingConditions;
+ }
+
+ public void setResposneAttributes(Map<String,String> responseAttributes){
+ this.responseAttributes = responseAttributes;
+ }
+
+ public void setPolicyConfigStatus(PolicyConfigStatus policyConfigStatus) {
+ this.policyConfigStatus = policyConfigStatus;
+ }
+
+ public void setPolicyConfigStatus(String configStatus, PolicyConfigStatus policyConfigStatus) {
+ this.policyConfigStatus = policyConfigStatus;
+ this.configStatus = configStatus;
+ }
+
+ @Override
+ public String toOther() {
+ return other;
+ }
+
+ public void setOther(String other) {
+ this.other = other;
+ }
+
+ public PolicyDecision getDecision() {
+ return policyDecision;
+ }
+ public void setDecision(PolicyDecision policyDecision) {
+ this.policyDecision = policyDecision;
+ }
+
+ public void setDetails(String details){
+ this.details = details;
+ }
+
+ public String getDetails(){
+ return details;
+ }
+}
diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/package-info.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/package-info.java
new file mode 100644
index 000000000..a10f347e9
--- /dev/null
+++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/package-info.java
@@ -0,0 +1,27 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PolicyEngineAPI
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.policy.std;
+/**
+ * Provides standard implementations of the interfaces from the {@link org.openecomp.policy.api} package.
+ *
+ * @version 0.3
+ *
+ */