|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.xebialabs.deployit.hostsession.common.AbstractHostSession
com.xebialabs.deployit.hostsession.ssh.SshSudoHostSession
public class SshSudoHostSession
A session to a remote host using SSH w/ SUDO.
| Field Summary | |
|---|---|
protected java.lang.String |
host
|
protected java.lang.String |
password
|
protected int |
port
|
protected com.jcraft.jsch.Session |
sharedSession
|
protected java.lang.String |
sudoUsername
|
protected java.lang.String |
username
|
| Fields inherited from class com.xebialabs.deployit.hostsession.common.AbstractHostSession |
|---|
MAX_TEMP_RETRIES |
| Constructor Summary | |
|---|---|
SshSudoHostSession(OperatingSystemFamily os,
java.lang.String temporaryDirectoryPath,
java.lang.String host,
int port,
java.lang.String username,
java.lang.String password,
java.lang.String sudoUsername)
Constructs an SshSudoHostSession |
|
| Method Summary | |
|---|---|
void |
close()
Closes the host session. |
protected HostFile |
createSessionTempDirectory(HostFile systemTempDirectory,
java.lang.String name)
|
protected void |
disconnectSession(com.jcraft.jsch.Session session,
java.lang.String purpose)
|
void |
disconnectSharedSession()
|
static java.lang.String |
encodeCommandLine(boolean hidePassword,
java.lang.String... commandLine)
|
int |
execute(CommandExecutionCallbackHandler handler,
java.util.Map<java.lang.String,java.lang.String> inputResponse,
java.lang.String... commandLine)
Executes a command and responds to any output with the provided responses. |
int |
execute(CommandExecutionCallbackHandler handler,
java.lang.String... commandLine)
Executes a command with its arguments. |
HostFile |
getFile(HostFile parent,
java.lang.String child)
Creates a reference to a file in a directory on the host. |
protected HostFile |
getFile(HostFile parent,
java.lang.String child,
boolean isTempFile)
|
HostFile |
getFile(java.lang.String hostPath)
Creates a reference to a file on the host. |
protected HostFile |
getFile(java.lang.String hostPath,
boolean isTempFile)
|
java.lang.String |
getHost()
|
protected CommandExecutionCallbackHandler |
getInputResponseHandler(CommandExecutionCallbackHandler originalHandler,
java.io.OutputStream remoteStdin,
java.util.Map<java.lang.String,java.lang.String> inputResponse)
|
java.lang.String |
getPassword()
|
int |
getPort()
|
protected com.jcraft.jsch.Session |
getSharedSession()
|
HostFile |
getTempFile(java.lang.String prefix,
java.lang.String suffix)
Creates a reference to a temporary file on the host. |
protected com.jcraft.jsch.UserInfo |
getUserInfo()
|
java.lang.String |
getUsername()
|
protected int |
noSudoExecute(CommandExecutionCallbackHandler handler,
java.lang.String... commandLine)
|
protected com.jcraft.jsch.Session |
openSession(java.lang.String purpose)
|
void |
setHost(java.lang.String host)
|
void |
setPassword(java.lang.String password)
|
void |
setPort(int port)
|
void |
setUsername(java.lang.String username)
|
CommandExecution |
startExecute(java.lang.String... commandLine)
Starts the execution of a command and gives the caller full control over the execution. |
java.lang.String |
toString()
|
| Methods inherited from class com.xebialabs.deployit.hostsession.common.AbstractHostSession |
|---|
cleanupTemporaryFiles, copyToTemporaryFile, copyToTemporaryFile, getHostOperatingSystem, getTempFile, getTemporaryDirectory |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.xebialabs.deployit.hostsession.HostSession |
|---|
copyToTemporaryFile, copyToTemporaryFile, getHostOperatingSystem, getTempFile |
| Field Detail |
|---|
protected java.lang.String sudoUsername
protected java.lang.String host
protected int port
protected java.lang.String username
protected java.lang.String password
protected com.jcraft.jsch.Session sharedSession
| Constructor Detail |
|---|
public SshSudoHostSession(OperatingSystemFamily os,
java.lang.String temporaryDirectoryPath,
java.lang.String host,
int port,
java.lang.String username,
java.lang.String password,
java.lang.String sudoUsername)
os - the operating system of the hosttemporaryDirectoryPath - the path of the directory in which to store temporary fileshost - the hostname or IP adress of the hostport - the port to connect tousername - the username to connect withpassword - the password to connect withsudoUsername - the username to sudo to| Method Detail |
|---|
public int execute(CommandExecutionCallbackHandler handler,
java.util.Map<java.lang.String,java.lang.String> inputResponse,
java.lang.String... commandLine)
throws RuntimeIOException
HostSession
execute in interface HostSessionhandler - the callback handler that will be invoked when the executed command generated output.inputResponse - expected output and the response to sendcommandLine - the command line to execute. The first element is the command, the other elements are its arguments.
RuntimeIOException - if an I/O error occurs
protected CommandExecutionCallbackHandler getInputResponseHandler(CommandExecutionCallbackHandler originalHandler,
java.io.OutputStream remoteStdin,
java.util.Map<java.lang.String,java.lang.String> inputResponse)
protected int noSudoExecute(CommandExecutionCallbackHandler handler,
java.lang.String... commandLine)
protected HostFile getFile(java.lang.String hostPath,
boolean isTempFile)
throws RuntimeIOException
RuntimeIOException
protected HostFile createSessionTempDirectory(HostFile systemTempDirectory,
java.lang.String name)
createSessionTempDirectory in class AbstractHostSessionpublic java.lang.String toString()
public void close()
HostSessionRuntimeException
close in interface HostSessionclose in class AbstractHostSessionprotected com.jcraft.jsch.Session getSharedSession()
public void disconnectSharedSession()
protected com.jcraft.jsch.Session openSession(java.lang.String purpose)
throws com.jcraft.jsch.JSchException
com.jcraft.jsch.JSchException
protected void disconnectSession(com.jcraft.jsch.Session session,
java.lang.String purpose)
public HostFile getFile(java.lang.String hostPath)
throws RuntimeIOException
HostSession
getFile in interface HostSessionhostPath - the path of the host
RuntimeIOException - if an I/O error occurs
public HostFile getFile(HostFile parent,
java.lang.String child)
throws RuntimeIOException
HostSession
getFile in interface HostSessionparent - the reference to the directory on the hostchild - the name of the file in the directory
RuntimeIOException - if an I/O error occurs
protected HostFile getFile(HostFile parent,
java.lang.String child,
boolean isTempFile)
throws RuntimeIOException
RuntimeIOException
public HostFile getTempFile(java.lang.String prefix,
java.lang.String suffix)
throws RuntimeIOException
HostSession
getTempFile in interface HostSessionprefix - the prefix string to be used in generating the file's name; must be at least three characters longsuffix - the suffix string to be used in generating the file's name; may be null, in which case
the suffix ".tmp" will be used
RuntimeIOException - if an I/O error occurs
public int execute(CommandExecutionCallbackHandler handler,
java.lang.String... commandLine)
throws RuntimeIOException
HostSession
execute in interface HostSessionhandler - the callback handler that will be invoked when the executed command generated output.commandLine - the command line to execute. The first element is the command, the other elements are its arguments.
RuntimeIOException - if an I/O error occurspublic CommandExecution startExecute(java.lang.String... commandLine)
HostSession
startExecute in interface HostSessioncommandLine - the command line to execute. The first element is the command, the other elements are its arguments.
protected com.jcraft.jsch.UserInfo getUserInfo()
public java.lang.String getHost()
public void setHost(java.lang.String host)
public int getPort()
public void setPort(int port)
public java.lang.String getUsername()
public void setUsername(java.lang.String username)
public java.lang.String getPassword()
public void setPassword(java.lang.String password)
public static java.lang.String encodeCommandLine(boolean hidePassword,
java.lang.String... commandLine)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||