Search in sources :

Example 26 with SshException

use of com.jn.agileway.ssh.client.SshException in project agileway by fangjinuo.

the class JschSessionedChannel method signal.

@Override
public void signal(Signal signal) throws SshException {
    Preconditions.checkState(channel != null && channel.isConnected());
    Preconditions.checkNotEmpty(signal, "the signal is null or empty");
    Preconditions.checkArgument(signal != Signal.UNKNOWN, "the signal is UNKNOWN");
    try {
        channel.sendSignal(signal.name());
    } catch (Throwable ex) {
        throw new SshException(ex);
    }
}
Also used : SshException(com.jn.agileway.ssh.client.SshException)

Example 27 with SshException

use of com.jn.agileway.ssh.client.SshException in project agileway by fangjinuo.

the class JschSessionedChannel method internalExec.

@Override
protected void internalExec(String command) throws SshException {
    Preconditions.checkNotEmpty(command, "the command is illegal : {}", command);
    Preconditions.checkState(session != null && session.isConnected(), "the session is not connected");
    this.type = JschChannelType.EXEC;
    try {
        ChannelExec channel = (ChannelExec) session.openChannel(type.getName());
        channel.setCommand(command);
        this.channel = channel;
        startChannel();
    } catch (Throwable ex) {
        throw new SshException(ex);
    }
}
Also used : SshException(com.jn.agileway.ssh.client.SshException)

Example 28 with SshException

use of com.jn.agileway.ssh.client.SshException in project agileway by fangjinuo.

the class Secg method getDecoded.

/**
 * SECG 2.3.4 Octet String to ECPoint
 */
public static ECPoint getDecoded(byte[] M, EllipticCurve curve) {
    int elementSize = getElementSize(curve);
    if (M.length != 2 * elementSize + 1 || M[0] != 0x04) {
        throw new SshException("Invalid 'f' for Elliptic Curve " + curve.toString());
    }
    byte[] xBytes = new byte[elementSize];
    byte[] yBytes = new byte[elementSize];
    System.arraycopy(M, 1, xBytes, 0, elementSize);
    System.arraycopy(M, 1 + elementSize, yBytes, 0, elementSize);
    return new ECPoint(new BigInteger(1, xBytes), new BigInteger(1, yBytes));
}
Also used : BigInteger(java.math.BigInteger) SshException(com.jn.agileway.ssh.client.SshException) ECPoint(java.security.spec.ECPoint) ECPoint(java.security.spec.ECPoint)

Example 29 with SshException

use of com.jn.agileway.ssh.client.SshException in project agileway by fangjinuo.

the class Ssh2ForwardingClient method startLocalForwarding.

@Override
public ForwardingChannelInfo startLocalForwarding(String bindToHost, int bindToPort, String destHost, int destPort) throws SshException {
    ForwardingChannelInfo channel = new ForwardingChannelInfo(ForwardingChannelInfo.LOCAL_FORWARDING_CHANNEL, bindToHost, bindToPort, destHost, destPort);
    LocalPortForwarder forwarder = localForwarderMap.get(channel);
    if (forwarder == null) {
        try {
            ch.ethz.ssh2.Connection delegate = this.connection.getDelegate();
            forwarder = delegate.createLocalPortForwarder(bindToPort, destHost, destPort);
            localForwarderMap.put(ForwardingChannelInfo.id(channel), forwarder);
        } catch (Throwable ex) {
            throw new SshException(ex);
        }
    }
    return channel;
}
Also used : LocalPortForwarder(ch.ethz.ssh2.LocalPortForwarder) ForwardingChannelInfo(com.jn.agileway.ssh.client.channel.forwarding.ForwardingChannelInfo) SshException(com.jn.agileway.ssh.client.SshException)

Example 30 with SshException

use of com.jn.agileway.ssh.client.SshException in project agileway by fangjinuo.

the class JschConnection method openSftpSession.

@Override
public SftpSession openSftpSession() throws SshException {
    try {
        ChannelSftp channel = (ChannelSftp) this.delegate.openChannel("sftp");
        channel.connect();
        JschSftpSession session = new JschSftpSession(channel);
        session.setSshConnection(this);
        return session;
    } catch (JSchException ex) {
        throw new SshException(ex);
    }
}
Also used : JSchException(com.jcraft.jsch.JSchException) ChannelSftp(com.jcraft.jsch.ChannelSftp) JschSftpSession(com.jn.agileway.ssh.client.impl.jsch.sftp.JschSftpSession) SshException(com.jn.agileway.ssh.client.SshException)

Aggregations

SshException (com.jn.agileway.ssh.client.SshException)40 ForwardingChannelInfo (com.jn.agileway.ssh.client.channel.forwarding.ForwardingChannelInfo)7 RequestFuture (com.sshtools.common.ssh.RequestFuture)4 SshClient (com.sshtools.j2ssh.SshClient)4 Connection (com.trilead.ssh2.Connection)3 InetSocketAddress (java.net.InetSocketAddress)3 SSHClient (net.schmizz.sshj.SSHClient)3 AbstractSshConnection (com.jn.agileway.ssh.client.AbstractSshConnection)2 Ssh2SftpSession (com.jn.agileway.ssh.client.impl.ganymedssh2.sftp.Ssh2SftpSession)2 ToSynergyHostKeyVerifierAdapter (com.jn.agileway.ssh.client.impl.synergy.verifier.ToSynergyHostKeyVerifierAdapter)2 Ssh2SftpSession (com.jn.agileway.ssh.client.impl.trileadssh2.sftp.Ssh2SftpSession)2 SftpSession (com.jn.agileway.ssh.client.sftp.SftpSession)2 SshClient (com.sshtools.client.SshClient)2 SshClientContext (com.sshtools.client.SshClientContext)2 RemotePortForwarder (net.schmizz.sshj.connection.channel.forwarded.RemotePortForwarder)2 Connection (ch.ethz.ssh2.Connection)1 LocalPortForwarder (ch.ethz.ssh2.LocalPortForwarder)1 SFTPv3Client (ch.ethz.ssh2.SFTPv3Client)1 Session (ch.ethz.ssh2.Session)1 ChannelSftp (com.jcraft.jsch.ChannelSftp)1