diff options
author | 2024-11-06 11:46:41 +0000 | |
---|---|---|
committer | 2024-11-07 11:33:37 +0000 | |
commit | d101f30f39531b45d568a177cb32e73e07486433 (patch) | |
tree | 52b4d574d16d68056054bd8ecec4d75cfb24baf1 /applications | |
parent | a7577cb59e90ef1c6ba5031b138fb1b45b828f95 (diff) |
Fix references and organize dependencies in xacml-pdp after
splitting policy-endpoints and message-bus
Issue-ID: POLICY-5131
Change-Id: I6181f763f140589f681beb602c56b4290e3fab1a
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'applications')
11 files changed, 466 insertions, 92 deletions
diff --git a/applications/common/pom.xml b/applications/common/pom.xml index c9254911..3b5d31c8 100644 --- a/applications/common/pom.xml +++ b/applications/common/pom.xml @@ -34,28 +34,19 @@ <dependencies> <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>jakarta.xml.bind</groupId> - <artifactId>jakarta.xml.bind-api</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.glassfish.jaxb</groupId> - <artifactId>jaxb-runtime</artifactId> + <groupId>org.onap.policy.common</groupId> + <artifactId>capabilities</artifactId> + <version>${policy.common.version}</version> </dependency> <dependency> - <groupId>com.h2database</groupId> - <artifactId>h2</artifactId> - <scope>test</scope> + <groupId>org.onap.policy.common</groupId> + <artifactId>common-parameters</artifactId> + <version>${policy.common.version}</version> </dependency> <dependency> - <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId> - <artifactId>guard</artifactId> - <version>${policy.models.version}</version> + <groupId>org.onap.policy.common</groupId> + <artifactId>gson</artifactId> + <version>${policy.common.version}</version> </dependency> <dependency> <groupId>org.onap.policy.common</groupId> @@ -74,22 +65,104 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.onap.policy.models</groupId> + <artifactId>policy-models-tosca</artifactId> + <version>${policy.models.version}</version> + </dependency> + <dependency> + <groupId>org.onap.policy.models</groupId> + <artifactId>policy-models-decisions</artifactId> + <version>${policy.models.version}</version> + </dependency> + <dependency> + <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId> + <artifactId>guard</artifactId> + <version>${policy.models.version}</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.models</groupId> + <artifactId>policy-models-examples</artifactId> + <version>${policy.models.version}</version> + <scope>runtime</scope> + </dependency> + <dependency> <groupId>com.att.research.xacml</groupId> <artifactId>xacml-pdp</artifactId> - <version>4.0.0</version> + </dependency> + <dependency> + <groupId>com.att.research.xacml</groupId> + <artifactId>xacml</artifactId> + </dependency> + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>jakarta.persistence</groupId> + <artifactId>jakarta.persistence-api</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>jakarta.ws.rs</groupId> + <artifactId>jakarta.ws.rs-api</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>jakarta.xml.bind</groupId> + <artifactId>jakarta.xml.bind-api</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.glassfish.jaxb</groupId> + <artifactId>jaxb-runtime</artifactId> + <scope>runtime</scope> </dependency> <dependency> <groupId>org.hibernate.orm</groupId> <artifactId>hibernate-core</artifactId> + <scope>runtime</scope> </dependency> <dependency> <groupId>org.glassfish.jersey.inject</groupId> <artifactId>jersey-hk2</artifactId> + <scope>runtime</scope> </dependency> <dependency> - <groupId>org.onap.policy.models</groupId> - <artifactId>policy-models-examples</artifactId> - <version>${policy.models.version}</version> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-junit-jupiter</artifactId> + <scope>test</scope> </dependency> </dependencies> </project> diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java index ee80641c..d25abeca 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2023 Nordix Foundation. + * Modifications Copyright (C) 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory; public class GetOperationOutcomePip extends StdOnapPip { public static final String ISSUER_NAME = "get-operation-outcome"; - private static Logger logger = LoggerFactory.getLogger(GetOperationOutcomePip.class); + private static final Logger logger = LoggerFactory.getLogger(GetOperationOutcomePip.class); public GetOperationOutcomePip() { super(); diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCallerTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCallerTest.java index a5a7b7c1..7350c878 100644 --- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCallerTest.java +++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCallerTest.java @@ -46,9 +46,9 @@ import org.onap.policy.common.endpoints.http.client.HttpClient; import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; import org.onap.policy.common.endpoints.http.server.HttpServletServer; import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; -import org.onap.policy.common.endpoints.parameters.RestClientParameters; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; import org.onap.policy.common.gson.GsonMessageBodyHandler; +import org.onap.policy.common.parameters.rest.RestClientParameters; import org.onap.policy.common.utils.network.NetworkUtil; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslatorTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslatorTest.java index 54c3a1b8..a0a66118 100644 --- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslatorTest.java +++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslatorTest.java @@ -62,9 +62,9 @@ import org.onap.policy.common.endpoints.http.client.HttpClient; import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; import org.onap.policy.common.endpoints.http.server.HttpServletServer; import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; -import org.onap.policy.common.endpoints.parameters.RestClientParameters; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; import org.onap.policy.common.gson.GsonMessageBodyHandler; +import org.onap.policy.common.parameters.rest.RestClientParameters; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardYamlCoder; import org.onap.policy.common.utils.network.NetworkUtil; diff --git a/applications/guard/pom.xml b/applications/guard/pom.xml index 1b3ba522..64bdb359 100644 --- a/applications/guard/pom.xml +++ b/applications/guard/pom.xml @@ -3,14 +3,14 @@ ONAP Policy Engine - XACML PDP ================================================================================ Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - Modifications Copyright (C) 2023 Nordix Foundation. + Modifications Copyright (C) 2023-2024 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. @@ -41,16 +41,92 @@ <version>${project.version}</version> </dependency> <dependency> - <groupId>com.h2database</groupId> - <artifactId>h2</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.onap.policy.xacml-pdp</groupId> <artifactId>xacml-test</artifactId> <version>${project.version}</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.onap.policy.common</groupId> + <artifactId>common-parameters</artifactId> + <version>${policy.common.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.common</groupId> + <artifactId>policy-endpoints</artifactId> + <version>${policy.common.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.common</groupId> + <artifactId>utils</artifactId> + <version>${policy.common.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId> + <artifactId>guard</artifactId> + <version>${policy.models.version}</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.models</groupId> + <artifactId>policy-models-tosca</artifactId> + <version>${policy.models.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.models</groupId> + <artifactId>policy-models-decisions</artifactId> + <version>${policy.models.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.att.research.xacml</groupId> + <artifactId>xacml</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>jakarta.persistence</groupId> + <artifactId>jakarta.persistence-api</artifactId> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>jakarta.xml.bind</groupId> + <artifactId>jakarta.xml.bind-api</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <scope>test</scope> + </dependency> </dependencies> </project> diff --git a/applications/match/pom.xml b/applications/match/pom.xml index 5c8d40e9..0ee90ad2 100644 --- a/applications/match/pom.xml +++ b/applications/match/pom.xml @@ -45,6 +45,45 @@ <version>${project.version}</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.onap.policy.common</groupId> + <artifactId>policy-endpoints</artifactId> + <version>${policy.common.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.common</groupId> + <artifactId>utils</artifactId> + <version>${policy.common.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.models</groupId> + <artifactId>policy-models-decisions</artifactId> + <version>${policy.models.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.models</groupId> + <artifactId>policy-models-tosca</artifactId> + <version>${policy.models.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.att.research.xacml</groupId> + <artifactId>xacml</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <scope>provided</scope> + </dependency> </dependencies> </project> diff --git a/applications/monitoring/pom.xml b/applications/monitoring/pom.xml index beedf1b1..cfdb5896 100644 --- a/applications/monitoring/pom.xml +++ b/applications/monitoring/pom.xml @@ -47,8 +47,39 @@ </dependency> <dependency> <groupId>org.onap.policy.common</groupId> + <artifactId>policy-endpoints</artifactId> + <version>${policy.common.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.common</groupId> <artifactId>utils</artifactId> <version>${policy.common.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.models</groupId> + <artifactId>policy-models-tosca</artifactId> + <version>${policy.models.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.models</groupId> + <artifactId>policy-models-decisions</artifactId> + <version>${policy.models.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.att.research.xacml</groupId> + <artifactId>xacml</artifactId> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> </dependency> </dependencies> diff --git a/applications/naming/pom.xml b/applications/naming/pom.xml index 61fdd2dc..a267d953 100644 --- a/applications/naming/pom.xml +++ b/applications/naming/pom.xml @@ -45,6 +45,45 @@ <version>${project.version}</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.onap.policy.common</groupId> + <artifactId>policy-endpoints</artifactId> + <version>${policy.common.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.common</groupId> + <artifactId>utils</artifactId> + <version>${policy.common.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.models</groupId> + <artifactId>policy-models-decisions</artifactId> + <version>${policy.models.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.models</groupId> + <artifactId>policy-models-tosca</artifactId> + <version>${policy.models.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.att.research.xacml</groupId> + <artifactId>xacml</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <scope>provided</scope> + </dependency> </dependencies> </project> diff --git a/applications/native/pom.xml b/applications/native/pom.xml index fa586d64..b24c0918 100644 --- a/applications/native/pom.xml +++ b/applications/native/pom.xml @@ -1,3 +1,24 @@ +<!-- + ============LICENSE_START======================================================= + ONAP Policy Engine - XACML PDP + ================================================================================ + Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + Modifications Copyright (C) 2023-2024 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. + ============LICENSE_END========================================================= + --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> @@ -24,6 +45,55 @@ <version>${project.version}</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.onap.policy.common</groupId> + <artifactId>common-parameters</artifactId> + <version>${policy.common.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.common</groupId> + <artifactId>policy-endpoints</artifactId> + <version>${policy.common.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.common</groupId> + <artifactId>utils</artifactId> + <version>${policy.common.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.models</groupId> + <artifactId>policy-models-decisions</artifactId> + <version>${policy.models.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.models</groupId> + <artifactId>policy-models-tosca</artifactId> + <version>${policy.models.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.att.research.xacml</groupId> + <artifactId>xacml</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>jakarta.xml.bind</groupId> + <artifactId>jakarta.xml.bind-api</artifactId> + </dependency> + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <scope>provided</scope> + </dependency> </dependencies> </project> diff --git a/applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTranslator.java b/applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTranslator.java index 5e87f226..a7ad4349 100644 --- a/applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTranslator.java +++ b/applications/native/src/main/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTranslator.java @@ -3,7 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2020 Nordix Foundation. + * Modifications Copyright (C) 2020, 2024 Nordix Foundation. * Modifications Copyright (C) 2024 Deutsche Telekom AG. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -73,7 +73,6 @@ import org.slf4j.LoggerFactory; * This class implements one translator that interprets TOSCA policy and decision API request/response payload. * * @author Chenfei Gao (cgao@research.att.com) - * */ @NoArgsConstructor public class NativePdpApplicationTranslator implements ToscaPolicyTranslator { @@ -134,7 +133,7 @@ public class NativePdpApplicationTranslator implements ToscaPolicyTranslator { protected String getNativeXacmlPolicy(ToscaPolicy toscaPolicy) throws ToscaPolicyConversionException { var nativeDefinition = ToscaPolicyTranslatorUtils.decodeProperties(toscaPolicy.getProperties(), - NativeDefinition.class); + NativeDefinition.class); LOGGER.debug("Base64 encoded native xacml policy {}", nativeDefinition.getPolicy()); return nativeDefinition.getPolicy(); @@ -167,13 +166,13 @@ public class NativePdpApplicationTranslator implements ToscaPolicyTranslator { policySetType.setVersion(String.valueOf(toscaPolicy.getMetadata().get("policy-version"))); policySetType.setDescription(String.valueOf(toscaPolicy.getMetadata().get(DESCRIPTION))); policySetType.setTarget(setPolicySetTarget(toscaPolicy.getMetadata().get("action"))); - for (Map<String, Object> type: (List<Map<String, Object>>) toscaPolicy.getProperties().get("policies")) { + for (Map<String, Object> type : (List<Map<String, Object>>) toscaPolicy.getProperties().get("policies")) { ToscaPolicy policy = new ToscaPolicy(); policy.setMetadata((Map<String, Object>) type.get("metadata")); policy.setProperties((Map<String, Object>) type.get("properties")); ObjectFactory objectFactory = new ObjectFactory(); policySetType.getPolicySetOrPolicyOrPolicySetIdReference() - .add(objectFactory.createPolicy(convertPolicyXacml(policy))); + .add(objectFactory.createPolicy(convertPolicyXacml(policy))); } return policySetType; } @@ -228,7 +227,7 @@ public class NativePdpApplicationTranslator implements ToscaPolicyTranslator { Map<String, Object> properties = toscaPolicy.getProperties(); if (properties.get("combiningAlgo") != null) { policyType.setRuleCombiningAlgId(validateFilterPropertyFunction((String) - properties.get("combiningAlgo")).stringValue()); + properties.get("combiningAlgo")).stringValue()); } else { policyType.setRuleCombiningAlgId(XACML3.ID_RULE_FIRST_APPLICABLE.stringValue()); } @@ -240,7 +239,7 @@ public class NativePdpApplicationTranslator implements ToscaPolicyTranslator { } private void setAdviceExpression(RuleType ruleType, Map<String, Object> rule) - throws ToscaPolicyConversionException { + throws ToscaPolicyConversionException { String decision = (String) rule.get("decision"); if ("Deny".equalsIgnoreCase(decision)) { ruleType.setEffect(EffectType.DENY); @@ -275,20 +274,20 @@ public class NativePdpApplicationTranslator implements ToscaPolicyTranslator { String datatype = getDatatype(operator); matchType.setMatchId(validateFilterPropertyFunction(operator).stringValue()); var valueType = setAttributeValueType(match.get(VALUE), - validateFilterPropertyFunction(datatype).stringValue()); + validateFilterPropertyFunction(datatype).stringValue()); matchType.setAttributeValue(valueType); String attribute = ""; String category = ""; if (((String) match.get("key")).contains("action")) { attribute = validateFilterPropertyFunction((String) match - .get("key")).stringValue(); + .get("key")).stringValue(); category = XACML3.ID_ATTRIBUTE_CATEGORY_ACTION.stringValue(); } else { attribute = (String) match.get("key"); category = XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE.stringValue(); } var designator = setAttributeDesignatorType(attribute, category, - validateFilterPropertyFunction(datatype).stringValue(), false); + validateFilterPropertyFunction(datatype).stringValue(), false); matchType.setAttributeDesignator(designator); listMatch.add(matchType); } @@ -310,8 +309,8 @@ public class NativePdpApplicationTranslator implements ToscaPolicyTranslator { var valueType = setAttributeValueType(value, XACML3.ID_DATATYPE_STRING.stringValue()); matchType.setAttributeValue(valueType); var designator = setAttributeDesignatorType(XACML3.ID_ACTION_ACTION_ID.stringValue(), - XACML3.ID_ATTRIBUTE_CATEGORY_ACTION.stringValue(), - XACML3.ID_DATATYPE_STRING.stringValue(), false); + XACML3.ID_ATTRIBUTE_CATEGORY_ACTION.stringValue(), + XACML3.ID_DATATYPE_STRING.stringValue(), false); matchType.setAttributeDesignator(designator); var anyOfType = new AnyOfType(); anyOfType.getAllOf().add(ToscaPolicyTranslatorUtils.buildAllOf(matchType)); @@ -369,7 +368,7 @@ public class NativePdpApplicationTranslator implements ToscaPolicyTranslator { keyList.add(setApply((Map<String, Object>) ((Map<?, ?>) keyObject).get(APPLY))); } else { throw new ToscaPolicyConversionException( - "Invalid key entry, object does not contain list, function or apply"); + "Invalid key entry, object does not contain list, function or apply"); } } else { setAttributes(keyObject, keyList, datatype, factory); @@ -379,37 +378,36 @@ public class NativePdpApplicationTranslator implements ToscaPolicyTranslator { private void setAttributeAndDesignator(List<Object> keyList, ApplyType apply, ObjectFactory factory) { keyList.stream() - .sorted((firstKey, secondKey) -> { - if (firstKey instanceof AttributeValueType) { - return -1; - } else if (firstKey instanceof ApplyType) { - return 1; - } - return 0; - }) - .forEach(key -> { - if (key instanceof AttributeValueType) { - apply.getExpression().add(factory.createAttributeValue((AttributeValueType) key)); - } - if (key instanceof ApplyType) { - apply.getExpression().add(factory.createApply((ApplyType) key)); - } - }); + .sorted((firstKey, secondKey) -> { + if (firstKey instanceof AttributeValueType) { + return -1; + } else if (firstKey instanceof ApplyType) { + return 1; + } + return 0; + }) + .forEach(key -> { + if (key instanceof AttributeValueType) { + apply.getExpression().add(factory.createAttributeValue((AttributeValueType) key)); + } + if (key instanceof ApplyType) { + apply.getExpression().add(factory.createApply((ApplyType) key)); + } + }); } private void setAttributes(Object key, List<Object> keyList, String datatype, ObjectFactory factory) - throws ToscaPolicyConversionException { + throws ToscaPolicyConversionException { try { - if (key instanceof String) { - String value = (String) key; + if (key instanceof String value) { if (value.startsWith("'") && value.endsWith("'")) { AttributeValueType attributeValue = setAttributeValueType(value.substring(1, value.length() - 1), - validateFilterPropertyFunction(datatype).stringValue()); + validateFilterPropertyFunction(datatype).stringValue()); keyList.add(attributeValue); } else { var keyDesignator = setAttributeDesignatorType(value, - XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE.stringValue(), - validateFilterPropertyFunction(datatype).stringValue(), false); + XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE.stringValue(), + validateFilterPropertyFunction(datatype).stringValue(), false); ApplyType keyApply = new ApplyType(); keyApply.setFunctionId(validateFilterPropertyFunction(datatype + ONE_AND_ONLY).stringValue()); keyApply.getExpression().add(factory.createAttributeDesignator(keyDesignator)); @@ -417,7 +415,7 @@ public class NativePdpApplicationTranslator implements ToscaPolicyTranslator { } } else { AttributeValueType attributeValue = setAttributeValueType(key, - validateFilterPropertyFunction(datatype).stringValue()); + validateFilterPropertyFunction(datatype).stringValue()); keyList.add(attributeValue); } } catch (NullPointerException ex) { @@ -426,34 +424,33 @@ public class NativePdpApplicationTranslator implements ToscaPolicyTranslator { } private void setBagApply(ApplyType apply, List<Object> list, String datatype, ObjectFactory factory) - throws ToscaPolicyConversionException { + throws ToscaPolicyConversionException { try { var bagApply = new ApplyType(); bagApply.setFunctionId(validateFilterPropertyFunction(datatype + "-bag").stringValue()); for (Object attribute : list) { if (attribute instanceof String && !(((String) attribute).startsWith("'") - && ((String) attribute).endsWith("'"))) { + && ((String) attribute).endsWith("'"))) { var applyDesignator = new ApplyType(); applyDesignator.setFunctionId( - validateFilterPropertyFunction(datatype + ONE_AND_ONLY).stringValue()); + validateFilterPropertyFunction(datatype + ONE_AND_ONLY).stringValue()); var designator = setAttributeDesignatorType((String) attribute, - XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE.stringValue(), - validateFilterPropertyFunction(datatype).stringValue(), false); + XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE.stringValue(), + validateFilterPropertyFunction(datatype).stringValue(), false); applyDesignator.getExpression().add(factory.createAttributeDesignator(designator)); bagApply.getExpression().add(factory.createApply(applyDesignator)); } } for (Object attribute : list) { - if (attribute instanceof String) { - String value = (String) attribute; + if (attribute instanceof String value) { if (value.startsWith("'") && value.endsWith("'")) { var attributeValue = setAttributeValueType(value.substring(1, value.length() - 1), - validateFilterPropertyFunction(datatype).stringValue()); + validateFilterPropertyFunction(datatype).stringValue()); bagApply.getExpression().add(factory.createAttributeValue(attributeValue)); } } else { var attributeValue = setAttributeValueType(attribute, - validateFilterPropertyFunction(datatype).stringValue()); + validateFilterPropertyFunction(datatype).stringValue()); bagApply.getExpression().add(factory.createAttributeValue(attributeValue)); } } @@ -464,7 +461,7 @@ public class NativePdpApplicationTranslator implements ToscaPolicyTranslator { } private void setFunctionType(ApplyType apply, String function, ObjectFactory factory) - throws ToscaPolicyConversionException { + throws ToscaPolicyConversionException { try { var functionType = new FunctionType(); functionType.setFunctionId(validateFilterPropertyFunction(function).stringValue()); @@ -483,12 +480,12 @@ public class NativePdpApplicationTranslator implements ToscaPolicyTranslator { apply.getExpression().add(factory.createApply(compareApply)); } else if (compareWith.get(VALUE) != null) { var attributeValue = setAttributeValueType(compareWith.get(VALUE), - validateFilterPropertyFunction(datatype).stringValue()); + validateFilterPropertyFunction(datatype).stringValue()); apply.getExpression().add(factory.createAttributeValue(attributeValue)); } else if (compareWith.get("key") != null) { var keyDesignator = setAttributeDesignatorType((String) compareWith.get("key"), - XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE.stringValue(), - validateFilterPropertyFunction(datatype).stringValue(), false); + XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE.stringValue(), + validateFilterPropertyFunction(datatype).stringValue(), false); var keyApply = new ApplyType(); keyApply.setFunctionId(validateFilterPropertyFunction(datatype + ONE_AND_ONLY).stringValue()); keyApply.getExpression().add(factory.createAttributeDesignator(keyDesignator)); @@ -502,7 +499,7 @@ public class NativePdpApplicationTranslator implements ToscaPolicyTranslator { } private AdviceExpressionsType setAdvice(Map<String, Object> advice, String decision) - throws ToscaPolicyConversionException { + throws ToscaPolicyConversionException { var adviceExpressions = new AdviceExpressionsType(); try { var adviceExpression = new AdviceExpressionType(); @@ -554,8 +551,8 @@ public class NativePdpApplicationTranslator implements ToscaPolicyTranslator { return DOUBLE; } List<String> datatypes = Arrays.asList("string", "boolean", "integer", DOUBLE, "time", "date", "dateTime", - "dayTimeDuration", "yearMonthDuration", "anyURI", "hexBinary", "rfc822Name", "base64Binary", - "x500Name", "ipAddress", "dnsName"); + "dayTimeDuration", "yearMonthDuration", "anyURI", "hexBinary", "rfc822Name", "base64Binary", + "x500Name", "ipAddress", "dnsName"); if (datatypes.stream().anyMatch(operator::contains)) { return operator.split("-")[0]; } @@ -590,7 +587,7 @@ public class NativePdpApplicationTranslator implements ToscaPolicyTranslator { identifierMap.put("datetime-add-yearmonthduration", XACML3.ID_FUNCTION_DATETIME_ADD_YEARMONTHDURATION); identifierMap.put("datetime-subtract-daytimeturation", XACML3.ID_FUNCTION_DATETIME_SUBTRACT_DAYTIMEDURATION); identifierMap.put("datetime-subtract-yearmonthduration", - XACML3.ID_FUNCTION_DATETIME_SUBTRACT_YEARMONTHDURATION); + XACML3.ID_FUNCTION_DATETIME_SUBTRACT_YEARMONTHDURATION); identifierMap.put("date-add-yearmonthduration", XACML3.ID_FUNCTION_DATE_ADD_YEARMONTHDURATION); identifierMap.put("date-subtract-yearmonthduration", XACML3.ID_FUNCTION_DATE_SUBTRACT_YEARMONTHDURATION); identifierMap.put("time-greater-than", XACML3.ID_FUNCTION_TIME_GREATER_THAN); @@ -777,19 +774,19 @@ public class NativePdpApplicationTranslator implements ToscaPolicyTranslator { identifierMap.put("hexbinary-set-equals", XACML3.ID_FUNCTION_HEXBINARY_SET_EQUALS); identifierMap.put("base64binary-intersection", XACML3.ID_FUNCTION_BASE64BINARY_INTERSECTION); identifierMap.put("base64binary-at-least-one-member-of", - XACML3.ID_FUNCTION_BASE64BINARY_AT_LEAST_ONE_MEMBER_OF); + XACML3.ID_FUNCTION_BASE64BINARY_AT_LEAST_ONE_MEMBER_OF); identifierMap.put("base64binary-union", XACML3.ID_FUNCTION_BASE64BINARY_UNION); identifierMap.put("base64binary-subset", XACML3.ID_FUNCTION_BASE64BINARY_SUBSET); identifierMap.put("base64binary-set-equals", XACML3.ID_FUNCTION_BASE64BINARY_SET_EQUALS); identifierMap.put("daytimeduration-intersection", XACML3.ID_FUNCTION_DAYTIMEDURATION_INTERSECTION); identifierMap.put("daytimeduration-at-least-one-member-of", - XACML3.ID_FUNCTION_DAYTIMEDURATION_AT_LEAST_ONE_MEMBER_OF); + XACML3.ID_FUNCTION_DAYTIMEDURATION_AT_LEAST_ONE_MEMBER_OF); identifierMap.put("daytimeduration-union", XACML3.ID_FUNCTION_DAYTIMEDURATION_UNION); identifierMap.put("daytimeduration-subset", XACML3.ID_FUNCTION_DAYTIMEDURATION_SUBSET); identifierMap.put("daytimeduration-set-equals", XACML3.ID_FUNCTION_DAYTIMEDURATION_SET_EQUALS); identifierMap.put("yearmonthduration-intersection", XACML3.ID_FUNCTION_YEARMONTHDURATION_INTERSECTION); identifierMap.put("yearmonthduration-at-least-one-member-of", - XACML3.ID_FUNCTION_YEARMONTHDURATION_AT_LEAST_ONE_MEMBER_OF); + XACML3.ID_FUNCTION_YEARMONTHDURATION_AT_LEAST_ONE_MEMBER_OF); identifierMap.put("yearmonthduration-union", XACML3.ID_FUNCTION_YEARMONTHDURATION_UNION); identifierMap.put("yearmonthduration-subset", XACML3.ID_FUNCTION_YEARMONTHDURATION_SUBSET); identifierMap.put("yearmonthduration-set-equals", XACML3.ID_FUNCTION_YEARMONTHDURATION_SET_EQUALS); diff --git a/applications/optimization/pom.xml b/applications/optimization/pom.xml index cfb7d931..690ea7e1 100644 --- a/applications/optimization/pom.xml +++ b/applications/optimization/pom.xml @@ -8,9 +8,9 @@ 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. @@ -45,6 +45,55 @@ <version>${project.version}</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.onap.policy.common</groupId> + <artifactId>policy-endpoints</artifactId> + <version>${policy.common.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.common</groupId> + <artifactId>utils</artifactId> + <version>${policy.common.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.models</groupId> + <artifactId>policy-models-decisions</artifactId> + <version>${policy.models.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.models</groupId> + <artifactId>policy-models-tosca</artifactId> + <version>${policy.models.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.att.research.xacml</groupId> + <artifactId>xacml</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>jakarta.xml.bind</groupId> + <artifactId>jakarta.xml.bind-api</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <scope>provided</scope> + </dependency> </dependencies> </project> |