diff options
Diffstat (limited to 'applications/monitoring/src')
4 files changed, 21 insertions, 50 deletions
diff --git a/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplication.java b/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplication.java index d4ffb487..0c928b8c 100644 --- a/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplication.java +++ b/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplication.java @@ -27,7 +27,6 @@ import com.att.research.xacml.api.Response; import com.att.research.xacml.util.XACMLPolicyScanner; import com.att.research.xacml.util.XACMLPolicyWriter; import com.att.research.xacml.util.XACMLProperties; -import com.google.common.collect.Lists; import java.io.ByteArrayOutputStream; import java.io.FileInputStream; @@ -35,8 +34,8 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; @@ -47,6 +46,7 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType; import org.onap.policy.models.decisions.concepts.DecisionRequest; import org.onap.policy.models.decisions.concepts.DecisionResponse; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier; import org.onap.policy.pdp.xacml.application.common.ToscaPolicyConversionException; import org.onap.policy.pdp.xacml.application.common.XacmlPolicyUtils; import org.onap.policy.pdp.xacml.application.common.std.StdCombinedPolicyResultsTranslator; @@ -70,7 +70,7 @@ public class MonitoringPdpApplication extends StdXacmlApplicationServiceProvider private static final String ONAP_MONITORING_DERIVED_POLICY_TYPE = "onap.policies.monitoring"; private StdCombinedPolicyResultsTranslator translator = new StdCombinedPolicyResultsTranslator(); - private Map<String, String> supportedPolicyTypes = new HashMap<>(); + private List<ToscaPolicyTypeIdentifier> supportedPolicyTypes = new ArrayList<>(); /** * Constructor. @@ -79,12 +79,12 @@ public class MonitoringPdpApplication extends StdXacmlApplicationServiceProvider // // By default this supports just Monitoring policy types // - supportedPolicyTypes.put(ONAP_MONITORING_BASE_POLICY_TYPE, "1.0.0"); + supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(ONAP_MONITORING_BASE_POLICY_TYPE, "1.0.0")); } @Override public String applicationName() { - return "Monitoring Application"; + return "monitoring"; } @Override @@ -93,19 +93,19 @@ public class MonitoringPdpApplication extends StdXacmlApplicationServiceProvider } @Override - public synchronized List<String> supportedPolicyTypes() { - return Lists.newArrayList(supportedPolicyTypes.keySet()); + public synchronized List<ToscaPolicyTypeIdentifier> supportedPolicyTypes() { + return supportedPolicyTypes; } @Override - public boolean canSupportPolicyType(String policyType, String policyTypeVersion) { + public boolean canSupportPolicyType(ToscaPolicyTypeIdentifier policyTypeId) { // // For Monitoring, we will attempt to support all versions // of the policy type. Since we are only packaging a decision // back with a JSON payload of the property contents. // - return (policyType.equals(ONAP_MONITORING_BASE_POLICY_TYPE) - || policyType.startsWith(ONAP_MONITORING_DERIVED_POLICY_TYPE)); + return (policyTypeId.getName().equals(ONAP_MONITORING_BASE_POLICY_TYPE) + || policyTypeId.getName().startsWith(ONAP_MONITORING_DERIVED_POLICY_TYPE)); } @Override diff --git a/applications/monitoring/src/main/resources/RootMonitoringPolicy.xml b/applications/monitoring/src/main/resources/RootMonitoringPolicy.xml deleted file mode 100644 index 5578fda9..00000000 --- a/applications/monitoring/src/main/resources/RootMonitoringPolicy.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<PolicySet xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" PolicyCombiningAlgId="urn:com:att:xacml:3.0:policy-combining-algorithm:combined-deny-overrides" PolicySetId="urn:org:onap:monitoring:policy:id" Version="1.0" xsi:schemaLocation="urn:oasis:names:tc:xacml:3.0:policy:schema:os access_control-xacml-2.0-policy-schema-os.xsd"> - <Description>The root policy for supporting in-memory onap.Monitoring policy-type policies.</Description> - <Target> - <AnyOf> - <AllOf> - <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal"> - <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DCAE</AttributeValue> - <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/> - </Match> - <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case"> - <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">configure</AttributeValue> - <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" MustBePresent="false"/> - </Match> - </AllOf> - </AnyOf> - </Target> - <!-- - - New Policies created from TOSCA policies can be stored like this. - - <PolicyIdReference>onap.scaleout.tca</PolicyIdReference> - <PolicySetIdReference>urn:oasis:names:tc:xacml:2.0:conformance-test:IIE001:policyset1</PolicySetIdReference> - --> - <Policy PolicyId="default" Version="1.0" RuleCombiningAlgId="urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-unless-deny" > - <Description>Default is to allow a permit - returning 0 obligations</Description> - <Target/> - <Rule RuleId="default" Effect="Permit"> - <Target/> - </Rule> - </Policy> -</PolicySet>
\ No newline at end of file diff --git a/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java b/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java index 4af4bac4..8099ffdd 100644 --- a/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java +++ b/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java @@ -46,6 +46,8 @@ import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.resources.TextFileUtils; import org.onap.policy.models.decisions.concepts.DecisionRequest; import org.onap.policy.models.decisions.concepts.DecisionResponse; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier; +import org.onap.policy.pdp.xacml.application.common.XacmlApplicationException; import org.onap.policy.pdp.xacml.application.common.XacmlApplicationServiceProvider; import org.onap.policy.pdp.xacml.application.common.XacmlPolicyUtils; import org.slf4j.Logger; @@ -131,11 +133,11 @@ public class MonitoringPdpApplicationTest { // Ensure it has the supported policy types and // can support the correct policy types. // - assertThat(service.canSupportPolicyType("onap.Monitoring", "1.0.0")).isTrue(); - assertThat(service.canSupportPolicyType("onap.Monitoring", "1.5.0")).isTrue(); - assertThat(service.canSupportPolicyType("onap.policies.monitoring.foobar", "1.0.1")).isTrue(); - assertThat(service.canSupportPolicyType("onap.foobar", "1.0.0")).isFalse(); - assertThat(service.supportedPolicyTypes()).contains("onap.Monitoring"); + assertThat(service.canSupportPolicyType(new ToscaPolicyTypeIdentifier("onap.Monitoring", "1.0.0"))).isTrue(); + assertThat(service.canSupportPolicyType(new ToscaPolicyTypeIdentifier("onap.Monitoring", "1.5.0"))).isTrue(); + assertThat(service.canSupportPolicyType(new ToscaPolicyTypeIdentifier( + "onap.policies.monitoring.foobar", "1.0.1"))).isTrue(); + assertThat(service.canSupportPolicyType(new ToscaPolicyTypeIdentifier("onap.foobar", "1.0.0"))).isFalse(); // // Ensure it supports decisions // @@ -156,7 +158,7 @@ public class MonitoringPdpApplicationTest { @SuppressWarnings("unchecked") @Test - public void test3AddvDnsPolicy() throws IOException, CoderException { + public void test3AddvDnsPolicy() throws IOException, CoderException, XacmlApplicationException { // // Now load the vDNS Policy - make sure // the pdp can support it and have it load @@ -185,8 +187,9 @@ public class MonitoringPdpApplicationTest { // assertThat(policyDefinition.containsKey("type")).isTrue(); assertThat(service.canSupportPolicyType( + new ToscaPolicyTypeIdentifier( policyDefinition.get("type").toString(), - policyDefinition.get("version").toString())) + policyDefinition.get("version").toString()))) .isTrue(); } } diff --git a/applications/monitoring/src/test/resources/xacml.properties b/applications/monitoring/src/test/resources/xacml.properties index 56a92d69..36eac3cd 100644 --- a/applications/monitoring/src/test/resources/xacml.properties +++ b/applications/monitoring/src/test/resources/xacml.properties @@ -22,5 +22,5 @@ xacml.att.policyFinderFactory=org.onap.policy.pdp.xacml.application.common.OnapP # Policies to load # xacml.rootPolicies=monitoring -monitoring.file=src/main/resources/RootMonitoringPolicy.xml +monitoring.file=../../packages/policy-xacmlpdp-tarball/src/main/resources/apps/monitoring/RootMonitoringPolicy.xml |