Class ScpExternalWagon
- java.lang.Object
-
- org.apache.maven.wagon.AbstractWagon
-
- org.apache.maven.wagon.providers.ssh.external.ScpExternalWagon
-
- All Implemented Interfaces:
CommandExecutor,Wagon
- Direct Known Subclasses:
ScpExternalCommandExecutor
public class ScpExternalWagon extends AbstractWagon implements CommandExecutor
SCP deployer using "external" scp program. To allow for ssh-agent type behavior, until we can construct a Java SSH Agent and interface for JSch.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringscpArgsArguments to pass to the SCP command.private java.lang.StringscpExecutableThe external SCP command to use - default isscp.private static intSSH_FATAL_EXIT_CODEprivate java.lang.StringsshArgsArguments to pass to the SSH command.private java.lang.StringsshExecutableThe external SSH command to use - default isssh.private ScpHelpersshTool-
Fields inherited from class org.apache.maven.wagon.AbstractWagon
authenticationInfo, BUFFER_SEGMENT_SIZE, DEFAULT_BUFFER_SIZE, interactive, MAXIMUM_BUFFER_SIZE, MINIMUM_AMOUNT_OF_TRANSFER_CHUNKS, proxyInfo, repository, sessionEventSupport, transferEventSupport
-
Fields inherited from interface org.apache.maven.wagon.CommandExecutor
ROLE
-
Fields inherited from interface org.apache.maven.wagon.Wagon
DEFAULT_CONNECTION_TIMEOUT, DEFAULT_READ_TIMEOUT, ROLE
-
-
Constructor Summary
Constructors Constructor Description ScpExternalWagon()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.StringbuildRemoteHost()voidcloseConnection()private org.codehaus.plexus.util.cli.CommandlinecreateBaseCommandLine(boolean putty, java.lang.String executable, java.io.File privateKey)voidexecuteCommand(java.lang.String command)StreamsexecuteCommand(java.lang.String command, boolean ignoreFailures)private voidexecuteScpCommand(Resource resource, java.io.File localFile, boolean put)voidget(java.lang.String resourceName, java.io.File destination)Downloads specified resource from the repository to given file.java.util.List<java.lang.String>getFileList(java.lang.String destinationDirectory)Returns aListof strings naming the files and directories in the directory denoted by this abstract pathname.booleangetIfNewer(java.lang.String resourceName, java.io.File destination, long timestamp)Downloads specified resource from the repository if it was modified since specified date.java.lang.StringgetScpArgs()java.lang.StringgetScpExecutable()java.lang.StringgetSshArgs()java.lang.StringgetSshExecutable()protected booleanisPuTTY()(package private) booleanisPuTTYSCP()private java.lang.StringnormalizeResource(Resource resource)protected voidopenConnectionInternal()voidput(java.io.File source, java.lang.String destination)Copy a file from local system to remotevoidputDirectory(java.io.File sourceDirectory, java.lang.String destinationDirectory)Copy a directory from local system to remotebooleanresourceExists(java.lang.String resourceName)Check if a remote resource existsvoidsetScpArgs(java.lang.String scpArgs)voidsetScpExecutable(java.lang.String scpExecutable)voidsetSshArgs(java.lang.String sshArgs)voidsetSshExecutable(java.lang.String sshExecutable)booleansupportsDirectoryCopy()Flag indicating if this wagon supports directory copy operations.-
Methods inherited from class org.apache.maven.wagon.AbstractWagon
addSessionListener, addTransferListener, cleanupGetTransfer, cleanupPutTransfer, connect, connect, connect, connect, connect, connect, createParentDirectories, disconnect, finishGetTransfer, finishPutTransfer, fireGetCompleted, fireGetInitiated, fireGetStarted, firePutCompleted, firePutInitiated, firePutStarted, fireSessionConnectionRefused, fireSessionDebug, fireSessionDisconnected, fireSessionDisconnecting, fireSessionError, fireSessionLoggedIn, fireSessionLoggedOff, fireSessionOpened, fireSessionOpening, fireTransferDebug, fireTransferError, fireTransferProgress, getAuthenticationInfo, getBufferCapacityForTransfer, getPath, getPermissionsOverride, getProxyInfo, getProxyInfo, getReadTimeout, getRepository, getSessionEventSupport, getTimeout, getTransfer, getTransfer, getTransfer, getTransfer, getTransfer, getTransfer, getTransferEventSupport, hasSessionListener, hasTransferListener, isInteractive, openConnection, postProcessListeners, putTransfer, putTransfer, removeSessionListener, removeTransferListener, setInteractive, setPermissionsOverride, setReadTimeout, setSessionEventSupport, setTimeout, setTransferEventSupport, transfer, transfer, transfer, transfer
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.maven.wagon.Wagon
addSessionListener, addTransferListener, connect, connect, connect, connect, connect, connect, disconnect, getReadTimeout, getRepository, getTimeout, hasSessionListener, hasTransferListener, isInteractive, openConnection, removeSessionListener, removeTransferListener, setInteractive, setReadTimeout, setTimeout
-
-
-
-
Field Detail
-
scpExecutable
private java.lang.String scpExecutable
The external SCP command to use - default isscp.
-
sshExecutable
private java.lang.String sshExecutable
The external SSH command to use - default isssh.
-
scpArgs
private java.lang.String scpArgs
Arguments to pass to the SCP command.
-
sshArgs
private java.lang.String sshArgs
Arguments to pass to the SSH command.
-
sshTool
private ScpHelper sshTool
-
SSH_FATAL_EXIT_CODE
private static final int SSH_FATAL_EXIT_CODE
- See Also:
- Constant Field Values
-
-
Method Detail
-
openConnectionInternal
protected void openConnectionInternal() throws AuthenticationException- Specified by:
openConnectionInternalin classAbstractWagon- Throws:
AuthenticationException
-
closeConnection
public void closeConnection()
- Specified by:
closeConnectionin classAbstractWagon
-
getIfNewer
public boolean getIfNewer(java.lang.String resourceName, java.io.File destination, long timestamp) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationExceptionDescription copied from interface:WagonDownloads specified resource from the repository if it was modified since specified date. The date is measured in milliseconds, between the current time and midnight, January 1, 1970 UTC and aligned to GMT timezone.- Specified by:
getIfNewerin interfaceWagon- Returns:
trueif newer resource has been downloaded,falseif resource in the repository is older or has the same age.- Throws:
TransferFailedExceptionResourceDoesNotExistExceptionAuthorizationException
-
buildRemoteHost
private java.lang.String buildRemoteHost()
- Returns:
- The hostname of the remote server prefixed with the username, which comes either from the repository URL or from the authenticationInfo.
-
executeCommand
public void executeCommand(java.lang.String command) throws CommandExecutionException- Specified by:
executeCommandin interfaceCommandExecutor- Throws:
CommandExecutionException
-
executeCommand
public Streams executeCommand(java.lang.String command, boolean ignoreFailures) throws CommandExecutionException
- Specified by:
executeCommandin interfaceCommandExecutor- Throws:
CommandExecutionException
-
isPuTTY
protected boolean isPuTTY()
-
createBaseCommandLine
private org.codehaus.plexus.util.cli.Commandline createBaseCommandLine(boolean putty, java.lang.String executable, java.io.File privateKey)
-
executeScpCommand
private void executeScpCommand(Resource resource, java.io.File localFile, boolean put) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
-
isPuTTYSCP
boolean isPuTTYSCP()
-
normalizeResource
private java.lang.String normalizeResource(Resource resource)
-
put
public void put(java.io.File source, java.lang.String destination) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationExceptionDescription copied from interface:WagonCopy a file from local system to remote- Specified by:
putin interfaceWagon- Parameters:
source- the local filedestination- the remote destination- Throws:
TransferFailedExceptionResourceDoesNotExistExceptionAuthorizationException
-
get
public void get(java.lang.String resourceName, java.io.File destination) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationExceptionDescription copied from interface:WagonDownloads specified resource from the repository to given file.- Specified by:
getin interfaceWagon- Throws:
TransferFailedExceptionResourceDoesNotExistExceptionAuthorizationException
-
getFileList
public java.util.List<java.lang.String> getFileList(java.lang.String destinationDirectory) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationExceptionDescription copied from interface:WagonReturns aListof strings naming the files and directories in the directory denoted by this abstract pathname. If this abstract pathname does not denote a directory, or does not exist, then this method throwsResourceDoesNotExistException. Otherwise aListof strings is returned, one for each file or directory in the directory. Names denoting the directory itself and the directory's parent directory are not included in the result. Each string is a file name rather than a complete path. There is no guarantee that the name strings in the resulting list will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.- Specified by:
getFileListin interfaceWagon- Overrides:
getFileListin classAbstractWagon- Parameters:
destinationDirectory- directory to list contents of- Returns:
- A
Listof strings naming the files and directories in the directory denoted by this abstract pathname. TheListwill be empty if the directory is empty. - Throws:
TransferFailedException- if there's an error trying to access the remote sideResourceDoesNotExistException- if destinationDirectory does not exist or is not a directoryAuthorizationException- if not authorized to list the contents of the directory
-
putDirectory
public void putDirectory(java.io.File sourceDirectory, java.lang.String destinationDirectory) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationExceptionDescription copied from interface:WagonCopy a directory from local system to remote- Specified by:
putDirectoryin interfaceWagon- Overrides:
putDirectoryin classAbstractWagon- Parameters:
sourceDirectory- the local directorydestinationDirectory- the remote destination- Throws:
TransferFailedExceptionResourceDoesNotExistExceptionAuthorizationException
-
resourceExists
public boolean resourceExists(java.lang.String resourceName) throws TransferFailedException, AuthorizationExceptionDescription copied from interface:WagonCheck if a remote resource exists- Specified by:
resourceExistsin interfaceWagon- Overrides:
resourceExistsin classAbstractWagon- Returns:
- whether the resource exists or not
- Throws:
TransferFailedException- if there's an error trying to access the remote sideAuthorizationException- if not authorized to verify the existence of the resource
-
supportsDirectoryCopy
public boolean supportsDirectoryCopy()
Description copied from interface:WagonFlag indicating if this wagon supports directory copy operations.- Specified by:
supportsDirectoryCopyin interfaceWagon- Overrides:
supportsDirectoryCopyin classAbstractWagon- Returns:
- whether if this wagon supports directory operations
-
getScpExecutable
public java.lang.String getScpExecutable()
-
setScpExecutable
public void setScpExecutable(java.lang.String scpExecutable)
-
getSshExecutable
public java.lang.String getSshExecutable()
-
setSshExecutable
public void setSshExecutable(java.lang.String sshExecutable)
-
getScpArgs
public java.lang.String getScpArgs()
-
setScpArgs
public void setScpArgs(java.lang.String scpArgs)
-
getSshArgs
public java.lang.String getSshArgs()
-
setSshArgs
public void setSshArgs(java.lang.String sshArgs)
-
-