- 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);
+
+ try (FileInputStream fis = new FileInputStream(path)){
+ AuthProvider authProvider = new AuthProvider(iUserManager,fis);
+ this.server = NetconfSSHServer.start(sshSocketAddressOptional.get().getPort(),tcpSocketAddress,authProvider);