summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
d7176dd)
Issue-ID: POLICY-2188
Change-Id: I64a115240a71e5014db9cfb66747887e156afb50
Signed-off-by: Taka Cho <takamune.cho@att.com>
17 files changed:
import com.att.research.xacml.api.Identifier;
import com.att.research.xacml.util.XACMLPolicyWriter;
import com.att.research.xacml.util.XACMLProperties;
import com.att.research.xacml.api.Identifier;
import com.att.research.xacml.util.XACMLPolicyWriter;
import com.att.research.xacml.util.XACMLProperties;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Set;
import java.util.StringJoiner;
import java.util.stream.Collectors;
import java.util.Set;
import java.util.StringJoiner;
import java.util.stream.Collectors;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.IdReferenceType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObjectFactory;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicySetType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.IdReferenceType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObjectFactory;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicySetType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 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.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
@Getter
import org.onap.policy.models.decisions.concepts.DecisionRequest;
@Getter
// contain potential matchables
//
if (propertyValue instanceof List) {
// contain potential matchables
//
if (propertyValue instanceof List) {
- for (Object listValue : ((List<?>)propertyValue)) {
+ for (Object listValue : ((List<?>) propertyValue)) {
if (listValue instanceof Map) {
fillTargetTypeWithMatchables(target, matchablePolicyType, (Map<String, Object>) listValue);
}
if (listValue instanceof Map) {
fillTargetTypeWithMatchables(target, matchablePolicyType, (Map<String, Object>) listValue);
}
import com.att.research.xacml.std.pip.StdMutablePIPResponse;
import com.att.research.xacml.std.pip.StdPIPRequest;
import com.att.research.xacml.std.pip.engines.StdConfigurableEngine;
import com.att.research.xacml.std.pip.StdMutablePIPResponse;
import com.att.research.xacml.std.pip.StdPIPRequest;
import com.att.research.xacml.std.pip.engines.StdConfigurableEngine;
import java.math.BigInteger;
import java.util.Base64;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Properties;
import java.math.BigInteger;
import java.util.Base64;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Properties;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import org.onap.policy.pdp.xacml.application.common.ToscaDictionary;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import org.onap.policy.pdp.xacml.application.common.ToscaDictionary;
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 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.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
import org.junit.Test;
public class ToscaDictionaryTest {
import org.junit.Test;
public class ToscaDictionaryTest {
import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.RuleType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.RuleType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
// contain potential matchables
//
if (propertyValue instanceof List) {
// contain potential matchables
//
if (propertyValue instanceof List) {
- for (Object listValue : ((List<?>)propertyValue)) {
+ for (Object listValue : ((List<?>) propertyValue)) {
if (listValue instanceof Map) {
generateTargetType(target, matchablePolicyType, (Map<String, Object>) listValue);
}
if (listValue instanceof Map) {
generateTargetType(target, matchablePolicyType, (Map<String, Object>) listValue);
}
* ============LICENSE_START=======================================================
* guard
* ================================================================================
* ============LICENSE_START=======================================================
* guard
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 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.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.io.Serializable;
import java.util.List;
import java.io.Serializable;
import java.util.List;
import lombok.Data;
@Data
import lombok.Data;
@Data
import com.att.research.xacml.api.Request;
import com.att.research.xacml.api.Response;
import com.att.research.xacml.util.XACMLPolicyScanner;
import com.att.research.xacml.api.Request;
import com.att.research.xacml.api.Response;
import com.att.research.xacml.util.XACMLPolicyScanner;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslator;
import org.onap.policy.pdp.xacml.application.common.std.StdXacmlApplicationServiceProvider;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslator;
import org.onap.policy.pdp.xacml.application.common.std.StdXacmlApplicationServiceProvider;
@Override
protected ToscaPolicyTranslator getTranslator(String type) {
LOGGER.debug("Policy type {}", type);
@Override
protected ToscaPolicyTranslator getTranslator(String type) {
LOGGER.debug("Policy type {}", type);
- if ( type.contains("coordination") ) {
+ if (type.contains("coordination")) {
LOGGER.debug("returning coordinationTranslator");
return coordinationTranslator;
} else {
LOGGER.debug("returning coordinationTranslator");
return coordinationTranslator;
} else {
import com.att.research.xacml.std.annotations.XACMLRequest;
import com.att.research.xacml.std.annotations.XACMLResource;
import com.att.research.xacml.std.annotations.XACMLSubject;
import com.att.research.xacml.std.annotations.XACMLRequest;
import com.att.research.xacml.std.annotations.XACMLResource;
import com.att.research.xacml.std.annotations.XACMLSubject;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyConversionException;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyConversionException;
if (! (rule instanceof RuleType)) {
continue;
}
if (! (rule instanceof RuleType)) {
continue;
}
- assertThat(((RuleType)rule).getCondition()).isNotNull();
- assertThat(((RuleType)rule).getCondition().getExpression()).isNotNull();
+ assertThat(((RuleType) rule).getCondition()).isNotNull();
+ assertThat(((RuleType) rule).getCondition().getExpression()).isNotNull();
if (! (rule instanceof RuleType)) {
continue;
}
if (! (rule instanceof RuleType)) {
continue;
}
- for (AnyOfType anyOf : ((RuleType)rule).getTarget().getAnyOf()) {
+ for (AnyOfType anyOf : ((RuleType) rule).getTarget().getAnyOf()) {
assertThat(anyOf.getAllOf()).isNotEmpty();
for (AllOfType allOf : anyOf.getAllOf()) {
assertThat(allOf.getMatch()).isNotEmpty();
assertThat(anyOf.getAllOf()).isNotEmpty();
for (AllOfType allOf : anyOf.getAllOf()) {
assertThat(allOf.getMatch()).isNotEmpty();
}
assertThat(((RuleType) rule).getTarget()).isNotNull();
assertThat(((RuleType) rule).getTarget().getAnyOf()).hasSize(1);
}
assertThat(((RuleType) rule).getTarget()).isNotNull();
assertThat(((RuleType) rule).getTarget().getAnyOf()).hasSize(1);
- for (AnyOfType anyOf : ((RuleType)rule).getTarget().getAnyOf()) {
+ for (AnyOfType anyOf : ((RuleType) rule).getTarget().getAnyOf()) {
assertThat(anyOf.getAllOf()).isNotEmpty();
for (AllOfType allOf : anyOf.getAllOf()) {
assertThat(allOf.getMatch()).isNotEmpty();
assertThat(anyOf.getAllOf()).isNotEmpty();
for (AllOfType allOf : anyOf.getAllOf()) {
assertThat(allOf.getMatch()).isNotEmpty();
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 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.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import com.att.research.xacml.std.annotations.XACMLRequest;
import com.att.research.xacml.std.annotations.XACMLResource;
import com.att.research.xacml.std.annotations.XACMLSubject;
import com.att.research.xacml.std.annotations.XACMLRequest;
import com.att.research.xacml.std.annotations.XACMLResource;
import com.att.research.xacml.std.annotations.XACMLSubject;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import org.junit.ClassRule;
import org.junit.rules.TemporaryFolder;
import org.junit.ClassRule;
import org.junit.rules.TemporaryFolder;
}).doesNotThrowAnyException();
*/
}
}).doesNotThrowAnyException();
*/
}
-}
\ No newline at end of file
//
// Add US to the geography list
//
//
// Add US to the geography list
//
- ((List<String>)baseRequest.getResource().get("geography")).add("US");
+ ((List<String>) baseRequest.getResource().get("geography")).add("US");
//
// Ask for a decision for default US Policy
//
//
// Ask for a decision for default US Policy
//
//
// Add vCPE to the service list
//
//
// Add vCPE to the service list
//
- ((List<String>)baseRequest.getResource().get("services")).add("vCPE");
+ ((List<String>) baseRequest.getResource().get("services")).add("vCPE");
//
// Ask for a decision for default US policy for vCPE service
//
//
// Ask for a decision for default US policy for vCPE service
//
//
// Add vG to the resource list
//
//
// Add vG to the resource list
//
- ((List<String>)baseRequest.getResource().get("resources")).add("vG");
+ ((List<String>) baseRequest.getResource().get("resources")).add("vG");
//
// Ask for a decision for default US service vCPE resource vG policy
//
//
// Ask for a decision for default US service vCPE resource vG policy
//
//
// Add gold as a scope
//
//
// Add gold as a scope
//
- ((List<String>)baseRequest.getContext().get("subscriberName")).add("subscriber_a");
+ ((List<String>) baseRequest.getContext().get("subscriberName")).add("subscriber_a");
//
// Ask for a decision for specific US vCPE vG gold
//
//
// Ask for a decision for specific US vCPE vG gold
//
//
// Add platinum to the scope list: this is now gold OR platinum
//
//
// Add platinum to the scope list: this is now gold OR platinum
//
- ((List<String>)baseRequest.getResource().get("scope")).remove("gold");
- ((List<String>)baseRequest.getContext().get("subscriberName")).add("subscriber_x");
+ ((List<String>) baseRequest.getResource().get("scope")).remove("gold");
+ ((List<String>) baseRequest.getContext().get("subscriberName")).add("subscriber_x");
//
// Ask for a decision for specific US vCPE vG (gold or platinum)
//
//
// Ask for a decision for specific US vCPE vG (gold or platinum)
//
//
// Add gold as a scope
//
//
// Add gold as a scope
//
- ((List<String>)baseRequest.getResource().get("scope")).remove("gold");
- ((List<String>)baseRequest.getResource().get("scope")).remove("platinum");
- ((List<String>)baseRequest.getContext().get("subscriberName")).remove("subscriber_a");
+ ((List<String>) baseRequest.getResource().get("scope")).remove("gold");
+ ((List<String>) baseRequest.getResource().get("scope")).remove("platinum");
+ ((List<String>) baseRequest.getContext().get("subscriberName")).remove("subscriber_a");
//
// Ask for a decision for specific US vCPE vG gold
//
//
// Ask for a decision for specific US vCPE vG gold
//
@SuppressWarnings("unchecked")
private void cleanOutResources() {
@SuppressWarnings("unchecked")
private void cleanOutResources() {
- ((List<String>)baseRequest.getResource().get("scope")).clear();
- ((List<String>)baseRequest.getResource().get("services")).clear();
- ((List<String>)baseRequest.getResource().get("resources")).clear();
- ((List<String>)baseRequest.getResource().get("geography")).clear();
- if (((List<String>)baseRequest.getResource().get("policy-type")) != null) {
+ ((List<String>) baseRequest.getResource().get("scope")).clear();
+ ((List<String>) baseRequest.getResource().get("services")).clear();
+ ((List<String>) baseRequest.getResource().get("resources")).clear();
+ ((List<String>) baseRequest.getResource().get("geography")).clear();
+ if (((List<String>) baseRequest.getResource().get("policy-type")) != null) {
baseRequest.getResource().remove("policy-type");
}
}
baseRequest.getResource().remove("policy-type");
}
}
@ResponseHeader(name = "X-ONAP-RequestID",
description = "Used to track REST transactions for logging purpose",
response = UUID.class)},
@ResponseHeader(name = "X-ONAP-RequestID",
description = "Used to track REST transactions for logging purpose",
response = UUID.class)},
- authorizations = @Authorization(value = "basicAuth"), tags = {"HealthCheck",},
+ authorizations = @Authorization(value = "basicAuth"), tags = {"HealthCheck", },
extensions = {@Extension(name = "interface info",
properties = {@ExtensionProperty(name = "pdpx-version", value = "1.0.0"),
@ExtensionProperty(name = "last-mod-release", value = "Dublin")})})
extensions = {@Extension(name = "interface info",
properties = {@ExtensionProperty(name = "pdpx-version", value = "1.0.0"),
@ExtensionProperty(name = "last-mod-release", value = "Dublin")})})
@ResponseHeader(name = "X-ONAP-RequestID",
description = "Used to track REST transactions for logging purpose",
response = UUID.class)},
@ResponseHeader(name = "X-ONAP-RequestID",
description = "Used to track REST transactions for logging purpose",
response = UUID.class)},
- authorizations = @Authorization(value = "basicAuth"), tags = {"Statistics",},
+ authorizations = @Authorization(value = "basicAuth"), tags = {"Statistics", },
extensions = {@Extension(name = "interface info",
properties = {@ExtensionProperty(name = "pdpx-version", value = "1.0.0"),
@ExtensionProperty(name = "last-mod-release", value = "Dublin")})})
extensions = {@Extension(name = "interface info",
properties = {@ExtensionProperty(name = "pdpx-version", value = "1.0.0"),
@ExtensionProperty(name = "last-mod-release", value = "Dublin")})})
@ResponseHeader(name = "X-ONAP-RequestID",
description = "Used to track REST transactions for logging purpose",
response = UUID.class)},
@ResponseHeader(name = "X-ONAP-RequestID",
description = "Used to track REST transactions for logging purpose",
response = UUID.class)},
- authorizations = @Authorization(value = "basicAuth"), tags = {"Decision",},
+ authorizations = @Authorization(value = "basicAuth"), tags = {"Decision", },
extensions = {@Extension(name = "interface info",
properties = {@ExtensionProperty(name = "pdpx-version", value = "1.0.0"),
@ExtensionProperty(name = "last-mod-release", value = "Dublin")})})
extensions = {@Extension(name = "interface info",
properties = {@ExtensionProperty(name = "pdpx-version", value = "1.0.0"),
@ExtensionProperty(name = "last-mod-release", value = "Dublin")})})
@ResponseHeader(name = "X-ONAP-RequestID",
description = "Used to track REST transactions for logging purpose",
response = UUID.class)},
@ResponseHeader(name = "X-ONAP-RequestID",
description = "Used to track REST transactions for logging purpose",
response = UUID.class)},
- authorizations = @Authorization(value = "basicAuth"), tags = {"Decision",},
+ authorizations = @Authorization(value = "basicAuth"), tags = {"Decision", },
extensions = {@Extension(name = "interface info",
properties = {@ExtensionProperty(name = "pdpx-version", value = "1.0.0"),
@ExtensionProperty(name = "last-mod-release", value = "Frankfurt")})})
extensions = {@Extension(name = "interface info",
properties = {@ExtensionProperty(name = "pdpx-version", value = "1.0.0"),
@ExtensionProperty(name = "last-mod-release", value = "Frankfurt")})})
// create a plain listener to test the "real" makeTimer() method
publisher = new XacmlPdpHearbeatPublisher(client, state);
// create a plain listener to test the "real" makeTimer() method
publisher = new XacmlPdpHearbeatPublisher(client, state);
- assertThatCode( () -> {
publisher.start();
publisher.restart(100L);
publisher.terminate();
publisher.start();
publisher.restart(100L);
publisher.terminate();
/*-
* ============LICENSE_START=======================================================
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 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.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import com.openpojo.validation.rule.impl.SetterMustExistRule;
import com.openpojo.validation.test.impl.GetterTester;
import com.openpojo.validation.test.impl.SetterTester;
import com.openpojo.validation.rule.impl.SetterMustExistRule;
import com.openpojo.validation.test.impl.GetterTester;
import com.openpojo.validation.test.impl.SetterTester;
import org.junit.Test;
import org.onap.policy.common.utils.test.ToStringTester;
import org.onap.policy.pdpx.main.rest.model.StatisticsReport;
import org.junit.Test;
import org.onap.policy.common.utils.test.ToStringTester;
import org.onap.policy.pdpx.main.rest.model.StatisticsReport;