support ssh/sftp with keyfiles (needed to add user name parameter to 'as')

This commit is contained in:
Mark Harrah 2010-04-28 20:45:35 -04:00
parent e3c7cb2ff9
commit a2d8bd1bee
2 changed files with 12 additions and 7 deletions

View File

@ -85,10 +85,11 @@ private object ConvertResolver
{
case RepositoryHelpers.PasswordAuthentication(user, password) =>
setUser(user)
setUserPassword(password)
case RepositoryHelpers.KeyFileAuthentication(file, password) =>
password.foreach(setUserPassword)
case RepositoryHelpers.KeyFileAuthentication(user, file, password) =>
setKeyFile(file)
setKeyFilePassword(password)
password.foreach(setKeyFilePassword)
setUser(user)
}
}
private def initializePatterns(resolver: AbstractPatternsBasedResolver, patterns: Patterns)

View File

@ -76,8 +76,8 @@ object RepositoryHelpers
def nonlocal() = FileConfiguration(false, isTransactional)
}
sealed trait SshAuthentication extends NotNull
final case class PasswordAuthentication(user: String, password: String) extends SshAuthentication
final case class KeyFileAuthentication(keyfile: File, password: String) extends SshAuthentication
final case class PasswordAuthentication(user: String, password: Option[String]) extends SshAuthentication
final case class KeyFileAuthentication(user: String, keyfile: File, password: Option[String]) extends SshAuthentication
}
import RepositoryHelpers.{SshConnection, FileConfiguration}
import RepositoryHelpers.{KeyFileAuthentication, PasswordAuthentication, SshAuthentication}
@ -124,9 +124,13 @@ sealed abstract class SshBasedRepository extends PatternsBasedRepository
def connection: SshConnection
/** Configures this to use the specified user name and password when connecting to the remote repository. */
def as(user: String, password: String): RepositoryType = copy(new PasswordAuthentication(user, password))
def as(user: String, password: String): RepositoryType = as(user, Some(password))
def as(user: String): RepositoryType = as(user, None)
def as(user: String, password: Option[String]) = copy(new PasswordAuthentication(user, password))
/** Configures this to use the specified keyfile and password for the keyfile when connecting to the remote repository. */
def as(keyfile: File, password: String): RepositoryType = copy(new KeyFileAuthentication(keyfile, password))
def as(user: String, keyfile: File): RepositoryType = as(user, keyfile, None)
def as(user: String, keyfile: File, password: String): RepositoryType = as(user, keyfile, Some(password))
def as(user: String, keyfile: File, password: Option[String]): RepositoryType = copy(new KeyFileAuthentication(user, keyfile, password))
}
/** sbt interface for an Ivy repository over ssh. More convenient construction is done using Resolver.ssh. */
final case class SshRepository(name: String, connection: SshConnection, patterns: Patterns, publishPermissions: Option[String]) extends SshBasedRepository