com.sshtools.daemon.scp
Class ScpServer

java.lang.Object
  extended by com.sshtools.daemon.platform.NativeProcessProvider
      extended by com.sshtools.daemon.scp.ScpServer
All Implemented Interfaces:
java.lang.Runnable

public class ScpServer
extends NativeProcessProvider
implements java.lang.Runnable

Version:
$Revision: 1.1 $
Author:
$author$

Field Summary
private  byte[] buffer
           
private static int BUFFER_SIZE
           
private  java.lang.String currentDirectory
           
private  java.lang.String destination
           
private  boolean directory
           
private  java.io.InputStream err
           
private  int exitCode
           
private  boolean from
           
private  java.io.InputStream in
           
private static org.apache.commons.logging.Log log
           
private  NativeFileSystemProvider nfs
           
private  java.io.OutputStream out
           
private  java.io.PipedOutputStream pipeErr
           
private  java.io.PipedOutputStream pipeIn
           
private  java.io.PipedInputStream pipeOut
           
private  boolean preserveAttributes
           
private  boolean recursive
           
private  SshThread scpServerThread
           
private  boolean to
           
private  int verbosity
           
 
Constructor Summary
ScpServer()
          Creates a new ScpServer object.
 
Method Summary
 boolean allocatePseudoTerminal(java.lang.String term, int cols, int rows, int width, int height, java.lang.String modes)
           
 boolean createProcess(java.lang.String command, java.util.Map environment)
           
 java.lang.String getDefaultTerminalProvider()
           
 java.io.InputStream getInputStream()
           
 java.io.OutputStream getOutputStream()
           
 java.io.InputStream getStderrInputStream()
           
 void kill()
           
private  void parseCommand(java.lang.String cmd, java.lang.String[] cmdParts)
           
private  void readFromRemote(java.lang.String path)
           
private  java.lang.String readString()
           
 void run()
           
private  void scp(java.lang.String args)
           
 void start()
           
 boolean stillActive()
           
 boolean supportsPseudoTerminal(java.lang.String term)
           
 int waitForExitCode()
           
private  void waitForResponse()
           
private  void writeCommand(java.lang.String cmd)
          Send command to client
private  boolean writeDirToRemote(java.lang.String path)
           
private  void writeError(java.lang.String msg)
          Send error message to client
private  void writeError(java.lang.String msg, boolean serious)
          Send error message to client
private  void writeFileToRemote(java.lang.String path)
           
private  void writeOk()
          Send ok command to client
 
Methods inherited from class com.sshtools.daemon.platform.NativeProcessProvider
newInstance, setProvider
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log

BUFFER_SIZE

private static int BUFFER_SIZE

in

private java.io.InputStream in

err

private java.io.InputStream err

out

private java.io.OutputStream out

destination

private java.lang.String destination

pipeIn

private java.io.PipedOutputStream pipeIn

pipeErr

private java.io.PipedOutputStream pipeErr

pipeOut

private java.io.PipedInputStream pipeOut

scpServerThread

private SshThread scpServerThread

verbosity

private int verbosity

exitCode

private int exitCode

directory

private boolean directory

recursive

private boolean recursive

from

private boolean from

to

private boolean to

nfs

private NativeFileSystemProvider nfs

buffer

private byte[] buffer

currentDirectory

private java.lang.String currentDirectory

preserveAttributes

private boolean preserveAttributes
Constructor Detail

ScpServer

public ScpServer()
Creates a new ScpServer object.

Method Detail

allocatePseudoTerminal

public boolean allocatePseudoTerminal(java.lang.String term,
                                      int cols,
                                      int rows,
                                      int width,
                                      int height,
                                      java.lang.String modes)
Specified by:
allocatePseudoTerminal in class NativeProcessProvider
Returns:

createProcess

public boolean createProcess(java.lang.String command,
                             java.util.Map environment)
                      throws java.io.IOException
Specified by:
createProcess in class NativeProcessProvider
Returns:
Throws:
java.io.IOException

getDefaultTerminalProvider

public java.lang.String getDefaultTerminalProvider()
Specified by:
getDefaultTerminalProvider in class NativeProcessProvider
Returns:

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Specified by:
getInputStream in class NativeProcessProvider
Returns:
Throws:
java.io.IOException

getStderrInputStream

public java.io.InputStream getStderrInputStream()
Specified by:
getStderrInputStream in class NativeProcessProvider
Returns:

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Specified by:
getOutputStream in class NativeProcessProvider
Returns:
Throws:
java.io.IOException

kill

public void kill()
Specified by:
kill in class NativeProcessProvider

start

public void start()
           throws java.io.IOException
Specified by:
start in class NativeProcessProvider
Throws:
java.io.IOException

stillActive

public boolean stillActive()
Specified by:
stillActive in class NativeProcessProvider
Returns:

supportsPseudoTerminal

public boolean supportsPseudoTerminal(java.lang.String term)
Specified by:
supportsPseudoTerminal in class NativeProcessProvider
Returns:

waitForExitCode

public int waitForExitCode()
Specified by:
waitForExitCode in class NativeProcessProvider
Returns:

scp

private void scp(java.lang.String args)
          throws java.io.IOException
Throws:
java.io.IOException

writeOk

private void writeOk()
              throws java.io.IOException
Send ok command to client

Throws:
java.io.IOException - on any error

writeCommand

private void writeCommand(java.lang.String cmd)
                   throws java.io.IOException
Send command to client

Parameters:
cmd - command
Throws:
java.io.IOException - on any error

writeError

private void writeError(java.lang.String msg)
                 throws java.io.IOException
Send error message to client

Parameters:
msg - error message
Throws:
java.io.IOException - on any error

writeError

private void writeError(java.lang.String msg,
                        boolean serious)
                 throws java.io.IOException
Send error message to client

Parameters:
msg - error message
serious - serious error
Throws:
java.io.IOException - on any error

run

public void run()
Specified by:
run in interface java.lang.Runnable

writeDirToRemote

private boolean writeDirToRemote(java.lang.String path)
                          throws java.io.IOException
Throws:
java.io.IOException

writeFileToRemote

private void writeFileToRemote(java.lang.String path)
                        throws java.io.IOException,
                               PermissionDeniedException,
                               InvalidHandleException
Throws:
java.io.IOException
PermissionDeniedException
InvalidHandleException

waitForResponse

private void waitForResponse()
                      throws java.io.IOException
Throws:
java.io.IOException

readFromRemote

private void readFromRemote(java.lang.String path)
                     throws java.io.IOException
Throws:
java.io.IOException

parseCommand

private void parseCommand(java.lang.String cmd,
                          java.lang.String[] cmdParts)
                   throws java.io.IOException
Throws:
java.io.IOException

readString

private java.lang.String readString()
                             throws java.io.IOException
Throws:
java.io.IOException