Extract HV VES Client ssl-related classes 89/77589/5
authorJakub Dudycz <jakub.dudycz@nokia.com>
Wed, 30 Jan 2019 14:58:36 +0000 (15:58 +0100)
committerJakub Dudycz <jakub.dudycz@nokia.com>
Thu, 31 Jan 2019 11:55:19 +0000 (12:55 +0100)
- Create common ssl module
- Extract ssl-related classes from HV VES Client module
- Mark org.onap.dcaegen2.services.sdk.rest.services.ssl.SslFactory
  class as deprecated

Change-Id: I31ef784e8822981ba541fb3f525f003218cd5c88
Signed-off-by: Jakub Dudycz <jakub.dudycz@nokia.com>
Issue-ID: DCAEGEN2-1135

15 files changed:
rest-services/common-dependency/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/ssl/SslFactory.java
security/pom.xml
security/ssl/pom.xml [new file with mode: 0644]
security/ssl/src/main/java/org/onap/dcaegen2/services/sdk/security/ssl/Password.java [moved from services/hv-ves-client/producer/api/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/api/options/Password.java with 95% similarity]
security/ssl/src/main/java/org/onap/dcaegen2/services/sdk/security/ssl/Passwords.java [moved from services/hv-ves-client/producer/api/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/api/options/Passwords.java with 97% similarity]
security/ssl/src/main/java/org/onap/dcaegen2/services/sdk/security/ssl/SecurityKeys.java [moved from services/hv-ves-client/producer/api/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/api/options/SecurityKeys.java with 93% similarity]
security/ssl/src/main/java/org/onap/dcaegen2/services/sdk/security/ssl/SslFactory.java [moved from services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/SslFactory.java with 86% similarity]
security/ssl/src/test/java/org/onap/dcaegen2/services/sdk/security/ssl/PasswordTest.java [moved from services/hv-ves-client/producer/api/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/api/options/PasswordTest.java with 97% similarity]
security/ssl/src/test/java/org/onap/dcaegen2/services/sdk/security/ssl/PasswordsTest.java [moved from services/hv-ves-client/producer/api/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/api/options/PasswordsTest.java with 95% similarity]
security/ssl/src/test/resources/password.txt [moved from services/hv-ves-client/producer/api/src/test/resources/password.txt with 100% similarity]
services/hv-ves-client/producer/api/pom.xml
services/hv-ves-client/producer/api/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/api/options/ProducerOptions.java
services/hv-ves-client/producer/ct/src/test/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/ct/SystemUnderTestWrapper.java
services/hv-ves-client/producer/impl/pom.xml
services/hv-ves-client/producer/impl/src/main/java/org/onap/dcaegen2/services/sdk/services/hvves/client/producer/impl/HvVesProducerFactoryImpl.java

index cce811c..92de660 100644 (file)
@@ -38,6 +38,10 @@ import java.nio.file.Paths;
 import java.security.GeneralSecurityException;
 import java.security.KeyStore;
 
