Search in sources :

Example 1 with ToSsh2HostKeyVerifierAdapter

use of com.jn.agileway.ssh.client.impl.trileadssh2.verifier.ToSsh2HostKeyVerifierAdapter in project agileway by fangjinuo.

the class Ssh2Connection method connect.

@Override
public void connect(InetAddress host, int port, InetAddress localAddr, int localPort) throws SshException {
    try {
        if (delegate == null) {
            Socket localSocket = null;
            if (localAddr != null && Nets.isValidPort(localPort)) {
                localSocket = new Socket(localAddr, localPort);
            }
            Connection conn = new Connection(host.getHostName(), port, localSocket);
            if (this.hostKeyVerifier.isEmpty()) {
                conn.connect();
            } else {
                conn.connect(new ToSsh2HostKeyVerifierAdapter(this.hostKeyVerifier));
            }
            setStatus(SshConnectionStatus.CONNECTED);
            this.delegate = conn;
        }
    } catch (Throwable ex) {
        throw new SshException(ex);
    }
}
Also used : ToSsh2HostKeyVerifierAdapter(com.jn.agileway.ssh.client.impl.ganymedssh2.verifier.ToSsh2HostKeyVerifierAdapter) AbstractSshConnection(com.jn.agileway.ssh.client.AbstractSshConnection) Connection(ch.ethz.ssh2.Connection) SshException(com.jn.agileway.ssh.client.SshException) Socket(java.net.Socket)

Example 2 with ToSsh2HostKeyVerifierAdapter

use of com.jn.agileway.ssh.client.impl.trileadssh2.verifier.ToSsh2HostKeyVerifierAdapter in project agileway by fangjinuo.

the class Ssh2Connection method connect.

@Override
public void connect(InetAddress host, int port, InetAddress localAddr, int localPort) throws SshException {
    try {
        if (delegate == null) {
            Connection conn = new Connection(host.getHostName(), port);
            if (this.hostKeyVerifier.isEmpty()) {
                conn.connect();
            } else {
                conn.connect(new ToSsh2HostKeyVerifierAdapter(this.hostKeyVerifier));
            }
            setStatus(SshConnectionStatus.CONNECTED);
            this.delegate = conn;
        }
    } catch (Throwable ex) {
        throw new SshException(ex);
    }
}
Also used : ToSsh2HostKeyVerifierAdapter(com.jn.agileway.ssh.client.impl.trileadssh2.verifier.ToSsh2HostKeyVerifierAdapter) AbstractSshConnection(com.jn.agileway.ssh.client.AbstractSshConnection) Connection(com.trilead.ssh2.Connection) SshException(com.jn.agileway.ssh.client.SshException)

Aggregations

AbstractSshConnection (com.jn.agileway.ssh.client.AbstractSshConnection)2 SshException (com.jn.agileway.ssh.client.SshException)2 Connection (ch.ethz.ssh2.Connection)1 ToSsh2HostKeyVerifierAdapter (com.jn.agileway.ssh.client.impl.ganymedssh2.verifier.ToSsh2HostKeyVerifierAdapter)1 ToSsh2HostKeyVerifierAdapter (com.jn.agileway.ssh.client.impl.trileadssh2.verifier.ToSsh2HostKeyVerifierAdapter)1 Connection (com.trilead.ssh2.Connection)1 Socket (java.net.Socket)1