use of com.jn.agileway.ssh.client.SshException in project agileway by fangjinuo.
the class Eddsa25519PublicKeyCodec method decode.
@Override
public PublicKey decode(byte[] bytes) {
try {
Buffer buf = new Buffer.PlainBuffer(bytes);
final int keyLen = buf.readUInt32AsInt();
final byte[] p = new byte[keyLen];
buf.readRawBytes(p);
if (logger.isDebugEnabled()) {
logger.debug("Key algo: {}, Key curve: 25519, Key Len: {}\np: {}", getName(), keyLen, Arrays.toString(p));
}
EdDSANamedCurveSpec ed25519 = EdDSANamedCurveTable.getByName("Ed25519");
EdDSAPublicKeySpec publicSpec = new EdDSAPublicKeySpec(p, ed25519);
return new Ed25519PublicKey(publicSpec);
} catch (Buffer.BufferException be) {
throw new SshException(be);
}
}
use of com.jn.agileway.ssh.client.SshException in project agileway by fangjinuo.
the class JschSessionedChannel method getErrorInputStream.
@Override
public InputStream getErrorInputStream() throws SshException {
Preconditions.checkState(channel != null);
if (this.errorInputStream == null) {
try {
InputStream errorInputStream = null;
switch(type) {
case EXEC:
errorInputStream = ((ChannelExec) channel).getErrStream();
break;
case SUBSYSTEM:
errorInputStream = ((ChannelSubsystem) channel).getErrStream();
break;
case SHELL:
break;
default:
break;
}
this.errorInputStream = errorInputStream;
} catch (Throwable ex) {
throw new SshException(ex);
}
}
return this.errorInputStream;
}
use of com.jn.agileway.ssh.client.SshException in project agileway by fangjinuo.
the class J2sshConnectionFactory method setKnownHosts0.
protected void setKnownHosts0(SshConnection connection, J2sshConnectionConfig sshConfig) {
String filepath = sshConfig.getKnownHostsPath();
List<File> files = SshConfigs.getKnownHostsFiles(filepath);
HostKeyVerification verifier = null;
if (files.isEmpty()) {
verifier = new IgnoreHostKeyVerification();
} else {
try {
verifier = new KnownHostsVerifier(files.get(0).getAbsolutePath());
} catch (Throwable ex) {
throw new SshException(ex);
}
}
connection.addHostKeyVerifier(new FromJ2ssHostKeyVerifier(verifier));
}
use of com.jn.agileway.ssh.client.SshException in project agileway by fangjinuo.
the class SynergySessionedChannel method internalShell.
@Override
protected void internalShell() throws SshException {
try {
RequestFuture future = channel.startShell();
future.waitForever();
} catch (Throwable ex) {
throw new SshException(ex);
}
}
use of com.jn.agileway.ssh.client.SshException in project agileway by fangjinuo.
the class Ssh2Connection method openSftpSession.
@Override
public SftpSession openSftpSession() throws SshException {
try {
SFTPv3Client sftpClient = new SFTPv3Client(this.delegate);
Ssh2SftpSession session = new Ssh2SftpSession(sftpClient);
session.setSshConnection(this);
return session;
} catch (Throwable ex) {
throw new SshException(ex.getMessage(), ex);
}
}
Aggregations