+/**
+ * @deprecated org.onap.dcaegen2.services.sdk.security.ssl.SslFactory should be used instead
+ */
+@Deprecated
 public class SslFactory {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(SslFactory.class);
index 9c4412a..bcd93de 100644 (file)
@@ -21,6 +21,7 @@
 
   <modules>
     <module>crypt-password</module>
+    <module>ssl</module>
   </modules>
 
 </project>
\ No newline at end of file
diff --git a/security/ssl/pom.xml b/security/ssl/pom.xml
new file mode 100644 (file)
index 0000000..ecccd76
--- /dev/null
@@ -0,0 +1,48 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.onap.dcaegen2.services.sdk.security</groupId>
+    <artifactId>dcaegen2-services-sdk-security</artifactId>
+    <version>1.1.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>ssl</artifactId>
+  <version>1.1.1-SNAPSHOT</version>
+
+  <name>SSL</name>
+  <description>Common SSL-related Classes Library</description>
+  <packaging>jar</packaging>
+
+  <dependencies>
+    <dependency>
+      <groupId>io.projectreactor.netty</groupId>
+      <artifactId>reactor-netty</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.immutables</groupId>
+      <artifactId>value</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.vavr</groupId>
+      <artifactId>vavr</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jetbrains</groupId>
+      <artifactId>annotations</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-engine</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.assertj</groupId>
+      <artifactId>assertj-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>
\ No newline at end of file
  * ============LICENSE_END=====================================
  */
 
-package org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.options;
+package org.onap.dcaegen2.services.sdk.security.ssl;
 
 import io.vavr.CheckedFunction1;
 import io.vavr.Function1;
 import io.vavr.control.Try;
-import java.io.IOException;
 import java.security.GeneralSecurityException;
 import java.util.Arrays;
 import org.jetbrains.annotations.NotNull;
  * ============LICENSE_END=====================================
  */
 
-package org.onap.dcaegen2.services.sdk.services.hvves.client.producer.impl;
+package org.onap.dcaegen2.services.sdk.security.ssl;
 
 import io.netty.handler.ssl.SslContext;
 import io.netty.handler.ssl.SslContextBuilder;
-import io.vavr.Tuple;
+import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
 import io.vavr.control.Try;
 import java.io.IOException;
 import java.nio.file.Files;
@@ -32,12 +32,7 @@ import java.security.GeneralSecurityException;
 import java.security.KeyStore;
 import javax.net.ssl.KeyManagerFactory;
 import javax.net.ssl.TrustManagerFactory;
-import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.options.Password;
-import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.options.SecurityKeys;
 
-/*
- * TODO: To be merged with org.onap.dcaegen2.services.sdk.rest.services.ssl.SslFactory
- */
 public class SslFactory {
 
     /**
@@ -80,4 +75,15 @@ public class SslFactory {
         ks.load(Files.newInputStream(path, StandardOpenOption.READ), keyStorePassword);
         return ks;
     }
-}
\ No newline at end of file
+
+    /**
+     * Function for creating insecure ssl context.
+     *
+     * @return configured insecure ssl context
+     */
+    public Try<SslContext> createInsecureContext() {
+        return Try.success(SslContextBuilder.forClient())
+            .map(ctx -> ctx.trustManager(InsecureTrustManagerFactory.INSTANCE))
+            .mapTry(SslContextBuilder::build);
+    }
+}
  * ============LICENSE_END=====================================
  */
 
-package org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.options;
+package org.onap.dcaegen2.services.sdk.security.ssl;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Fail.fail;
 
 import io.vavr.control.Try;
 import java.io.File;
index 1804b16..882ac1c 100644 (file)
@@ -34,7 +34,6 @@
     <version>1.1.1-SNAPSHOT</version>
 
     <name>High Volume VES Collector Client :: Producer :: API</name>
-    <description></description>
     <packaging>jar</packaging>
 
     <dependencies>
             <version>${project.parent.version}</version>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>org.onap.dcaegen2.services.sdk.security</groupId>
+            <artifactId>ssl</artifactId>
+            <version>1.1.1-SNAPSHOT</version>
+        </dependency>
         <dependency>
             <groupId>org.reactivestreams</groupId>
             <artifactId>reactive-streams</artifactId>
index aead525..921db52 100644 (file)
@@ -24,6 +24,7 @@ import java.net.InetSocketAddress;
 import org.immutables.value.Value;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
+import org.onap.dcaegen2.services.sdk.security.ssl.SecurityKeys;
 
 /**
  * @author <a href="mailto:piotr.jaszczyk@nokia.com">Piotr Jaszczyk</a>
@@ -43,7 +44,6 @@ public interface ProducerOptions {
 
     /**
      * Security keys definition used when connecting to the collector.
-
      *
      * @return security keys definition or null when plain TCP sockets are to be used.
      * @since 1.1.1
index 2cc2c0b..ddc87bc 100644 (file)
@@ -26,12 +26,12 @@ import java.net.InetSocketAddress;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.time.Duration;
+import org.onap.dcaegen2.services.sdk.security.ssl.ImmutableSecurityKeys;
+import org.onap.dcaegen2.services.sdk.security.ssl.Passwords;
 import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.HvVesProducer;
 import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.HvVesProducerFactory;
 import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.options.ImmutableProducerOptions;
 import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.options.ImmutableProducerOptions.Builder;
-import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.options.ImmutableSecurityKeys;
-import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.options.Passwords;
 import org.onap.ves.VesEventOuterClass.VesEvent;
 import reactor.core.publisher.Flux;
 
index b099b31..38b2360 100644 (file)
@@ -34,7 +34,6 @@
   <version>1.1.1-SNAPSHOT</version>
 
   <name>High Volume VES Collector Client :: Producer :: Implementation</name>
-  <description></description>
   <packaging>jar</packaging>
 
   <dependencies>
index cf656ad..ab10088 100644 (file)
@@ -21,6 +21,7 @@ package org.onap.dcaegen2.services.sdk.services.hvves.client.producer.impl;
 
 import io.netty.handler.ssl.SslContext;
 import org.jetbrains.annotations.NotNull;
+import org.onap.dcaegen2.services.sdk.security.ssl.SslFactory;
 import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.HvVesProducer;
 import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.HvVesProducerFactory;
 import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.options.ProducerOptions;