summaryrefslogtreecommitdiffstats
path: root/ONAP-PAP-REST
diff options
context:
space:
mode:
authorrb7147 <rb7147@att.com>2018-07-18 12:50:06 -0400
committerrb7147 <rb7147@att.com>2018-07-24 14:16:12 -0400
commit95524c8ef8be0d41de8bb2b918f320e464ebb897 (patch)
treed3b5cdf4ebd9b42aff5e48e54cfd45f353c89f52 /ONAP-PAP-REST
parent9bfa1d61dc77973f85a42174b199d4c744265521 (diff)
Decision BlackList Guard Enhancements
While creating a decision Bl Guard Policy we are allowing to add Blacklist entries through file upload for bulk from GUI. Issue-ID: POLICY-901 Change-Id: I4031fd4a96937b9facc330cecf72777d701d4678 Signed-off-by: rb7147 <rb7147@att.com>
Diffstat (limited to 'ONAP-PAP-REST')
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java16
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreation.java12
-rw-r--r--ONAP-PAP-REST/src/main/resources/Decision_GuardBLPolicyTemplate.xml2
-rw-r--r--ONAP-PAP-REST/src/main/resources/Decision_GuardPolicyTemplate.xml2
4 files changed, 27 insertions, 5 deletions
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java
index 56c23ac2c..c8c540c34 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java
@@ -167,7 +167,9 @@ public class DecisionPolicy extends Policy {
if(policyAdapter.getRuleProvider().equals(GUARD_YAML) || policyAdapter.getRuleProvider().equals(GUARD_BL_YAML)){
Map<String, String> yamlParams = new HashMap<>();
- yamlParams.put(DESCRIPTION, (policyAdapter.getPolicyDescription()!=null)? policyAdapter.getPolicyDescription(): "YAML Guard Policy");
+ String blackListEntryType = policyAdapter.getBlackListEntryType() !=null ? policyAdapter.getBlackListEntryType(): "Use Manual Entry";
+ String description = policyAdapter.getPolicyDescription() != null? policyAdapter.getPolicyDescription(): "YAML Guard Policy";
+ yamlParams.put(DESCRIPTION, description + "@blEntry@" + blackListEntryType + "@blEntry@");
String fileName = policyAdapter.getNewFileName();
String name = fileName.substring(fileName.lastIndexOf('\\') + 1, fileName.length());
if ((name == null) || ("".equals(name))) {
@@ -295,6 +297,16 @@ public class DecisionPolicy extends Policy {
blackList.add(blackListString);
}
}
+ if(yamlParams.containsKey("appendBlackList")){
+ String appendBlackListString = yamlParams.get("appendBlackList");
+ List<String> appendBlackList = null;
+ if(appendBlackListString!=null && !appendBlackListString.trim().isEmpty()){
+ appendBlackList = Arrays.asList(appendBlackListString.split(","));
+ for(int i=0; i<appendBlackList.size();i++){
+ blackList.remove(appendBlackList.get(i));
+ }
+ }
+ }
File templateFile;
Path xacmlTemplatePath;
ClassLoader classLoader = getClass().getClassLoader();
@@ -781,7 +793,7 @@ public class DecisionPolicy extends Policy {
}
public String getFunctionDefinitionId(String key){
- FunctionDefinition object = (FunctionDefinition) commonClassDao.getDataById(FunctionDefinition.class, "short_name", key);
+ FunctionDefinition object = (FunctionDefinition) commonClassDao.getDataById(FunctionDefinition.class, "shortname", key);
if(object != null){
return object.getXacmlid();
}
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreation.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreation.java
index f7ef1a097..a6cda5e68 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreation.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreation.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -416,6 +416,16 @@ public class PolicyCreation extends AbstractPolicyCreation{
String blackList = StringUtils.join(policyData.getYamlparams().getBlackList(), ",");
attributeMap.put("blackList", blackList);
}
+ if(DecisionPolicy.GUARD_BL_YAML.equals(policyData.getRuleProvider()) && "Use File Upload".equals(policyData.getBlackListEntryType())){
+ if(policyData.getBlackListEntries() != null && !policyData.getBlackListEntries().isEmpty()){
+ String blackList = StringUtils.join(policyData.getBlackListEntries(), ",");
+ attributeMap.put("blackList", blackList);
+ }
+ if(policyData.getAppendBlackListEntries() != null && !policyData.getAppendBlackListEntries().isEmpty()){
+ String blackList = StringUtils.join(policyData.getAppendBlackListEntries(), ",");
+ attributeMap.put("appendBlackList", blackList);
+ }
+ }
if(policyData.getYamlparams().getTargets()!=null){
String targets = StringUtils.join(policyData.getYamlparams().getTargets(),",");
attributeMap.put("targets", targets);
diff --git a/ONAP-PAP-REST/src/main/resources/Decision_GuardBLPolicyTemplate.xml b/ONAP-PAP-REST/src/main/resources/Decision_GuardBLPolicyTemplate.xml
index 1ac292c3f..43d7a2349 100644
--- a/ONAP-PAP-REST/src/main/resources/Decision_GuardBLPolicyTemplate.xml
+++ b/ONAP-PAP-REST/src/main/resources/Decision_GuardBLPolicyTemplate.xml
@@ -122,7 +122,7 @@
<AdviceExpressions>
<AdviceExpression AdviceId="GUARD_BL_YAML" AppliesTo="Deny">
<AttributeAssignmentExpression AttributeId="guard.response" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
- <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Denied!</AttributeValue>
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Denied By Blacklist</AttributeValue>
</AttributeAssignmentExpression>
</AdviceExpression>
</AdviceExpressions>
diff --git a/ONAP-PAP-REST/src/main/resources/Decision_GuardPolicyTemplate.xml b/ONAP-PAP-REST/src/main/resources/Decision_GuardPolicyTemplate.xml
index 15465f3c0..809dc99fb 100644
--- a/ONAP-PAP-REST/src/main/resources/Decision_GuardPolicyTemplate.xml
+++ b/ONAP-PAP-REST/src/main/resources/Decision_GuardPolicyTemplate.xml
@@ -118,7 +118,7 @@
<AdviceExpressions>
<AdviceExpression AdviceId="GUARD_YAML" AppliesTo="Deny">
<AttributeAssignmentExpression AttributeId="guard.response" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
- <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Denied!</AttributeValue>
+ <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Denied By Guard</AttributeValue>
</AttributeAssignmentExpression>
</AdviceExpression>
</AdviceExpressions>