Revert "Bug 5377: Support configuring cipher suites to use for SSLEngine"
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / yang / gen / v1 / urn / opendaylight / params / xml / ns / yang / openflow / _switch / connection / provider / impl / rev140328 / SwitchConnectionProviderModule.java
index 6dbdef09b37381c6824ecf9239ab0a0695b054d3..6077c787017ae0e26376fea066764f7641c3cb0f 100644 (file)
@@ -9,12 +9,16 @@
 */
 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328;
 
+import com.google.common.base.MoreObjects;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
-
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration;
-import org.opendaylight.openflowjava.protocol.impl.connection.SwitchConnectionProviderImpl;
+import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration;
+import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration;
+import org.opendaylight.openflowjava.protocol.impl.core.SwitchConnectionProviderImpl;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -23,7 +27,7 @@ import org.slf4j.LoggerFactory;
 */
 public final class SwitchConnectionProviderModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.provider.impl.rev140328.AbstractSwitchConnectionProviderModule
  {
-    
+
     private static Logger LOG = LoggerFactory
             .getLogger(SwitchConnectionProviderModule.class);
 
@@ -31,7 +35,7 @@ public final class SwitchConnectionProviderModule extends org.opendaylight.yang.
      * @param identifier
      * @param dependencyResolver
      */
-    public SwitchConnectionProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+    public SwitchConnectionProviderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
     }
 
@@ -41,8 +45,8 @@ public final class SwitchConnectionProviderModule extends org.opendaylight.yang.
      * @param oldModule
      * @param oldInstance
      */
-    public SwitchConnectionProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
-            SwitchConnectionProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
+    public SwitchConnectionProviderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+            final SwitchConnectionProviderModule oldModule, final java.lang.AutoCloseable oldInstance) {
         super(identifier, dependencyResolver, oldModule, oldInstance);
     }
 
@@ -54,25 +58,29 @@ public final class SwitchConnectionProviderModule extends org.opendaylight.yang.
     @Override
     public java.lang.AutoCloseable createInstance() {
         LOG.info("SwitchConnectionProvider started.");
-        SwitchConnectionProviderImpl switchConnectionProviderImpl = new SwitchConnectionProviderImpl();
+        final SwitchConnectionProviderImpl switchConnectionProviderImpl = new SwitchConnectionProviderImpl();
         try {
-            ConnectionConfiguration connConfiguration = createConnectionConfiguration();
+            final ConnectionConfiguration connConfiguration = createConnectionConfiguration();
             switchConnectionProviderImpl.setConfiguration(connConfiguration);
-        } catch (UnknownHostException e) {
+        } catch (final UnknownHostException e) {
             throw new IllegalArgumentException(e.getMessage(), e);
         }
         return switchConnectionProviderImpl;
     }
 
     /**
-     * @return
-     * @throws UnknownHostException 
+     * @return instance configuration object
+     * @throws UnknownHostException
      */
     private ConnectionConfiguration createConnectionConfiguration() throws UnknownHostException {
         final InetAddress address = extractIpAddressBin(getAddress());
         final Integer port = getPort();
         final long switchIdleTimeout = getSwitchIdleTimeout();
-        
+        final Tls tlsConfig = getTls();
+        final Threads threads = getThreads();
+        final Boolean useBarrier = getUseBarrier();
+        final TransportProtocol transportProtocol = getTransportProtocol();
+
         return new ConnectionConfiguration() {
             @Override
             public InetAddress getAddress() {
@@ -84,13 +92,51 @@ public final class SwitchConnectionProviderModule extends org.opendaylight.yang.
             }
             @Override
             public Object getTransferProtocol() {
-                // TODO Auto-generated method stub
-                return null;
+                return transportProtocol;
             }
             @Override
-            public FEATURE_SUPPORT getTlsSupport() {
-                // TODO Auto-generated method stub
-                return null;
+            public TlsConfiguration getTlsConfiguration() {
+                if (tlsConfig == null || !(TransportProtocol.TLS.equals(transportProtocol))) {
+                    return null;
+                }
+                return new TlsConfiguration() {
+                    @Override
+                    public KeystoreType getTlsTruststoreType() {
+                        return MoreObjects.firstNonNull(tlsConfig.getTruststoreType(), null);
+                    }
+                    @Override
+                    public String getTlsTruststore() {
+                        return MoreObjects.firstNonNull(tlsConfig.getTruststore(), null);
+                    }
+                    @Override
+                    public KeystoreType getTlsKeystoreType() {
+                        return MoreObjects.firstNonNull(tlsConfig.getKeystoreType(), null);
+                    }
+                    @Override
+                    public String getTlsKeystore() {
+                        return MoreObjects.firstNonNull(tlsConfig.getKeystore(), null);
+                    }
+                    @Override
+                    public org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType getTlsKeystorePathType() {
+                        return MoreObjects.firstNonNull(tlsConfig.getKeystorePathType(), null);
+                    }
+                    @Override
+                    public org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType getTlsTruststorePathType() {
+                        return MoreObjects.firstNonNull(tlsConfig.getTruststorePathType(), null);
+                    }
+                    @Override
+                    public String getKeystorePassword() {
+                        return MoreObjects.firstNonNull(tlsConfig.getKeystorePassword(), null);
+                    }
+                    @Override
+                    public String getCertificatePassword() {
+                        return MoreObjects.firstNonNull(tlsConfig.getCertificatePassword(), null);
+                    }
+                    @Override
+                    public String getTruststorePassword() {
+                        return MoreObjects.firstNonNull(tlsConfig.getTruststorePassword(), null);
+                    }
+                };
             }
             @Override
             public long getSwitchIdleTimeout() {
@@ -101,15 +147,38 @@ public final class SwitchConnectionProviderModule extends org.opendaylight.yang.
                 // TODO Auto-generated method stub
                 return null;
             }
+            @Override
+            public ThreadConfiguration getThreadConfiguration() {
+                if (threads == null) {
+                    return null;
+                }
+                return new ThreadConfiguration() {
+
+                    @Override
+                    public int getWorkerThreadCount() {
+                        return threads.getWorkerThreads();
+                    }
+
+                    @Override
+                    public int getBossThreadCount() {
+                        return threads.getBossThreads();
+                    }
+                };
+            }
+
+            @Override
+            public boolean useBarrier() {
+                return useBarrier;
+            }
         };
     }
 
     /**
      * @param address
      * @return
-     * @throws UnknownHostException 
+     * @throws UnknownHostException
      */
-    private static InetAddress extractIpAddressBin(IpAddress address) throws UnknownHostException {
+    private static InetAddress extractIpAddressBin(final IpAddress address) throws UnknownHostException {
         byte[] addressBin = null;
         if (address != null) {
             if (address.getIpv4Address() != null) {
@@ -118,7 +187,7 @@ public final class SwitchConnectionProviderModule extends org.opendaylight.yang.
                 addressBin = address2bin(address.getIpv6Address().getValue());
             }
         }
-        
+
         if (addressBin == null) {
             return null;
         } else {
@@ -130,7 +199,7 @@ public final class SwitchConnectionProviderModule extends org.opendaylight.yang.
      * @param value
      * @return
      */
-    private static byte[] address2bin(String value) {
+    private static byte[] address2bin(final String value) {
         //TODO: translate ipv4 or ipv6 into byte[]
         return null;
     }