summaryrefslogtreecommitdiffstats
path: root/ONAP-REST
diff options
context:
space:
mode:
Diffstat (limited to 'ONAP-REST')
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidationRequestWrapper.java625
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyValidationRequestWrapperTest.java422
-rw-r--r--ONAP-REST/src/test/resources/policies/DecisionPolicy.json1556
-rw-r--r--ONAP-REST/src/test/resources/policies/PolicyJsonTrapFault.json9
4 files changed, 2290 insertions, 322 deletions
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidationRequestWrapper.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidationRequestWrapper.java
index 8fdc1e1d2..ad60a7512 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidationRequestWrapper.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidationRequestWrapper.java
@@ -42,6 +42,7 @@ import javax.json.JsonReader;
import javax.servlet.http.HttpServletRequest;
import org.onap.policy.api.AttributeType;
+import org.onap.policy.api.PolicyClass;
import org.onap.policy.api.PolicyParameters;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
@@ -64,8 +65,10 @@ public class PolicyValidationRequestWrapper {
private static final String PRIORITY = "priority";
private static final String RISKLEVEL = "riskLevel";
private static final String RISKTYPE = "riskType";
+ private static final String SECURITY_ZONE_ID = "securityZoneId";
private static final String SERVICE = "service";
private static final String SERVICETYPE_POLICY_NAME = "serviceTypePolicyName";
+ private static final String UUID = "uuid";
private static final String VERSION = "version";
/**
@@ -75,7 +78,6 @@ public class PolicyValidationRequestWrapper {
* @return the policy rest adapter
*/
public PolicyRestAdapter populateRequestParameters(HttpServletRequest request) {
-
PolicyRestAdapter policyData = null;
ClosedLoopFaultTrapDatas trapDatas = null;
ClosedLoopFaultTrapDatas faultDatas = null;
@@ -93,18 +95,13 @@ public class PolicyValidationRequestWrapper {
policyData.setFaultDatas(faultDatas);
}
- JsonObject json;
- json = stringToJsonObject(root.toString());
-
- if (json != null) {
- if (json.containsKey("policyJSON")) {
- policyData.setPolicyJSON(root.get("policyJSON"));
- } else {
- String jsonBodyData = json.getJsonObject("policyData").get("jsonBodyData").toString();
- policyData.setJsonBody(jsonBodyData);
- }
+ JsonObject json = stringToJsonObject(root.toString());
+ if (json.containsKey("policyJSON")) {
+ policyData.setPolicyJSON(root.get("policyJSON"));
+ } else {
+ String jsonBodyData = json.getJsonObject("policyData").get("jsonBodyData").toString();
+ policyData.setJsonBody(jsonBodyData);
}
-
} catch (Exception e) {
LOGGER.error("Exception Occured while populating request parameters: " + e);
}
@@ -119,7 +116,6 @@ public class PolicyValidationRequestWrapper {
* @return the policy rest adapter
*/
public PolicyRestAdapter populateRequestParameters(PolicyParameters parameters) {
-
PolicyRestAdapter policyData = new PolicyRestAdapter();
/*
@@ -148,336 +144,321 @@ public class PolicyValidationRequestWrapper {
return null;
}
- if (parameters.getPolicyClass() != null && !"Config".equals(parameters.getPolicyClass().toString())) {
+ if (parameters.getPolicyClass() == null) {
+ parameters.setPolicyClass(PolicyClass.Config);
+ }
+
+ policyData.setPolicyType(parameters.getPolicyClass().toString());
+
+ switch (parameters.getPolicyClass()) {
+ case Config:
+ return populateConfigParameters(parameters, policyData, json);
+
+ case Decision:
+ return populateDecisionParameters(parameters, policyData, getMatchingAttributeValues(parameters));
+
+ case Action:
+ return populateActionParameters(parameters, policyData, getMatchingAttributeValues(parameters));
+
+ default:
+ return null;
+ }
+ }
+
+ private PolicyRestAdapter populateConfigParameters(PolicyParameters parameters, PolicyRestAdapter policyData,
+ JsonObject json) {
+ policyData.setConfigPolicyType(parameters.getPolicyConfigType().toString());
+
+ // Config Specific
+ policyData.setConfigBodyData(parameters.getConfigBody()); // Base
+ policyData.setConfigType((parameters.getConfigBodyType() != null)
+ ? parameters.getConfigBodyType().toString().toUpperCase()
+ : null); // Base
+
+ switch (parameters.getPolicyConfigType()) {
+ case Firewall:
+ return populateConfigFirewallParameters(policyData, json);
+ case MicroService:
+ return populateConfigMicroserviceParameters(parameters, policyData, json);
+ case Optimization:
+ return populateConfigOptimizationParameters(parameters, policyData, json);
+ case ClosedLoop_Fault:
+ return populateConfigClosedLoopFaultParameters(policyData, json);
+ case ClosedLoop_PM:
+ return populateConfigClosedLoopPmParameters(policyData, json);
+ case BRMS_PARAM:
+ return populateConfigBrmsParameters(parameters, policyData);
+
+ // case BRMS_RAW:, case Base:, and case Extended: handled as default cases
+ default:
+ return policyData;
+ }
+ }
+
+ private PolicyRestAdapter populateConfigFirewallParameters(PolicyRestAdapter policyData, JsonObject json) {
+ policyData.setConfigPolicyType("Firewall Config");
+
+ // get values and attributes from the JsonObject
+ if (json != null) {
+ policyData.setSecurityZone(getNewOrExistingKeyValue(json, SECURITY_ZONE_ID, policyData.getSecurityZone()));
+ policyData.setConfigName(getNewOrExistingKeyValue(json, CONFIG_NAME, policyData.getConfigName()));
+ }
+ return policyData;
+ }
+
+ private PolicyRestAdapter populateConfigMicroserviceParameters(PolicyParameters parameters,
+ PolicyRestAdapter policyData, JsonObject json) {
+ policyData.setConfigPolicyType("Micro Service");
+
+ // Get values and attributes from the JsonObject
+ if (json != null) {
+ return getJsonObjectValuesAndAttributes(parameters, policyData, json);
+ } else {
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE + INVALIDJSON + parameters.getConfigBody();
+ LOGGER.error(message);
+ return null;
+ }
+ }
+
+ private PolicyRestAdapter populateConfigOptimizationParameters(PolicyParameters parameters,
+ PolicyRestAdapter policyData, JsonObject json) {
+ policyData.setConfigPolicyType("Optimization");
+
+ // get values and attributes from the JsonObject
+ if (json != null) {
+ return getJsonObjectValuesAndAttributes(parameters, policyData, json);
+ } else {
+ return policyData;
+ }
+ }
+
+ private PolicyRestAdapter populateConfigClosedLoopFaultParameters(PolicyRestAdapter policyData, JsonObject json) {
+ policyData.setConfigPolicyType("ClosedLoop_Fault");
+
+ if (json != null) {
+ policyData.setJsonBody(json.toString());
+ policyData.setOnapName(getNewOrExistingKeyValue(json, ONAPNAME, policyData.getOnapName()));
+ }
+ return policyData;
+ }
+
+ private PolicyRestAdapter populateConfigClosedLoopPmParameters(PolicyRestAdapter policyData, JsonObject json) {
+ policyData.setConfigPolicyType("ClosedLoop_PM");
+
+ if (json != null) {
+ policyData.setJsonBody(json.toString());
+ policyData.setOnapName(getNewOrExistingKeyValue(json, ONAPNAME, policyData.getOnapName()));
+ if (json.get(SERVICETYPE_POLICY_NAME) != null) {
+ String serviceType = json.get(SERVICETYPE_POLICY_NAME).toString().replace("\"", "");
+ LinkedHashMap<String, String> serviceTypePolicyName = new LinkedHashMap<>();
+ serviceTypePolicyName.put(SERVICETYPE_POLICY_NAME, serviceType);
+ policyData.setServiceTypePolicyName(serviceTypePolicyName);
+ }
+ }
+ return policyData;
+ }
+
+ private PolicyRestAdapter populateConfigBrmsParameters(PolicyParameters parameters, PolicyRestAdapter policyData) {
+ Map<AttributeType, Map<String, String>> drlRuleAndUiParams = parameters.getAttributes();
+ Map<String, String> rule = drlRuleAndUiParams.get(AttributeType.RULE);
+ policyData.setRuleName(rule.get("templateName"));
+
+ return policyData;
+ }
+
+ private PolicyRestAdapter populateDecisionParameters(PolicyParameters parameters, PolicyRestAdapter policyData,
+ Map<String, String> matching) {
+ policyData.setRuleProvider(parameters.getRuleProvider().toString());
+
+ switch (parameters.getRuleProvider()) {
+ case RAINY_DAY:
+ return populateDecisionRainyDayParameters(parameters, policyData, matching);
+
+ case GUARD_BL_YAML:
+ case GUARD_MIN_MAX:
+ case GUARD_YAML:
+ return populateDecisionGuardParameters(policyData, matching);
+
+ case AAF:
+ case CUSTOM:
+ case RAW:
+ default:
+ return policyData;
+ }
+ }
+
+ private PolicyRestAdapter populateDecisionRainyDayParameters(PolicyParameters parameters,
+ PolicyRestAdapter policyData, Map<String, String> matching) {
+ // Set Matching attributes in RainyDayParams in adapter
+ RainyDayParams rainyday = new RainyDayParams();
+
+ if (matching != null) {
+ rainyday.setServiceType(matching.get("ServiceType"));
+ rainyday.setVnfType(matching.get("VNFType"));
+ rainyday.setBbid(matching.get("BB_ID"));
+ rainyday.setWorkstep(matching.get("WorkStep"));
+ }
+
+ Map<String, String> treatments = parameters.getTreatments();
+ ArrayList<Object> treatmentsTableChoices = new ArrayList<>();
+
+ for (String keyField : treatments.keySet()) {
+ LinkedHashMap<String, String> treatmentMap = new LinkedHashMap<>();
+ String errorcode = keyField;
+ String treatment = treatments.get(errorcode);
+ treatmentMap.put("errorcode", errorcode);
+ treatmentMap.put("treatment", treatment);
+ treatmentsTableChoices.add(treatmentMap);
+ }
+ rainyday.setTreatmentTableChoices(treatmentsTableChoices);
+ policyData.setRainyday(rainyday);
+
+ return policyData;
+ }
+
+ private PolicyRestAdapter populateDecisionGuardParameters(PolicyRestAdapter policyData,
+ Map<String, String> matching) {
+ // Set Matching attributes in YAMLParams in adapter
+ YAMLParams yamlparams = new YAMLParams();
+
+ if (matching == null) {
+ policyData.setYamlparams(yamlparams);
+ return policyData;
+ }
+
+ yamlparams.setActor(matching.get("actor"));
+ yamlparams.setRecipe(matching.get("recipe"));
+ yamlparams.setGuardActiveStart(matching.get("guardActiveStart"));
+ yamlparams.setGuardActiveEnd(matching.get("guardActiveEnd"));
- policyData.setPolicyType(parameters.getPolicyClass().toString());
+ yamlparams.setLimit(matching.get("limit"));
+ yamlparams.setTimeWindow(matching.get("timeWindow"));
+ yamlparams.setTimeUnits(matching.get("timeUnits"));
- // Get Matching attribute values
- Map<AttributeType, Map<String, String>> attributes = parameters.getAttributes();
- Map<String, String> matching = null;
- if (attributes != null) {
- matching = attributes.get(AttributeType.MATCHING);
+ yamlparams.setMin(matching.get("min"));
+ yamlparams.setMax(matching.get("max"));
+
+ List<String> blackList = new ArrayList<>();
+
+ if (!Strings.isNullOrEmpty(matching.get("blackList"))) {
+ String[] blackListArray = matching.get("blackList").split(",");
+ for (String element : blackListArray) {
+ blackList.add(element);
}
+ }
- if ("Decision".equals(parameters.getPolicyClass().toString())) {
+ yamlparams.setBlackList(blackList);
+
+ policyData.setYamlparams(yamlparams);
+ return policyData;
+ }
- String ruleProvider = parameters.getRuleProvider().toString();
- policyData.setRuleProvider(ruleProvider);
-
- if ("Rainy_Day".equals(ruleProvider)) {
-
- // Set Matching attributes in RainyDayParams in adapter
- RainyDayParams rainyday = new RainyDayParams();
-
- if (matching != null) {
- rainyday.setServiceType(matching.get("ServiceType"));
- rainyday.setVnfType(matching.get("VNFType"));
- rainyday.setBbid(matching.get("BB_ID"));
- rainyday.setWorkstep(matching.get("WorkStep"));
- }
-
- Map<String, String> treatments = parameters.getTreatments();
- ArrayList<Object> treatmentsTableChoices = new ArrayList<>();
-
- for (String keyField : treatments.keySet()) {
- LinkedHashMap<String, String> treatmentMap = new LinkedHashMap<>();
- String errorcode = keyField;
- String treatment = treatments.get(errorcode);
- treatmentMap.put("errorcode", errorcode);
- treatmentMap.put("treatment", treatment);
- treatmentsTableChoices.add(treatmentMap);
- }
- rainyday.setTreatmentTableChoices(treatmentsTableChoices);
- policyData.setRainyday(rainyday);
-
- } else if ("GUARD_YAML".equals(ruleProvider) || "GUARD_BL_YAML".equals(ruleProvider)
- || "GUARD_MIN_MAX".equals(ruleProvider)) {
-
- // Set Matching attributes in YAMLParams in adapter
- YAMLParams yamlparams = new YAMLParams();
-
- if (matching != null) {
- yamlparams.setActor(matching.get("actor"));
- yamlparams.setRecipe(matching.get("recipe"));
- yamlparams.setGuardActiveStart(matching.get("guardActiveStart"));
- yamlparams.setGuardActiveEnd(matching.get("guardActiveEnd"));
-
- if ("GUARD_YAML".equals(ruleProvider)) {
- yamlparams.setLimit(matching.get("limit"));
- yamlparams.setTimeWindow(matching.get("timeWindow"));
- yamlparams.setTimeUnits(matching.get("timeUnits"));
- } else if ("GUARD_MIN_MAX".equals(ruleProvider)) {
- yamlparams.setMin(matching.get("min"));
- yamlparams.setMax(matching.get("max"));
- } else {
-
- List<String> blackList = new ArrayList<>();
-
- if (!Strings.isNullOrEmpty(matching.get("blackList"))) {
- String[] blackListArray = matching.get("blackList").split(",");
- for (String element : blackListArray) {
- blackList.add(element);
- }
- }
-
- yamlparams.setBlackList(blackList);
-
- }
- }
- policyData.setYamlparams(yamlparams);
- }
-
- } else if ("Action".equals(parameters.getPolicyClass().toString())) {
-
- ArrayList<Object> ruleAlgorithmChoices = new ArrayList<>();
-
- List<String> dynamicLabelRuleAlgorithms = parameters.getDynamicRuleAlgorithmLabels();
- List<String> dynamicFieldFunctionRuleAlgorithms = parameters.getDynamicRuleAlgorithmFunctions();
- List<String> dynamicFieldOneRuleAlgorithms = parameters.getDynamicRuleAlgorithmField1();
- List<String> dyrnamicFieldTwoRuleAlgorithms = parameters.getDynamicRuleAlgorithmField2();
-
- if (dynamicLabelRuleAlgorithms != null && !dynamicLabelRuleAlgorithms.isEmpty()) {
-
- for (int i = dynamicLabelRuleAlgorithms.size() - 1; i >= 0; i--) {
- LinkedHashMap<String, String> ruleAlgorithm = new LinkedHashMap<>();
-
- String id = dynamicLabelRuleAlgorithms.get(i);
- String dynamicRuleAlgorithmField1 = dynamicFieldOneRuleAlgorithms.get(i);
- String dynamicRuleAlgorithmCombo = dynamicFieldFunctionRuleAlgorithms.get(i);
- String dynamicRuleAlgorithmField2 = dyrnamicFieldTwoRuleAlgorithms.get(i);
-
- ruleAlgorithm.put("id", id);
- ruleAlgorithm.put("dynamicRuleAlgorithmField1", dynamicRuleAlgorithmField1);
- ruleAlgorithm.put("dynamicRuleAlgorithmCombo", dynamicRuleAlgorithmCombo);
- ruleAlgorithm.put("dynamicRuleAlgorithmField2", dynamicRuleAlgorithmField2);
-
- ruleAlgorithmChoices.add(ruleAlgorithm);
- }
- }
-
- policyData.setRuleAlgorithmschoices(ruleAlgorithmChoices);
-
- ArrayList<Object> attributeList = new ArrayList<>();
- if (matching != null) {
- for (Map.Entry<String, String> entry : matching.entrySet()) {
- LinkedHashMap<String, String> attributeMap = new LinkedHashMap<>();
- String key = entry.getKey();
- String value = entry.getValue();
- attributeMap.put("key", key);
- attributeMap.put("value", value);
- attributeList.add(attributeMap);
- }
- }
-
- policyData.setAttributes(attributeList);
- policyData.setActionAttributeValue(parameters.getActionAttribute());
- policyData.setActionPerformer(parameters.getActionPerformer());
+ private PolicyRestAdapter populateActionParameters(PolicyParameters parameters, PolicyRestAdapter policyData,
+ Map<String, String> matching) {
+ ArrayList<Object> ruleAlgorithmChoices = new ArrayList<>();
+ List<String> dynamicLabelRuleAlgorithms = parameters.getDynamicRuleAlgorithmLabels();
+ List<String> dynamicFieldFunctionRuleAlgorithms = parameters.getDynamicRuleAlgorithmFunctions();
+ List<String> dynamicFieldOneRuleAlgorithms = parameters.getDynamicRuleAlgorithmField1();
+ List<String> dynamicFieldTwoRuleAlgorithms = parameters.getDynamicRuleAlgorithmField2();
+
+ if (dynamicLabelRuleAlgorithms != null && !dynamicLabelRuleAlgorithms.isEmpty()) {
+
+ for (int i = dynamicLabelRuleAlgorithms.size() - 1; i >= 0; i--) {
+ LinkedHashMap<String, String> ruleAlgorithm = new LinkedHashMap<>();
+
+ String id = dynamicLabelRuleAlgorithms.get(i);
+ String dynamicRuleAlgorithmField1 = dynamicFieldOneRuleAlgorithms.get(i);
+ String dynamicRuleAlgorithmCombo = dynamicFieldFunctionRuleAlgorithms.get(i);
+ String dynamicRuleAlgorithmField2 = dynamicFieldTwoRuleAlgorithms.get(i);
+
+ ruleAlgorithm.put("id", id);
+ ruleAlgorithm.put("dynamicRuleAlgorithmField1", dynamicRuleAlgorithmField1);
+ ruleAlgorithm.put("dynamicRuleAlgorithmCombo", dynamicRuleAlgorithmCombo);
+ ruleAlgorithm.put("dynamicRuleAlgorithmField2", dynamicRuleAlgorithmField2);
+
+ ruleAlgorithmChoices.add(ruleAlgorithm);
}
- } else {
+ }
+
+ policyData.setRuleAlgorithmschoices(ruleAlgorithmChoices);
+
+ ArrayList<Object> attributeList = new ArrayList<>();
+ if (matching != null) {
+ for (Map.Entry<String, String> entry : matching.entrySet()) {
+ LinkedHashMap<String, String> attributeMap = new LinkedHashMap<>();
+ String key = entry.getKey();
+ String value = entry.getValue();
+ attributeMap.put("key", key);
+ attributeMap.put("value", value);
+ attributeList.add(attributeMap);
+ }
+ }
- policyData.setPolicyType("Config");
- policyData.setConfigPolicyType(parameters.getPolicyConfigType().toString());
-
- // Config Specific
- policyData.setConfigBodyData(parameters.getConfigBody()); // Base
- policyData.setConfigType((parameters.getConfigBodyType() != null)
- ? parameters.getConfigBodyType().toString().toUpperCase()
- : null); // Base
-
- if ("FW".equalsIgnoreCase(parameters.getPolicyConfigType().toString())) {
-
- policyData.setConfigPolicyType("Firewall Config");
-
- // get values and attributes from the JsonObject
- if (json != null) {
- if (json.get("securityZoneId") != null) {
- String securityZone = json.get("securityZoneId").toString().replace("\"", "");
- policyData.setSecurityZone(securityZone);
- }
- if (json.get(CONFIG_NAME) != null) {
- String configName = json.get(CONFIG_NAME).toString().replace("\"", "");
- policyData.setConfigName(configName);
- }
- }
-
- } else if ("MS".equals(parameters.getPolicyConfigType().toString())) {
-
- policyData.setConfigPolicyType("Micro Service");
-
- // get values and attributes from the JsonObject
- if (json != null) {
- if (json.containsKey(CONTENT)) {
- String content = json.get(CONTENT).toString();
- ObjectMapper mapper = new ObjectMapper();
- JsonNode policyJson = null;
- try {
- policyJson = mapper.readTree(content);
- } catch (IOException e) {
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + INVALIDJSON
- + parameters.getConfigBody();
- LOGGER.error(message, e);
- return null;
- }
- policyData.setPolicyJSON(policyJson);
- }
- if (json.containsKey(SERVICE)) {
- String serviceType = json.get(SERVICE).toString().replace("\"", "");
- policyData.setServiceType(serviceType);
- }
- if (json.containsKey("uuid")) {
- String uuid = json.get("uuid").toString().replace("\"", "");
- policyData.setUuid(uuid);
- }
- if (json.containsKey(LOCATION)) {
- String msLocation = json.get(LOCATION).toString().replace("\"", "");
- policyData.setLocation(msLocation);
- }
- if (json.containsKey(CONFIG_NAME)) {
- String configName = json.get(CONFIG_NAME).toString().replace("\"", "");
- policyData.setConfigName(configName);
- }
- if (json.containsKey(PRIORITY)) {
- String priority = json.get(PRIORITY).toString().replace("\"", "");
- policyData.setPriority(priority);
- }
- if (json.containsKey(VERSION)) {
- String version = json.get(VERSION).toString().replace("\"", "");
- policyData.setVersion(version);
- }
- if (json.containsKey(POLICYSCOPE)) {
- String policyScope = json.get(POLICYSCOPE).toString().replace("\"", "");
- policyData.setPolicyScope(policyScope);
- }
- if (json.containsKey(RISKTYPE)) {
- String riskType = json.get(RISKTYPE).toString().replace("\"", "");
- policyData.setRiskType(riskType);
- }
- if (json.containsKey(RISKLEVEL)) {
- String riskLevel = json.get(RISKLEVEL).toString().replace("\"", "");
- policyData.setRiskLevel(riskLevel);
- }
- if (json.containsKey(GUARD)) {
- String guard = json.get(GUARD).toString().replace("\"", "");
- policyData.setGuard(guard);
- }
- } else {
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + INVALIDJSON + parameters.getConfigBody();
- LOGGER.error(message);
- return null;
- }
-
- } else if ("Optimization".equals(parameters.getPolicyConfigType().toString())) {
-
- policyData.setConfigPolicyType("Optimization");
-
- // get values and attributes from the JsonObject
- if (json != null) {
- if (json.containsKey(CONTENT)) {
- String content = json.get(CONTENT).toString();
- ObjectMapper mapper = new ObjectMapper();
- JsonNode policyJson = null;
- try {
- policyJson = mapper.readTree(content);
- } catch (IOException e) {
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + INVALIDJSON
- + parameters.getConfigBody();
- LOGGER.error(message, e);
- return null;
- }
- policyData.setPolicyJSON(policyJson);
- }
- if (json.containsKey(SERVICE)) {
- String serviceType = json.get(SERVICE).toString().replace("\"", "");
- policyData.setServiceType(serviceType);
- }
- if (json.containsKey("uuid")) {
- String uuid = json.get("uuid").toString().replace("\"", "");
- policyData.setUuid(uuid);
- }
- if (json.containsKey(LOCATION)) {
- String msLocation = json.get(LOCATION).toString().replace("\"", "");
- policyData.setLocation(msLocation);
- }
- if (json.containsKey(CONFIG_NAME)) {
- String configName = json.get(CONFIG_NAME).toString().replace("\"", "");
- policyData.setConfigName(configName);
- }
- if (json.containsKey(PRIORITY)) {
- String priority = json.get(PRIORITY).toString().replace("\"", "");
- policyData.setPriority(priority);
- }
- if (json.containsKey(VERSION)) {
- String version = json.get(VERSION).toString().replace("\"", "");
- policyData.setVersion(version);
- }
- if (json.containsKey(POLICYSCOPE)) {
- String policyScope = json.get(POLICYSCOPE).toString().replace("\"", "");
- policyData.setPolicyScope(policyScope);
- }
- if (json.containsKey(RISKTYPE)) {
- String riskType = json.get(RISKTYPE).toString().replace("\"", "");
- policyData.setRiskType(riskType);
- }
- if (json.containsKey(RISKLEVEL)) {
- String riskLevel = json.get(RISKLEVEL).toString().replace("\"", "");
- policyData.setRiskLevel(riskLevel);
- }
- if (json.containsKey(GUARD)) {
- String guard = json.get(GUARD).toString().replace("\"", "");
- policyData.setGuard(guard);
- }
- }
-
- } else if ("Fault".equals(parameters.getPolicyConfigType().toString())) {
-
- policyData.setConfigPolicyType("ClosedLoop_Fault");
-
- if (json != null) {
- policyData.setJsonBody(json.toString());
- if (json.get(ONAPNAME) != null) {
- String onapName = json.get(ONAPNAME).toString().replace("\"", "");
- policyData.setOnapName(onapName);
- }
- }
-
- } else if ("PM".equals(parameters.getPolicyConfigType().toString())) {
-
- policyData.setConfigPolicyType("ClosedLoop_PM");
-
- if (json != null) {
- policyData.setJsonBody(json.toString());
- if (json.get(ONAPNAME) != null) {
- String onapName = json.get(ONAPNAME).toString().replace("\"", "");
- policyData.setOnapName(onapName);
- }
- if (json.get(SERVICETYPE_POLICY_NAME) != null) {
- String serviceType = json.get(SERVICETYPE_POLICY_NAME).toString().replace("\"", "");
- LinkedHashMap<String, String> serviceTypePolicyName = new LinkedHashMap<>();
- serviceTypePolicyName.put(SERVICETYPE_POLICY_NAME, serviceType);
- policyData.setServiceTypePolicyName(serviceTypePolicyName);
- }
- }
- } else if ("BRMS_Param".equals(parameters.getPolicyConfigType().toString())) {
- Map<AttributeType, Map<String, String>> drlRuleAndUiParams = parameters.getAttributes();
- Map<String, String> rule = drlRuleAndUiParams.get(AttributeType.RULE);
- policyData.setRuleName(rule.get("templateName"));
+ policyData.setAttributes(attributeList);
+ policyData.setActionAttributeValue(parameters.getActionAttribute());
+ policyData.setActionPerformer(parameters.getActionPerformer());
+ return policyData;
+ }
+
+ private PolicyRestAdapter getJsonObjectValuesAndAttributes(PolicyParameters parameters,
+ PolicyRestAdapter policyData, JsonObject json) {
+ if (json.containsKey(CONTENT)) {
+ String content = json.get(CONTENT).toString();
+ JsonNode policyJson = null;
+ try {
+ policyJson = new ObjectMapper().readTree(content);
+ } catch (IOException e) {
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE + INVALIDJSON + parameters.getConfigBody();
+ LOGGER.error(message, e);
+ return null;
}
+ policyData.setPolicyJSON(policyJson);
}
+ // @formatter:off
+ policyData.setServiceType(getNewOrExistingKeyValue(json, SERVICE, policyData.getServiceType()));
+ policyData.setUuid(getNewOrExistingKeyValue( json, UUID, policyData.getUuid()));
+ policyData.setLocation(getNewOrExistingKeyValue( json, LOCATION, policyData.getLocation()));
+ policyData.setConfigName(getNewOrExistingKeyValue( json, CONFIG_NAME, policyData.getConfigName()));
+ policyData.setPriority(getNewOrExistingKeyValue( json, PRIORITY, policyData.getPriority()));
+ policyData.setVersion(getNewOrExistingKeyValue( json, VERSION, policyData.getVersion()));
+ policyData.setPolicyScope(getNewOrExistingKeyValue(json, POLICYSCOPE, policyData.getPolicyScope()));
+ policyData.setRiskType(getNewOrExistingKeyValue( json, RISKTYPE, policyData.getRiskType()));
+ policyData.setRiskLevel(getNewOrExistingKeyValue( json, RISKLEVEL, policyData.getRiskLevel()));
+ policyData.setGuard(getNewOrExistingKeyValue( json, GUARD, policyData.getGuard()));
+ // @formatter:on
+
return policyData;
+ }
+ private String getNewOrExistingKeyValue(final JsonObject json, final String key, final String existingValue) {
+ if (json.containsKey(key)) {
+ return json.get(key).toString().replace("\"", "");
+ } else {
+ return existingValue;
+ }
+ }
+
+ private Map<String, String> getMatchingAttributeValues(PolicyParameters parameters) {
+ // Get Matching attribute values
+ Map<AttributeType, Map<String, String>> attributes = parameters.getAttributes();
+
+ if (attributes != null) {
+ return attributes.get(AttributeType.MATCHING);
+ }
+ return null;
}
private JsonObject stringToJsonObject(String value) {
try (JsonReader jsonReader = Json.createReader(new StringReader(value))) {
return jsonReader.readObject();
- } catch (JsonException | IllegalStateException e) {
+ } catch (JsonException | IllegalStateException jsonHandlingException) {
LOGGER.info(XACMLErrorConstants.ERROR_DATA_ISSUE
+ "Improper JSON format... may or may not cause issues in validating the policy: " + value,
- e);
- return null;
+ jsonHandlingException);
+ throw jsonHandlingException;
}
}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyValidationRequestWrapperTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyValidationRequestWrapperTest.java
new file mode 100644
index 000000000..517058309
--- /dev/null
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/util/PolicyValidationRequestWrapperTest.java
@@ -0,0 +1,422 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.rest.util;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.BufferedReader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.policy.api.AttributeType;
+import org.onap.policy.api.PolicyClass;
+import org.onap.policy.api.PolicyConfigType;
+import org.onap.policy.api.PolicyParameters;
+import org.onap.policy.api.PolicyType;
+import org.onap.policy.api.RuleProvider;
+import org.onap.policy.common.utils.resources.TextFileUtils;
+import org.onap.policy.rest.adapter.PolicyRestAdapter;
+
+@RunWith(MockitoJUnitRunner.class)
+public class PolicyValidationRequestWrapperTest {
+
+ @Mock
+ HttpServletRequest request;
+
+ @Test
+ public void testHttpRequest() throws Exception {
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+
+ assertNull(wrapper.populateRequestParameters((HttpServletRequest) null));
+
+ BufferedReader decisionPolicyReader = new BufferedReader(new StringReader(
+ TextFileUtils.getTextFileAsString("src/test/resources/policies/DecisionPolicy.json")));
+
+ Mockito.when(request.getReader()).thenReturn(decisionPolicyReader);
+
+ wrapper.populateRequestParameters(request);
+
+ BufferedReader policyJsonTrapFaultReader = new BufferedReader(new StringReader(
+ TextFileUtils.getTextFileAsString("src/test/resources/policies/PolicyJsonTrapFault.json")));
+
+ Mockito.when(request.getReader()).thenReturn(policyJsonTrapFaultReader);
+
+ wrapper.populateRequestParameters(request);
+
+ BufferedReader badJsonReader = new BufferedReader(new StringReader("{"));
+
+ Mockito.when(request.getReader()).thenReturn(badJsonReader);
+
+ wrapper.populateRequestParameters(request);
+ }
+
+ @Test
+ public void testDefaultParameterHandling() throws Exception {
+ PolicyParameters parameters = createParametersObject();
+
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+
+ assertThatThrownBy(() -> wrapper.populateRequestParameters(parameters))
+ .isInstanceOf(NullPointerException.class);
+
+ parameters.setPolicyConfigType(PolicyConfigType.Firewall);
+ PolicyRestAdapter adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("Firewall Config", adapter.getConfigPolicyType());
+
+ parameters.setConfigBody("");
+ assertNull(wrapper.populateRequestParameters((parameters)));
+
+ parameters.setConfigBody("{\"name");
+ assertNull(wrapper.populateRequestParameters((parameters)));
+
+ parameters.setConfigBodyType(PolicyType.OTHER);
+ parameters.setConfigBody(null);
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("Firewall Config", adapter.getConfigPolicyType());
+
+ parameters.setPolicyConfigType(PolicyConfigType.Extended);
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("EXTENDED", adapter.getConfigPolicyType());
+
+ parameters.setTtlDate(null);
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("NA", adapter.getTtlDate());
+ }
+
+ @Test
+ public void testConfigFirewallParameterHandling() throws Exception {
+ PolicyParameters parameters = createParametersObject();
+ parameters.setPolicyConfigType(PolicyConfigType.Firewall);
+
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+
+ PolicyRestAdapter adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("Firewall Config", adapter.getConfigPolicyType());
+
+ parameters.setConfigBody("{\"someParameter\": \"someValue\"}");
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals(null, adapter.getSecurityZone());
+ assertEquals("ConfigName", adapter.getConfigName());
+
+ parameters.setConfigBody("{\"securityZoneId\": \"SecurityZone\"}");
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("SecurityZone", adapter.getSecurityZone());
+
+ parameters.setConfigBody("{\"configName\": \"AnotherConfigName\"}");
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("AnotherConfigName", adapter.getConfigName());
+ }
+
+ @Test
+ public void testConfigMicroserviceParameterHandling() throws Exception {
+ PolicyParameters parameters = createParametersObject();
+ parameters.setPolicyConfigType(PolicyConfigType.MicroService);
+
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+
+ assertNull(wrapper.populateRequestParameters((parameters)));
+
+ parameters.setConfigBody("{\"someParameter\": \"someValue\"}");
+
+ PolicyRestAdapter adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("Micro Service", adapter.getConfigPolicyType());
+
+ parameters.setConfigBody("{\"service\": \"MyService\"}");
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("MyService", adapter.getServiceType());
+
+ parameters.setConfigBody("{\"content\": \"{}\"}");
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("\"{}\"", adapter.getPolicyJSON().toString());
+
+ parameters.setConfigBody("{\"content\": {hess:}}");
+ assertNull(wrapper.populateRequestParameters((parameters)));
+ }
+
+ @Test
+ public void testConfigOptimizationParameterHandling() throws Exception {
+ PolicyParameters parameters = createParametersObject();
+ parameters.setPolicyConfigType(PolicyConfigType.Optimization);
+
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+
+ PolicyRestAdapter adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("Optimization", adapter.getConfigPolicyType());
+
+ parameters.setConfigBody("{\"someParameter\": \"someValue\"}");
+
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("Optimization", adapter.getConfigPolicyType());
+
+ parameters.setConfigBody("{\"service\": \"MyService\"}");
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("MyService", adapter.getServiceType());
+ }
+
+ @Test
+ public void testConfigClosedLoopFaultParameterHandling() throws Exception {
+ PolicyParameters parameters = createParametersObject();
+ parameters.setPolicyConfigType(PolicyConfigType.ClosedLoop_Fault);
+
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+
+ PolicyRestAdapter adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("ClosedLoop_Fault", adapter.getConfigPolicyType());
+
+ parameters.setConfigBody("{\"someParameter\": \"someValue\"}");
+
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("ClosedLoop_Fault", adapter.getConfigPolicyType());
+
+ parameters.setConfigBody("{\"onapname\": \"MyOnapName\"}");
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("MyOnapName", adapter.getOnapName());
+ }
+
+ @Test
+ public void testConfigClosedLoopPmParameterHandling() throws Exception {
+ PolicyParameters parameters = createParametersObject();
+ parameters.setPolicyConfigType(PolicyConfigType.ClosedLoop_PM);
+
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+
+ PolicyRestAdapter adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("ClosedLoop_PM", adapter.getConfigPolicyType());
+
+ parameters.setConfigBody("{\"someParameter\": \"someValue\"}");
+
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("ClosedLoop_PM", adapter.getConfigPolicyType());
+
+ parameters.setConfigBody(
+ "{\"onapname\": \"MyOnapName\",\"serviceTypePolicyName\":\"Service Type Policy Name\"}");
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("MyOnapName", adapter.getOnapName());
+ }
+
+ @Test
+ public void testConfigBrmsParameterHandling() throws Exception {
+ PolicyParameters parameters = createParametersObject();
+ parameters.setPolicyConfigType(PolicyConfigType.BRMS_PARAM);
+
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+ assertThatThrownBy(() -> wrapper.populateRequestParameters(parameters))
+ .isInstanceOf(NullPointerException.class);
+
+ Map<AttributeType, Map<String, String>> attributes = new LinkedHashMap<>();
+ parameters.setAttributes(attributes);
+ assertThatThrownBy(() -> wrapper.populateRequestParameters(parameters))
+ .isInstanceOf(NullPointerException.class);
+
+ Map<String, String> templateMap = new LinkedHashMap<>();
+ templateMap.put("templateName", "Template Name");
+ attributes.put(AttributeType.RULE, templateMap);
+ PolicyRestAdapter adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("BRMS_Param", adapter.getConfigPolicyType());
+ assertEquals("Template Name", adapter.getRuleName());
+
+ parameters.setConfigBody("{\"someParameter\": \"someValue\"}");
+
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("BRMS_Param", adapter.getConfigPolicyType());
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testDecisionRainyDayParameterHandling() throws Exception {
+ PolicyParameters parameters = createParametersObject();
+ parameters.setPolicyClass(PolicyClass.Decision);
+
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+ assertThatThrownBy(() -> wrapper.populateRequestParameters(parameters))
+ .isInstanceOf(NullPointerException.class);
+
+ Map<AttributeType, Map<String, String>> attributes = new LinkedHashMap<>();
+ parameters.setAttributes(attributes);
+ assertThatThrownBy(() -> wrapper.populateRequestParameters(parameters))
+ .isInstanceOf(NullPointerException.class);
+
+ parameters.setRuleProvider(RuleProvider.RAINY_DAY);
+ assertThatThrownBy(() -> wrapper.populateRequestParameters(parameters))
+ .isInstanceOf(NullPointerException.class);
+
+ Map<String, String> treatments = new LinkedHashMap<>();
+ parameters.setTreatments(treatments);
+
+ PolicyRestAdapter adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("Rainy_Day", adapter.getRuleProvider());
+
+ treatments.put("ATreatment", "A Treatment Value");
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("ATreatment", ((Map<String, String>) adapter.getRainyday().getTreatmentTableChoices().get(0))
+ .get("errorcode"));
+ assertEquals("A Treatment Value",
+ ((Map<String, String>) adapter.getRainyday().getTreatmentTableChoices().get(0))
+ .get("treatment"));
+
+ Map<String, String> matchingMap = new LinkedHashMap<>();
+ matchingMap.put("ServiceType", "AServiceType");
+ attributes.put(AttributeType.MATCHING, matchingMap);
+ parameters.setAttributes(attributes);
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("AServiceType", adapter.getRainyday().getServiceType());
+ }
+
+ @Test
+ public void testDecisionGuardParameterHandling() throws Exception {
+ PolicyParameters parameters = createParametersObject();
+ parameters.setPolicyClass(PolicyClass.Decision);
+
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+ assertThatThrownBy(() -> wrapper.populateRequestParameters(parameters))
+ .isInstanceOf(NullPointerException.class);
+
+ Map<AttributeType, Map<String, String>> attributes = new LinkedHashMap<>();
+ parameters.setAttributes(attributes);
+ assertThatThrownBy(() -> wrapper.populateRequestParameters(parameters))
+ .isInstanceOf(NullPointerException.class);
+
+ parameters.setRuleProvider(RuleProvider.GUARD_BL_YAML);
+
+ PolicyRestAdapter adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("GUARD_BL_YAML", adapter.getRuleProvider());
+
+ parameters.setRuleProvider(RuleProvider.GUARD_MIN_MAX);
+
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("GUARD_MIN_MAX", adapter.getRuleProvider());
+
+ parameters.setRuleProvider(RuleProvider.GUARD_YAML);
+
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("GUARD_YAML", adapter.getRuleProvider());
+
+ Map<String, String> matchingMap = new LinkedHashMap<>();
+ matchingMap.put("actor", "Actor");
+ matchingMap.put("recipe", "Recipe");
+ matchingMap.put("guardActiveStart", "GuardActiveStart");
+ matchingMap.put("guardActiveEnd", "GuardActiveEnd");
+ matchingMap.put("limit", "Limit");
+ matchingMap.put("timeWindow", "Window");
+ matchingMap.put("timeUnits", "Units");
+
+ attributes.put(AttributeType.MATCHING, matchingMap);
+ parameters.setAttributes(attributes);
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("Actor", adapter.getYamlparams().getActor());
+ assertEquals("Recipe", adapter.getYamlparams().getRecipe());
+ assertEquals("GuardActiveStart", adapter.getYamlparams().getGuardActiveStart());
+ assertEquals("GuardActiveEnd", adapter.getYamlparams().getGuardActiveEnd());
+ assertEquals("Limit", adapter.getYamlparams().getLimit());
+ assertEquals("Window", adapter.getYamlparams().getTimeWindow());
+ assertEquals("Units", adapter.getYamlparams().getTimeUnits());
+
+ parameters.setRuleProvider(RuleProvider.GUARD_MIN_MAX);
+ matchingMap.put("min", "TheMin");
+ matchingMap.put("max", "TheMax");
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("TheMin", adapter.getYamlparams().getMin());
+ assertEquals("TheMax", adapter.getYamlparams().getMax());
+
+ parameters.setRuleProvider(RuleProvider.GUARD_BL_YAML);
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertTrue(adapter.getYamlparams().getBlackList().isEmpty());
+
+ matchingMap.put("blackList", "Bad0,Bad1");
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("Bad0", adapter.getYamlparams().getBlackList().get(0));
+ assertEquals("Bad1", adapter.getYamlparams().getBlackList().get(1));
+
+ parameters.setRuleProvider(RuleProvider.AAF);
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertNull(adapter.getYamlparams());
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testActionParameterHandling() throws Exception {
+ PolicyParameters parameters = createParametersObject();
+ parameters.setPolicyClass(PolicyClass.Action);
+
+ PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
+
+ PolicyRestAdapter adapter = wrapper.populateRequestParameters((parameters));
+ assertTrue(adapter.getRuleAlgorithmschoices().isEmpty());
+
+ List<String> dynamicRuleAlgorithmLabels = new ArrayList<>();
+ parameters.setDynamicRuleAlgorithmLabels(dynamicRuleAlgorithmLabels);
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertTrue(adapter.getRuleAlgorithmschoices().isEmpty());
+
+ dynamicRuleAlgorithmLabels.add("Label0");
+ List<String> dynamicRuleAlgorithmFunctions = new ArrayList<>();
+ dynamicRuleAlgorithmFunctions.add("FirstAlgorithmFunction");
+ parameters.setDynamicRuleAlgorithmFunctions(dynamicRuleAlgorithmFunctions);
+ List<String> dynamicRuleAlgorithmField1 = new ArrayList<>();
+ dynamicRuleAlgorithmField1.add("FirstAlgorithmFunctionField1");
+ parameters.setDynamicRuleAlgorithmField1(dynamicRuleAlgorithmField1);
+ List<String> dynamicRuleAlgorithmField2 = new ArrayList<>();
+ dynamicRuleAlgorithmField2.add("FirstAlgorithmFunctionField2");
+ parameters.setDynamicRuleAlgorithmField2(dynamicRuleAlgorithmField2);
+ parameters.setDynamicRuleAlgorithmLabels(dynamicRuleAlgorithmLabels);
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals(1, adapter.getRuleAlgorithmschoices().size());
+ assertEquals("Label0", ((LinkedHashMap<String, String>) adapter.getRuleAlgorithmschoices().get(0)).get("id"));
+
+ Map<String, String> matchingMap = new LinkedHashMap<>();
+ matchingMap.put("AKey", "AValue");
+
+ Map<AttributeType, Map<String, String>> attributes = new LinkedHashMap<>();
+ attributes.put(AttributeType.MATCHING, matchingMap);
+ parameters.setAttributes(attributes);
+ adapter = wrapper.populateRequestParameters((parameters));
+ assertEquals("AKey", ((LinkedHashMap<String, String>) adapter.getAttributes().get(0)).get("key"));
+ }
+
+ private PolicyParameters createParametersObject() {
+ PolicyParameters parameters = new PolicyParameters();
+
+ parameters.setPolicyName("PolicyName");
+ parameters.setOnapName("ONAPName");
+ parameters.setPriority("SomePriority");
+ parameters.setConfigName("ConfigName");
+ parameters.setRiskType("RiskType");
+ parameters.setRiskLevel("RiskLevel");
+ parameters.setGuard(false);
+ parameters.setTtlDate(new Date());
+
+ return parameters;
+ }
+}
diff --git a/ONAP-REST/src/test/resources/policies/DecisionPolicy.json b/ONAP-REST/src/test/resources/policies/DecisionPolicy.json
new file mode 100644
index 000000000..a316b0e7e
--- /dev/null
+++ b/ONAP-REST/src/test/resources/policies/DecisionPolicy.json
@@ -0,0 +1,1556 @@
+{
+ "policyData": {
+ "data": {
+ "description": "SampelGuardBLOne@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:",
+ "policyIssuer": null,
+ "policyDefaults": null,
+ "target": {
+ "anyOf": [
+ {
+ "allOf": [
+ {
+ "match": [
+ {
+ "attributeValue": {
+ "content": [
+ "com.Decision_SampelGuardBLOne.4.xml"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:1.0:subject-category:access-subject",
+ "attributeId": "PolicyName",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "org.onap.function.regex-match"
+ }
+ ]
+ },
+ {
+ "match": [
+ {
+ "attributeValue": {
+ "content": [
+ "Test"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:1.0:subject-category:access-subject",
+ "attributeId": "ONAPName",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "org.onap.function.regex-match"
+ },
+ {
+ "attributeValue": {
+ "content": [
+ "(?i)testActor"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "actor",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"
+ },
+ {
+ "attributeValue": {
+ "content": [
+ "(?i)testRecipe"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "recipe",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"
+ },
+ {
+ "attributeValue": {
+ "content": [
+ "testCLName"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "clname",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"
+ },
+ {
+ "attributeValue": {
+ "content": [
+ "Use Manual Entry"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "blackListEntryType",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "combinerParametersOrRuleCombinerParametersOrVariableDefinition": [
+ {
+ "description": null,
+ "target": {
+ "anyOf": [
+ {
+ "allOf": [
+ {
+ "match": [
+ {
+ "attributeValue": {
+ "content": [
+ "DECIDE"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:action",
+ "attributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "condition": {
+ "expression": {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:environment",
+ "attributeId": "urn:oasis:names:tc:xacml:1.0:environment:current-time",
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:time-one-and-only"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "5:00"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "10:00"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:2.0:function:time-in-range"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Function",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.FunctionType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-equal"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "target",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-one-and-only"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL2"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL3"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL4"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-bag"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:3.0:function:any-of"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:and"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:not"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ },
+ "obligationExpressions": null,
+ "adviceExpressions": null,
+ "ruleId": "urn:com:xacml:rule:id:284d9393-f861-4250-b62d-fc36640a363a",
+ "effect": "PERMIT"
+ },
+ {
+ "description": null,
+ "target": {
+ "anyOf": [
+ {
+ "allOf": [
+ {
+ "match": [
+ {
+ "attributeValue": {
+ "content": [
+ "DECIDE"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:action",
+ "attributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "condition": {
+ "expression": {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:environment",
+ "attributeId": "urn:oasis:names:tc:xacml:1.0:environment:current-time",
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:time-one-and-only"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "5:00"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "10:00"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:2.0:function:time-in-range"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Function",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.FunctionType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-equal"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "target",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-one-and-only"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL2"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL3"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL4"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-bag"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:3.0:function:any-of"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:and"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:not"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:not"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ },
+ "obligationExpressions": null,
+ "adviceExpressions": {
+ "adviceExpression": [
+ {
+ "attributeAssignmentExpression": [
+ {
+ "expression": {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "Denied!"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ "attributeId": "guard.response",
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "issuer": null
+ }
+ ],
+ "adviceId": "GUARD_BL_YAML",
+ "appliesTo": "DENY"
+ }
+ ]
+ },
+ "ruleId": "urn:com:xacml:rule:id:284d9393-f861-4250-b62d-fc36640a363a",
+ "effect": "DENY"
+ }
+ ],
+ "obligationExpressions": null,
+ "adviceExpressions": null,
+ "policyId": "urn:com:xacml:policy:id:d56af069-6cf1-430c-ba07-e26602e06a52",
+ "version": "4",
+ "ruleCombiningAlgId": "urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides",
+ "maxDelegationDepth": null
+ },
+ "policyName": "SampelGuardBLOne",
+ "configBodyData": null,
+ "configType": null,
+ "policyID": null,
+ "policyType": "Decision",
+ "comboPolicyType": null,
+ "configPolicyType": null,
+ "policyDescription": "SampelGuardBLOne",
+ "onapName": "Test",
+ "configName": null,
+ "ruleID": null,
+ "parentPath": null,
+ "adminNotification": null,
+ "policyData": {
+ "description": "SampelGuardBLOne@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:",
+ "policyIssuer": null,
+ "policyDefaults": null,
+ "target": {
+ "anyOf": [
+ {
+ "allOf": [
+ {
+ "match": [
+ {
+ "attributeValue": {
+ "content": [
+ "com.Decision_SampelGuardBLOne.4.xml"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:1.0:subject-category:access-subject",
+ "attributeId": "PolicyName",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "org.onap.function.regex-match"
+ }
+ ]
+ },
+ {
+ "match": [
+ {
+ "attributeValue": {
+ "content": [
+ "Test"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:1.0:subject-category:access-subject",
+ "attributeId": "ONAPName",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "org.onap.function.regex-match"
+ },
+ {
+ "attributeValue": {
+ "content": [
+ "(?i)testActor"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "actor",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"
+ },
+ {
+ "attributeValue": {
+ "content": [
+ "(?i)testRecipe"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "recipe",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"
+ },
+ {
+ "attributeValue": {
+ "content": [
+ "testCLName"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "clname",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"
+ },
+ {
+ "attributeValue": {
+ "content": [
+ "Use Manual Entry"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "blackListEntryType",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "combinerParametersOrRuleCombinerParametersOrVariableDefinition": [
+ {
+ "description": null,
+ "target": {
+ "anyOf": [
+ {
+ "allOf": [
+ {
+ "match": [
+ {
+ "attributeValue": {
+ "content": [
+ "DECIDE"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:action",
+ "attributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "condition": {
+ "expression": {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:environment",
+ "attributeId": "urn:oasis:names:tc:xacml:1.0:environment:current-time",
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:time-one-and-only"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "5:00"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "10:00"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:2.0:function:time-in-range"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Function",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.FunctionType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-equal"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "target",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-one-and-only"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL2"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL3"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL4"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-bag"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:3.0:function:any-of"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:and"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:not"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ },
+ "obligationExpressions": null,
+ "adviceExpressions": null,
+ "ruleId": "urn:com:xacml:rule:id:284d9393-f861-4250-b62d-fc36640a363a",
+ "effect": "PERMIT"
+ },
+ {
+ "description": null,
+ "target": {
+ "anyOf": [
+ {
+ "allOf": [
+ {
+ "match": [
+ {
+ "attributeValue": {
+ "content": [
+ "DECIDE"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "attributeDesignator": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:action",
+ "attributeId": "urn:oasis:names:tc:xacml:1.0:action:action-id",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "attributeSelector": null,
+ "matchId": "urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "condition": {
+ "expression": {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:environment",
+ "attributeId": "urn:oasis:names:tc:xacml:1.0:environment:current-time",
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:time-one-and-only"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "5:00"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "10:00"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#time",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:2.0:function:time-in-range"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Function",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.FunctionType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-equal"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "attributeId": "target",
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "issuer": null,
+ "mustBePresent": false
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-one-and-only"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "description": null,
+ "expression": [
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL2"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL3"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "testBL4"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:string-bag"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:3.0:function:any-of"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:and"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:not"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ ],
+ "functionId": "urn:oasis:names:tc:xacml:1.0:function:not"
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ }
+ },
+ "obligationExpressions": null,
+ "adviceExpressions": {
+ "adviceExpression": [
+ {
+ "attributeAssignmentExpression": [
+ {
+ "expression": {
+ "name": "{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue",
+ "declaredType": "oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType",
+ "scope": "javax.xml.bind.JAXBElement$GlobalScope",
+ "value": {
+ "content": [
+ "Denied!"
+ ],
+ "dataType": "http://www.w3.org/2001/XMLSchema#string",
+ "otherAttributes": {
+ }
+ },
+ "nil": false,
+ "globalScope": true,
+ "typeSubstituted": false
+ },
+ "attributeId": "guard.response",
+ "category": "urn:oasis:names:tc:xacml:3.0:attribute-category:resource",
+ "issuer": null
+ }
+ ],
+ "adviceId": "GUARD_BL_YAML",
+ "appliesTo": "DENY"
+ }
+ ]
+ },
+ "ruleId": "urn:com:xacml:rule:id:284d9393-f861-4250-b62d-fc36640a363a",
+ "effect": "DENY"
+ }
+ ],
+ "obligationExpressions": null,
+ "adviceExpressions": null,
+ "policyId": "urn:com:xacml:policy:id:d56af069-6cf1-430c-ba07-e26602e06a52",
+ "version": "4",
+ "ruleCombiningAlgId": "urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides",
+ "maxDelegationDepth": null
+ },
+ "gitPath": null,
+ "readOnly": false,
+ "configHome": null,
+ "configUrl": null,
+ "finalPolicyPath": null,
+ "version": null,
+ "jsonBody": null,
+ "apiflag": null,
+ "prevJsonBody": null,
+ "highestVersion": null,
+ "entityManagerFactory": null,
+ "policyExists": false,
+ "oldPolicyFileName": "Decision_SampelGuardBLOne",
+ "userId": null,
+ "newFileName": null,
+ "clWarning": null,
+ "newCLName": null,
+ "existingCLName": null,
+ "onapNameField": null,
+ "jsonBodyData": null,
+ "dirPath": null,
+ "configBodyPath": null,
+ "attributes": [
+ ],
+ "settings": [
+ ],
+ "ruleAlgorithmschoices": [
+ ],
+ "serviceTypePolicyName": null,
+ "verticaMetrics": null,
+ "description": null,
+ "attributeFields": null,
+ "clearTimeOut": null,
+ "trapMaxAge": null,
+ "verificationclearTimeOut": null,
+ "dynamicLayoutMap": null,
+ "trapDatas": null,
+ "faultDatas": null,
+ "fwPolicyType": null,
+ "fwattributes": null,
+ "parentForChild": null,
+ "securityZone": null,
+ "ruleCombiningAlgId": null,
+ "dynamicFieldConfigAttributes": null,
+ "dynamicSettingsMap": null,
+ "dropDownMap": null,
+ "actionPerformer": null,
+ "actionAttribute": null,
+ "dynamicRuleAlgorithmLabels": null,
+ "dynamicRuleAlgorithmCombo": null,
+ "dynamicRuleAlgorithmField1": null,
+ "dynamicRuleAlgorithmField2": null,
+ "dynamicVariableList": null,
+ "dataTypeList": null,
+ "actionAttributeValue": null,
+ "ruleProvider": "GUARD_BL_YAML",
+ "actionBody": null,
+ "actionDictHeader": null,
+ "actionDictType": null,
+ "actionDictUrl": null,
+ "actionDictMethod": null,
+ "yamlparams": {
+ "actor": "testActor",
+ "recipe": "testRecipe",
+ "clname": "testCLName",
+ "limit": null,
+ "timeWindow": null,
+ "timeUnits": null,
+ "guardActiveStart": "5:00",
+ "guardActiveEnd": "10:00",
+ "blackList": [
+ "testBL2",
+ "testBL3",
+ "testBL4"
+ ],
+ "targets": null,
+ "blackListEntryType": "Use Manual Entry"
+ },
+ "blackListEntries": [
+ ],
+ "appendBlackListEntries": [
+ ],
+ "rainyday": {
+ "serviceType": null,
+ "vnfType": null,
+ "bbid": null,
+ "workstep": null,
+ "treatmentTableChoices": [
+ ],
+ "errorcode": null,
+ "treatment": null
+ },
+ "rainydayMap": null,
+ "errorCodeList": null,
+ "treatmentList": null,
+ "serviceType": null,
+ "uuid": null,
+ "location": null,
+ "priority": null,
+ "msLocation": null,
+ "policyJSON": null,
+ "ruleName": null,
+ "brmsParamBody": null,
+ "brmsController": null,
+ "brmsDependency": null,
+ "ruleData": null,
+ "ruleListData": null,
+ "drlRuleAndUIParams": null,
+ "policyScope": null,
+ "providerComboBox": null,
+ "riskType": null,
+ "riskLevel": null,
+ "guard": null,
+ "ttlDate": null,
+ "matching": null,
+ "triggerSignatures": null,
+ "symptomSignatures": null,
+ "logicalConnector": null,
+ "policyStatus": null,
+ "gocServerScope": null,
+ "supressionType": null,
+ "editPolicy": true,
+ "domainDir": "com",
+ "validData": false,
+ "draft": false,
+ "viewPolicy": false,
+ "blackListEntryType": "Use Manual Entry"
+ },
+ "date": "2018-03-27 13:36:12.0",
+ "version": 4
+}
diff --git a/ONAP-REST/src/test/resources/policies/PolicyJsonTrapFault.json b/ONAP-REST/src/test/resources/policies/PolicyJsonTrapFault.json
new file mode 100644
index 000000000..8eafe2c2b
--- /dev/null
+++ b/ONAP-REST/src/test/resources/policies/PolicyJsonTrapFault.json
@@ -0,0 +1,9 @@
+{
+ "policyData": {
+ },
+ "trapData": {
+ },
+ "faultData": {
+ },
+ "policyJSON": "Policy JSON String"
+}