Change HTTP Requests into HTTPS Ones 75/34175/1
authorShiwei Tian <tian.shiwei@zte.com.cn>
Tue, 6 Mar 2018 02:01:38 +0000 (10:01 +0800)
committerShiwei Tian <tian.shiwei@zte.com.cn>
Tue, 6 Mar 2018 02:01:38 +0000 (10:01 +0800)
Issue-ID: HOLMES-104

Change-Id: I535050f7dcacc2caa75d9a8941d93000fd91c361
Signed-off-by: Shiwei Tian <tian.shiwei@zte.com.cn>
engine-d-standalone/src/main/assembly/bin/run.sh
engine-d-standalone/src/main/assembly/conf/engine-d.yml
engine-d-standalone/src/main/assembly/conf/holmes.keystore [new file with mode: 0644]
engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java
engine-d/src/main/java/org/onap/holmes/engine/request/CompileRuleRequest.java
engine-d/src/main/java/org/onap/holmes/engine/request/DeployRuleRequest.java
engine-d/src/main/java/org/onap/holmes/engine/resources/DmaapConfigurationService.java
engine-d/src/main/java/org/onap/holmes/engine/resources/EngineResources.java
engine-d/src/main/java/org/onap/holmes/engine/response/CorrelationRuleResponse.java
pom.xml

index dab4cbc..d3d5348 100644 (file)
@@ -70,6 +70,13 @@ fi
 #ActiveMQ IP Configurations
 sed -i "s|brokerIp:.*|brokerIp: $SERVICE_IP|" "$main_path/conf/engine-d.yml"
 
+KEY_PATH="$main_path/conf/holmes.keystore"
+KEY_PASSWORD="holmes"
+
+#HTTPS Configurations
+sed -i "s|keyStorePath:.*|keyStorePath: $KEY_PATH|" "$main_path/conf/engine-d.yml"
+sed -i "s|keyStorePassword:.*|keyStorePassword: $KEY_PASSWORD|" "$main_path/conf/engine-d.yml"
+
 cat "$main_path/conf/engine-d.yml"
 
 
index ff3201b..c5a750a 100644 (file)
@@ -19,8 +19,12 @@ server:
   applicationContextPath: /\r
   adminContextPath: /admin\r
   connector:\r
-    type: http\r
+    type: https\r
     port: 9102\r
+    keyStorePath: /home/holmes/conf/holmes.keystore\r
+    keyStorePassword: holmes\r
+    validateCerts: false\r
+    validatePeers: false\r
 \r
 \r
 # Logging settings.\r
