- // Constants Used in XML Creation
- public static final String CATEGORY_RECIPIENT_SUBJECT = "urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject";
- public static final String CATEGORY_RESOURCE = "urn:oasis:names:tc:xacml:3.0:attribute-category:resource";
- public static final String CATEGORY_ACTION = "urn:oasis:names:tc:xacml:3.0:attribute-category:action";
- public static final String CATEGORY_ACCESS_SUBJECT = "urn:oasis:names:tc:xacml:1.0:subject-category:access-subject";
- public static final String ACTION_ID = "urn:oasis:names:tc:xacml:1.0:action:action-id";
- public static final String SUBJECT_ID = "urn:oasis:names:tc:xacml:1.0:subject:subject-id";
- public static final String RESOURCE_ID = "urn:oasis:names:tc:xacml:1.0:resource:resource-id";
- public static final String FUNTION_INTEGER_ONE_AND_ONLY = "urn:oasis:names:tc:xacml:1.0:function:integer-one-and-only";
- public static final String FUNCTION_STRING_ONE_AND_ONLY = "urn:oasis:names:tc:xacml:1.0:function:string-one-and-only";
- public static final String FUNCTION_BOOLEAN_ONE_AND_ONLY = "urn:oasis:names:tc:xacml:1.0:function:boolean-one-and-only";
- public static final String FUNCTION_STRING_EQUAL = "urn:oasis:names:tc:xacml:1.0:function:string-equal";
- public static final String FUNCTION_STRING_REGEX_MATCH = "org.openecomp.function.regex-match";
- public static final String FUNCTION_STRING_EQUAL_IGNORE = "urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case";
- public static final String INTEGER_DATATYPE = "http://www.w3.org/2001/XMLSchema#integer";
- public static final String BOOLEAN_DATATYPE = "http://www.w3.org/2001/XMLSchema#boolean";
- public static final String STRING_DATATYPE = "http://www.w3.org/2001/XMLSchema#string";
- public static final String URI_DATATYPE = "http://www.w3.org/2001/XMLSchema#anyURI";
- public static final String RULE_VARIABLE = "var:";
- public static final String EMPTY_STRING = "";
- private static final String String = null;
-
- public static String CONFIG_HOME = null;
- public static String ACTION_HOME = null;
- public static String CONFIG_URL = null;
-
- protected Map<String, String> performer = new HashMap<String, String>();
-
- private static String actionHome = null;
- private static String configHome = null;
-
- public PolicyRestAdapter policyAdapter = null;
- String ruleID = "";
-
- public Policy() {
- CONFIG_HOME = getConfigHome();
- ACTION_HOME = getActionHome();
- CONFIG_URL = "$URL";
- performer.put("PDP", "PDPAction");
- performer.put("PEP", "PEPAction");
+ // Constants Used in XML Creation
+ public static final String CATEGORY_RECIPIENT_SUBJECT = "urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject";
+ public static final String CATEGORY_RESOURCE = "urn:oasis:names:tc:xacml:3.0:attribute-category:resource";
+ public static final String CATEGORY_ACTION = "urn:oasis:names:tc:xacml:3.0:attribute-category:action";
+ public static final String CATEGORY_ACCESS_SUBJECT = "urn:oasis:names:tc:xacml:1.0:subject-category:access-subject";
+ public static final String ACTION_ID = "urn:oasis:names:tc:xacml:1.0:action:action-id";
+ public static final String SUBJECT_ID = "urn:oasis:names:tc:xacml:1.0:subject:subject-id";
+ public static final String RESOURCE_ID = "urn:oasis:names:tc:xacml:1.0:resource:resource-id";
+ public static final String FUNTION_INTEGER_ONE_AND_ONLY = "urn:oasis:names:tc:xacml:1.0:function:integer-one-and-only";
+ public static final String FUNCTION_STRING_ONE_AND_ONLY = "urn:oasis:names:tc:xacml:1.0:function:string-one-and-only";
+ public static final String FUNCTION_BOOLEAN_ONE_AND_ONLY = "urn:oasis:names:tc:xacml:1.0:function:boolean-one-and-only";
+ public static final String FUNCTION_STRING_EQUAL = "urn:oasis:names:tc:xacml:1.0:function:string-equal";
+ public static final String FUNCTION_STRING_REGEX_MATCH = "org.openecomp.function.regex-match";
+ public static final String FUNCTION_STRING_EQUAL_IGNORE = "urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case";
+ public static final String INTEGER_DATATYPE = "http://www.w3.org/2001/XMLSchema#integer";
+ public static final String BOOLEAN_DATATYPE = "http://www.w3.org/2001/XMLSchema#boolean";
+ public static final String STRING_DATATYPE = "http://www.w3.org/2001/XMLSchema#string";
+ public static final String URI_DATATYPE = "http://www.w3.org/2001/XMLSchema#anyURI";
+ public static final String RULE_VARIABLE = "var:";
+ public static final String EMPTY_STRING = "";
+ private static final String String = null;
+
+ public static String CONFIG_HOME = null;
+ public static String ACTION_HOME = null;
+ public static String CONFIG_URL = null;
+
+ protected Map<String, String> performer = new HashMap<>();
+
+ private static String actionHome = null;
+ private static String configHome = null;
+
+ public PolicyRestAdapter policyAdapter = null;
+ String ruleID = "";
+
+ public Policy() {
+ CONFIG_HOME = getConfigHome();
+ ACTION_HOME = getActionHome();
+ CONFIG_URL = "$URL";
+ performer.put("PDP", "PDPAction");
+ performer.put("PEP", "PEPAction");
+ }
+
+ //Each policy type seems to either use policyData or data field policy adapter when
+ //getting the xml to save the policy. Instead of keep this hardcoded in the save method,
+ //this method makes it usable outside.
+ /**
+ * Return the data field of the PolicyAdapter that will be used when saving this policy
+ * with the savePolicies method.
+ * @return Either the PolicyAdapter.getData() or PolicyAdapter.getPolicyData()
+ */
+ public abstract Object getCorrectPolicyDataObject();
+ public abstract Map<String, String> savePolicies() throws Exception;
+
+ //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
+ public abstract boolean prepareToSave() throws Exception;
+
+
+ // create match for ecomp and config name
+ protected MatchType createMatch(String key, String value) {
+ MatchType match = new MatchType();
+
+ AttributeValueType attributeValue = new AttributeValueType();
+ attributeValue.setDataType(STRING_DATATYPE);
+ attributeValue.getContent().add(value);
+ match.setAttributeValue(attributeValue);
+ AttributeDesignatorType attributeDesignator = new AttributeDesignatorType();
+ URI uri = null;
+ try {
+ uri = new URI(key);
+ } catch (URISyntaxException e) {
+ LOGGER.error("Exception Occured"+e);