import org.onap.policy.xacml.std.pip.engines.aaf.AAFEngine;
import org.onap.policy.xacml.util.XACMLPolicyScanner;
+import com.att.research.xacml.api.XACML3;
+import com.att.research.xacml.api.pap.PAPException;
import com.att.research.xacml.std.IdentifierImpl;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionType;
}
@Override
- public Map<String, String> savePolicies() throws Exception {
+ public Map<String, String> savePolicies() throws PAPException {
Map<String, String> successMap = new HashMap<>();
if(isPolicyExists()){
//This is the method for preparing the policy for saving. We have broken it out
//separately because the fully configured policy is used for multiple things
@Override
- public boolean prepareToSave() throws Exception{
+ public boolean prepareToSave() throws PAPException{
if(isPreparedToSave()){
//we have already done this
yamlParams.put(ONAPNAME, policyAdapter.getOnapName());
Map<String, String> params = policyAdapter.getDynamicFieldConfigAttributes();
yamlParams.putAll(params);
- // Call YAML to XACML
- PolicyType decisionPolicy = getGuardPolicy(yamlParams, policyAdapter.getRuleProvider());
- decisionPolicy.setRuleCombiningAlgId(policyAdapter.getRuleCombiningAlgId());
- decisionPolicy.setVersion(Integer.toString(version));
- policyAdapter.setPolicyData(decisionPolicy);
- policyAdapter.setData(decisionPolicy);
+ // Call YAML to XACML
+ try {
+ PolicyType decisionPolicy = getGuardPolicy(yamlParams, policyAdapter.getRuleProvider());
+ decisionPolicy.setRuleCombiningAlgId(policyAdapter.getRuleCombiningAlgId());
+ decisionPolicy.setVersion(Integer.toString(version));
+ policyAdapter.setPolicyData(decisionPolicy);
+ policyAdapter.setData(decisionPolicy);
+ } catch (BuilderException e) {
+ LOGGER.error(e);
+ throw new PAPException(e);
+ }
}else if (policyAdapter.getData() != null) {
PolicyType decisionPolicy = (PolicyType) policyAdapter.getData();
activeTimeRange.put("end", yamlParams.get("guardActiveEnd"));
String blackListString = yamlParams.get("blackList");
List<String> blackList = null;
- if(blackListString!=null){
+ if(blackListString!=null && !blackListString.trim().isEmpty()){
if (blackListString.contains(",")){
blackList = Arrays.asList(blackListString.split(","));
}
templateFile = new File(classLoader.getResource(XACML_BLGUARD_TEMPLATE).getFile());
xacmlTemplatePath = templateFile.toPath();
cons.setActive_time_range(activeTimeRange);
+ if(blackList==null || blackList.isEmpty()){
+ throw new BuilderException("blackList is required");
+ }
cons.setBlacklist(blackList);
break;
default:
// Values for AAF Provider are here for XML Creation.
ConditionType condition = new ConditionType();
ApplyType decisionApply = new ApplyType();
- String selectedFunction = "boolean-equal";
AttributeValueType value1 = new AttributeValueType();
value1.setDataType(BOOLEAN_DATATYPE);
innerDecisionApply.setFunctionId(FUNCTION_BOOLEAN_ONE_AND_ONLY);
innerDecisionApply.getExpression().add(new ObjectFactory().createAttributeDesignator(value2));
- decisionApply.setFunctionId(dropDownMap.get(selectedFunction));
+ decisionApply.setFunctionId(XACML3.ID_FUNCTION_BOOLEAN_EQUAL.stringValue());
decisionApply.getExpression().add(new ObjectFactory().createAttributeValue(value1));
decisionApply.getExpression().add(new ObjectFactory().createApply(innerDecisionApply));
condition.setExpression(new ObjectFactory().createApply(decisionApply));