diff options
author | Arindam Mondal <arind.mondal@samsung.com> | 2019-07-16 13:18:53 +0900 |
---|---|---|
committer | Arindam Mondal <arind.mondal@samsung.com> | 2019-07-16 06:10:54 +0000 |
commit | 655ab9613d658733fde9c3b1d13f0252b102f9bd (patch) | |
tree | 56bc978610f3a252200522664da359838ee78410 | |
parent | f63cbc60cea79e8dc338b722d385618e98a8c78b (diff) |
Update sshd library version
+)Updated sshd version to 1.7.0
++)Done necessary code changes.
Issue-ID: CCSDK-386
Change-Id: I7272c52c845fac55025cda9e904c74e84cd004e0
Signed-off-by: arind.mondal <arind.mondal@samsung.com>
-rw-r--r-- | saltstack-adapter/saltstack-adapter-provider/pom.xml | 2 | ||||
-rw-r--r-- | saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SshConnection.java | 35 |
2 files changed, 18 insertions, 19 deletions
diff --git a/saltstack-adapter/saltstack-adapter-provider/pom.xml b/saltstack-adapter/saltstack-adapter-provider/pom.xml index 91e72d5f..d703f6b0 100644 --- a/saltstack-adapter/saltstack-adapter-provider/pom.xml +++ b/saltstack-adapter/saltstack-adapter-provider/pom.xml @@ -78,7 +78,7 @@ <dependency> <groupId>org.apache.sshd</groupId> <artifactId>sshd-core</artifactId> - <version>0.12.0</version> + <version>1.7.0</version> </dependency> <!-- Needed to run test cases --> diff --git a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SshConnection.java b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SshConnection.java index eb45ead5..25d2d840 100644 --- a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SshConnection.java +++ b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SshConnection.java @@ -24,21 +24,21 @@ package org.onap.ccsdk.sli.adaptors.saltstack.impl; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.apache.sshd.ClientChannel; -import org.apache.sshd.ClientSession; -import org.apache.sshd.SshClient; +import java.io.OutputStream; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.security.KeyPair; +import org.apache.sshd.client.SshClient; import org.apache.sshd.client.channel.ChannelExec; import org.apache.sshd.client.future.AuthFuture; import org.apache.sshd.client.future.OpenFuture; -import org.apache.sshd.common.KeyPairProvider; +import org.apache.sshd.client.session.ClientSession; import org.apache.sshd.common.keyprovider.FileKeyPairProvider; +import org.apache.sshd.common.keyprovider.KeyPairProvider; import org.onap.ccsdk.sli.adaptors.saltstack.model.Constants; import org.onap.ccsdk.sli.adaptors.saltstack.model.SshException; - -import java.io.OutputStream; -import java.security.KeyPair; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; /** * Implementation of SshConnection interface based on Apache MINA SSHD library. @@ -79,16 +79,15 @@ class SshConnection { sshClient.start(); try { clientSession = - sshClient.connect(username, host, port).await().getSession(); + sshClient.connect(username, host, port).getSession(); if (password != null) { clientSession.addPasswordIdentity(password); - } else if (keyFile != null) { - KeyPairProvider keyPairProvider = new FileKeyPairProvider(new String[]{ - keyFile - }); - KeyPair keyPair = keyPairProvider.loadKeys().iterator().next(); - clientSession.addPublicKeyIdentity(keyPair); - } + } else if (keyFile != null) { + Path keyFilePath = Paths.get(keyFile); + KeyPairProvider keyPairProvider = new FileKeyPairProvider(keyFilePath); + KeyPair keyPair = keyPairProvider.loadKeys().iterator().next(); + clientSession.addPublicKeyIdentity(keyPair); + } AuthFuture authFuture = clientSession.auth(); authFuture.await(AUTH_TIMEOUT); if (!authFuture.isSuccess()) { @@ -168,7 +167,7 @@ class SshConnection { OpenFuture openFuture = client.open(); int exitStatus; try { - client.waitFor(ClientChannel.CLOSED, timeout); + client.wait(timeout); openFuture.verify(); Integer exitStatusI = client.getExitStatus(); if (exitStatusI == null) { |