Class AbstractSshBasedRepository
- java.lang.Object
-
- org.apache.ivy.plugins.repository.AbstractRepository
-
- org.apache.ivy.plugins.repository.ssh.AbstractSshBasedRepository
-
- All Implemented Interfaces:
Repository
- Direct Known Subclasses:
SFTPRepository
,SshRepository
public abstract class AbstractSshBasedRepository extends AbstractRepository
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
allowedAgentUse
private static java.util.Map<java.lang.String,Credentials>
credentialsCache
hashmap of user/hosts with credentials.private java.lang.String
host
private java.io.File
keyFile
private java.lang.String
keyFilePassword
private static int
MAX_CREDENTIALS_CACHE_SIZE
private java.io.File
passFile
private int
port
private java.lang.String
sshConfig
private java.lang.String
user
private java.lang.String
userPassword
-
Constructor Summary
Constructors Constructor Description AbstractSshBasedRepository()
AbstractSshBasedRepository(TimeoutConstraint timeoutConstraint)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.String
getHost()
java.io.File
getKeyFile()
java.lang.String
getKeyFilePassword()
java.io.File
getPassFile()
int
getPort()
protected abstract java.lang.String
getRepositoryScheme()
protected com.jcraft.jsch.Session
getSession(java.lang.String pathOrUri)
get a new session using the default attributes if the given String is a full uri, use the data from the uri insteadjava.lang.String
getSshConfig()
java.lang.String
getUser()
java.lang.String
getUserPassword()
boolean
isAllowedAgentUse()
private java.net.URI
parseURI(java.lang.String source)
Just check the uri for sanityprotected void
releaseSession(com.jcraft.jsch.Session session, java.lang.String pathOrUri)
closes the session and remove it from the cache (eg.private Credentials
requestCredentials(java.lang.String host)
Called, when user was not found in URL.void
setAllowedAgentUse(boolean allowedAgentUse)
void
setHost(java.lang.String host)
void
setKeyFile(java.io.File filePath)
Sets the full file path to use for accessing a PEM key filevoid
setKeyFilePassword(java.lang.String keyFilePassword)
void
setPassFile(java.io.File passFile)
void
setPort(int port)
void
setSshConfig(java.lang.String sshConfig)
void
setUser(java.lang.String user)
set the default user to use for the connection if no user is given or a PEM file is usedvoid
setUserPassword(java.lang.String password)
-
Methods inherited from class org.apache.ivy.plugins.repository.AbstractRepository
addTransferListener, fireTransferCompleted, fireTransferCompleted, fireTransferError, fireTransferError, fireTransferEvent, fireTransferInitiated, fireTransferProgress, fireTransferStarted, fireTransferStarted, getFileSeparator, getName, getTimeoutConstraint, hasTransferListener, put, put, removeTransferListener, setName, standardize, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.ivy.plugins.repository.Repository
get, getResource, list
-
-
-
-
Field Detail
-
keyFile
private java.io.File keyFile
-
passFile
private java.io.File passFile
-
userPassword
private java.lang.String userPassword
-
keyFilePassword
private java.lang.String keyFilePassword
-
user
private java.lang.String user
-
host
private java.lang.String host
-
port
private int port
-
allowedAgentUse
private boolean allowedAgentUse
-
sshConfig
private java.lang.String sshConfig
-
credentialsCache
private static final java.util.Map<java.lang.String,Credentials> credentialsCache
hashmap of user/hosts with credentials. key is hostname, value is Credentials
-
MAX_CREDENTIALS_CACHE_SIZE
private static final int MAX_CREDENTIALS_CACHE_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractSshBasedRepository
public AbstractSshBasedRepository()
-
AbstractSshBasedRepository
public AbstractSshBasedRepository(TimeoutConstraint timeoutConstraint)
-
-
Method Detail
-
getSession
protected com.jcraft.jsch.Session getSession(java.lang.String pathOrUri) throws java.io.IOException
get a new session using the default attributes if the given String is a full uri, use the data from the uri instead- Parameters:
pathOrUri
- might be just a path or a full ssh or sftp uri- Returns:
- matching Session
- Throws:
java.io.IOException
- if something goes wrong
-
parseURI
private java.net.URI parseURI(java.lang.String source)
Just check the uri for sanity- Parameters:
source
- String of the uri- Returns:
- URI object of the String or null
-
requestCredentials
private Credentials requestCredentials(java.lang.String host)
Called, when user was not found in URL. Maintain static hash of credentials and retrieve or ask credentials for host.- Parameters:
host
- host for which we want to get credentials.- Returns:
- credentials for given host
-
releaseSession
protected void releaseSession(com.jcraft.jsch.Session session, java.lang.String pathOrUri)
closes the session and remove it from the cache (eg. on case of errors)- Parameters:
session
- key for the cachepathOrUri
- to release
-
setUser
public void setUser(java.lang.String user)
set the default user to use for the connection if no user is given or a PEM file is used- Parameters:
user
- to use
-
getUser
public java.lang.String getUser()
- Returns:
- the user to use for the connection if no user is given or a PEM file is used
-
setKeyFile
public void setKeyFile(java.io.File filePath)
Sets the full file path to use for accessing a PEM key file- Parameters:
filePath
- fully qualified name
-
getKeyFile
public java.io.File getKeyFile()
- Returns:
- the keyFile
-
setUserPassword
public void setUserPassword(java.lang.String password)
- Parameters:
password
- password to use for user/password authentication
-
getKeyFilePassword
public java.lang.String getKeyFilePassword()
- Returns:
- the keyFile password for public key based authentication
-
setKeyFilePassword
public void setKeyFilePassword(java.lang.String keyFilePassword)
- Parameters:
keyFilePassword
- sets password for public key based authentication
-
getUserPassword
public java.lang.String getUserPassword()
- Returns:
- the user password
-
getHost
public java.lang.String getHost()
- Returns:
- the host
-
setHost
public void setHost(java.lang.String host)
- Parameters:
host
- the host to set
-
getPort
public int getPort()
- Returns:
- the port
-
setPort
public void setPort(int port)
- Parameters:
port
- the port to set
-
setPassFile
public void setPassFile(java.io.File passFile)
- Parameters:
passFile
- the passfile to set
-
getPassFile
public java.io.File getPassFile()
- Returns:
- the passFile
-
isAllowedAgentUse
public boolean isAllowedAgentUse()
- Returns:
- allowedAgentUse Whether use of a local SSH agent for authentication is allowed
-
setAllowedAgentUse
public void setAllowedAgentUse(boolean allowedAgentUse)
- Parameters:
allowedAgentUse
- Whether use of a local SSH agent for authentication is allowed
-
getSshConfig
public java.lang.String getSshConfig()
- Returns:
- sshConfig Path to a local ssh config file
-
setSshConfig
public void setSshConfig(java.lang.String sshConfig)
- Parameters:
sshConfig
- Path to a local ssh config file
-
getRepositoryScheme
protected abstract java.lang.String getRepositoryScheme()
-
-