+ if (sshSocketAddressOptional.isPresent()){
+ 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);
+ serverThread.start();
+ logger.trace("Netconf SSH bridge up and running.");
+ } else {
+ logger.trace("No valid connection configuration for SSH bridge found.");
+ throw new Exception("No valid connection configuration for SSH bridge found.");
+ }
+ }
+ private void onUserManagerFound(IUserManager userManager) throws Exception{
+ if (server!=null && server.isUp()){
+ server.addUserManagerService(userManager);
+ } else {
+ startSSHServer();
+ }
+ }
+ private void removeUserManagerService(){
+ this.server.removeUserManagerService();
+ }
+ private void listenForManagerService(){
+ ServiceTracker<IUserManager, IUserManager> listenerTracker = new ServiceTracker<>(context, IUserManager.class,customizer);
+ listenerTracker.open();