Merge "Clean up netconf-parent root pom"
[netconf.git] / netconf / netconf-ssh / src / main / java / org / opendaylight / netconf / ssh / osgi / NetconfSSHActivator.java
index e498b56e7375e3be20574ee6851c8e0a11970f6a..0a15fdb608c3bde1774ab265ddb9a9ae2ddc9e06 100644 (file)
@@ -9,13 +9,15 @@ package org.opendaylight.netconf.ssh.osgi;
 
 import io.netty.channel.local.LocalAddress;
 import io.netty.channel.nio.NioEventLoopGroup;
+import java.io.File;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
-import org.apache.sshd.common.util.ThreadUtils;
-import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider;
+import org.apache.sshd.common.util.security.SecurityUtils;
+import org.apache.sshd.common.util.threads.ThreadUtils;
+import org.apache.sshd.server.keyprovider.AbstractGeneratorHostKeyProvider;
 import org.opendaylight.netconf.ssh.SshProxyServer;
 import org.opendaylight.netconf.ssh.SshProxyServerConfigurationBuilder;
 import org.opendaylight.netconf.util.osgi.NetconfConfigUtil;
@@ -88,12 +90,16 @@ public class NetconfSSHActivator implements BundleActivator {
         LOG.trace("Starting netconf SSH server with path to ssh private key {}", path);
 
         final SshProxyServer sshProxyServer = new SshProxyServer(minaTimerExecutor, clientGroup, nioExecutor);
+        final AbstractGeneratorHostKeyProvider keyPairProvider = SecurityUtils.createGeneratorHostKeyProvider(null);
+        keyPairProvider.setAlgorithm(ALGORITHM);
+        keyPairProvider.setKeySize(KEY_SIZE);
+        keyPairProvider.setFile(new File(path));
         sshProxyServer.bind(
                 new SshProxyServerConfigurationBuilder()
                         .setBindingAddress(sshSocketAddress)
                         .setLocalAddress(localAddress)
                         .setAuthenticator(authProviderTracker)
-                        .setKeyPairProvider(new PEMGeneratorHostKeyProvider(path, ALGORITHM, KEY_SIZE))
+                        .setKeyPairProvider(keyPairProvider)
                         .setIdleTimeout(DEFAULT_IDLE_TIMEOUT)
                         .createSshProxyServerConfiguration());
         return sshProxyServer;