public void onChannelOpen() throws SshException { try { sess.execCommand(command); } catch (IOException e) { throw new SshException(SshException.IO_ERROR, e); } } };
protected void onClose() throws SshException { try { session.delPortForwardingL(localAddress, localPort); } catch (JSchException e) { throw new SshException("Failed to configure local port forward"); } finally { channelCount--; } } };
protected void onOpen() throws SshException { try { client = this.ganymedSshClient.connection.createSCPClient(); } catch (IOException e) { throw new SshException(SshException.IO_ERROR, e); } }
public void onOpen() throws SshException { try { channel.connect(); home = channel.pwd(); } catch (JSchException e) { throw new SshException("Failed to open SFTP client.", e); } catch (SftpException e) { throw new SshException("Failed to get home directory.", e); } }
protected void onClose() throws SshException { try { session.delPortForwardingR(remotePort); } catch (JSchException e) { throw new SshException("Failed to configure remote port forward"); } finally { channelCount--; } } };
public SftpClient createSftpClient() throws SshException { try { ChannelSftp channel = (ChannelSftp) session.openChannel("sftp"); return new JschSftpClient(channel); } catch (JSchException e) { throw new SshException("Failed to open SFTP channel.", e); } }
public final void open() throws SshException { if (open) { throw new SshException(SshException.ALREADY_OPEN, "The port forward is already open"); } onOpen(); open = true; fireOpened(); }
public void onChannelOpen() throws SshException { try { ((Session) getSession()).startShell(); } catch (IOException e) { throw new SshException(SshException.IO_ERROR, e); } }
public final void open() throws SshException { if (open) { throw new SshException(SshException.ALREADY_OPEN, "The port forward is already open"); } onOpen(); open = true; fireOpened(); }
private void reload() throws SshException { try { knownHostsFile = Util.getKnownHostsFile(configuration); knownHosts = new KnownHosts(knownHostsFile); } catch (IOException e) { throw new SshException(SshException.IO_ERROR, e); } }
public void disconnect() throws SshException { if (!isConnected()) { throw new SshException(SshException.NOT_OPEN, "Not connected."); } try { connection.close(); } finally { connected = false; connection = null; } }
public void close() throws SshException { if (!open) { throw new SshException(SshException.NOT_OPEN, "The port forward is not open"); } fireClosing(); onClose(); open = false; fireClosed(); }
public void mkdir(String path, int permissions) throws SshException { int ret = library.sftp_mkdir(sftp, path, permissions); if (ret != SshLibrary.SSH_OK) { throw new SshException(SshException.GENERAL, "Failed to create directory. " + library.ssh_get_error(libSshSession.getPointer())); } }
public void rename(String path, String newPath) throws SshException { int ret = library.sftp_rename(sftp, path, newPath); if (ret != SshLibrary.SSH_OK) { throw new SshException(SshException.GENERAL, "Failed to remove file. " + library.ssh_get_error(libSshSession.getPointer())); } }
public void rmdir(String path) throws SshException { try { client.rmdir(path); } catch (SFTPException sftpe) { throw new SftpException(sftpe.getServerErrorCode(), sftpe.getLocalizedMessage()); } catch (IOException e) { throw new SshException(SshException.IO_ERROR, e); } }
public void chgrp(String path, int gid) throws SshException { sftp_attributes_struct attr = library.sftp_stat(sftp, path); int ret = library.sftp_chown(sftp, path, attr.uid, gid); if (ret != SshLibrary.SSH_OK) { throw new SshException(SshException.GENERAL, "Failed to set group. " + library.ssh_get_error(libSshSession.getPointer())); } } }
public final void close() throws SshException { if (!isOpen()) { throw new SshException(SshException.NOT_OPEN, "Channel not open."); } fireClosing(); onClose(); open = false; fireClosed(); }
public SftpFile stat(String path) throws SshException { try { SFTPv3FileAttributes entry = client.stat(path); return entryToFile(path, entry); } catch (SFTPException sftpE) { throw new SftpException(sftpE.getServerErrorCode(), sftpE.getLocalizedMessage()); } catch (IOException e) { throw new SshException(SshException.IO_ERROR, "Failed to list directory.", e); } }
public void add(SshHostKey hostKey, boolean persist) throws SshException { try { KnownHosts.addHostkeyToFile(knownHostsFile, new String[] { hostKey.getHost() }, hostKey.getType(), hostKey.getKey()); } catch (IOException e) { throw new SshException(SshException.IO_ERROR, e); } reload(); }
public SshKeyPair toKeyPair() throws SshException { if (isEncrypted()) { throw new SshException(SshException.PASSPHRASE_REQUIRED, "Key is currently encrypyted. Please decrypt before changing passphrase."); } System.out.println("KEYBITS: " + kpair.getPublicKeyBlob().length); return new SshKeyPair(new JschPublicKey(kpair, kpair.getPublicKeyBlob().length), new JschPrivateKey(kpair)); }