org.kuali.common.util.secure.channel
Class DefaultSecureChannel
java.lang.Object
org.kuali.common.util.secure.channel.DefaultSecureChannel
- All Implemented Interfaces:
- SecureChannel
public final class DefaultSecureChannel
- extends Object
- implements SecureChannel
Method Summary |
void |
close()
|
protected void |
closeQuietly(com.jcraft.jsch.Channel channel)
|
protected void |
closeQuietly(com.jcraft.jsch.Session session)
|
protected void |
connect(com.jcraft.jsch.Channel channel,
com.google.common.base.Optional<Integer> timeout)
|
void |
copyFile(File source,
RemoteFile destination)
|
void |
copyFile(RemoteFile source,
File destination)
|
void |
copyFile(RemoteFile source,
OutputStream out)
|
void |
copyFileToDirectory(File source,
RemoteFile directory)
|
void |
copyFileToDirectory(RemoteFile source,
File destination)
|
void |
copyInputStreamToFile(InputStream source,
RemoteFile destination)
|
void |
copyLocationToDirectory(String location,
RemoteFile directory)
|
void |
copyLocationToFile(String location,
RemoteFile destination)
|
void |
copyRemoteFile(String absolutePath,
OutputStream out)
|
void |
copyStringToFile(String string,
RemoteFile destination)
|
protected void |
createDirectories(RemoteFile file)
|
void |
createDirectory(RemoteFile dir)
|
void |
deleteFile(String absolutePath)
|
Result |
executeCommand(String command)
|
Result |
executeCommand(String command,
String stdin)
|
void |
executeNoWait(String command)
|
boolean |
exists(String absolutePath)
|
protected RemoteFile |
fillInAttributes(String path)
|
protected RemoteFile |
fillInAttributes(String path,
com.jcraft.jsch.SftpATTRS attributes)
|
protected String |
getAbsolutePath(String absolutePath,
String filename)
|
File |
getConfig()
|
com.google.common.base.Optional<Integer> |
getConnectTimeout()
|
String |
getEncoding()
|
String |
getHostname()
|
protected InputStream |
getInputStream(String s,
String encoding)
|
protected String |
getInvalidExistingFileMessage(RemoteFile existing)
|
protected com.jcraft.jsch.JSch |
getJSch()
|
protected com.jcraft.jsch.JSch |
getJSch(List<File> privateKeys,
List<String> privateKeyStrings)
|
File |
getKnownHosts()
|
RemoteFile |
getMetaData(String absolutePath)
|
Properties |
getOptions()
|
int |
getPort()
|
List<File> |
getPrivateKeys()
|
List<String> |
getPrivateKeyStrings()
|
com.jcraft.jsch.Session |
getSession()
|
com.jcraft.jsch.ChannelSftp |
getSftp()
|
protected static List<File> |
getUniquePrivateKeyFiles(List<File> privateKeys,
boolean useConfigFile,
File config,
boolean includeDefaultPrivateKeyLocations)
|
String |
getUsername()
|
int |
getWaitForClosedSleepMillis()
|
RemoteFile |
getWorkingDirectory()
|
protected RemoteFile |
handleNoSuchFileException(String path,
com.jcraft.jsch.SftpException e)
|
boolean |
isDirectory(String absolutePath)
|
boolean |
isIncludeDefaultPrivateKeyLocations()
|
protected boolean |
isNoSuchFileException(com.jcraft.jsch.SftpException exception)
|
protected boolean |
isStatus(RemoteFile file,
Status status)
|
boolean |
isStrictHostKeyChecking()
|
boolean |
isUseConfigFile()
|
protected void |
logOpen()
|
protected void |
mkdir(RemoteFile dir)
|
void |
open()
|
protected com.jcraft.jsch.Session |
openSession(com.jcraft.jsch.JSch jsch)
|
protected com.jcraft.jsch.ChannelSftp |
openSftpChannel(com.jcraft.jsch.Session session,
com.google.common.base.Optional<Integer> timeout)
|
protected void |
setAttributes(RemoteFile file)
|
void |
setSession(com.jcraft.jsch.Session session)
|
void |
setSftp(com.jcraft.jsch.ChannelSftp sftp)
|
String |
toString(RemoteFile source)
|
protected void |
validate(RemoteFile file,
boolean directoryIndicator)
|
protected void |
waitForClosed(com.jcraft.jsch.ChannelExec exec,
long millis)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
open
public void open()
throws IOException
- Specified by:
open
in interface SecureChannel
- Throws:
IOException
close
public void close()
- Specified by:
close
in interface SecureChannel
executeCommand
public Result executeCommand(String command)
- Specified by:
executeCommand
in interface SecureChannel
executeCommand
public Result executeCommand(String command,
String stdin)
- Specified by:
executeCommand
in interface SecureChannel
executeNoWait
public void executeNoWait(String command)
- Specified by:
executeNoWait
in interface SecureChannel
getInputStream
protected InputStream getInputStream(String s,
String encoding)
waitForClosed
protected void waitForClosed(com.jcraft.jsch.ChannelExec exec,
long millis)
getWorkingDirectory
public RemoteFile getWorkingDirectory()
- Specified by:
getWorkingDirectory
in interface SecureChannel
logOpen
protected void logOpen()
openSftpChannel
protected com.jcraft.jsch.ChannelSftp openSftpChannel(com.jcraft.jsch.Session session,
com.google.common.base.Optional<Integer> timeout)
throws com.jcraft.jsch.JSchException
- Throws:
com.jcraft.jsch.JSchException
connect
protected void connect(com.jcraft.jsch.Channel channel,
com.google.common.base.Optional<Integer> timeout)
throws com.jcraft.jsch.JSchException
- Throws:
com.jcraft.jsch.JSchException
closeQuietly
protected void closeQuietly(com.jcraft.jsch.Session session)
closeQuietly
protected void closeQuietly(com.jcraft.jsch.Channel channel)
openSession
protected com.jcraft.jsch.Session openSession(com.jcraft.jsch.JSch jsch)
throws com.jcraft.jsch.JSchException
- Throws:
com.jcraft.jsch.JSchException
getJSch
protected com.jcraft.jsch.JSch getJSch()
throws com.jcraft.jsch.JSchException
- Throws:
com.jcraft.jsch.JSchException
getJSch
protected com.jcraft.jsch.JSch getJSch(List<File> privateKeys,
List<String> privateKeyStrings)
throws com.jcraft.jsch.JSchException
- Throws:
com.jcraft.jsch.JSchException
getUniquePrivateKeyFiles
protected static List<File> getUniquePrivateKeyFiles(List<File> privateKeys,
boolean useConfigFile,
File config,
boolean includeDefaultPrivateKeyLocations)
getMetaData
public RemoteFile getMetaData(String absolutePath)
- Specified by:
getMetaData
in interface SecureChannel
deleteFile
public void deleteFile(String absolutePath)
- Specified by:
deleteFile
in interface SecureChannel
exists
public boolean exists(String absolutePath)
- Specified by:
exists
in interface SecureChannel
isDirectory
public boolean isDirectory(String absolutePath)
- Specified by:
isDirectory
in interface SecureChannel
fillInAttributes
protected RemoteFile fillInAttributes(String path)
fillInAttributes
protected RemoteFile fillInAttributes(String path,
com.jcraft.jsch.SftpATTRS attributes)
copyFile
public void copyFile(File source,
RemoteFile destination)
- Specified by:
copyFile
in interface SecureChannel
copyFileToDirectory
public void copyFileToDirectory(File source,
RemoteFile directory)
- Specified by:
copyFileToDirectory
in interface SecureChannel
copyLocationToFile
public void copyLocationToFile(String location,
RemoteFile destination)
- Specified by:
copyLocationToFile
in interface SecureChannel
copyStringToFile
public void copyStringToFile(String string,
RemoteFile destination)
- Specified by:
copyStringToFile
in interface SecureChannel
toString
public String toString(RemoteFile source)
- Specified by:
toString
in interface SecureChannel
copyInputStreamToFile
public void copyInputStreamToFile(InputStream source,
RemoteFile destination)
- Specified by:
copyInputStreamToFile
in interface SecureChannel
getAbsolutePath
protected String getAbsolutePath(String absolutePath,
String filename)
copyLocationToDirectory
public void copyLocationToDirectory(String location,
RemoteFile directory)
- Specified by:
copyLocationToDirectory
in interface SecureChannel
copyFile
public void copyFile(RemoteFile source,
File destination)
- Specified by:
copyFile
in interface SecureChannel
copyRemoteFile
public void copyRemoteFile(String absolutePath,
OutputStream out)
throws IOException
- Specified by:
copyRemoteFile
in interface SecureChannel
- Throws:
IOException
copyFile
public void copyFile(RemoteFile source,
OutputStream out)
throws IOException
- Specified by:
copyFile
in interface SecureChannel
- Throws:
IOException
copyFileToDirectory
public void copyFileToDirectory(RemoteFile source,
File destination)
- Specified by:
copyFileToDirectory
in interface SecureChannel
createDirectory
public void createDirectory(RemoteFile dir)
- Specified by:
createDirectory
in interface SecureChannel
createDirectories
protected void createDirectories(RemoteFile file)
throws com.jcraft.jsch.SftpException
- Throws:
com.jcraft.jsch.SftpException
isStatus
protected boolean isStatus(RemoteFile file,
Status status)
validate
protected void validate(RemoteFile file,
boolean directoryIndicator)
getInvalidExistingFileMessage
protected String getInvalidExistingFileMessage(RemoteFile existing)
mkdir
protected void mkdir(RemoteFile dir)
setAttributes
protected void setAttributes(RemoteFile file)
throws com.jcraft.jsch.SftpException
- Throws:
com.jcraft.jsch.SftpException
handleNoSuchFileException
protected RemoteFile handleNoSuchFileException(String path,
com.jcraft.jsch.SftpException e)
isNoSuchFileException
protected boolean isNoSuchFileException(com.jcraft.jsch.SftpException exception)
getSession
public com.jcraft.jsch.Session getSession()
setSession
public void setSession(com.jcraft.jsch.Session session)
getSftp
public com.jcraft.jsch.ChannelSftp getSftp()
setSftp
public void setSftp(com.jcraft.jsch.ChannelSftp sftp)
getKnownHosts
public File getKnownHosts()
getConfig
public File getConfig()
isUseConfigFile
public boolean isUseConfigFile()
isIncludeDefaultPrivateKeyLocations
public boolean isIncludeDefaultPrivateKeyLocations()
isStrictHostKeyChecking
public boolean isStrictHostKeyChecking()
getPort
public int getPort()
- Specified by:
getPort
in interface SecureChannel
getWaitForClosedSleepMillis
public int getWaitForClosedSleepMillis()
getEncoding
public String getEncoding()
getUsername
public String getUsername()
- Specified by:
getUsername
in interface SecureChannel
getHostname
public String getHostname()
- Specified by:
getHostname
in interface SecureChannel
getConnectTimeout
public com.google.common.base.Optional<Integer> getConnectTimeout()
getPrivateKeys
public List<File> getPrivateKeys()
getPrivateKeyStrings
public List<String> getPrivateKeyStrings()
getOptions
public Properties getOptions()
Copyright © 2010-2013 The Kuali Foundation. All Rights Reserved.