X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-ssh%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fosgi%2FNetconfSSHActivator.java;fp=opendaylight%2Fnetconf%2Fnetconf-ssh%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fosgi%2FNetconfSSHActivator.java;h=446c5008960e92a001bf78f332435276dc1aef95;hb=ebb776d215a9285d56ca5121f3e5fc6678253538;hp=3b513790bd128806a7ef1bec2561bd90fee6420a;hpb=6397a0f2a8b4e0aecb7c42f589d17cd7511827c3;p=controller.git diff --git a/opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/osgi/NetconfSSHActivator.java b/opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/osgi/NetconfSSHActivator.java index 3b513790bd..446c500896 100644 --- a/opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/osgi/NetconfSSHActivator.java +++ b/opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/osgi/NetconfSSHActivator.java @@ -8,6 +8,8 @@ package org.opendaylight.controller.netconf.osgi; import com.google.common.base.Optional; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.net.InetSocketAddress; import org.opendaylight.controller.netconf.ssh.NetconfSSHServer; import org.opendaylight.controller.netconf.ssh.authentication.AuthProvider; @@ -85,7 +87,28 @@ public class NetconfSSHActivator implements BundleActivator{ EXCEPTION_MESSAGE, true); if (sshSocketAddressOptional.isPresent()){ - AuthProvider authProvider = new AuthProvider(iUserManager); + String path = NetconfConfigUtil.getPrivateKeyPath(context); + path = path.replace("\\", "/"); + if (path.equals("")){ + throw new Exception("Missing netconf.ssh.pk.path key in configuration file."); + } + FileInputStream fis = null; + try { + fis = new FileInputStream(path); + } catch (FileNotFoundException e){ + throw new Exception("Missing file described by netconf.ssh.pk.path key in configuration file."); + } catch (SecurityException e){ + throw new Exception("Read access denied to file described by netconf.ssh.pk.path key in configuration file."); + } + AuthProvider authProvider = null; + try { + authProvider = new AuthProvider(iUserManager,fis); + } catch (Exception e){ + if (fis!=null){ + fis.close(); + } + throw (e); + } this.server = NetconfSSHServer.start(sshSocketAddressOptional.get().getPort(),tcpSocketAddress,authProvider); Thread serverThread = new Thread(server,"netconf SSH server thread"); serverThread.setDaemon(true);