public class JschProcessExecutor extends Object implements ProcessExecutor
ProcessExecutor
using JSch.Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_TEMPORARY_BLOB_PREFIX
The default value of
KEY_TEMPORARY_BLOB_PREFIX . |
static String |
KEY_HOST
The key of host name.
|
static String |
KEY_PASS_PHRASE
The key of passphrase.
|
static String |
KEY_PORT
The key of port number.
|
static String |
KEY_PRIVATE_KEY
The key of path to the private key.
|
static String |
KEY_TEMPORARY_BLOB_PREFIX
The key of BLOB storage path prefix.
|
static String |
KEY_USER
The key of user name.
|
Constructor and Description |
---|
JschProcessExecutor(String user,
String host,
Integer portOrNull,
String privateKeyPath,
String passPhraseOrNull)
Creates a new instance.
|
JschProcessExecutor(String user,
String host,
Integer portOrNull,
String privateKeyPath,
String passPhraseOrNull,
String temporaryBlobPrefix)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
int |
execute(ExecutionContext context,
List<String> commandLineTokens,
Map<String,String> environmentVariables,
Map<String,Blob> extensions,
OutputStream output)
Executes a process.
|
static JschProcessExecutor |
extract(String servicePrefix,
Map<String,String> configuration,
VariableResolver variables)
Extracts SSH profiles from configuration and returns a related executor.
|
String |
getHost()
Returns the remote host name.
|
String |
getPassPhrase()
Returns a pass phrase for private key.
|
Integer |
getPort()
Returns the remote port number.
|
String |
getPrivateKey()
Returns the path to the private key file.
|
String |
getTemporaryBlobPrefix()
Returns the BLOB storage remote path prefix.
|
String |
getUser()
Returns the remote user name.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
execute, execute
public static final String KEY_USER
${VARIABLE-NAME}
.public static final String KEY_HOST
${VARIABLE-NAME}
.public static final String KEY_PORT
public static final String KEY_PRIVATE_KEY
${VARIABLE-NAME}
.public static final String KEY_PASS_PHRASE
public static final String KEY_TEMPORARY_BLOB_PREFIX
public static final String DEFAULT_TEMPORARY_BLOB_PREFIX
KEY_TEMPORARY_BLOB_PREFIX
.public JschProcessExecutor(String user, String host, Integer portOrNull, String privateKeyPath, String passPhraseOrNull) throws com.jcraft.jsch.JSchException
user
- remote user namehost
- remote host nameportOrNull
- remote port number (nullable)privateKeyPath
- path to private key filepassPhraseOrNull
- passphrase for the private key (nullable)com.jcraft.jsch.JSchException
- if failed to initialize SSH clientIllegalArgumentException
- if some parameters were null
public JschProcessExecutor(String user, String host, Integer portOrNull, String privateKeyPath, String passPhraseOrNull, String temporaryBlobPrefix) throws com.jcraft.jsch.JSchException
user
- remote user namehost
- remote host nameportOrNull
- remote port number (nullable)privateKeyPath
- path to private key filepassPhraseOrNull
- passphrase for the private key (nullable)temporaryBlobPrefix
- the temporary BLOB storage path prefixcom.jcraft.jsch.JSchException
- if failed to initialize SSH clientIllegalArgumentException
- if some parameters were null
public String getUser()
public String getHost()
public Integer getPort()
null
if is not specifiedpublic String getPrivateKey()
public String getPassPhrase()
null
if is not specifiedpublic String getTemporaryBlobPrefix()
public static JschProcessExecutor extract(String servicePrefix, Map<String,String> configuration, VariableResolver variables) throws com.jcraft.jsch.JSchException
configuration
:
remote user name
remote host name
remote port number
(can omit) private key path
KEY_PASS_PHRASE
(can omit) servicePrefix
- prefix of configuration keysconfiguration
- target configurationvariables
- variable resolvercom.jcraft.jsch.JSchException
- if failed to initialize SSH clientIllegalArgumentException
- if configuration is invalidpublic int execute(ExecutionContext context, List<String> commandLineTokens, Map<String,String> environmentVariables, Map<String,Blob> extensions, OutputStream output) throws InterruptedException, IOException
ProcessExecutor
execute
in interface ProcessExecutor
context
- current execution contextcommandLineTokens
- target commandenvironmentVariables
- environment variablesextensions
- the extension BLOBsoutput
- information outputInterruptedException
- if interrupted while waiting process exitIOException
- if failed to execute the commandCopyright © 2011–2019 Asakusa Framework Team. All rights reserved.