summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--common-parameters/src/main/java/org/onap/policy/common/parameters/GroupMapValidationResult.java2
-rw-r--r--common-parameters/src/main/java/org/onap/policy/common/parameters/GroupValidationResult.java4
-rw-r--r--common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Invalid.txt9
-rw-r--r--common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Observation.txt7
-rw-r--r--common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Warning.txt9
-rw-r--r--common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Invalid.txt16
-rw-r--r--common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Observation.txt14
-rw-r--r--common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Warning.txt16
-rw-r--r--policy-endpoints/pom.xml8
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java3
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java119
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java55
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSinkFactory.java13
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceFactory.java21
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java201
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java88
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBase.java29
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParams.java316
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSink.java26
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSink.java97
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSink.java41
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java37
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java133
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSource.java39
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java32
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactory.java62
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java11
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java76
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java107
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java77
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java11
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestFilter.java41
-rw-r--r--policy-endpoints/src/test/resources/keystore-testbin0 -> 3895 bytes
34 files changed, 1189 insertions, 534 deletions
diff --git a/.gitignore b/.gitignore
index ae515bd8..13d4a1eb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,9 @@
target
bin
.metadata/
+.idea/
+**/*.iml
+*/logs/
integrity-audit/sql/generatedCreateIA.ddl
integrity-audit/sql/generatedDropIA.ddl
integrity-audit/sql/iaTest.mv.db
diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/GroupMapValidationResult.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/GroupMapValidationResult.java
index 09cdc1de..e607ff98 100644
--- a/common-parameters/src/main/java/org/onap/policy/common/parameters/GroupMapValidationResult.java
+++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/GroupMapValidationResult.java
@@ -122,7 +122,7 @@ public class GroupMapValidationResult implements ValidationResult {
// Set the status of the parameter group and replace the field result
validationResultMap.put(entryName, mapEntryValidationResult);
- this.setResult(status);
+ this.setResult(mapEntryValidationResult.getStatus());
}
/**
diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/GroupValidationResult.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/GroupValidationResult.java
index 703de927..ac9dc7ba 100644
--- a/common-parameters/src/main/java/org/onap/policy/common/parameters/GroupValidationResult.java
+++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/GroupValidationResult.java
@@ -255,7 +255,7 @@ public class GroupValidationResult implements ValidationResult {
// Set the status of the parameter group and replace the field result
validationResultMap.put(parameterName, nestedValidationResult);
- this.setResult(status);
+ this.setResult(nestedValidationResult.getStatus());
}
/**
@@ -280,7 +280,7 @@ public class GroupValidationResult implements ValidationResult {
// Set the status of the parameter group and the field
groupMapValidationResult.setResult(key, nestedMapValidationResult);
- this.setResult(status);
+ this.setResult(nestedMapValidationResult.getStatus());
}
/**
diff --git a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Invalid.txt b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Invalid.txt
index cec8f208..0dec4a61 100644
--- a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Invalid.txt
+++ b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Invalid.txt
@@ -6,4 +6,11 @@ parameter group "l0Parameters" type "org.onap.policy.common.parameters.testclass
field "l10StringField" type "java.lang.String" value "" INVALID, l10StringField must be a non-blank string
parameter group "l00LGenericNested" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" INVALID, parameter group has status INVALID
field "lgenericIntField" type "int" value "-1" INVALID, lgenericIntField must be a positive integer
- field "lgenericStringField" type "java.lang.String" value "" INVALID, lgenericStringField must be a non-blank string \ No newline at end of file
+ field "lgenericStringField" type "java.lang.String" value "" INVALID, lgenericStringField must be a non-blank string
+ parameter group map "l00LGenericNestedMap" INVALID, parameter group has status INVALID
+ parameter group "l00LGenericNestedMapVal0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" INVALID, parameter group has status INVALID
+ field "lgenericIntField" type "int" value "-1" INVALID, lgenericIntField must be a positive integer
+ field "lgenericStringField" type "java.lang.String" value "" INVALID, lgenericStringField must be a non-blank string
+ parameter group "l00LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" INVALID, parameter group has status INVALID
+ field "lgenericIntField" type "int" value "-1" INVALID, lgenericIntField must be a positive integer
+ field "lgenericStringField" type "java.lang.String" value "" INVALID, lgenericStringField must be a non-blank string \ No newline at end of file
diff --git a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Observation.txt b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Observation.txt
index 45402033..e0e78ccb 100644
--- a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Observation.txt
+++ b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Observation.txt
@@ -7,3 +7,10 @@ parameter group "l0Parameters" type "org.onap.policy.common.parameters.testclass
parameter group "l00LGenericNested" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" OBSERVATION, parameter group has status OBSERVATION
field "lgenericIntField" type "int" value "2" OBSERVATION, this field has been set to 2
field "lgenericStringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful
+ parameter group map "l00LGenericNestedMap" OBSERVATION, parameter group has status OBSERVATION
+ parameter group "l00LGenericNestedMapVal0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" OBSERVATION, parameter group has status OBSERVATION
+ field "lgenericIntField" type "int" value "2" OBSERVATION, this field has been set to 2
+ field "lgenericStringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful
+ parameter group "l00LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" OBSERVATION, parameter group has status OBSERVATION
+ field "lgenericIntField" type "int" value "2" OBSERVATION, this field has been set to 2
+ field "lgenericStringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful
diff --git a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Warning.txt b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Warning.txt
index 33d1d16a..d03ecdf5 100644
--- a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Warning.txt
+++ b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_2_Warning.txt
@@ -6,4 +6,11 @@ parameter group "l0Parameters" type "org.onap.policy.common.parameters.testclass
field "l10StringField" type "java.lang.String" value "l10StringField" WARNING, using the field name for the parameter value is dangerous
parameter group "l00LGenericNested" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" WARNING, parameter group has status WARNING
field "lgenericIntField" type "int" value "3" WARNING, values greater than 2 are not recommended
- field "lgenericStringField" type "java.lang.String" value "lgenericStringField" WARNING, using the field name for the parameter value is dangerous \ No newline at end of file
+ field "lgenericStringField" type "java.lang.String" value "lgenericStringField" WARNING, using the field name for the parameter value is dangerous
+ parameter group map "l00LGenericNestedMap" WARNING, parameter group has status WARNING
+ parameter group "l00LGenericNestedMapVal0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" WARNING, parameter group has status WARNING
+ field "lgenericIntField" type "int" value "3" WARNING, values greater than 2 are not recommended
+ field "lgenericStringField" type "java.lang.String" value "lgenericStringField" WARNING, using the field name for the parameter value is dangerous
+ parameter group "l00LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" WARNING, parameter group has status WARNING
+ field "lgenericIntField" type "int" value "3" WARNING, values greater than 2 are not recommended
+ field "lgenericStringField" type "java.lang.String" value "lgenericStringField" WARNING, using the field name for the parameter value is dangerous \ No newline at end of file
diff --git a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Invalid.txt b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Invalid.txt
index fecfe70d..762ef46c 100644
--- a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Invalid.txt
+++ b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Invalid.txt
@@ -10,6 +10,20 @@ parameter group "l0Parameters" type "org.onap.policy.common.parameters.testclass
parameter group "l10LGenericNested1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" INVALID, parameter group has status INVALID
field "lgenericIntField" type "int" value "-1" INVALID, lgenericIntField must be a positive integer
field "lgenericStringField" type "java.lang.String" value "" INVALID, lgenericStringField must be a non-blank string
+ parameter group map "l10LGenericNestedMap" INVALID, parameter group has status INVALID
+ parameter group "l10LGenericNestedMapVal0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" INVALID, parameter group has status INVALID
+ field "lgenericIntField" type "int" value "-1" INVALID, lgenericIntField must be a positive integer
+ field "lgenericStringField" type "java.lang.String" value "" INVALID, lgenericStringField must be a non-blank string
+ parameter group "l10LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" INVALID, parameter group has status INVALID
+ field "lgenericIntField" type "int" value "-1" INVALID, lgenericIntField must be a positive integer
+ field "lgenericStringField" type "java.lang.String" value "" INVALID, lgenericStringField must be a non-blank string
parameter group "l00LGenericNested" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" INVALID, parameter group has status INVALID
field "lgenericIntField" type "int" value "-1" INVALID, lgenericIntField must be a positive integer
- field "lgenericStringField" type "java.lang.String" value "" INVALID, lgenericStringField must be a non-blank string \ No newline at end of file
+ field "lgenericStringField" type "java.lang.String" value "" INVALID, lgenericStringField must be a non-blank string
+ parameter group map "l00LGenericNestedMap" INVALID, parameter group has status INVALID
+ parameter group "l00LGenericNestedMapVal0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" INVALID, parameter group has status INVALID
+ field "lgenericIntField" type "int" value "-1" INVALID, lgenericIntField must be a positive integer
+ field "lgenericStringField" type "java.lang.String" value "" INVALID, lgenericStringField must be a non-blank string
+ parameter group "l00LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" INVALID, parameter group has status INVALID
+ field "lgenericIntField" type "int" value "-1" INVALID, lgenericIntField must be a positive integer
+ field "lgenericStringField" type "java.lang.String" value "" INVALID, lgenericStringField must be a non-blank string \ No newline at end of file
diff --git a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Observation.txt b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Observation.txt
index 00fe6627..da943135 100644
--- a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Observation.txt
+++ b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Observation.txt
@@ -10,6 +10,20 @@ parameter group "l0Parameters" type "org.onap.policy.common.parameters.testclass
parameter group "l10LGenericNested1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" OBSERVATION, parameter group has status OBSERVATION
field "lgenericIntField" type "int" value "2" OBSERVATION, this field has been set to 2
field "lgenericStringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful
+ parameter group map "l10LGenericNestedMap" OBSERVATION, parameter group has status OBSERVATION
+ parameter group "l10LGenericNestedMapVal0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" OBSERVATION, parameter group has status OBSERVATION
+ field "lgenericIntField" type "int" value "2" OBSERVATION, this field has been set to 2
+ field "lgenericStringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful
+ parameter group "l10LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" OBSERVATION, parameter group has status OBSERVATION
+ field "lgenericIntField" type "int" value "2" OBSERVATION, this field has been set to 2
+ field "lgenericStringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful
parameter group "l00LGenericNested" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" OBSERVATION, parameter group has status OBSERVATION
field "lgenericIntField" type "int" value "2" OBSERVATION, this field has been set to 2
field "lgenericStringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful
+ parameter group map "l00LGenericNestedMap" OBSERVATION, parameter group has status OBSERVATION
+ parameter group "l00LGenericNestedMapVal0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" OBSERVATION, parameter group has status OBSERVATION
+ field "lgenericIntField" type "int" value "2" OBSERVATION, this field has been set to 2
+ field "lgenericStringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful
+ parameter group "l00LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" OBSERVATION, parameter group has status OBSERVATION
+ field "lgenericIntField" type "int" value "2" OBSERVATION, this field has been set to 2
+ field "lgenericStringField" type "java.lang.String" value "aString" OBSERVATION, this value for name is unhelpful
diff --git a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Warning.txt b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Warning.txt
index 6c1c639d..67a0932e 100644
--- a/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Warning.txt
+++ b/common-parameters/src/test/resources/expectedValidationResults/TestParametersL0_3_Warning.txt
@@ -10,6 +10,20 @@ parameter group "l0Parameters" type "org.onap.policy.common.parameters.testclass
parameter group "l10LGenericNested1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" WARNING, parameter group has status WARNING
field "lgenericIntField" type "int" value "3" WARNING, values greater than 2 are not recommended
field "lgenericStringField" type "java.lang.String" value "lgenericStringField" WARNING, using the field name for the parameter value is dangerous
+ parameter group map "l10LGenericNestedMap" WARNING, parameter group has status WARNING
+ parameter group "l10LGenericNestedMapVal0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" WARNING, parameter group has status WARNING
+ field "lgenericIntField" type "int" value "3" WARNING, values greater than 2 are not recommended
+ field "lgenericStringField" type "java.lang.String" value "lgenericStringField" WARNING, using the field name for the parameter value is dangerous
+ parameter group "l10LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" WARNING, parameter group has status WARNING
+ field "lgenericIntField" type "int" value "3" WARNING, values greater than 2 are not recommended
+ field "lgenericStringField" type "java.lang.String" value "lgenericStringField" WARNING, using the field name for the parameter value is dangerous
parameter group "l00LGenericNested" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" WARNING, parameter group has status WARNING
field "lgenericIntField" type "int" value "3" WARNING, values greater than 2 are not recommended
- field "lgenericStringField" type "java.lang.String" value "lgenericStringField" WARNING, using the field name for the parameter value is dangerous \ No newline at end of file
+ field "lgenericStringField" type "java.lang.String" value "lgenericStringField" WARNING, using the field name for the parameter value is dangerous
+ parameter group map "l00LGenericNestedMap" WARNING, parameter group has status WARNING
+ parameter group "l00LGenericNestedMapVal0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" WARNING, parameter group has status WARNING
+ field "lgenericIntField" type "int" value "3" WARNING, values greater than 2 are not recommended
+ field "lgenericStringField" type "java.lang.String" value "lgenericStringField" WARNING, using the field name for the parameter value is dangerous
+ parameter group "l00LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" WARNING, parameter group has status WARNING
+ field "lgenericIntField" type "int" value "3" WARNING, values greater than 2 are not recommended
+ field "lgenericStringField" type "java.lang.String" value "lgenericStringField" WARNING, using the field name for the parameter value is dangerous \ No newline at end of file
diff --git a/policy-endpoints/pom.xml b/policy-endpoints/pom.xml
index 5510f3d6..fb546a5a 100644
--- a/policy-endpoints/pom.xml
+++ b/policy-endpoints/pom.xml
@@ -35,7 +35,7 @@
<description>Endpoints</description>
<properties>
- <jetty.version>9.3.20.v20170531</jetty.version>
+ <jetty.version>9.3.24.v20180605</jetty.version>
<jersey.swagger.version>1.5.18</jersey.swagger.version>
<dmaap.version>1.1.3</dmaap.version>
<cambria.version>1.2.1-oss</cambria.version>
@@ -87,6 +87,12 @@
</dependency>
<dependency>
+ <groupId>org.onap.aaf.authz</groupId>
+ <artifactId>aaf-cadi-aaf</artifactId>
+ <version>2.1.1</version>
+ </dependency>
+
+ <dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty.version}</version>
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java
index e7a21ca1..4e2f4ecf 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java
@@ -75,7 +75,7 @@ public interface TopicEndpoint extends Startable, Lockable {
/**
* get the Topic Sources for the given topic name
*
- * @param topicName the topic name
+ * @param topicNames the topic name
*
* @return the Topic Source List
* @throws IllegalStateException if the entity is in an invalid state
@@ -150,7 +150,6 @@ public interface TopicEndpoint extends Startable, Lockable {
* infrastructure type
*
* @param topicName the topic name
- * @param commType communication infrastructure type
*
* @return the Topic Sink List
* @throws IllegalStateException if the entity is in an invalid state, for example multiple
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java
index 26e8d413..08a1db8f 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSinkFactory.java
@@ -3,13 +3,14 @@
* policy-endpoints
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* 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.
@@ -27,6 +28,7 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
+import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.event.comm.bus.internal.InlineDmaapTopicSink;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.slf4j.Logger;
@@ -47,53 +49,50 @@ public interface DmaapTopicSinkFactory {
/**
* Instantiates a new DMAAP Topic Sink
- *
- * @param servers list of servers
- * @param topic topic name
- * @param apiKey API Key
- * @param apiSecret API Secret
- * @param userName AAF user name
- * @param password AAF password
- * @param partitionKey Consumer Group
- * @param environment DME2 environment
- * @param aftEnvironment DME2 AFT environment
- * @param partner DME2 Partner
- * @param latitude DME2 latitude
- * @param longitude DME2 longitude
+ *
+ * @param servers list of servers
+ * @param topic topic name
+ * @param apiKey API Key
+ * @param apiSecret API Secret
+ * @param userName AAF user name
+ * @param password AAF password
+ * @param partitionKey Consumer Group
+ * @param environment DME2 environment
+ * @param aftEnvironment DME2 AFT environment
+ * @param partner DME2 Partner
+ * @param latitude DME2 latitude
+ * @param longitude DME2 longitude
* @param additionalProps additional properties to pass to DME2
- * @param managed is this sink endpoint managed?
- *
+ * @param managed is this sink endpoint managed?
* @return an DMAAP Topic Sink
* @throws IllegalArgumentException if invalid parameters are present
*/
public DmaapTopicSink build(List<String> servers, String topic, String apiKey, String apiSecret, String userName,
- String password, String partitionKey, String environment, String aftEnvironment, String partner,
- String latitude, String longitude, Map<String, String> additionalProps, boolean managed, boolean useHttps,
- boolean allowSelfSignedCerts);
+ String password, String partitionKey, String environment, String aftEnvironment, String partner,
+ String latitude, String longitude, Map<String, String> additionalProps, boolean managed, boolean useHttps,
+ boolean allowSelfSignedCerts);
/**
* Instantiates a new DMAAP Topic Sink
- *
- * @param servers list of servers
- * @param topic topic name
- * @param apiKey API Key
- * @param apiSecret API Secret
- * @param userName AAF user name
- * @param password AAF password
+ *
+ * @param servers list of servers
+ * @param topic topic name
+ * @param apiKey API Key
+ * @param apiSecret API Secret
+ * @param userName AAF user name
+ * @param password AAF password
* @param partitionKey Consumer Group
- * @param managed is this sink endpoint managed?
- *
+ * @param managed is this sink endpoint managed?
* @return an DMAAP Topic Sink
* @throws IllegalArgumentException if invalid parameters are present
*/
public DmaapTopicSink build(List<String> servers, String topic, String apiKey, String apiSecret, String userName,
- String password, String partitionKey, boolean managed, boolean useHttps, boolean allowSelfSignedCerts);
+ String password, String partitionKey, boolean managed, boolean useHttps, boolean allowSelfSignedCerts);
/**
* Creates an DMAAP Topic Sink based on properties files
- *
+ *
* @param properties Properties containing initialization values
- *
* @return an DMAAP Topic Sink
* @throws IllegalArgumentException if invalid parameters are present
*/
@@ -101,10 +100,9 @@ public interface DmaapTopicSinkFactory {
/**
* Instantiates a new DMAAP Topic Sink
- *
+ *
* @param servers list of servers
- * @param topic topic name
- *
+ * @param topic topic name
* @return an DMAAP Topic Sink
* @throws IllegalArgumentException if invalid parameters are present
*/
@@ -112,7 +110,7 @@ public interface DmaapTopicSinkFactory {
/**
* Destroys an DMAAP Topic Sink based on a topic
- *
+ *
* @param topic topic name
* @throws IllegalArgumentException if invalid parameters are present
*/
@@ -120,18 +118,17 @@ public interface DmaapTopicSinkFactory {
/**
* gets an DMAAP Topic Sink based on topic name
- *
+ *
* @param topic the topic name
- *
* @return an DMAAP Topic Sink with topic name
* @throws IllegalArgumentException if an invalid topic is provided
- * @throws IllegalStateException if the DMAAP Topic Reader is an incorrect state
+ * @throws IllegalStateException if the DMAAP Topic Reader is an incorrect state
*/
public DmaapTopicSink get(String topic);
/**
* Provides a snapshot of the DMAAP Topic Sinks
- *
+ *
* @return a list of the DMAAP Topic Sinks
*/
public List<DmaapTopicSink> inventory();
@@ -163,9 +160,9 @@ class IndexedDmaapTopicSinkFactory implements DmaapTopicSinkFactory {
@Override
public DmaapTopicSink build(List<String> servers, String topic, String apiKey, String apiSecret, String userName,
- String password, String partitionKey, String environment, String aftEnvironment, String partner,
- String latitude, String longitude, Map<String, String> additionalProps, boolean managed, boolean useHttps,
- boolean allowSelfSignedCerts) {
+ String password, String partitionKey, String environment, String aftEnvironment, String partner,
+ String latitude, String longitude, Map<String, String> additionalProps, boolean managed, boolean useHttps,
+ boolean allowSelfSignedCerts) {
if (topic == null || topic.isEmpty()) {
throw new IllegalArgumentException(MISSING_TOPIC);
@@ -176,9 +173,23 @@ class IndexedDmaapTopicSinkFactory implements DmaapTopicSinkFactory {
return dmaapTopicWriters.get(topic);
}
- DmaapTopicSink dmaapTopicSink = new InlineDmaapTopicSink(servers, topic, apiKey, apiSecret, userName,
- password, partitionKey, environment, aftEnvironment, partner, latitude, longitude, additionalProps,
- useHttps, allowSelfSignedCerts);
+ DmaapTopicSink dmaapTopicSink = new InlineDmaapTopicSink(BusTopicParams.builder()
+ .servers(servers)
+ .topic(topic)
+ .apiKey(apiKey)
+ .apiSecret(apiSecret)
+ .userName(userName)
+ .password(password)
+ .partitionId(partitionKey)
+ .environment(environment)
+ .aftEnvironment(aftEnvironment)
+ .partner(partner)
+ .latitude(latitude)
+ .longitude(longitude)
+ .additionalProps(additionalProps)
+ .useHttps(useHttps)
+ .allowSelfSignedCerts(allowSelfSignedCerts)
+ .build());
if (managed) {
dmaapTopicWriters.put(topic, dmaapTopicSink);
@@ -189,7 +200,8 @@ class IndexedDmaapTopicSinkFactory implements DmaapTopicSinkFactory {
@Override
public DmaapTopicSink build(List<String> servers, String topic, String apiKey, String apiSecret, String userName,
- String password, String partitionKey, boolean managed, boolean useHttps, boolean allowSelfSignedCerts) {
+ String password, String partitionKey, boolean managed, boolean useHttps,
+ boolean allowSelfSignedCerts) {
if (topic == null || topic.isEmpty()) {
throw new IllegalArgumentException(MISSING_TOPIC);
@@ -200,8 +212,17 @@ class IndexedDmaapTopicSinkFactory implements DmaapTopicSinkFactory {
return dmaapTopicWriters.get(topic);
}
- DmaapTopicSink dmaapTopicSink = new InlineDmaapTopicSink(servers, topic, apiKey, apiSecret, userName,
- password, partitionKey, useHttps, allowSelfSignedCerts);
+ DmaapTopicSink dmaapTopicSink = new InlineDmaapTopicSink(BusTopicParams.builder()
+ .servers(servers)
+ .topic(topic)
+ .apiKey(apiKey)
+ .apiSecret(apiSecret)
+ .userName(userName)
+ .password(password)
+ .partitionId(partitionKey)
+ .useHttps(useHttps)
+ .allowSelfSignedCerts(allowSelfSignedCerts)
+ .build());
if (managed) {
dmaapTopicWriters.put(topic, dmaapTopicSink);
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java
index 96ab6c63..11dfd292 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/DmaapTopicSourceFactory.java
@@ -3,6 +3,7 @@
* policy-endpoints
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +28,7 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
+import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.event.comm.bus.internal.SingleThreadedDmaapTopicSource;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.slf4j.Logger;
@@ -76,12 +78,12 @@ public interface DmaapTopicSourceFactory {
* @throws IllegalArgumentException if invalid parameters are present
*/
public DmaapTopicSource build(List<String> servers, String topic, String apiKey, String apiSecret, String userName,
- String password, String consumerGroup, String consumerInstance, int fetchTimeout, int fetchLimit,
- boolean managed, boolean useHttps, boolean allowSelfSignedCerts);
+ String password, String consumerGroup, String consumerInstance, int fetchTimeout, int fetchLimit,
+ boolean managed, boolean useHttps, boolean allowSelfSignedCerts);
/**
* Instantiates a new DMAAP Topic Source
- *
+ *
* @param servers list of servers
* @param topic topic name
* @param apiKey API Key
@@ -101,14 +103,14 @@ public interface DmaapTopicSourceFactory {
* @param managed is this endpoind managed?
* @param useHttps does the connection use HTTPS?
* @param allowSelfSignedCerts does connection allow self-signed certificates?
- *
+ *
* @return an DMAAP Topic Source
* @throws IllegalArgumentException if invalid parameters are present
*/
public DmaapTopicSource build(List<String> servers, String topic, String apiKey, String apiSecret, String userName,
- String password, String consumerGroup, String consumerInstance, int fetchTimeout, int fetchLimit,
- String environment, String aftEnvironment, String partner, String latitude, String longitude,
- Map<String, String> additionalProps, boolean managed, boolean useHttps, boolean allowSelfSignedCerts);
+ String password, String consumerGroup, String consumerInstance, int fetchTimeout, int fetchLimit,
+ String environment, String aftEnvironment, String partner, String latitude, String longitude,
+ Map<String, String> additionalProps, boolean managed, boolean useHttps, boolean allowSelfSignedCerts);
/**
* Instantiates a new DMAAP Topic Source
@@ -203,9 +205,26 @@ class IndexedDmaapTopicSourceFactory implements DmaapTopicSourceFactory {
return dmaapTopicSources.get(topic);
}
- DmaapTopicSource dmaapTopicSource = new SingleThreadedDmaapTopicSource(servers, topic, apiKey, apiSecret,
- userName, password, consumerGroup, consumerInstance, fetchTimeout, fetchLimit, environment,
- aftEnvironment, partner, latitude, longitude, additionalProps, useHttps, allowSelfSignedCerts);
+ DmaapTopicSource dmaapTopicSource = new SingleThreadedDmaapTopicSource(BusTopicParams.builder()
+ .servers(servers)
+ .topic(topic)
+ .apiKey(apiKey)
+ .apiSecret(apiSecret)
+ .userName(userName)
+ .password(password)
+ .consumerGroup(consumerGroup)
+ .consumerInstance(consumerInstance)
+ .fetchTimeout(fetchTimeout)
+ .fetchLimit(fetchLimit)
+ .environment(environment)
+ .aftEnvironment(aftEnvironment)
+ .partner(partner)
+ .latitude(latitude)
+ .longitude(longitude)
+ .additionalProps(additionalProps)
+ .useHttps(useHttps)
+ .allowSelfSignedCerts(allowSelfSignedCerts)
+ .build());
if (managed) {
dmaapTopicSources.put(topic, dmaapTopicSource);
@@ -237,8 +256,20 @@ class IndexedDmaapTopicSourceFactory implements DmaapTopicSourceFactory {
}
DmaapTopicSource dmaapTopicSource =
- new SingleThreadedDmaapTopicSource(servers, topic, apiKey, apiSecret, userName, password,
- consumerGroup, consumerInstance, fetchTimeout, fetchLimit, useHttps, allowSelfSignedCerts);
+ new SingleThreadedDmaapTopicSource(BusTopicParams.builder()
+ .servers(servers)
+ .topic(topic)
+ .apiKey(apiKey)
+ .apiSecret(apiSecret)
+ .userName(userName)
+ .password(password)
+ .consumerGroup(consumerGroup)
+ .consumerInstance(consumerInstance)
+ .fetchTimeout(fetchTimeout)
+ .fetchLimit(fetchLimit)
+ .useHttps(useHttps)
+ .allowSelfSignedCerts(allowSelfSignedCerts)
+ .build());
if (managed) {
dmaapTopicSources.put(topic, dmaapTopicSource);
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSinkFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSinkFactory.java
index a522e2c5..9d1bd8ad 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSinkFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSinkFactory.java
@@ -3,6 +3,7 @@
* policy-endpoints
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,6 +27,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Properties;
+import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.event.comm.bus.internal.InlineUebTopicSink;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.slf4j.Logger;
@@ -141,8 +143,15 @@ class IndexedUebTopicSinkFactory implements UebTopicSinkFactory {
return uebTopicSinks.get(topic);
}
- UebTopicSink uebTopicWriter = new InlineUebTopicSink(servers, topic, apiKey, apiSecret, partitionKey,
- useHttps, allowSelfSignedCerts);
+ UebTopicSink uebTopicWriter = new InlineUebTopicSink(BusTopicParams.builder()
+ .servers(servers)
+ .topic(topic)
+ .apiKey(apiKey)
+ .apiSecret(apiSecret)
+ .partitionId(partitionKey)
+ .useHttps(useHttps)
+ .allowSelfSignedCerts(allowSelfSignedCerts)
+ .build());
if (managed) {
uebTopicSinks.put(topic, uebTopicWriter);
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceFactory.java
index c6cf3095..8d3f28e9 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/UebTopicSourceFactory.java
@@ -3,6 +3,7 @@
* policy-endpoints
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,6 +27,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Properties;
+import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.event.comm.bus.internal.SingleThreadedUebTopicSource;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.slf4j.Logger;
@@ -63,8 +65,8 @@ public interface UebTopicSourceFactory {
* @throws IllegalArgumentException if invalid parameters are present
*/
public UebTopicSource build(List<String> servers, String topic, String apiKey, String apiSecret,
- String consumerGroup, String consumerInstance, int fetchTimeout, int fetchLimit, boolean managed,
- boolean useHttps, boolean allowSelfSignedCerts);
+ String consumerGroup, String consumerInstance, int fetchTimeout, int fetchLimit, boolean managed,
+ boolean useHttps, boolean allowSelfSignedCerts);
/**
* Instantiates a new UEB Topic Source
@@ -160,8 +162,18 @@ class IndexedUebTopicSourceFactory implements UebTopicSourceFactory {
return uebTopicSources.get(topic);
}
- UebTopicSource uebTopicSource = new SingleThreadedUebTopicSource(servers, topic, apiKey, apiSecret,
- consumerGroup, consumerInstance, fetchTimeout, fetchLimit, useHttps, allowSelfSignedCerts);
+ UebTopicSource uebTopicSource = new SingleThreadedUebTopicSource(BusTopicParams.builder()
+ .servers(servers)
+ .topic(topic)
+ .apiKey(apiKey)
+ .apiSecret(apiSecret)
+ .consumerGroup(consumerGroup)
+ .consumerInstance(consumerInstance)
+ .fetchTimeout(fetchTimeout)
+ .fetchLimit(fetchLimit)
+ .useHttps(useHttps)
+ .allowSelfSignedCerts(allowSelfSignedCerts)
+ .build());
if (managed) {
uebTopicSources.put(topic, uebTopicSource);
@@ -355,5 +367,4 @@ class IndexedUebTopicSourceFactory implements UebTopicSourceFactory {
builder.append("IndexedUebTopicSourceFactory []");
return builder.toString();
}
-
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java
index 636dc6e3..6d34d32b 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java
@@ -3,6 +3,7 @@
* policy-endpoints
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,7 +33,6 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
-import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -43,7 +43,6 @@ import org.slf4j.LoggerFactory;
/**
* Wrapper around libraries to consume from message bus
- *
*/
public interface BusConsumer {
@@ -67,7 +66,7 @@ public interface BusConsumer {
/**
* Sets the server-side filter.
- *
+ *
* @param filter new filter value, or {@code null}
* @throws IllegalArgumentException if the consumer cannot be built with the new filter
*/
@@ -116,53 +115,47 @@ public interface BusConsumer {
/**
* Cambria Consumer Wrapper
+ * BusTopicParam object contains the following parameters
+ * servers messaging bus hosts
+ * topic topic
+ * apiKey API Key
+ * apiSecret API Secret
+ * consumerGroup Consumer Group
+ * consumerInstance Consumer Instance
+ * fetchTimeout Fetch Timeout
+ * fetchLimit Fetch Limit
*
- * @param servers messaging bus hosts
- * @param topic topic
- * @param apiKey API Key
- * @param apiSecret API Secret
- * @param consumerGroup Consumer Group
- * @param consumerInstance Consumer Instance
- * @param fetchTimeout Fetch Timeout
- * @param fetchLimit Fetch Limit
+ * @param busTopicParams
* @throws GeneralSecurityException
* @throws MalformedURLException
*/
- public CambriaConsumerWrapper(List<String> servers, String topic, String apiKey, String apiSecret,
- String consumerGroup, String consumerInstance, int fetchTimeout, int fetchLimit, boolean useHttps,
- boolean useSelfSignedCerts) {
- this(servers, topic, apiKey, apiSecret, null, null, consumerGroup, consumerInstance, fetchTimeout,
- fetchLimit, useHttps, useSelfSignedCerts);
- }
+ public CambriaConsumerWrapper(BusTopicParams busTopicParams) {
- public CambriaConsumerWrapper(List<String> servers, String topic, String apiKey, String apiSecret,
- String username, String password, String consumerGroup, String consumerInstance, int fetchTimeout,
- int fetchLimit, boolean useHttps, boolean useSelfSignedCerts) {
-
- this.fetchTimeout = fetchTimeout;
+ this.fetchTimeout = busTopicParams.getFetchTimeout();
this.builder = new CambriaClientBuilders.ConsumerBuilder();
- builder.knownAs(consumerGroup, consumerInstance).usingHosts(servers).onTopic(topic)
- .waitAtServer(fetchTimeout).receivingAtMost(fetchLimit);
+ builder.knownAs(busTopicParams.getConsumerGroup(), busTopicParams.getConsumerInstance())
+ .usingHosts(busTopicParams.getServers()).onTopic(busTopicParams.getTopic())
+ .waitAtServer(fetchTimeout).receivingAtMost(busTopicParams.getFetchLimit());
// Set read timeout to fetch timeout + 30 seconds (TBD: this should be configurable)
builder.withSocketTimeout(fetchTimeout + 30000);
- if (useHttps) {
+ if (busTopicParams.isUseHttps()) {
builder.usingHttps();
- if (useSelfSignedCerts) {
+ if (busTopicParams.isAllowSelfSignedCerts()) {
builder.allowSelfSignedCertificates();
}
}
- if (apiKey != null && !apiKey.isEmpty() && apiSecret != null && !apiSecret.isEmpty()) {
- builder.authenticatedBy(apiKey, apiSecret);
+ if (busTopicParams.isApiKeyValid() && busTopicParams.isApiSecretValid()) {
+ builder.authenticatedBy(busTopicParams.getApiKey(), busTopicParams.getApiSecret());
}
- if (username != null && !username.isEmpty() && password != null && !password.isEmpty()) {
- builder.authenticatedByHttp(username, password);
+ if (busTopicParams.isUserNameValid() && busTopicParams.isPasswordValid()) {
+ builder.authenticatedByHttp(busTopicParams.getUserName(), busTopicParams.getPassword());
}
try {
@@ -282,34 +275,36 @@ public interface BusConsumer {
/**
* MR Consumer Wrapper
+ * <p>
+ * servers messaging bus hosts
+ * topic topic
+ * apiKey API Key
+ * apiSecret API Secret
+ * username AAF Login
+ * password AAF Password
+ * consumerGroup Consumer Group
+ * consumerInstance Consumer Instance
+ * fetchTimeout Fetch Timeout
+ * fetchLimit Fetch Limit
*
- * @param servers messaging bus hosts
- * @param topic topic
- * @param apiKey API Key
- * @param apiSecret API Secret
- * @param username AAF Login
- * @param password AAF Password
- * @param consumerGroup Consumer Group
- * @param consumerInstance Consumer Instance
- * @param fetchTimeout Fetch Timeout
- * @param fetchLimit Fetch Limit
+ * @param busTopicParams contains above listed attributes
* @throws MalformedURLException
*/
- public DmaapConsumerWrapper(List<String> servers, String topic, String apiKey, String apiSecret,
- String username, String password, String consumerGroup, String consumerInstance, int fetchTimeout,
- int fetchLimit) throws MalformedURLException {
+ public DmaapConsumerWrapper(BusTopicParams busTopicParams) throws MalformedURLException {
- this.fetchTimeout = fetchTimeout;
+ this.fetchTimeout = busTopicParams.getFetchTimeout();
- if (topic == null || topic.isEmpty()) {
+ if (busTopicParams.isTopicNullOrEmpty()) {
throw new IllegalArgumentException("No topic for DMaaP");
}
- this.consumer = new MRConsumerImpl(servers, topic, consumerGroup, consumerInstance, fetchTimeout,
- fetchLimit, null, apiKey, apiSecret);
+ this.consumer = new MRConsumerImpl(busTopicParams.getServers(), busTopicParams.getTopic(),
+ busTopicParams.getConsumerGroup(), busTopicParams.getConsumerInstance(),
+ busTopicParams.getFetchTimeout(), busTopicParams.getFetchLimit(), null,
+ busTopicParams.getApiKey(), busTopicParams.getApiSecret());
- this.consumer.setUsername(username);
- this.consumer.setPassword(password);
+ this.consumer.setUsername(busTopicParams.getUserName());
+ this.consumer.setPassword(busTopicParams.getPassword());
}
@Override
@@ -374,29 +369,29 @@ public interface BusConsumer {
private final Properties props;
/**
+ * BusTopicParams contain the following parameters
* MR Consumer Wrapper
+ * <p>
+ * servers messaging bus hosts
+ * topic topic
+ * apiKey API Key
+ * apiSecret API Secret
+ * aafLogin AAF Login
+ * aafPassword AAF Password
+ * consumerGroup Consumer Group
+ * consumerInstance Consumer Instance
+ * fetchTimeout Fetch Timeout
+ * fetchLimit Fetch Limit
*
- * @param servers messaging bus hosts
- * @param topic topic
- * @param apiKey API Key
- * @param apiSecret API Secret
- * @param aafLogin AAF Login
- * @param aafPassword AAF Password
- * @param consumerGroup Consumer Group
- * @param consumerInstance Consumer Instance
- * @param fetchTimeout Fetch Timeout
- * @param fetchLimit Fetch Limit
+ * @param busTopicParams contains above listed params
* @throws MalformedURLException
*/
- public DmaapAafConsumerWrapper(List<String> servers, String topic, String apiKey, String apiSecret,
- String aafLogin, String aafPassword, String consumerGroup, String consumerInstance, int fetchTimeout,
- int fetchLimit, boolean useHttps) throws MalformedURLException {
+ public DmaapAafConsumerWrapper(BusTopicParams busTopicParams) throws MalformedURLException {
- super(servers, topic, apiKey, apiSecret, aafLogin, aafPassword, consumerGroup, consumerInstance,
- fetchTimeout, fetchLimit);
+ super(busTopicParams);
// super constructor sets servers = {""} if empty to avoid errors when using DME2
- if ((servers.size() == 1 && ("".equals(servers.get(0)))) || (servers == null) || (servers.isEmpty())) {
+ if (busTopicParams.isServersNullOrEmpty()) {
throw new IllegalArgumentException("Must provide at least one host for HTTP AAF");
}
@@ -404,13 +399,13 @@ public interface BusConsumer {
props = new Properties();
- if (useHttps) {
+ if (busTopicParams.isUseHttps()) {
props.setProperty(PROTOCOL_PROP, "https");
- this.consumer.setHost(servers.get(0) + ":3905");
+ this.consumer.setHost(busTopicParams.getServers().get(0) + ":3905");
} else {
props.setProperty(PROTOCOL_PROP, "http");
- this.consumer.setHost(servers.get(0) + ":3904");
+ this.consumer.setHost(busTopicParams.getServers().get(0) + ":3904");
}
this.consumer.setProps(props);
@@ -434,70 +429,72 @@ public interface BusConsumer {
private final Properties props;
- public DmaapDmeConsumerWrapper(List<String> servers, String topic, String apiKey, String apiSecret,
- String dme2Login, String dme2Password, String consumerGroup, String consumerInstance, int fetchTimeout,
- int fetchLimit, String environment, String aftEnvironment, String dme2Partner, String latitude,
- String longitude, Map<String, String> additionalProps, boolean useHttps) throws MalformedURLException {
-
+ public DmaapDmeConsumerWrapper(BusTopicParams busTopicParams) throws MalformedURLException {
- super(servers, topic, apiKey, apiSecret, dme2Login, dme2Password, consumerGroup, consumerInstance,
- fetchTimeout, fetchLimit);
+ super(busTopicParams);
- final String dme2RouteOffer = additionalProps.get(DmaapTopicSinkFactory.DME2_ROUTE_OFFER_PROPERTY);
+ final String dme2RouteOffer = busTopicParams.getAdditionalProps()
+ .get(DmaapTopicSinkFactory.DME2_ROUTE_OFFER_PROPERTY);
- if (environment == null || environment.isEmpty()) {
- throw parmException(topic, PolicyEndPointProperties.PROPERTY_DMAAP_DME2_ENVIRONMENT_SUFFIX);
+ if (busTopicParams.isEnvironmentNullOrEmpty()) {
+ throw parmException(busTopicParams.getTopic(),
+ PolicyEndPointProperties.PROPERTY_DMAAP_DME2_ENVIRONMENT_SUFFIX);
}
- if (aftEnvironment == null || aftEnvironment.isEmpty()) {
- throw parmException(topic, PolicyEndPointProperties.PROPERTY_DMAAP_DME2_AFT_ENVIRONMENT_SUFFIX);
+ if (busTopicParams.isAftEnvironmentNullOrEmpty()) {
+ throw parmException(busTopicParams.getTopic(),
+ PolicyEndPointProperties.PROPERTY_DMAAP_DME2_AFT_ENVIRONMENT_SUFFIX);
}
- if (latitude == null || latitude.isEmpty()) {
- throw parmException(topic, PolicyEndPointProperties.PROPERTY_DMAAP_DME2_LATITUDE_SUFFIX);
+ if (busTopicParams.isLatitudeNullOrEmpty()) {
+ throw parmException(busTopicParams.getTopic(),
+ PolicyEndPointProperties.PROPERTY_DMAAP_DME2_LATITUDE_SUFFIX);
}
- if (longitude == null || longitude.isEmpty()) {
- throw parmException(topic, PolicyEndPointProperties.PROPERTY_DMAAP_DME2_LONGITUDE_SUFFIX);
+ if (busTopicParams.isLongitudeNullOrEmpty()) {
+ throw parmException(busTopicParams.getTopic(),
+ PolicyEndPointProperties.PROPERTY_DMAAP_DME2_LONGITUDE_SUFFIX);
}
- if ((dme2Partner == null || dme2Partner.isEmpty())
+ if ((busTopicParams.isPartnerNullOrEmpty())
&& (dme2RouteOffer == null || dme2RouteOffer.isEmpty())) {
throw new IllegalArgumentException(
- "Must provide at least " + PolicyEndPointProperties.PROPERTY_DMAAP_SOURCE_TOPICS + "." + topic
+ "Must provide at least " + PolicyEndPointProperties.PROPERTY_DMAAP_SOURCE_TOPICS
+ + "." + busTopicParams.getTopic()
+ PolicyEndPointProperties.PROPERTY_DMAAP_DME2_PARTNER_SUFFIX + " or "
- + PolicyEndPointProperties.PROPERTY_DMAAP_SOURCE_TOPICS + "." + topic
+ + PolicyEndPointProperties.PROPERTY_DMAAP_SOURCE_TOPICS + "."
+ + busTopicParams.getTopic()
+ PolicyEndPointProperties.PROPERTY_DMAAP_DME2_ROUTE_OFFER_SUFFIX + " for DME2");
}
- final String serviceName = servers.get(0);
+ final String serviceName = busTopicParams.getServers().get(0);
this.consumer.setProtocolFlag(ProtocolTypeConstants.DME2.getValue());
- this.consumer.setUsername(dme2Login);
- this.consumer.setPassword(dme2Password);
+ this.consumer.setUsername(busTopicParams.getUserName());
+ this.consumer.setPassword(busTopicParams.getPassword());
props = new Properties();
props.setProperty(DmaapTopicSinkFactory.DME2_SERVICE_NAME_PROPERTY, serviceName);
- props.setProperty("username", dme2Login);
- props.setProperty("password", dme2Password);
+ props.setProperty("username", busTopicParams.getUserName());
+ props.setProperty("password", busTopicParams.getPassword());
/* These are required, no defaults */
- props.setProperty("topic", topic);
+ props.setProperty("topic", busTopicParams.getTopic());
- props.setProperty("Environment", environment);
- props.setProperty("AFT_ENVIRONMENT", aftEnvironment);
+ props.setProperty("Environment", busTopicParams.getEnvironment());
+ props.setProperty("AFT_ENVIRONMENT", busTopicParams.getAftEnvironment());
- if (dme2Partner != null) {
- props.setProperty("Partner", dme2Partner);
+ if (busTopicParams.getPartner() != null) {
+ props.setProperty("Partner", busTopicParams.getPartner());
}
if (dme2RouteOffer != null) {
props.setProperty(DmaapTopicSinkFactory.DME2_ROUTE_OFFER_PROPERTY, dme2RouteOffer);
}
- props.setProperty("Latitude", latitude);
- props.setProperty("Longitude", longitude);
+ props.setProperty("Latitude", busTopicParams.getLatitude());
+ props.setProperty("Longitude", busTopicParams.getLongitude());
/* These are optional, will default to these values if not set in additionalProps */
props.setProperty("AFT_DME2_EP_READ_TIMEOUT_MS", "50000");
@@ -511,7 +508,7 @@ public interface BusConsumer {
props.setProperty("TransportType", "DME2");
props.setProperty("MethodType", "GET");
- if (useHttps) {
+ if (busTopicParams.isUseHttps()) {
props.setProperty(PROTOCOL_PROP, "https");
} else {
@@ -520,8 +517,8 @@ public interface BusConsumer {
props.setProperty("contenttype", "application/json");
- if (additionalProps != null) {
- for (Map.Entry<String, String> entry : additionalProps.entrySet()) {
+ if (busTopicParams.isAdditionalPropsValid()) {
+ for (Map.Entry<String, String> entry : busTopicParams.getAdditionalProps().entrySet()) {
props.put(entry.getKey(), entry.getValue());
}
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java
index 9db9131c..348100ab 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java
@@ -3,6 +3,7 @@
* policy-endpoints
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,7 +48,7 @@ public interface BusPublisher {
/**
* sends a message
*
- * @param partition id
+ * @param partitionId id
* @param message the message
* @return true if success, false otherwise
* @throws IllegalArgumentException if no message provided
@@ -72,23 +73,17 @@ public interface BusPublisher {
@JsonIgnore
protected volatile CambriaBatchingPublisher publisher;
- public CambriaPublisherWrapper(List<String> servers, String topic, String apiKey, String apiSecret,
- boolean useHttps) {
- this(servers, topic, apiKey, apiSecret, null, null, useHttps, false);
- }
-
- public CambriaPublisherWrapper(List<String> servers, String topic, String apiKey, String apiSecret,
- String username, String password, boolean useHttps, boolean selfSignedCerts) {
+ public CambriaPublisherWrapper(BusTopicParams busTopicParams) {
PublisherBuilder builder = new CambriaClientBuilders.PublisherBuilder();
- builder.usingHosts(servers).onTopic(topic);
+ builder.usingHosts(busTopicParams.getServers()).onTopic(busTopicParams.getTopic());
// Set read timeout to 30 seconds (TBD: this should be configurable)
builder.withSocketTimeout(30000);
- if (useHttps) {
- if (selfSignedCerts) {
+ if (busTopicParams.isUseHttps()) {
+ if (busTopicParams.isAllowSelfSignedCerts()) {
builder.withConnectionType(ConnectionType.HTTPS_NO_VALIDATION);
} else {
builder.withConnectionType(ConnectionType.HTTPS);
@@ -96,12 +91,12 @@ public interface BusPublisher {
}
- if (apiKey != null && !apiKey.isEmpty() && apiSecret != null && !apiSecret.isEmpty()) {
- builder.authenticatedBy(apiKey, apiSecret);
+ if (busTopicParams.isApiKeyValid() && busTopicParams.isApiSecretValid()) {
+ builder.authenticatedBy(busTopicParams.getApiKey(), busTopicParams.getApiSecret());
}
- if (username != null && !username.isEmpty() && password != null && !password.isEmpty()) {
- builder.authenticatedByHttp(username, password);
+ if (busTopicParams.isUserNameValid() && busTopicParams.isPasswordValid()) {
+ builder.authenticatedByHttp(busTopicParams.getUserName(), busTopicParams.getPassword());
}
try {
@@ -297,55 +292,60 @@ public interface BusPublisher {
}
public static class DmaapDmePublisherWrapper extends DmaapPublisherWrapper {
- public DmaapDmePublisherWrapper(List<String> servers, String topic, String username, String password,
- String environment, String aftEnvironment, String dme2Partner, String latitude, String longitude,
- Map<String, String> additionalProps, boolean useHttps) {
-
- super(ProtocolTypeConstants.DME2, servers, topic, username, password, useHttps);
-
-
-
- String dme2RouteOffer = additionalProps.get(DmaapTopicSinkFactory.DME2_ROUTE_OFFER_PROPERTY);
+ public DmaapDmePublisherWrapper(BusTopicParams busTopicParams) {
+
+ super(ProtocolTypeConstants.DME2, busTopicParams.getServers(),busTopicParams.getTopic(),
+ busTopicParams.getUserName(),busTopicParams.getPassword(),busTopicParams.isUseHttps());
+ String dme2RouteOffer = null;
+ if (busTopicParams.isAdditionalPropsValid()) {
+ dme2RouteOffer = busTopicParams.getAdditionalProps().get(
+ DmaapTopicSinkFactory.DME2_ROUTE_OFFER_PROPERTY);
+ }
- if (environment == null || environment.isEmpty()) {
- throw parmException(topic, PolicyEndPointProperties.PROPERTY_DMAAP_DME2_ENVIRONMENT_SUFFIX);
+ if (busTopicParams.isEnvironmentNullOrEmpty()) {
+ throw parmException(busTopicParams.getTopic(),
+ PolicyEndPointProperties.PROPERTY_DMAAP_DME2_ENVIRONMENT_SUFFIX);
}
- if (aftEnvironment == null || aftEnvironment.isEmpty()) {
- throw parmException(topic, PolicyEndPointProperties.PROPERTY_DMAAP_DME2_AFT_ENVIRONMENT_SUFFIX);
+ if (busTopicParams.isAftEnvironmentNullOrEmpty()) {
+ throw parmException(busTopicParams.getTopic(),
+ PolicyEndPointProperties.PROPERTY_DMAAP_DME2_AFT_ENVIRONMENT_SUFFIX);
}
- if (latitude == null || latitude.isEmpty()) {
- throw parmException(topic, PolicyEndPointProperties.PROPERTY_DMAAP_DME2_LATITUDE_SUFFIX);
+ if (busTopicParams.isLatitudeNullOrEmpty()) {
+ throw parmException(busTopicParams.getTopic(),
+ PolicyEndPointProperties.PROPERTY_DMAAP_DME2_LATITUDE_SUFFIX);
}
- if (longitude == null || longitude.isEmpty()) {
- throw parmException(topic, PolicyEndPointProperties.PROPERTY_DMAAP_DME2_LONGITUDE_SUFFIX);
+ if (busTopicParams.isLongitudeNullOrEmpty()) {
+ throw parmException(busTopicParams.getTopic(),
+ PolicyEndPointProperties.PROPERTY_DMAAP_DME2_LONGITUDE_SUFFIX);
}
- if ((dme2Partner == null || dme2Partner.isEmpty())
- && (dme2RouteOffer == null || dme2RouteOffer.isEmpty())) {
+ if ((busTopicParams.isPartnerNullOrEmpty())
+ && (dme2RouteOffer == null || dme2RouteOffer.trim().isEmpty())) {
throw new IllegalArgumentException(
- "Must provide at least " + PolicyEndPointProperties.PROPERTY_DMAAP_SOURCE_TOPICS + "." + topic
+ "Must provide at least " + PolicyEndPointProperties.PROPERTY_DMAAP_SOURCE_TOPICS + "."
+ + busTopicParams.getTopic()
+ PolicyEndPointProperties.PROPERTY_DMAAP_DME2_PARTNER_SUFFIX + " or "
- + PolicyEndPointProperties.PROPERTY_DMAAP_SINK_TOPICS + "." + topic
+ + PolicyEndPointProperties.PROPERTY_DMAAP_SINK_TOPICS + "." + busTopicParams.getTopic()
+ PolicyEndPointProperties.PROPERTY_DMAAP_DME2_ROUTE_OFFER_SUFFIX + " for DME2");
}
- String serviceName = servers.get(0);
+ String serviceName = busTopicParams.getServers().get(0);
/* These are required, no defaults */
- props.setProperty("Environment", environment);
- props.setProperty("AFT_ENVIRONMENT", aftEnvironment);
+ props.setProperty("Environment", busTopicParams.getEnvironment());
+ props.setProperty("AFT_ENVIRONMENT", busTopicParams.getAftEnvironment());
props.setProperty(DmaapTopicSinkFactory.DME2_SERVICE_NAME_PROPERTY, serviceName);
- if (dme2Partner != null) {
- props.setProperty("Partner", dme2Partner);
+ if (busTopicParams.getPartner() != null) {
+ props.setProperty("Partner", busTopicParams.getPartner());
}
if (dme2RouteOffer != null) {
props.setProperty(DmaapTopicSinkFactory.DME2_ROUTE_OFFER_PROPERTY, dme2RouteOffer);
}
- props.setProperty("Latitude", latitude);
- props.setProperty("Longitude", longitude);
+ props.setProperty("Latitude", busTopicParams.getLatitude());
+ props.setProperty("Longitude", busTopicParams.getLongitude());
// ServiceName also a default, found in additionalProps
@@ -361,7 +361,7 @@ public interface BusPublisher {
props.setProperty("TransportType", "DME2");
props.setProperty("MethodType", "POST");
- for (Map.Entry<String, String> entry : additionalProps.entrySet()) {
+ for (Map.Entry<String, String> entry : busTopicParams.getAdditionalProps().entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBase.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBase.java
index 7f4c0ddd..08993126 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBase.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBase.java
@@ -52,25 +52,22 @@ public abstract class BusTopicBase extends TopicBase implements ApiKeyEnabled {
/**
* Instantiates a new Bus Topic Base
*
- * @param servers list of servers
- * @param topic topic name
- * @param apiKey API Key
- * @param apiSecret API Secret
- * @param useHttps does connection use HTTPS?
- * @param allowSelfSignedCerts are self-signed certificates allow
- *
+ * servers list of servers
+ * topic topic name
+ * apiKey API Key
+ * apiSecret API Secret
+ * useHttps does connection use HTTPS?
+ * allowSelfSignedCerts are self-signed certificates allow
+ * @param busTopicParams
* @return a Bus Topic Base
* @throws IllegalArgumentException if invalid parameters are present
*/
- public BusTopicBase(List<String> servers, String topic, String apiKey, String apiSecret, boolean useHttps,
- boolean allowSelfSignedCerts) {
-
- super(servers, topic);
-
- this.apiKey = apiKey;
- this.apiSecret = apiSecret;
- this.useHttps = useHttps;
- this.allowSelfSignedCerts = allowSelfSignedCerts;
+ public BusTopicBase(BusTopicParams busTopicParams) {
+ super(busTopicParams.getServers(), busTopicParams.getTopic());
+ this.apiKey = busTopicParams.getApiKey();
+ this.apiSecret = busTopicParams.getApiSecret();
+ this.useHttps = busTopicParams.isUseHttps();
+ this.allowSelfSignedCerts = busTopicParams.isAllowSelfSignedCerts();
}
@Override
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParams.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParams.java
new file mode 100644
index 00000000..ffefcbf2
--- /dev/null
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParams.java
@@ -0,0 +1,316 @@
+/*
+ * ============LICENSE_START=======================================================
+ * policy-endpoints
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. 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.
+ * 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=========================================================
+ */
+
+package org.onap.policy.common.endpoints.event.comm.bus.internal;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Member variables of this Params class are as follows
+ * servers DMaaP servers
+ * topic DMaaP Topic to be monitored
+ * apiKey DMaaP API Key (optional)
+ * apiSecret DMaaP API Secret (optional)
+ * consumerGroup DMaaP Reader Consumer Group
+ * consumerInstance DMaaP Reader Instance
+ * fetchTimeout DMaaP fetch timeout
+ * fetchLimit DMaaP fetch limit
+ * environment DME2 Environment
+ * aftEnvironment DME2 AFT Environment
+ * partner DME2 Partner
+ * latitude DME2 Latitude
+ * longitude DME2 Longitude
+ * additionalProps Additional properties to pass to DME2
+ * useHttps does connection use HTTPS?
+ * allowSelfSignedCerts are self-signed certificates allow
+ */
+public class BusTopicParams {
+
+ public static TopicParamsBuilder builder() {
+ return new TopicParamsBuilder();
+ }
+
+ private List<String> servers;
+ private String topic;
+ private String apiKey;
+ private String apiSecret;
+ private String consumerGroup;
+ private String consumerInstance;
+ private int fetchTimeout;
+ private int fetchLimit;
+ private boolean useHttps;
+ private boolean allowSelfSignedCerts;
+
+ private String userName;
+ private String password;
+ private String environment;
+ private String aftEnvironment;
+ private String partner;
+ private String latitude;
+ private String longitude;
+ private Map<String, String> additionalProps;
+ private String partitionId;
+
+ String getPartitionId() {
+ return partitionId;
+ }
+
+ String getUserName() {
+ return userName;
+ }
+
+ String getPassword() {
+ return password;
+ }
+
+ String getEnvironment() {
+ return environment;
+ }
+
+ String getAftEnvironment() {
+ return aftEnvironment;
+ }
+
+ String getPartner() {
+ return partner;
+ }
+
+ String getLatitude() {
+ return latitude;
+ }
+
+ String getLongitude() {
+ return longitude;
+ }
+
+ Map<String, String> getAdditionalProps() {
+ return additionalProps;
+ }
+
+ List<String> getServers() {
+ return servers;
+ }
+
+ String getTopic() {
+ return topic;
+ }
+
+ String getApiKey() {
+ return apiKey;
+ }
+
+ String getApiSecret() {
+ return apiSecret;
+ }
+
+ String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+ String getConsumerInstance() {
+ return consumerInstance;
+ }
+
+ int getFetchTimeout() {
+ return fetchTimeout;
+ }
+
+ int getFetchLimit() {
+ return fetchLimit;
+ }
+
+ boolean isUseHttps() {
+ return useHttps;
+ }
+
+ boolean isAllowSelfSignedCerts() {
+ return allowSelfSignedCerts;
+ }
+
+ boolean isEnvironmentNullOrEmpty() {
+ return (environment == null || environment.trim().isEmpty());
+ }
+
+ boolean isAftEnvironmentNullOrEmpty() {
+ return (aftEnvironment == null || aftEnvironment.trim().isEmpty());
+ }
+
+ boolean isLatitudeNullOrEmpty() {
+ return (latitude == null || latitude.trim().isEmpty());
+ }
+
+ boolean isLongitudeNullOrEmpty() {
+ return (longitude == null || longitude.trim().isEmpty());
+ }
+
+ boolean isConsumerInstanceNullOrEmpty() {
+ return (consumerInstance == null || consumerInstance.trim().isEmpty());
+ }
+
+ boolean isConsumerGroupNullOrEmpty() {
+ return (consumerGroup == null || consumerGroup.trim().isEmpty());
+ }
+
+ boolean isApiKeyValid() {
+ return !(apiKey == null || apiKey.trim().isEmpty());
+ }
+
+ boolean isApiSecretValid() {
+ return !(apiSecret == null || apiSecret.trim().isEmpty());
+ }
+
+ boolean isUserNameValid() {
+ return !(userName == null || userName.trim().isEmpty());
+ }
+
+ boolean isPasswordValid() {
+ return !(password == null || password.trim().isEmpty());
+ }
+
+ boolean isPartnerNullOrEmpty() {
+ return (partner == null || partner.trim().isEmpty());
+ }
+
+ boolean isServersNullOrEmpty() {
+ return (servers == null || servers.isEmpty()
+ || (servers.size() == 1 && ("".equals(servers.get(0)))));
+ }
+
+ boolean isAdditionalPropsValid() {
+ return additionalProps != null;
+ }
+
+ boolean isTopicNullOrEmpty() {
+ return (topic == null || topic.trim().isEmpty());
+ }
+
+ boolean isPartitionIdNullOrEmpty() {
+ return (partitionId == null || partitionId.trim().isEmpty());
+ }
+
+ public static class TopicParamsBuilder {
+ BusTopicParams m = new BusTopicParams();
+
+ private TopicParamsBuilder() {
+ }
+
+ public TopicParamsBuilder servers(List<String> servers) {
+ this.m.servers = servers;
+ return this;
+ }
+
+ public TopicParamsBuilder topic(String topic) {
+ this.m.topic = topic;
+ return this;
+ }
+
+ public TopicParamsBuilder apiKey(String apiKey) {
+ this.m.apiKey = apiKey;
+ return this;
+ }
+
+ public TopicParamsBuilder apiSecret(String apiSecret) {
+ this.m.apiSecret = apiSecret;
+ return this;
+ }
+
+ public TopicParamsBuilder consumerGroup(String consumerGroup) {
+ this.m.consumerGroup = consumerGroup;
+ return this;
+ }
+
+ public TopicParamsBuilder consumerInstance(String consumerInstance) {
+ this.m.consumerInstance = consumerInstance;
+ return this;
+ }
+
+ public TopicParamsBuilder fetchTimeout(int fetchTimeout) {
+ this.m.fetchTimeout = fetchTimeout;
+ return this;
+ }
+
+ public TopicParamsBuilder fetchLimit(int fetchLimit) {
+ this.m.fetchLimit = fetchLimit;
+ return this;
+ }
+
+ public TopicParamsBuilder useHttps(boolean useHttps) {
+ this.m.useHttps = useHttps;
+ return this;
+ }
+
+ public TopicParamsBuilder allowSelfSignedCerts(boolean allowSelfSignedCerts) {
+ this.m.allowSelfSignedCerts = allowSelfSignedCerts;
+ return this;
+ }
+
+ public TopicParamsBuilder userName(String userName) {
+ this.m.userName = userName;
+ return this;
+ }
+
+ public TopicParamsBuilder password(String password) {
+ this.m.password = password;
+ return this;
+ }
+
+ public TopicParamsBuilder environment(String environment) {
+ this.m.environment = environment;
+ return this;
+ }
+
+ public TopicParamsBuilder aftEnvironment(String aftEnvironment) {
+ this.m.aftEnvironment = aftEnvironment;
+ return this;
+ }
+
+ public TopicParamsBuilder partner(String partner) {
+ this.m.partner = partner;
+ return this;
+ }
+
+ public TopicParamsBuilder latitude(String latitude) {
+ this.m.latitude = latitude;
+ return this;
+ }
+
+ public TopicParamsBuilder longitude(String longitude) {
+ this.m.longitude = longitude;
+ return this;
+ }
+
+ public TopicParamsBuilder additionalProps(Map<String, String> additionalProps) {
+ this.m.additionalProps = additionalProps;
+ return this;
+ }
+
+ public TopicParamsBuilder partitionId(String partitionId) {
+ this.m.partitionId = partitionId;
+ return this;
+ }
+
+ public BusTopicParams build() {
+ return m;
+ }
+
+ }
+}
+
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSink.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSink.java
index f3c736da..5493468a 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSink.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSink.java
@@ -3,6 +3,7 @@
* policy-endpoints
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,23 +53,24 @@ public abstract class InlineBusTopicSink extends BusTopicBase implements BusTopi
/**
* constructor for abstract sink
- *
- * @param servers servers
- * @param topic topic
- * @param apiKey api secret
- * @param apiSecret api secret
- * @param partitionId partition id
- * @param useHttps does connection use HTTPS?
- * @param allowSelfSignedCerts are self-signed certificates allow
+ * @param busTopicParams contains below listed attributes
+ * servers servers
+ * topic topic
+ * apiKey api secret
+ * apiSecret api secret
+ * partitionId partition id
+ * useHttps does connection use HTTPS?
+ * allowSelfSignedCerts are self-signed certificates allow *
* @throws IllegalArgumentException in invalid parameters are passed in
*/
- public InlineBusTopicSink(List<String> servers, String topic, String apiKey, String apiSecret, String partitionId,
- boolean useHttps, boolean allowSelfSignedCerts) {
+ public InlineBusTopicSink(BusTopicParams busTopicParams) {
- super(servers, topic, apiKey, apiSecret, useHttps, allowSelfSignedCerts);
+ super(busTopicParams);
- if (partitionId == null || partitionId.isEmpty()) {
+ if (busTopicParams.isPartitionIdNullOrEmpty()) {
this.partitionId = UUID.randomUUID().toString();
+ } else {
+ this.partitionId = busTopicParams.getPartitionId();
}
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSink.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSink.java
index 3ea7185e..3dd40312 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSink.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineDmaapTopicSink.java
@@ -3,13 +3,14 @@
* policy-endpoints
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* 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.
@@ -48,65 +49,67 @@ public class InlineDmaapTopicSink extends InlineBusTopicSink implements DmaapTop
protected Map<String, String> additionalProps = null;
/**
- *
- * @param servers DMaaP servers
- * @param topic DMaaP Topic to be monitored
- * @param apiKey DMaaP API Key (optional)
- * @param apiSecret DMaaP API Secret (optional)
- * @param consumerGroup DMaaP Reader Consumer Group
- * @param consumerInstance DMaaP Reader Instance
- * @param fetchTimeout DMaaP fetch timeout
- * @param fetchLimit DMaaP fetch limit
- * @param environment DME2 Environment
- * @param aftEnvironment DME2 AFT Environment
- * @param partner DME2 Partner
- * @param latitude DME2 Latitude
- * @param longitude DME2 Longitude
- * @param additionalProps Additional properties to pass to DME2
- * @param useHttps does connection use HTTPS?
- * @param allowSelfSignedCerts are self-signed certificates allow
- *
+ * BusTopicParams contains the below mentioned attributes
+ * servers DMaaP servers
+ * topic DMaaP Topic to be monitored
+ * apiKey DMaaP API Key (optional)
+ * apiSecret DMaaP API Secret (optional)
+ * environment DME2 Environment
+ * aftEnvironment DME2 AFT Environment
+ * partner DME2 Partner
+ * latitude DME2 Latitude
+ * longitude DME2 Longitude
+ * additionalProps Additional properties to pass to DME2
+ * useHttps does connection use HTTPS?
+ * allowSelfSignedCerts are self-signed certificates allow
+ * @param busTopicParams Contains the above mentioned parameters
* @throws IllegalArgumentException An invalid parameter passed in
*/
- public InlineDmaapTopicSink(List<String> servers, String topic, String apiKey, String apiSecret, String userName,
- String password, String partitionKey, String environment, String aftEnvironment, String partner,
- String latitude, String longitude, Map<String, String> additionalProps, boolean useHttps,
- boolean allowSelfSignedCerts) {
+ public InlineDmaapTopicSink(BusTopicParams busTopicParams) {
- super(servers, topic, apiKey, apiSecret, partitionKey, useHttps, allowSelfSignedCerts);
+ super(busTopicParams);
- this.userName = userName;
- this.password = password;
+ this.userName = busTopicParams.getUserName();
+ this.password = busTopicParams.getPassword();
- this.environment = environment;
- this.aftEnvironment = aftEnvironment;
- this.partner = partner;
+ this.environment = busTopicParams.getEnvironment();
+ this.aftEnvironment = busTopicParams.getAftEnvironment();
+ this.partner = busTopicParams.getPartner();
- this.latitude = latitude;
- this.longitude = longitude;
+ this.latitude = busTopicParams.getLatitude();
+ this.longitude = busTopicParams.getLongitude();
- this.additionalProps = additionalProps;
- }
-
- public InlineDmaapTopicSink(List<String> servers, String topic, String apiKey, String apiSecret, String userName,
- String password, String partitionKey, boolean useHttps, boolean allowSelfSignedCerts) {
-
- super(servers, topic, apiKey, apiSecret, partitionKey, useHttps, allowSelfSignedCerts);
-
- this.userName = userName;
- this.password = password;
+ this.additionalProps = busTopicParams.getAdditionalProps();
}
@Override
public void init() {
if (allNullOrEmpty(this.environment, this.aftEnvironment, this.latitude, this.longitude, this.partner)) {
- this.publisher = new BusPublisher.CambriaPublisherWrapper(this.servers, this.topic, this.apiKey,
- this.apiSecret, this.userName, this.password, this.useHttps, this.allowSelfSignedCerts);
+ this.publisher = new BusPublisher.CambriaPublisherWrapper(BusTopicParams.builder()
+ .servers(this.servers)
+ .topic(this.topic)
+ .apiKey(this.apiKey)
+ .apiSecret(this.apiSecret)
+ .userName(this.userName)
+ .password(this.password)
+ .useHttps(this.useHttps)
+ .allowSelfSignedCerts(this.allowSelfSignedCerts)
+ .build());
} else {
- this.publisher = new BusPublisher.DmaapDmePublisherWrapper(this.servers, this.topic, this.userName,
- this.password, this.environment, this.aftEnvironment, this.partner, this.latitude, this.longitude,
- this.additionalProps, this.useHttps);
+ this.publisher = new BusPublisher.DmaapDmePublisherWrapper(BusTopicParams.builder()
+ .servers(this.servers)
+ .topic(this.topic)
+ .userName(this.userName)
+ .password(this.password)
+ .environment(this.environment)
+ .aftEnvironment(this.aftEnvironment)
+ .partner(this.partner)
+ .latitude(this.latitude)
+ .longitude(this.longitude)
+ .additionalProps(this.additionalProps)
+ .useHttps(this.useHttps)
+ .build());
}
logger.info("{}: DMAAP SINK created", this);
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSink.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSink.java
index fefe6493..218e44b4 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSink.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineUebTopicSink.java
@@ -3,13 +3,14 @@
* policy-endpoints
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* 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.
@@ -39,21 +40,21 @@ public class InlineUebTopicSink extends InlineBusTopicSink implements UebTopicSi
private static Logger logger = LoggerFactory.getLogger(InlineUebTopicSink.class);
/**
- * Argument-based UEB Topic Writer instantiation
- *
- * @param servers list of UEB servers available for publishing
- * @param topic the topic to publish to
- * @param apiKey the api key (optional)
- * @param apiSecret the api secret (optional)
- * @param partitionId the partition key (optional, autogenerated if not provided)
- * @param useHttps does connection use HTTPS?
- * @param allowSelfSignedCerts are self-signed certificates allow
- *
+ * Argument-based UEB Topic Writer instantiation. BusTopicParams contains below mentioned
+ * attributes
+ *
+ * servers list of UEB servers available for publishing
+ * topic the topic to publish to
+ * apiKey the api key (optional)
+ * apiSecret the api secret (optional)
+ * partitionId the partition key (optional, autogenerated if not provided)
+ * useHttps does connection use HTTPS?
+ * allowSelfSignedCerts are self-signed certificates allow
+ * @param busTopicParams contains attributes needed
* @throws IllegalArgumentException if invalid arguments are detected
*/
- public InlineUebTopicSink(List<String> servers, String topic, String apiKey, String apiSecret, String partitionId,
- boolean useHttps, boolean allowSelfSignedCerts) {
- super(servers, topic, apiKey, apiSecret, partitionId, useHttps, allowSelfSignedCerts);
+ public InlineUebTopicSink(BusTopicParams busTopicParams) {
+ super(busTopicParams);
}
/**
@@ -62,8 +63,14 @@ public class InlineUebTopicSink extends InlineBusTopicSink implements UebTopicSi
@Override
public void init() {
- this.publisher = new BusPublisher.CambriaPublisherWrapper(this.servers, this.topic, this.apiKey, this.apiSecret,
- null, null, this.useHttps, this.allowSelfSignedCerts);
+ this.publisher = new BusPublisher.CambriaPublisherWrapper(BusTopicParams.builder()
+ .servers(this.servers)
+ .topic(this.topic)
+ .apiKey(this.apiKey)
+ .apiSecret(this.apiSecret)
+ .useHttps(this.useHttps)
+ .allowSelfSignedCerts(this.allowSelfSignedCerts)
+ .build());
logger.info("{}: UEB SINK created", this);
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java
index 97ebbd50..400cbfe2 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java
@@ -3,6 +3,7 @@
* policy-endpoints
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +22,6 @@
package org.onap.policy.common.endpoints.event.comm.bus.internal;
import java.net.MalformedURLException;
-import java.util.List;
import java.util.UUID;
import org.onap.policy.common.endpoints.event.comm.FilterableTopicSource;
@@ -79,46 +79,35 @@ public abstract class SingleThreadedBusTopicSource extends BusTopicBase
/**
*
- * @param servers Bus servers
- * @param topic Bus Topic to be monitored
- * @param apiKey Bus API Key (optional)
- * @param apiSecret Bus API Secret (optional)
- * @param consumerGroup Bus Reader Consumer Group
- * @param consumerInstance Bus Reader Instance
- * @param fetchTimeout Bus fetch timeout
- * @param fetchLimit Bus fetch limit
- * @param useHttps does the bus use https
- * @param allowSelfSignedCerts are self-signed certificates allowed
- * @throws IllegalArgumentException An invalid parameter passed in
+ *
+ * @param busTopicParams@throws IllegalArgumentException An invalid parameter passed in
*/
- public SingleThreadedBusTopicSource(List<String> servers, String topic, String apiKey, String apiSecret,
- String consumerGroup, String consumerInstance, int fetchTimeout, int fetchLimit, boolean useHttps,
- boolean allowSelfSignedCerts) {
+ public SingleThreadedBusTopicSource(BusTopicParams busTopicParams) {
- super(servers, topic, apiKey, apiSecret, useHttps, allowSelfSignedCerts);
+ super(busTopicParams);
- if (consumerGroup == null || consumerGroup.isEmpty()) {
+ if (busTopicParams.isConsumerGroupNullOrEmpty()) {
this.consumerGroup = UUID.randomUUID().toString();
} else {
- this.consumerGroup = consumerGroup;
+ this.consumerGroup = busTopicParams.getConsumerGroup();
}
- if (consumerInstance == null || consumerInstance.isEmpty()) {
+ if (busTopicParams.isConsumerInstanceNullOrEmpty()) {
this.consumerInstance = NetworkUtil.getHostname();
} else {
- this.consumerInstance = consumerInstance;
+ this.consumerInstance = busTopicParams.getConsumerInstance();
}
- if (fetchTimeout <= 0) {
+ if (busTopicParams.getFetchTimeout() <= 0) {
this.fetchTimeout = NO_TIMEOUT_MS_FETCH;
} else {
- this.fetchTimeout = fetchTimeout;
+ this.fetchTimeout = busTopicParams.getFetchTimeout();
}
- if (fetchLimit <= 0) {
+ if (busTopicParams.getFetchLimit() <= 0) {
this.fetchLimit = NO_LIMIT_FETCH;
} else {
- this.fetchLimit = fetchLimit;
+ this.fetchLimit = busTopicParams.getFetchLimit();
}
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java
index 8ac41424..65f75aa5 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedDmaapTopicSource.java
@@ -3,6 +3,7 @@
* policy-endpoints
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +22,6 @@
package org.onap.policy.common.endpoints.event.comm.bus.internal;
import java.net.MalformedURLException;
-import java.util.List;
import java.util.Map;
import org.onap.policy.common.endpoints.event.comm.Topic;
@@ -52,81 +52,28 @@ public class SingleThreadedDmaapTopicSource extends SingleThreadedBusTopicSource
/**
*
- * @param servers DMaaP servers
- * @param topic DMaaP Topic to be monitored
- * @param apiKey DMaaP API Key (optional)
- * @param apiSecret DMaaP API Secret (optional)
- * @param consumerGroup DMaaP Reader Consumer Group
- * @param consumerInstance DMaaP Reader Instance
- * @param fetchTimeout DMaaP fetch timeout
- * @param fetchLimit DMaaP fetch limit
- * @param environment DME2 Environment
- * @param aftEnvironment DME2 AFT Environment
- * @param partner DME2 Partner
- * @param latitude DME2 Latitude
- * @param longitude DME2 Longitude
- * @param additionalProps Additional properties to pass to DME2
- * @param useHttps does connection use HTTPS?
- * @param allowSelfSignedCerts are self-signed certificates allow
- *
+ * @param busTopicParams Parameters object containing all the required inputs *
* @throws IllegalArgumentException An invalid parameter passed in
*/
- public SingleThreadedDmaapTopicSource(List<String> servers, String topic, String apiKey, String apiSecret,
- String userName, String password, String consumerGroup, String consumerInstance, int fetchTimeout,
- int fetchLimit, String environment, String aftEnvironment, String partner, String latitude,
- String longitude, Map<String, String> additionalProps, boolean useHttps, boolean allowSelfSignedCerts) {
-
- super(servers, topic, apiKey, apiSecret, consumerGroup, consumerInstance, fetchTimeout, fetchLimit, useHttps,
- allowSelfSignedCerts);
-
- this.userName = userName;
- this.password = password;
-
- this.environment = environment;
- this.aftEnvironment = aftEnvironment;
- this.partner = partner;
-
- this.latitude = latitude;
- this.longitude = longitude;
-
- this.additionalProps = additionalProps;
- try {
- this.init();
- } catch (Exception e) {
- logger.error("ERROR during init of topic {}", this.topic);
- throw new IllegalArgumentException(e);
- }
- }
+ public SingleThreadedDmaapTopicSource(BusTopicParams busTopicParams) {
- /**
- *
- * @param servers DMaaP servers
- * @param topic DMaaP Topic to be monitored
- * @param apiKey DMaaP API Key (optional)
- * @param apiSecret DMaaP API Secret (optional)
- * @param consumerGroup DMaaP Reader Consumer Group
- * @param consumerInstance DMaaP Reader Instance
- * @param fetchTimeout DMaaP fetch timeout
- * @param fetchLimit DMaaP fetch limit
- * @param useHttps does connection use HTTPS?
- * @param allowSelfSignedCerts are self-signed certificates allow
- * @throws IllegalArgumentException An invalid parameter passed in
- */
- public SingleThreadedDmaapTopicSource(List<String> servers, String topic, String apiKey, String apiSecret,
- String userName, String password, String consumerGroup, String consumerInstance, int fetchTimeout,
- int fetchLimit, boolean useHttps, boolean allowSelfSignedCerts) {
+ super(busTopicParams);
+ this.userName = busTopicParams.getUserName();
+ this.password = busTopicParams.getPassword();
- super(servers, topic, apiKey, apiSecret, consumerGroup, consumerInstance, fetchTimeout, fetchLimit, useHttps,
- allowSelfSignedCerts);
+ this.environment = busTopicParams.getEnvironment();
+ this.aftEnvironment = busTopicParams.getAftEnvironment();
+ this.partner = busTopicParams.getPartner();
- this.userName = userName;
- this.password = password;
+ this.latitude = busTopicParams.getLatitude();
+ this.longitude = busTopicParams.getLongitude();
+ this.additionalProps = busTopicParams.getAdditionalProps();
try {
this.init();
} catch (Exception e) {
- logger.warn("dmaap-source: cannot create topic {} because of {}", topic, e.getMessage(), e);
+ logger.error("ERROR during init in dmaap-source: cannot create topic {} because of {}", topic, e.getMessage(), e);
throw new IllegalArgumentException(e);
}
}
@@ -138,18 +85,52 @@ public class SingleThreadedDmaapTopicSource extends SingleThreadedBusTopicSource
@Override
public void init() throws MalformedURLException {
if (anyNullOrEmpty(this.userName, this.password)) {
- this.consumer = new BusConsumer.CambriaConsumerWrapper(this.servers, this.topic, this.apiKey,
- this.apiSecret, this.consumerGroup, this.consumerInstance, this.fetchTimeout, this.fetchLimit,
- this.useHttps, this.allowSelfSignedCerts);
+ this.consumer = new BusConsumer.CambriaConsumerWrapper(BusTopicParams.builder()
+ .servers(this.servers)
+ .topic(this.topic)
+ .apiKey(this.apiKey)
+ .apiSecret(this.apiSecret)
+ .consumerGroup(this.consumerGroup)
+ .consumerInstance(this.consumerInstance)
+ .fetchTimeout(this.fetchTimeout)
+ .fetchLimit(this.fetchLimit)
+ .useHttps(this.useHttps)
+ .allowSelfSignedCerts(this.allowSelfSignedCerts)
+ .build());
} else if (allNullOrEmpty(this.environment, this.aftEnvironment, this.latitude, this.longitude, this.partner)) {
- this.consumer = new BusConsumer.CambriaConsumerWrapper(this.servers, this.topic, this.apiKey,
- this.apiSecret, this.userName, this.password, this.consumerGroup, this.consumerInstance,
- this.fetchTimeout, this.fetchLimit, this.useHttps, this.allowSelfSignedCerts);
+ this.consumer = new BusConsumer.CambriaConsumerWrapper(BusTopicParams.builder()
+ .servers(this.servers)
+ .topic(this.topic)
+ .apiKey(this.apiKey)
+ .apiSecret(this.apiSecret)
+ .userName(this.userName)
+ .password(this.password)
+ .consumerGroup(this.consumerGroup)
+ .consumerInstance(this.consumerInstance)
+ .fetchTimeout(this.fetchTimeout)
+ .fetchLimit(this.fetchLimit)
+ .useHttps(this.useHttps)
+ .allowSelfSignedCerts(this.allowSelfSignedCerts)
+ .build());
} else {
- this.consumer = new BusConsumer.DmaapDmeConsumerWrapper(this.servers, this.topic, this.apiKey,
- this.apiSecret, this.userName, this.password, this.consumerGroup, this.consumerInstance,
- this.fetchTimeout, this.fetchLimit, this.environment, this.aftEnvironment, this.partner,
- this.latitude, this.longitude, this.additionalProps, this.useHttps);
+ this.consumer = new BusConsumer.DmaapDmeConsumerWrapper(BusTopicParams.builder()
+ .servers(this.servers)
+ .topic(this.topic)
+ .apiKey(this.apiKey)
+ .apiSecret(this.apiSecret)
+ .userName(this.userName)
+ .password(this.password)
+ .consumerGroup(this.consumerGroup)
+ .consumerInstance(this.consumerInstance)
+ .fetchTimeout(this.fetchTimeout)
+ .fetchLimit(this.fetchLimit)
+ .environment(this.environment)
+ .aftEnvironment(this.aftEnvironment)
+ .partner(this.partner)
+ .latitude(this.latitude)
+ .longitude(this.longitude)
+ .additionalProps(this.additionalProps)
+ .useHttps(this.useHttps).build());
}
logger.info("{}: INITTED", this);
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSource.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSource.java
index b7a20503..fb20ccc4 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSource.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedUebTopicSource.java
@@ -3,6 +3,7 @@
* policy-endpoints
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,8 +21,6 @@
package org.onap.policy.common.endpoints.event.comm.bus.internal;
-import java.util.List;
-
import org.onap.policy.common.endpoints.event.comm.Topic;
import org.onap.policy.common.endpoints.event.comm.bus.UebTopicSource;
@@ -32,30 +31,16 @@ import org.onap.policy.common.endpoints.event.comm.bus.UebTopicSource;
public class SingleThreadedUebTopicSource extends SingleThreadedBusTopicSource implements UebTopicSource {
/**
- *
- * @param servers UEB servers
- * @param topic UEB Topic to be monitored
- * @param apiKey UEB API Key (optional)
- * @param apiSecret UEB API Secret (optional)
- * @param consumerGroup UEB Reader Consumer Group
- * @param consumerInstance UEB Reader Instance
- * @param fetchTimeout UEB fetch timeout
- * @param fetchLimit UEB fetch limit
- * @param useHttps does topicSource use HTTPS?
- * @param allowSelfSignedCerts does topicSource allow self-signed certs?
- *
+ * @param busTopicParams Parameters object containing all the required inputs
* @throws IllegalArgumentException An invalid parameter passed in
*/
- public SingleThreadedUebTopicSource(List<String> servers, String topic, String apiKey, String apiSecret,
- String consumerGroup, String consumerInstance, int fetchTimeout, int fetchLimit, boolean useHttps,
- boolean allowSelfSignedCerts) {
+ public SingleThreadedUebTopicSource(BusTopicParams busTopicParams) {
- super(servers, topic, apiKey, apiSecret, consumerGroup, consumerInstance, fetchTimeout, fetchLimit, useHttps,
- allowSelfSignedCerts);
+ super(busTopicParams);
- this.allowSelfSignedCerts = allowSelfSignedCerts;
+ this.allowSelfSignedCerts = busTopicParams.isAllowSelfSignedCerts();
this.init();
}
@@ -65,9 +50,17 @@ public class SingleThreadedUebTopicSource extends SingleThreadedBusTopicSource i
*/
@Override
public void init() {
- this.consumer = new BusConsumer.CambriaConsumerWrapper(this.servers, this.topic, this.apiKey, this.apiSecret,
- this.consumerGroup, this.consumerInstance, this.fetchTimeout, this.fetchLimit, this.useHttps,
- this.allowSelfSignedCerts);
+ this.consumer = new BusConsumer.CambriaConsumerWrapper(BusTopicParams.builder()
+ .servers(this.servers)
+ .topic(this.topic)
+ .apiKey(this.apiKey)
+ .apiSecret(this.apiSecret)
+ .consumerGroup(this.consumerGroup)
+ .consumerInstance(this.consumerInstance)
+ .fetchTimeout(this.fetchTimeout)
+ .fetchLimit(this.fetchLimit)
+ .useHttps(this.useHttps)
+ .allowSelfSignedCerts(this.allowSelfSignedCerts).build());
}
/**
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java
index c1d1a353..a2dd948a 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * policy-endpoints
+ * ONAP
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -23,30 +23,38 @@ package org.onap.policy.common.endpoints.http.server;
import org.onap.policy.common.capabilities.Startable;
/**
- * A Jetty Server to server REST Requests
+ * Http Servlet Server interface
*/
public interface HttpServletServer extends Startable {
/**
- * factory for managing and tracking DMAAP sources
+ * Factory of Http Servlet Servers
*/
- public static HttpServletServerFactory factory = new IndexedHttpServletServerFactory();
+ HttpServletServerFactory factory = new IndexedHttpServletServerFactory();
/**
*
* @return port
*/
- public int getPort();
+ int getPort();
/**
* enables basic authentication with user and password on the the relative path relativeUriPath
*
- * @param user
- * @param password
- * @param relativeUriPath
+ * @param user user
+ * @param password password
+ * @param relativeUriPath relative path
*/
- public void setBasicAuthentication(String user, String password, String relativeUriPath);
+ void setBasicAuthentication(String user, String password, String relativeUriPath);
+
+ /**
+ * adds a filter at the specified path
+ *
+ * @param filterPath filter path
+ * @param filterClass filter class
+ */
+ void addFilterClass(String filterPath, String filterClass);
/**
* adds a JAX-RS servlet class to serve REST requests
@@ -57,7 +65,7 @@ public interface HttpServletServer extends Startable {
* @throws IllegalArgumentException unable to process because of invalid input
* @throws IllegalStateException unable to process because of invalid state
*/
- public void addServletClass(String servletPath, String restClass);
+ void addServletClass(String servletPath, String restClass);
/**
* adds a package containing JAX-RS classes to serve REST requests
@@ -68,7 +76,7 @@ public interface HttpServletServer extends Startable {
* @throws IllegalArgumentException unable to process because of invalid input
* @throws IllegalStateException unable to process because of invalid state
*/
- public void addServletPackage(String servletPath, String restPackage);
+ void addServletPackage(String servletPath, String restPackage);
/**
* blocking start of the http server
@@ -79,5 +87,5 @@ public interface HttpServletServer extends Startable {
* @throws IllegalArgumentException if arguments are invalid
* @throws InterruptedException if the blocking operation is interrupted
*/
- public boolean waitedStart(long maxWaitTime) throws InterruptedException;
+ boolean waitedStart(long maxWaitTime) throws InterruptedException;
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactory.java
index f09893b2..4a430b20 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactory.java
@@ -26,6 +26,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Properties;
+import org.onap.aaf.cadi.filter.CadiFilter;
import org.onap.policy.common.endpoints.http.server.internal.JettyJerseyServer;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.slf4j.Logger;
@@ -37,9 +38,10 @@ import org.slf4j.LoggerFactory;
public interface HttpServletServerFactory {
/**
- * builds an http server with support for servlets
+ * builds an http or https server with support for servlets
*
* @param name name
+ * @param https use secured http over tls connection
* @param host binding host
* @param port port
* @param contextPath server base path
@@ -48,17 +50,32 @@ public interface HttpServletServerFactory {
* @return http server
* @throws IllegalArgumentException when invalid parameters are provided
*/
- public HttpServletServer build(String name, String host, int port, String contextPath, boolean swagger,
+ HttpServletServer build(String name, boolean https, String host, int port, String contextPath, boolean swagger,
boolean managed);
/**
+ * builds an http server with support for servlets
+ *
+ * @param name name
+ * @param host binding host
+ * @param port port
+ * @param contextPath server base path
+ * @param swagger enable swagger documentation
+ * @param managed is it managed by infrastructure
+ * @return http server
+ * @throws IllegalArgumentException when invalid parameters are provided
+ */
+ HttpServletServer build(String name, String host, int port, String contextPath, boolean swagger,
+ boolean managed);
+
+ /**
* list of http servers per properties
*
* @param properties properties based configuration
* @return list of http servers
* @throws IllegalArgumentException when invalid parameters are provided
*/
- public List<HttpServletServer> build(Properties properties);
+ List<HttpServletServer> build(Properties properties);
/**
* gets a server based on the port
@@ -66,26 +83,26 @@ public interface HttpServletServerFactory {
* @param port port
* @return http server
*/
- public HttpServletServer get(int port);
+ HttpServletServer get(int port);
/**
* provides an inventory of servers
*
* @return inventory of servers
*/
- public List<HttpServletServer> inventory();
+ List<HttpServletServer> inventory();
/**
* destroys server bound to a port
*
* @param port
*/
- public void destroy(int port);
+ void destroy(int port);
/**
* destroys the factory and therefore all servers
*/
- public void destroy();
+ void destroy();
}
@@ -107,14 +124,14 @@ class IndexedHttpServletServerFactory implements HttpServletServerFactory {
protected HashMap<Integer, HttpServletServer> servers = new HashMap<>();
@Override
- public synchronized HttpServletServer build(String name, String host, int port, String contextPath, boolean swagger,
+ public synchronized HttpServletServer build(String name, boolean https, String host, int port, String contextPath, boolean swagger,
boolean managed) {
if (servers.containsKey(port)) {
return servers.get(port);
}
- JettyJerseyServer server = new JettyJerseyServer(name, host, port, contextPath, swagger);
+ JettyJerseyServer server = new JettyJerseyServer(name, https, host, port, contextPath, swagger);
if (managed) {
servers.put(port, server);
}
@@ -123,6 +140,13 @@ class IndexedHttpServletServerFactory implements HttpServletServerFactory {
}
@Override
+ public synchronized HttpServletServer build(String name, String host, int port, String contextPath,
+ boolean swagger, boolean managed) {
+ return build(name, false, host, port, contextPath, swagger, managed);
+ }
+
+
+ @Override
public synchronized List<HttpServletServer> build(Properties properties) {
ArrayList<HttpServletServer> serviceList = new ArrayList<>();
@@ -192,7 +216,21 @@ class IndexedHttpServletServerFactory implements HttpServletServerFactory {
swagger = Boolean.parseBoolean(swaggerString);
}
- HttpServletServer service = build(serviceName, hostName, servicePort, contextUriPath, swagger, managed);
+ String httpsString = properties.getProperty(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
+ + serviceName + PolicyEndPointProperties.PROPERTY_HTTP_HTTPS_SUFFIX);
+ boolean https = false;
+ if (httpsString != null && !httpsString.isEmpty()) {
+ https = Boolean.parseBoolean(httpsString);
+ }
+
+ String aafString = properties.getProperty(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
+ + serviceName + PolicyEndPointProperties.PROPERTY_AAF_SUFFIX);
+ boolean aaf = false;
+ if (aafString != null && !aafString.isEmpty()) {
+ aaf = Boolean.parseBoolean(httpsString);
+ }
+
+ HttpServletServer service = build(serviceName, https, hostName, servicePort, contextUriPath, swagger, managed);
if (userName != null && !userName.isEmpty() && password != null && !password.isEmpty()) {
service.setBasicAuthentication(userName, password, authUriPath);
}
@@ -211,6 +249,10 @@ class IndexedHttpServletServerFactory implements HttpServletServerFactory {
}
}
+ if (aaf) {
+ service.addFilterClass(contextUriPath, CadiFilter.class.getCanonicalName());
+ }
+
serviceList.add(service);
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java
index cd286927..9932d094 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java
@@ -104,6 +104,7 @@ public class JettyJerseyServer extends JettyServletServer {
* Constructor
*
* @param name name
+ * @param https enable https?
* @param host host server host
* @param port port server port
* @param swagger support swagger?
@@ -111,19 +112,19 @@ public class JettyJerseyServer extends JettyServletServer {
*
* @throws IllegalArgumentException in invalid arguments are provided
*/
- public JettyJerseyServer(String name, String host, int port, String contextPath, boolean swagger) {
+ public JettyJerseyServer(String name, boolean https, String host, int port, String contextPath, boolean swagger) {
- super(name, host, port, contextPath);
+ super(name, https, host, port, contextPath);
if (swagger) {
this.swaggerId = "swagger-" + this.port;
- attachSwaggerServlet();
+ attachSwaggerServlet(https);
}
}
/**
* attaches a swagger initialization servlet
*/
- protected void attachSwaggerServlet() {
+ protected void attachSwaggerServlet(boolean https) {
ServletHolder swaggerServlet = context.addServlet(JerseyJaxrsConfig.class, "/");
@@ -133,7 +134,7 @@ public class JettyJerseyServer extends JettyServletServer {
}
swaggerServlet.setInitParameter(SWAGGER_API_BASEPATH,
- "http://" + hostname + ":" + this.connector.getPort() + "/");
+ ((https) ? "https://" : "http://") + hostname + ":" + this.connector.getPort() + "/");
swaggerServlet.setInitParameter(SWAGGER_CONTEXT_ID, swaggerId);
swaggerServlet.setInitParameter(SWAGGER_SCANNER_ID, swaggerId);
swaggerServlet.setInitParameter(SWAGGER_PRETTY_PRINT, "true");
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java
index 97166ec7..b22a9401 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -22,16 +22,22 @@ package org.onap.policy.common.endpoints.http.server.internal;
import com.fasterxml.jackson.annotation.JsonIgnore;
+import java.util.EnumSet;
+import javax.servlet.DispatcherType;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.security.authentication.BasicAuthenticator;
+import org.eclipse.jetty.server.HttpConfiguration;
+import org.eclipse.jetty.server.HttpConnectionFactory;
+import org.eclipse.jetty.server.SecureRequestCustomizer;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.Slf4jRequestLog;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.security.Constraint;
import org.eclipse.jetty.util.security.Credential;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,6 +48,14 @@ import org.slf4j.LoggerFactory;
public abstract class JettyServletServer implements HttpServletServer, Runnable {
/**
+ * Keystore/Truststore system property names
+ */
+ public static final String SYSTEM_KEYSTORE_PROPERTY_NAME = "javax.net.ssl.keyStore";
+ public static final String SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME = "javax.net.ssl.keyStorePassword";
+ public static final String SYSTEM_TRUSTSTORE_PROPERTY_NAME = "javax.net.ssl.trustStore";
+ public static final String SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME = "javax.net.ssl.trustStorePassword";
+
+ /**
* Logger
*/
private static Logger logger = LoggerFactory.getLogger(JettyServletServer.class);
@@ -111,7 +125,7 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable
*
* @throws IllegalArgumentException if invalid parameters are passed in
*/
- public JettyServletServer(String name, String host, int port, String contextPath) {
+ public JettyServletServer(String name, boolean https, String host, int port, String contextPath) {
String srvName = name;
String srvHost = host;
String ctxtPath = contextPath;
@@ -120,7 +134,7 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable
srvName = "http-" + port;
}
- if (port <= 0 && port >= 65535) {
+ if (port <= 0 || port >= 65535) {
throw new IllegalArgumentException("Invalid Port provided: " + port);
}
@@ -145,7 +159,11 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable
this.jettyServer = new Server();
this.jettyServer.setRequestLog(new Slf4jRequestLog());
- this.connector = new ServerConnector(this.jettyServer);
+ if (https)
+ this.connector = httpsConnector();
+ else
+ this.connector = httpConnector();
+
this.connector.setName(srvName);
this.connector.setReuseAddress(true);
this.connector.setPort(port);
@@ -155,6 +173,56 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable
this.jettyServer.setHandler(context);
}
+ public JettyServletServer(String name, String host, int port, String contextPath) {
+ this(name, false, host, port, contextPath);
+ }
+
+ @Override
+ public void addFilterClass(String aFilterPath, String aFilterClass) {
+ if (aFilterClass == null || aFilterClass.isEmpty()) {
+ throw new IllegalArgumentException("No filter class provided");
+ }
+
+ String filterPath = aFilterPath;
+ if (aFilterPath == null || aFilterPath.isEmpty()) {
+ filterPath = "/*";
+ }
+
+ context.addFilter(aFilterClass, filterPath,
+ EnumSet.of(DispatcherType.INCLUDE, DispatcherType.REQUEST));
+ }
+
+ public ServerConnector httpsConnector() {
+ SslContextFactory sslContextFactory = new SslContextFactory();
+
+ String keyStore = System.getProperty(SYSTEM_KEYSTORE_PROPERTY_NAME);
+ if (keyStore != null) {
+ sslContextFactory.setKeyStorePath(keyStore);
+
+ String ksPassword = System.getProperty(SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME);
+ if (ksPassword != null)
+ sslContextFactory.setKeyStorePassword(ksPassword);
+ }
+
+ String trustStore = System.getProperty(SYSTEM_TRUSTSTORE_PROPERTY_NAME);
+ if (trustStore != null) {
+ sslContextFactory.setTrustStorePath(trustStore);
+
+ String tsPassword = System.getProperty(SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME);
+ if (tsPassword != null)
+ sslContextFactory.setTrustStorePassword(tsPassword);
+ }
+
+ HttpConfiguration https = new HttpConfiguration();
+ https.addCustomizer(new SecureRequestCustomizer());
+
+ return new ServerConnector(jettyServer, sslContextFactory, new HttpConnectionFactory(https));
+ }
+
+ public ServerConnector httpConnector() {
+ return new ServerConnector(this.jettyServer);
+ }
+
@Override
public void setBasicAuthentication(String user, String password, String servletPath) {
String srvltPath = servletPath;
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java
index 38f9b94d..bd8ea6f5 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java
@@ -24,77 +24,78 @@ public interface PolicyEndPointProperties {
/* Generic property suffixes */
- public static final String PROPERTY_TOPIC_SERVERS_SUFFIX = ".servers";
- public static final String PROPERTY_TOPIC_API_KEY_SUFFIX = ".apiKey";
- public static final String PROPERTY_TOPIC_API_SECRET_SUFFIX = ".apiSecret";
- public static final String PROPERTY_TOPIC_AAF_MECHID_SUFFIX = ".aafMechId";
- public static final String PROPERTY_TOPIC_AAF_PASSWORD_SUFFIX = ".aafPassword";
- public static final String PROPERTY_TOPIC_EVENTS_SUFFIX = ".events";
- public static final String PROPERTY_TOPIC_EVENTS_FILTER_SUFFIX = ".filter";
- public static final String PROPERTY_TOPIC_EVENTS_CUSTOM_MODEL_CODER_GSON_SUFFIX = ".events.custom.gson";
- public static final String PROPERTY_TOPIC_EVENTS_CUSTOM_MODEL_CODER_JACKSON_SUFFIX = ".events.custom.jackson";
-
- public static final String PROPERTY_TOPIC_SOURCE_CONSUMER_GROUP_SUFFIX = ".consumerGroup";
- public static final String PROPERTY_TOPIC_SOURCE_CONSUMER_INSTANCE_SUFFIX = ".consumerInstance";
- public static final String PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX = ".fetchTimeout";
- public static final String PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX = ".fetchLimit";
- public static final String PROPERTY_MANAGED_SUFFIX = ".managed";
-
- public static final String PROPERTY_TOPIC_SINK_PARTITION_KEY_SUFFIX = ".partitionKey";
-
- public static final String PROPERTY_ALLOW_SELF_SIGNED_CERTIFICATES_SUFFIX = ".selfSignedCertificates";
+ String PROPERTY_TOPIC_SERVERS_SUFFIX = ".servers";
+ String PROPERTY_TOPIC_API_KEY_SUFFIX = ".apiKey";
+ String PROPERTY_TOPIC_API_SECRET_SUFFIX = ".apiSecret";
+ String PROPERTY_TOPIC_AAF_MECHID_SUFFIX = ".aafMechId";
+ String PROPERTY_TOPIC_AAF_PASSWORD_SUFFIX = ".aafPassword";
+ String PROPERTY_TOPIC_EVENTS_SUFFIX = ".events";
+ String PROPERTY_TOPIC_EVENTS_FILTER_SUFFIX = ".filter";
+ String PROPERTY_TOPIC_EVENTS_CUSTOM_MODEL_CODER_GSON_SUFFIX = ".events.custom.gson";
+ String PROPERTY_TOPIC_EVENTS_CUSTOM_MODEL_CODER_JACKSON_SUFFIX = ".events.custom.jackson";
+
+ String PROPERTY_TOPIC_SOURCE_CONSUMER_GROUP_SUFFIX = ".consumerGroup";
+ String PROPERTY_TOPIC_SOURCE_CONSUMER_INSTANCE_SUFFIX = ".consumerInstance";
+ String PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX = ".fetchTimeout";
+ String PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX = ".fetchLimit";
+ String PROPERTY_MANAGED_SUFFIX = ".managed";
+ String PROPERTY_AAF_SUFFIX = ".aaf";
+
+ String PROPERTY_TOPIC_SINK_PARTITION_KEY_SUFFIX = ".partitionKey";
+
+ String PROPERTY_ALLOW_SELF_SIGNED_CERTIFICATES_SUFFIX = ".selfSignedCertificates";
/* UEB Properties */
- public static final String PROPERTY_UEB_SOURCE_TOPICS = "ueb.source.topics";
- public static final String PROPERTY_UEB_SINK_TOPICS = "ueb.sink.topics";
+ String PROPERTY_UEB_SOURCE_TOPICS = "ueb.source.topics";
+ String PROPERTY_UEB_SINK_TOPICS = "ueb.sink.topics";
/* DMAAP Properties */
- public static final String PROPERTY_DMAAP_SOURCE_TOPICS = "dmaap.source.topics";
- public static final String PROPERTY_DMAAP_SINK_TOPICS = "dmaap.sink.topics";
-
- public static final String PROPERTY_DMAAP_DME2_PARTNER_SUFFIX = ".dme2.partner";
- public static final String PROPERTY_DMAAP_DME2_ROUTE_OFFER_SUFFIX = ".dme2.routeOffer";
- public static final String PROPERTY_DMAAP_DME2_ENVIRONMENT_SUFFIX = ".dme2.environment";
- public static final String PROPERTY_DMAAP_DME2_AFT_ENVIRONMENT_SUFFIX = ".dme2.aft.environment";
- public static final String PROPERTY_DMAAP_DME2_LATITUDE_SUFFIX = ".dme2.latitude";
- public static final String PROPERTY_DMAAP_DME2_LONGITUDE_SUFFIX = ".dme2.longitude";
-
- public static final String PROPERTY_DMAAP_DME2_EP_READ_TIMEOUT_MS_SUFFIX = ".dme2.epReadTimeoutMs";
- public static final String PROPERTY_DMAAP_DME2_EP_CONN_TIMEOUT_SUFFIX = ".dme2.epConnTimeout";
- public static final String PROPERTY_DMAAP_DME2_ROUNDTRIP_TIMEOUT_MS_SUFFIX = ".dme2.roundtripTimeoutMs";
- public static final String PROPERTY_DMAAP_DME2_VERSION_SUFFIX = ".dme2.version";
- public static final String PROPERTY_DMAAP_DME2_SERVICE_NAME_SUFFIX = ".dme2.serviceName";
- public static final String PROPERTY_DMAAP_DME2_SUB_CONTEXT_PATH_SUFFIX = ".dme2.subContextPath";
- public static final String PROPERTY_DMAAP_DME2_SESSION_STICKINESS_REQUIRED_SUFFIX =
+ String PROPERTY_DMAAP_SOURCE_TOPICS = "dmaap.source.topics";
+ String PROPERTY_DMAAP_SINK_TOPICS = "dmaap.sink.topics";
+
+ String PROPERTY_DMAAP_DME2_PARTNER_SUFFIX = ".dme2.partner";
+ String PROPERTY_DMAAP_DME2_ROUTE_OFFER_SUFFIX = ".dme2.routeOffer";
+ String PROPERTY_DMAAP_DME2_ENVIRONMENT_SUFFIX = ".dme2.environment";
+ String PROPERTY_DMAAP_DME2_AFT_ENVIRONMENT_SUFFIX = ".dme2.aft.environment";
+ String PROPERTY_DMAAP_DME2_LATITUDE_SUFFIX = ".dme2.latitude";
+ String PROPERTY_DMAAP_DME2_LONGITUDE_SUFFIX = ".dme2.longitude";
+
+ String PROPERTY_DMAAP_DME2_EP_READ_TIMEOUT_MS_SUFFIX = ".dme2.epReadTimeoutMs";
+ String PROPERTY_DMAAP_DME2_EP_CONN_TIMEOUT_SUFFIX = ".dme2.epConnTimeout";
+ String PROPERTY_DMAAP_DME2_ROUNDTRIP_TIMEOUT_MS_SUFFIX = ".dme2.roundtripTimeoutMs";
+ String PROPERTY_DMAAP_DME2_VERSION_SUFFIX = ".dme2.version";
+ String PROPERTY_DMAAP_DME2_SERVICE_NAME_SUFFIX = ".dme2.serviceName";
+ String PROPERTY_DMAAP_DME2_SUB_CONTEXT_PATH_SUFFIX = ".dme2.subContextPath";
+ String PROPERTY_DMAAP_DME2_SESSION_STICKINESS_REQUIRED_SUFFIX =
".dme2.sessionStickinessRequired";
- public static final String PROPERTY_NOOP_SINK_TOPICS = "noop.sink.topics";
+ String PROPERTY_NOOP_SINK_TOPICS = "noop.sink.topics";
/* HTTP Server Properties */
- public static final String PROPERTY_HTTP_SERVER_SERVICES = "http.server.services";
+ String PROPERTY_HTTP_SERVER_SERVICES = "http.server.services";
- public static final String PROPERTY_HTTP_HOST_SUFFIX = ".host";
- public static final String PROPERTY_HTTP_PORT_SUFFIX = ".port";
- public static final String PROPERTY_HTTP_CONTEXT_URIPATH_SUFFIX = ".contextUriPath";
+ String PROPERTY_HTTP_HOST_SUFFIX = ".host";
+ String PROPERTY_HTTP_PORT_SUFFIX = ".port";
+ String PROPERTY_HTTP_CONTEXT_URIPATH_SUFFIX = ".contextUriPath";
- public static final String PROPERTY_HTTP_AUTH_USERNAME_SUFFIX = ".userName";
- public static final String PROPERTY_HTTP_AUTH_PASSWORD_SUFFIX = ".password";
- public static final String PROPERTY_HTTP_AUTH_URIPATH_SUFFIX = ".authUriPath";
+ String PROPERTY_HTTP_AUTH_USERNAME_SUFFIX = ".userName";
+ String PROPERTY_HTTP_AUTH_PASSWORD_SUFFIX = ".password";
+ String PROPERTY_HTTP_AUTH_URIPATH_SUFFIX = ".authUriPath";
- public static final String PROPERTY_HTTP_REST_CLASSES_SUFFIX = ".restClasses";
- public static final String PROPERTY_HTTP_REST_PACKAGES_SUFFIX = ".restPackages";
- public static final String PROPERTY_HTTP_REST_URIPATH_SUFFIX = ".restUriPath";
+ String PROPERTY_HTTP_REST_CLASSES_SUFFIX = ".restClasses";
+ String PROPERTY_HTTP_REST_PACKAGES_SUFFIX = ".restPackages";
+ String PROPERTY_HTTP_REST_URIPATH_SUFFIX = ".restUriPath";
- public static final String PROPERTY_HTTP_HTTPS_SUFFIX = ".https";
- public static final String PROPERTY_HTTP_SWAGGER_SUFFIX = ".swagger";
+ String PROPERTY_HTTP_HTTPS_SUFFIX = ".https";
+ String PROPERTY_HTTP_SWAGGER_SUFFIX = ".swagger";
/* HTTP Client Properties */
- public static final String PROPERTY_HTTP_CLIENT_SERVICES = "http.client.services";
+ String PROPERTY_HTTP_CLIENT_SERVICES = "http.client.services";
- public static final String PROPERTY_HTTP_URL_SUFFIX = PROPERTY_HTTP_CONTEXT_URIPATH_SUFFIX;
+ String PROPERTY_HTTP_URL_SUFFIX = PROPERTY_HTTP_CONTEXT_URIPATH_SUFFIX;
}
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java
index 08399e91..6ec9bc21 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java
@@ -1,8 +1,8 @@
/*-
* ============LICENSE_START=======================================================
- * policy-endpoints
+ * ONAP
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -23,6 +23,7 @@ package org.onap.policy.common.endpoints.http.server.test;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
+import java.util.HashMap;
import java.util.List;
import java.util.Properties;
@@ -33,20 +34,22 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.http.server.internal.JettyJerseyServer;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.common.utils.network.NetworkUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HttpClientTest {
+ private static final Logger logger = LoggerFactory.getLogger(HttpClientTest.class);
- private static Logger logger = LoggerFactory.getLogger(HttpClientTest.class);
+ private static final HashMap<String, String> savedValuesMap = new HashMap<>();
@BeforeClass
public static void setUp() throws InterruptedException, IOException {
logger.info("-- setup() --");
- /* echo server */
+ /* echo server - http + no auth */
final HttpServletServer echoServerNoAuth =
HttpServletServer.factory.build("echo", "localhost", 6666, "/", false, true);
@@ -57,10 +60,38 @@ public class HttpClientTest {
throw new IllegalStateException("cannot connect to port " + echoServerNoAuth.getPort());
}
- /* no auth echo server */
+ String keyStoreSystemProperty = System.getProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME);
+ if (keyStoreSystemProperty != null) {
+ savedValuesMap.put(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME, keyStoreSystemProperty);
+ }
+
+ String keyStorePasswordSystemProperty = System.getProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME);
+ if (keyStorePasswordSystemProperty != null) {
+ savedValuesMap.put(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME, keyStorePasswordSystemProperty);
+ }
+
+ String trustStoreSystemProperty = System.getProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME);
+ if (trustStoreSystemProperty != null) {
+ savedValuesMap
+ .put(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME, trustStoreSystemProperty);
+ }
+
+ String trustStorePasswordSystemProperty = System.getProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME);
+ if (trustStorePasswordSystemProperty != null) {
+ savedValuesMap
+ .put(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME, trustStorePasswordSystemProperty);
+ }
+
+ System.setProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME, "src/test/resources/keystore-test");
+ System.setProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME, "kstest");
+
+ System.setProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME, "src/test/resources/keystore-test");
+ System.setProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME, "kstest");
+
+ /* echo server - https + basic auth */
final HttpServletServer echoServerAuth =
- HttpServletServer.factory.build("echo", "localhost", 6667, "/", false, true);
+ HttpServletServer.factory.build("echo", true, "localhost", 6667, "/", false, true);
echoServerAuth.setBasicAuthentication("x", "y", null);
echoServerAuth.addServletPackage("/*", HttpClientTest.class.getPackage().getName());
echoServerAuth.waitedStart(5000);
@@ -76,6 +107,36 @@ public class HttpClientTest {
HttpServletServer.factory.destroy();
HttpClient.factory.destroy();
+
+ if (savedValuesMap.containsKey(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME)) {
+ System.setProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME, savedValuesMap.get(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME));
+ savedValuesMap.remove(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME);
+ } else {
+ System.clearProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME);
+ }
+
+ if (savedValuesMap.containsKey(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME)) {
+ System.setProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME, savedValuesMap.get(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME));
+ savedValuesMap.remove(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME);
+ } else {
+ System.clearProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME);
+ }
+
+ if (savedValuesMap.containsKey(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME)) {
+ System.setProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME, savedValuesMap.get(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME));
+ savedValuesMap.remove(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME);
+ } else {
+ System.clearProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME);
+ }
+
+ if (savedValuesMap.containsKey(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME)) {
+ System.setProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME, savedValuesMap.get(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME));
+ savedValuesMap.remove(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME);
+ } else {
+ System.clearProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME);
+ }
+
+
}
@Test
@@ -95,7 +156,7 @@ public class HttpClientTest {
public void testHttpAuthClient() throws Exception {
logger.info("-- testHttpAuthClient() --");
- final HttpClient client = HttpClient.factory.build("testHttpAuthClient", false, false, "localhost", 6667,
+ final HttpClient client = HttpClient.factory.build("testHttpAuthClient", true, true,"localhost", 6667,
"junit/echo", "x", "y", true);
final Response response = client.get("hello");
final String body = HttpClient.getBody(response, String.class);
@@ -108,7 +169,7 @@ public class HttpClientTest {
public void testHttpAuthClient401() throws Exception {
logger.info("-- testHttpAuthClient401() --");
- final HttpClient client = HttpClient.factory.build("testHttpAuthClient401", false, false, "localhost", 6667,
+ final HttpClient client = HttpClient.factory.build("testHttpAuthClient401", true, true, "localhost", 6667,
"junit/echo", null, null, true);
final Response response = client.get("hello");
assertTrue(response.getStatus() == 401);
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
index b6f0c0e8..d4c14a8a 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
@@ -1,8 +1,8 @@
/*-
* ============LICENSE_START=======================================================
- * policy-endpoints
+ * ONAP
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -20,6 +20,7 @@
package org.onap.policy.common.endpoints.http.server.test;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.BufferedReader;
@@ -51,6 +52,7 @@ public class HttpServerTest {
HttpServletServer server = HttpServletServer.factory.build("echo", "localhost", 5678, "/", false, true);
server.addServletPackage("/*", this.getClass().getPackage().getName());
+ server.addFilterClass("/*", TestFilter.class.getCanonicalName());
server.waitedStart(5000);
assertTrue(HttpServletServer.factory.get(5678).isAlive());
@@ -66,6 +68,9 @@ public class HttpServerTest {
}
assertTrue(response == null);
+ response = http(HttpServletServer.factory.get(5678), "http://localhost:5678/junit/echo/hello?block=true");
+ assertEquals("FILTERED", response);
+
assertTrue(HttpServletServer.factory.get(5678).isAlive());
assertTrue(HttpServletServer.factory.inventory().size() == 1);
@@ -77,7 +82,7 @@ public class HttpServerTest {
public void testMultipleServers() throws Exception {
logger.info("-- testMultipleServers() --");
- HttpServletServer server1 = HttpServletServer.factory.build("echo-1", "localhost", 5688, "/", true, true);
+ HttpServletServer server1 = HttpServletServer.factory.build("echo-1", false,"localhost", 5688, "/", true, true);
server1.addServletPackage("/*", this.getClass().getPackage().getName());
server1.waitedStart(5000);
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestFilter.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestFilter.java
new file mode 100644
index 00000000..5de96930
--- /dev/null
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestFilter.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2018 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.
+ * 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=========================================================
+ */
+package org.onap.policy.common.endpoints.http.server.test;
+
+import java.io.IOException;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+public class TestFilter implements Filter {
+
+ @Override
+ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
+ throws IOException, ServletException {
+
+ if (servletRequest.getParameter("block") != null) {
+ servletResponse.getWriter().write("FILTERED");
+ } else {
+ filterChain.doFilter(servletRequest, servletResponse);
+ }
+ }
+} \ No newline at end of file
diff --git a/policy-endpoints/src/test/resources/keystore-test b/policy-endpoints/src/test/resources/keystore-test
new file mode 100644
index 00000000..5820e0f0
--- /dev/null
+++ b/policy-endpoints/src/test/resources/keystore-test
Binary files differ