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);
}
}
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);
}
}
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));
}
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;
}
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);
}
}
Aggregations