From a2d8bd1bee0ac14c5e42649223bc2cb985a06ad2 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Wed, 28 Apr 2010 20:45:35 -0400 Subject: [PATCH] support ssh/sftp with keyfiles (needed to add user name parameter to 'as') --- ivy/ConvertResolver.scala | 7 ++++--- ivy/IvyInterface.scala | 12 ++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ivy/ConvertResolver.scala b/ivy/ConvertResolver.scala index 085689dca..7901eb744 100644 --- a/ivy/ConvertResolver.scala +++ b/ivy/ConvertResolver.scala @@ -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) diff --git a/ivy/IvyInterface.scala b/ivy/IvyInterface.scala index 68e878eb2..531597e19 100644 --- a/ivy/IvyInterface.scala +++ b/ivy/IvyInterface.scala @@ -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