@Override public int copyFromServer(Map<String,?> props, String pathAndFileOnRemoteServer, File localFile) { LocalDestFile localDestFile = acquire(new GetFileAction(pathAndFileOnRemoteServer, localFile)); return 0; }
protected static Builder fromSSHClientConnection(SshjClientConnection in) { return new Builder().hostAndPort(in.getHostAndPort()).connectTimeout(in.getConnectTimeout()).sessionTimeout( in.getSessionTimeout()).username(in.username).password(in.password).privateKey(in.privateKeyData).privateKeyFile(in.privateKeyFile); } }
private int copyToServer(Map<String,?> props, Supplier<InputStream> contentsSupplier, long length, String pathAndFileOnRemoteServer) { acquire(new PutFileAction(props, pathAndFileOnRemoteServer, contentsSupplier, length)); return 0; // TODO Can we assume put will have thrown exception if failed? Rather than exit code != 0? }
@Override public int run() { String scriptContents = toScript(props, commands, env); if (LOG.isTraceEnabled()) LOG.trace("Running shell command at {} as script: {}", host, scriptContents); copyToServer(ImmutableMap.of("permissions", "0700"), scriptContents.getBytes(), scriptPath); return asInt(acquire(new ShellAction(buildRunScriptCommand(), out, err, execTimeout)), -1); } }.run();
@Override @SuppressWarnings("unchecked") public T build() { return (T) new SshjTool(this); } }
@Override public boolean isConnected() { return sshClientConnection.isConnected() && sshClientConnection.isAuthenticated(); }
@Override @Deprecated // see super public void connect(int maxAttempts) { connect(); // FIXME Should callers instead configure sshTries? But that would apply to all ssh attempts }
public B sshRetries(int val) { this.sshTries = val; return self(); } public B sshRetriesTimeout(int val) {
public static Builder builder() { return new Builder(); }
public SshjClientConnection build() { return new SshjClientConnection(this); }
public static SshjToolBuilder builder() { return new SshjToolBuilder(); }
private SshjClientConnection(Builder builder) { this.hostAndPort = checkNotNull(builder.hostAndPort); this.username = builder.username; this.password = builder.password; this.privateKeyPassphrase = builder.privateKeyPassphrase; this.privateKeyData = builder.privateKeyData; this.privateKeyFile = builder.privateKeyFile; this.strictHostKeyChecking = builder.strictHostKeyChecking; this.connectTimeout = checkInt("connectTimeout", builder.connectTimeout, Integer.MAX_VALUE); this.sessionTimeout = checkInt("sessionTimeout", builder.sessionTimeout, Integer.MAX_VALUE); }
@Override public SFTPClient create() throws IOException { checkConnected(); sftp = sshClientConnection.ssh.newSFTPClient(); return sftp; }
@Override protected SshTool newSshTool(Map<String,?> flags) { return new SshjTool(flags); }
public B sshRetriesTimeout(int val) { this.sshTriesTimeout = val; return self(); } public B sshRetryDelay(long val) {
@Override protected SshTool newUnregisteredTool(Map<String,?> flags) { return new SshjTool(flags); }
public B sshRetryDelay(long val) { this.sshRetryDelay = val; return self(); } @Override
public B connectTimeout(int val) { this.connectTimeout = val; return self(); } public B sessionTimeout(int val) {
public B sessionTimeout(int val) { this.sessionTimeout = val; return self(); } public B sshRetries(int val) {