org.kuali.common.util.secure
Class DefaultSecureChannel
java.lang.Object
org.kuali.common.util.secure.DefaultSecureChannel
- All Implemented Interfaces:
- SecureChannel
public class DefaultSecureChannel
- extends Object
- implements SecureChannel
Field Summary |
protected com.jcraft.jsch.Session |
session
|
protected com.jcraft.jsch.ChannelSftp |
sftp
|
Method Summary |
protected void |
addFilenameToPath(RemoteFile destination,
String filename)
|
protected RemoteFile |
clone(RemoteFile file)
|
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,
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 destination)
|
void |
copyFileToDirectory(RemoteFile source,
File destination)
|
void |
copyInputStreamToFile(InputStream source,
RemoteFile destination)
|
void |
copyLocationToDirectory(String location,
RemoteFile destination)
|
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 void |
fillInAttributes(RemoteFile file)
|
protected void |
fillInAttributes(RemoteFile file,
com.jcraft.jsch.SftpATTRS attributes)
|
protected void |
fillInAttributes(RemoteFile file,
String path)
|
protected String |
getAbsolutePath(String absolutePath,
String filename)
|
File |
getConfig()
|
int |
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()
|
protected Properties |
getSessionProperties(Properties options,
boolean strictHostKeyChecking)
|
protected List<File> |
getUniquePrivateKeyFiles()
|
String |
getUsername()
|
int |
getWaitForClosedSleepMillis()
|
RemoteFile |
getWorkingDirectory()
|
protected void |
handleNoSuchFileException(RemoteFile file,
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,
Integer timeout)
|
protected void |
setAttributes(RemoteFile file)
|
void |
setConfig(File config)
|
void |
setConnectTimeout(int connectTimeout)
|
void |
setConnectTimeout(Integer connectTimeout)
|
void |
setEncoding(String encoding)
|
void |
setHostname(String hostname)
|
void |
setIncludeDefaultPrivateKeyLocations(boolean includeDefaultPrivateKeyLocations)
|
void |
setKnownHosts(File knownHosts)
|
void |
setOptions(Properties options)
|
void |
setPort(int port)
|
void |
setPrivateKeys(List<File> privateKeys)
|
void |
setPrivateKeyStrings(List<String> privateKeyStrings)
|
void |
setStrictHostKeyChecking(boolean strictHostKeyChecking)
|
void |
setUseConfigFile(boolean useConfigFile)
|
void |
setUsername(String username)
|
void |
setWaitForClosedSleepMillis(int waitForClosedSleepMillis)
|
protected void |
sleep(long millis)
|
String |
toString(RemoteFile source)
|
protected void |
validate()
|
protected boolean |
validate(RemoteFile file,
boolean directoryIndicator)
|
protected void |
validate(RemoteFile file,
Status... allowed)
|
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 |
session
protected com.jcraft.jsch.Session session
sftp
protected com.jcraft.jsch.ChannelSftp sftp
DefaultSecureChannel
public DefaultSecureChannel()
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)
sleep
protected void sleep(long millis)
getWorkingDirectory
public RemoteFile getWorkingDirectory()
- Specified by:
getWorkingDirectory
in interface SecureChannel
validate
protected void validate()
logOpen
protected void logOpen()
openSftpChannel
protected com.jcraft.jsch.ChannelSftp openSftpChannel(com.jcraft.jsch.Session session,
Integer timeout)
throws com.jcraft.jsch.JSchException
- Throws:
com.jcraft.jsch.JSchException
connect
protected void connect(com.jcraft.jsch.Channel channel,
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)
getSessionProperties
protected Properties getSessionProperties(Properties options,
boolean strictHostKeyChecking)
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 List<File> getUniquePrivateKeyFiles()
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 void fillInAttributes(RemoteFile file)
fillInAttributes
protected void fillInAttributes(RemoteFile file,
String path)
fillInAttributes
protected void fillInAttributes(RemoteFile file,
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 destination)
- Specified by:
copyFileToDirectory
in interface SecureChannel
clone
protected RemoteFile clone(RemoteFile file)
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)
addFilenameToPath
protected void addFilenameToPath(RemoteFile destination,
String filename)
copyLocationToDirectory
public void copyLocationToDirectory(String location,
RemoteFile destination)
- 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,
Status... allowed)
validate
protected boolean 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 void handleNoSuchFileException(RemoteFile file,
com.jcraft.jsch.SftpException e)
isNoSuchFileException
protected boolean isNoSuchFileException(com.jcraft.jsch.SftpException exception)
getKnownHosts
public File getKnownHosts()
setKnownHosts
public void setKnownHosts(File knownHosts)
getConfig
public File getConfig()
setConfig
public void setConfig(File config)
isIncludeDefaultPrivateKeyLocations
public boolean isIncludeDefaultPrivateKeyLocations()
setIncludeDefaultPrivateKeyLocations
public void setIncludeDefaultPrivateKeyLocations(boolean includeDefaultPrivateKeyLocations)
isStrictHostKeyChecking
public boolean isStrictHostKeyChecking()
setStrictHostKeyChecking
public void setStrictHostKeyChecking(boolean strictHostKeyChecking)
getUsername
public String getUsername()
setUsername
public void setUsername(String username)
getHostname
public String getHostname()
setHostname
public void setHostname(String hostname)
getPort
public int getPort()
setPort
public void setPort(int port)
getConnectTimeout
public int getConnectTimeout()
setConnectTimeout
public void setConnectTimeout(int connectTimeout)
getPrivateKeys
public List<File> getPrivateKeys()
setPrivateKeys
public void setPrivateKeys(List<File> privateKeys)
getOptions
public Properties getOptions()
setOptions
public void setOptions(Properties options)
setConnectTimeout
public void setConnectTimeout(Integer connectTimeout)
getWaitForClosedSleepMillis
public int getWaitForClosedSleepMillis()
setWaitForClosedSleepMillis
public void setWaitForClosedSleepMillis(int waitForClosedSleepMillis)
getEncoding
public String getEncoding()
setEncoding
public void setEncoding(String encoding)
getPrivateKeyStrings
public List<String> getPrivateKeyStrings()
setPrivateKeyStrings
public void setPrivateKeyStrings(List<String> privateKeyStrings)
isUseConfigFile
public boolean isUseConfigFile()
setUseConfigFile
public void setUseConfigFile(boolean useConfigFile)
Copyright © 2010-2013 The Kuali Foundation. All Rights Reserved.