Convert transport-tls to a JPMS module 86/113986/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 15 Oct 2024 10:29:33 +0000 (12:29 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 15 Oct 2024 10:29:33 +0000 (12:29 +0200)
Now that we do not have generated code here, we can switch to being a
JPMS module, properly encapsulating our internals.

Change-Id: Ib8c06203408f53b40db996b868329ae928dd1745
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
transport/transport-tls/pom.xml
transport/transport-tls/src/main/java/module-info.java [new file with mode: 0644]
transport/transport-tls/src/main/java/org/opendaylight/netconf/transport/tls/KeyStoreUtils.java
transport/transport-tls/src/main/java/org/opendaylight/netconf/transport/tls/SslHandlerFactory.java
transport/transport-tls/src/main/java/org/opendaylight/netconf/transport/tls/impl/IetfTlsClientFeatureProvider.java [moved from transport/transport-tls/src/main/java/org/opendaylight/netconf/transport/tls/IetfTlsClientFeatureProvider.java with 96% similarity]
transport/transport-tls/src/main/java/org/opendaylight/netconf/transport/tls/impl/IetfTlsCommonFeatureProvider.java [moved from transport/transport-tls/src/main/java/org/opendaylight/netconf/transport/tls/IetfTlsCommonFeatureProvider.java with 93% similarity]
transport/transport-tls/src/main/java/org/opendaylight/netconf/transport/tls/impl/IetfTlsServerFeatureProvider.java [moved from transport/transport-tls/src/main/java/org/opendaylight/netconf/transport/tls/IetfTlsServerFeatureProvider.java with 97% similarity]
transport/transport-tls/src/main/java/org/opendaylight/netconf/transport/tls/package-info.java

index 533ca039d03cbd90482d46fee2ff287ab08aece4..c7a087a5c8770deacacde18fa343c2e4d20efe3e 100644 (file)
 
     <parent>
         <groupId>org.opendaylight.netconf</groupId>
-        <artifactId>netconf-parent</artifactId>
+        <artifactId>bnd-parent</artifactId>
         <version>8.0.3-SNAPSHOT</version>
-        <relativePath>../../parent</relativePath>
+        <relativePath>../../bnd-parent</relativePath>
     </parent>
 
     <artifactId>transport-tls</artifactId>
     <name>${project.artifactId}</name>
-    <packaging>bundle</packaging>
+    <packaging>jar</packaging>
     <description>NETCONF TLS transport</description>
 
-    <properties>
-        <odlparent.dependency.enforce>true</odlparent.dependency.enforce>
-    </properties>
-
     <dependencies>
         <dependency>
             <groupId>com.google.guava</groupId>
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>binding-spec</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-common</artifactId>
+            <!-- yeah... not quite ... but this works -->
+            <scope>provided</scope>
+        </dependency>
 
         <!-- testing -->
         <dependency>
             <classifier>linux-x86_64</classifier>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>yang-common</artifactId>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
             <artifactId>rfc6991-ietf-inet-types</artifactId>
diff --git a/transport/transport-tls/src/main/java/module-info.java b/transport/transport-tls/src/main/java/module-info.java
new file mode 100644 (file)
index 0000000..5e85599
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2024 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+module org.opendaylight.netconf.transport.tls {
+    exports org.opendaylight.netconf.transport.tls;
+
+    provides org.opendaylight.yangtools.binding.meta.YangFeatureProvider with
+        org.opendaylight.netconf.transport.tls.impl.IetfTlsClientFeatureProvider,
+        org.opendaylight.netconf.transport.tls.impl.IetfTlsCommonFeatureProvider,
+        org.opendaylight.netconf.transport.tls.impl.IetfTlsServerFeatureProvider;
+
+    requires transitive io.netty.handler;
+    requires transitive org.opendaylight.netconf.transport.api;
+    requires transitive org.opendaylight.yang.gen.ietf.tcp.client.rfc9643;
+    requires transitive org.opendaylight.yang.gen.ietf.tcp.server.rfc9643;
+    requires transitive org.opendaylight.yang.gen.ietf.tls.client.rfc9645;
+    requires transitive org.opendaylight.yang.gen.ietf.tls.server.rfc9645;
+    requires com.google.common;
+    requires io.netty.buffer;
+    requires io.netty.transport;
+    requires org.bouncycastle.provider;
+    requires org.opendaylight.netconf.transport.tcp;
+    requires org.opendaylight.yang.gen.iana.tls.cipher.suite.algs;
+    requires org.opendaylight.yang.gen.ietf.crypto.types.rfc9640;
+    requires org.opendaylight.yang.gen.ietf.keystore.rfc9642;
+    requires org.opendaylight.yang.gen.ietf.tls.common.rfc9645;
+    requires org.opendaylight.yang.gen.ietf.truststore.rfc9641;
+    requires org.opendaylight.yangtools.binding.spec;
+    requires org.slf4j;
+
+    // Annotation-only dependencies
+    requires static transitive org.eclipse.jdt.annotation;
+    requires static org.kohsuke.metainf_services;
+    requires static org.osgi.annotation.bundle;
+}
index bebfad935b1548a210b4a28e4cb393558ee45907..2b42617478d2c0d64bbc25c725063a08ce301529 100644 (file)
@@ -89,8 +89,7 @@ final class KeyStoreUtils {
      * @throws CertificateException if certificate error occurs
      * @throws IOException if input read error occurs
      */
-    static Certificate buildX509Certificate(final byte[] bytes)
-            throws CertificateException, IOException {
+    static Certificate buildX509Certificate(final byte[] bytes) throws CertificateException, IOException {
         try (var in = new ByteArrayInputStream(bytes)) {
             return CertificateFactory.getInstance("X.509").generateCertificate(in);
         }
index 419302cc06e18cc19cf8db6a45693487b5763c10..501c57e4439f10935cb1d781e3eb0ef78000d12f 100644 (file)
@@ -32,6 +32,7 @@ import javax.net.ssl.TrustManagerFactory;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.netconf.transport.api.UnsupportedConfigurationException;
+import org.opendaylight.netconf.transport.tls.impl.IetfTlsCommonFeatureProvider;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.tls.cipher.suite.algs.rev240316.TlsCipherSuiteAlgorithm;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.keystore.rev241010.InlineOrKeystoreAsymmetricKeyGrouping;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.keystore.rev241010.InlineOrKeystoreEndEntityCertWithKeyGrouping;
@@ -5,7 +5,7 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.netconf.transport.tls;
+package org.opendaylight.netconf.transport.tls.impl;
 
 import java.util.Set;
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -5,7 +5,7 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.netconf.transport.tls;
+package org.opendaylight.netconf.transport.tls.impl;
 
 import java.util.Map;
 import java.util.Set;
@@ -42,7 +42,7 @@ public final class IetfTlsCommonFeatureProvider implements YangFeatureProvider<I
         return Set.of(HelloParams.VALUE, Tls12$F.VALUE, Tls13$F.VALUE);
     }
 
-    static @Nullable String algorithmNameOf(final TlsVersionBase version) {
+    public static @Nullable String algorithmNameOf(final TlsVersionBase version) {
         return TLS_VERSIONS.get(version);
     }
 }
@@ -5,7 +5,7 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.netconf.transport.tls;
+package org.opendaylight.netconf.transport.tls.impl;
 
 import java.util.Set;
 import org.eclipse.jdt.annotation.NonNullByDefault;
index 8352857381f9e71d80bcb705c86fdc432ff06064..7073f50c0a6658adf3147996dc858f1c776ac644 100644 (file)
@@ -7,7 +7,7 @@
  */
 /**
  * NETCONF Secure Transport over TLS, as detailed in <a href="https://www.rfc-editor.org/rfc/rfc7589">RFC7589</a>.
- * Configuration follows <a href="https://datatracker.ietf.org/doc/html/draft-ietf-netconf-tls-client-server-29">
- * draft-ietf-netconf-tls-client-server</a>.
+ * Configuration follows <a href="https://www.rfc-editor.org/rfc/rfc9645">RFC9645</a>.
  */
+@org.osgi.annotation.bundle.Export
 package org.opendaylight.netconf.transport.tls;
\ No newline at end of file