Class SshCache
java.lang.Object
org.apache.ivy.plugins.repository.ssh.SshCache
a class to cache SSH Connections and Channel for the SSH Repository each session is defined by
connecting user / host / port two maps are used to find cache entries one map is using the above
keys, the other uses the session itself
-
Method Summary
Modifier and TypeMethodDescriptionvoid
attachChannelSftp
(com.jcraft.jsch.Session session, com.jcraft.jsch.ChannelSftp channel) attaches a channelSftp to an existing session cache entryvoid
clearSession
(com.jcraft.jsch.Session session) discards session entries from the cachecom.jcraft.jsch.ChannelSftp
getChannelSftp
(com.jcraft.jsch.Session session) retrieves an sftp channel from the cachestatic SshCache
com.jcraft.jsch.Session
getSession
(String host, int port, String username, String userPassword, File pemFile, String pemPassword, File passFile, boolean allowedAgentUse) Gets a session from the cache or establishes a new session if necessary
-
Method Details
-
getInstance
-
clearSession
public void clearSession(com.jcraft.jsch.Session session) discards session entries from the cache- Parameters:
session
- to clear
-
getChannelSftp
public com.jcraft.jsch.ChannelSftp getChannelSftp(com.jcraft.jsch.Session session) throws IOException retrieves an sftp channel from the cache- Parameters:
session
- to connect to- Returns:
- channelSftp or null if not successful (channel not existent or dead)
- Throws:
IOException
- should never happen
-
attachChannelSftp
public void attachChannelSftp(com.jcraft.jsch.Session session, com.jcraft.jsch.ChannelSftp channel) attaches a channelSftp to an existing session cache entry- Parameters:
session
- to attach the channel tochannel
- channel to attach
-
getSession
public com.jcraft.jsch.Session getSession(String host, int port, String username, String userPassword, File pemFile, String pemPassword, File passFile, boolean allowedAgentUse) throws IOException Gets a session from the cache or establishes a new session if necessary- Parameters:
host
- to connect toport
- to use for session (-1 == use standard port)username
- for the session to useuserPassword
- to use for authentication (optional)pemFile
- File to use for public key authenticationpemPassword
- to use for accessing the pemFile (optional)passFile
- to store credentialsallowedAgentUse
- Whether to communicate with an agent for authentication- Returns:
- session or null if not successful
- Throws:
IOException
- if something goes wrong
-