diff --git a/engine-d-standalone/src/main/assembly/conf/holmes.keystore b/engine-d-standalone/src/main/assembly/conf/holmes.keystore
new file mode 100644 (file)
index 0000000..a6266bb
Binary files /dev/null and b/engine-d-standalone/src/main/assembly/conf/holmes.keystore differ
index 4f5593c..0e7acac 100644 (file)
@@ -62,6 +62,7 @@ public class EngineDActiveApp extends IOCApplication<EngineDAppConfig> {
         msinfo.setUrl("/api/holmes-engine-mgmt/v1");
         msinfo.setProtocol("REST");
         msinfo.setVisualRange("0|1");
+        msinfo.setEnable_ssl(true);
         Set<Node> nodes = new HashSet<>();
         Node node = new Node();
         node.setIp(serviceAddrInfo[0]);
index 6e0da48..8af9778 100644 (file)
@@ -24,7 +24,6 @@ import lombok.Setter;
 @Setter
 public class CompileRuleRequest {
 
-    @JsonProperty(value = "content")
     @NotNull
     private String content;
 }
\ No newline at end of file
index 74ddf67..f2ef369 100644 (file)
@@ -15,7 +15,6 @@
  */
 package org.onap.holmes.engine.request;
 
-import com.fasterxml.jackson.annotation.JsonProperty;
 import javax.validation.constraints.NotNull;
 import lombok.Getter;
 import lombok.Setter;
@@ -24,14 +23,11 @@ import lombok.Setter;
 @Setter
 public class DeployRuleRequest {
 
-    @JsonProperty(value = "content")
     @NotNull
     private String content;
 
-    @JsonProperty(value = "engineid")
     private String engineId;
 
-    @JsonProperty(value = "loopcontrolname")
     @NotNull
     private String loopControlName;
 }
index 99567b8..548b9b2 100644 (file)
@@ -50,7 +50,7 @@ public class DmaapConfigurationService {
                     + " and <b>url</b>. Both fields are required.") DmaapConfigRequest config,
             @Context HttpServletRequest request){
         String url = config.getUrl();
-        if (url.startsWith("http://")) {
+        if (url.startsWith("http://") || url.startsWith("https://")) {
             Subscriber subscriber = new Subscriber();
             subscriber.setTopic(config.getName());
             subscriber.setUrl(url);
@@ -64,7 +64,7 @@ public class DmaapConfigurationService {
 
             return "{\"message\": \"Succeeded!\", \"topic\": \"" + config.getName() + "\"}";
         }
-        return "{\"message\": \"Only the HTTP protocol is supported!\"}";
+        return "{\"message\": \"Only the HTTP or HTTPS protocol is supported!\"}";
     }
 
     @DELETE
@@ -92,7 +92,7 @@ public class DmaapConfigurationService {
                 + " and <b>url</b>. Both fields are required.") DmaapConfigRequest config,
             @Context HttpServletRequest request){
         String url = config.getUrl();
-        if (url.startsWith("http://")) {
+        if (url.startsWith("http://") || url.startsWith("https://")) {
             SecurityInfo securityInfo = new SecurityInfo();
             SecurityInfo.DmaapInfo dmaapInfo = new SecurityInfo().new DmaapInfo();
             dmaapInfo.setTopicUrl(config.getUrl());
@@ -100,6 +100,6 @@ public class DmaapConfigurationService {
             DcaeConfigurationsCache.addPubSecInfo(config.getName(), securityInfo);
             return "{\"message\": \"Succeeded!\", \"topic\": \"" + config.getName() + "\"}";
         }
-        return "{\"message\": \"Only the HTTP protocol is supported!\"}";
+        return "{\"message\": \"Only the HTTP or HTTPS protocol is supported!\"}";
     }
 }
index b4cb0b1..b9875da 100644 (file)
@@ -61,8 +61,8 @@ public class EngineResources {
     @Timed
     public CorrelationRuleResponse deployRule(
             @ApiParam(value = "The request entity of the HTTP call, which comprises three "
-                    + "fields: \"content\" , \"loopcontrolname\" and \"engineid\". "
-                    + "The \"content\" should be a valid Drools rule string and the \"engineid\" "
+                    + "fields: \"content\" , \"loopControlName\" and \"engineId\". "
+                    + "The \"content\" should be a valid Drools rule string and the \"engineId\" "
                     + "has to be \"engine-d\" in the Amsterdam release.", required = true) DeployRuleRequest deployRuleRequest,
             @Context HttpServletRequest httpRequest) {
 
index b234f91..306bd7f 100644 (file)
@@ -15,7 +15,6 @@
  */
 package org.onap.holmes.engine.response;
 
-import com.fasterxml.jackson.annotation.JsonProperty;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -23,6 +22,5 @@ import lombok.Setter;
 @Setter
 public class CorrelationRuleResponse {
 
-    @JsonProperty(value = "package")
     private String packageName;
 }
diff --git a/pom.xml b/pom.xml
index 0a0caa1..68f7a01 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -75,7 +75,7 @@
             <dependency>
                 <groupId>org.onap.msb.java-sdk</groupId>
                 <artifactId>msb-java-sdk</artifactId>
-                <version>1.0.0</version>
+                <version>1.1.0-SNAPSHOT</version>
             </dependency>
             <dependency>
                 <groupId>org.reflections</groupId>