diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/credentials/Credentials.scala b/modules/lm-coursier/src/main/scala/lmcoursier/credentials/Credentials.scala index 47df861d8..8557ba188 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/credentials/Credentials.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/credentials/Credentials.scala @@ -2,10 +2,7 @@ package lmcoursier.credentials import java.io.File -abstract class Credentials extends Serializable { - // calling this may incur I/O - def get(): Seq[DirectCredentials] -} +abstract class Credentials extends Serializable object Credentials { diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/credentials/DirectCredentials.scala b/modules/lm-coursier/src/main/scala/lmcoursier/credentials/DirectCredentials.scala index e05cbe93c..d18b1bfe5 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/credentials/DirectCredentials.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/credentials/DirectCredentials.scala @@ -1,7 +1,5 @@ package lmcoursier.credentials -import java.net.URI - final class DirectCredentials private( val host: String, val username: String, @@ -52,32 +50,6 @@ final class DirectCredentials private( copy(matchHost = matchHost) def withHttpsOnly(httpsOnly: Boolean): DirectCredentials = copy(httpsOnly = httpsOnly) - - def autoMatches(url: String, realm0: Option[String]): Boolean = - matchHost && { - val uri = new URI(url) - val schemeOpt = Option(uri.getScheme) - val hostOpt = Option(uri.getHost) - ((schemeOpt.contains("http") && !httpsOnly) || schemeOpt.contains("https")) && - hostOpt.contains(host) && - realm.forall(realm0.contains) - } - - def matches(url: String, user: String): Boolean = { - val uri = new URI(url) - val schemeOpt = Option(uri.getScheme) - val hostOpt = Option(uri.getHost) - val userInfoOpt = Option(uri.getUserInfo) - // !matchHost && // ? - userInfoOpt.isEmpty && - ((schemeOpt.contains("http") && !httpsOnly) || schemeOpt.contains("https")) && - hostOpt.contains(host) && - user == username - } - - def get(): Seq[DirectCredentials] = - Seq(this) - } object DirectCredentials { diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/credentials/FileCredentials.scala b/modules/lm-coursier/src/main/scala/lmcoursier/credentials/FileCredentials.scala index ab4d8e100..073bb9690 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/credentials/FileCredentials.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/credentials/FileCredentials.scala @@ -1,10 +1,5 @@ package lmcoursier.credentials -import java.io.{File, FileInputStream} -import java.util.Properties - -import scala.collection.JavaConverters._ - final class FileCredentials private( val path: String, val optional: Boolean @@ -31,59 +26,6 @@ final class FileCredentials private( def withOptional(optional: Boolean): FileCredentials = { copy(optional = optional) } - - def get(): Seq[DirectCredentials] = { - - val f = new File(path) - - if (f.isFile) { - - val props = new Properties - - var fis: FileInputStream = null - try { - fis = new FileInputStream(f) - props.load(fis) - } finally { - if (fis != null) - fis.close() - } - - val userProps = props - .propertyNames() - .asScala - .map(_.asInstanceOf[String]) - .filter(_.endsWith(".username")) - .toVector - - userProps.map { userProp => - val prefix = userProp.stripSuffix(".username") - - val user = props.getProperty(userProp) - val password = Option(props.getProperty(s"$prefix.password")).getOrElse { - throw new Exception(s"Property $prefix.password not found in $path") - } - - val host = Option(props.getProperty(s"$prefix.host")).getOrElse { - throw new Exception(s"Property $prefix.host not found in $path") - } - - val realmOpt = Option(props.getProperty(s"$prefix.realm")) // filter if empty? - - val matchHost = Option(props.getProperty(s"$prefix.auto")).fold(false)(_.toBoolean) - val httpsOnly = Option(props.getProperty(s"$prefix.https-only")).fold(true)(_.toBoolean) - - DirectCredentials(host, user, password) - .withRealm(realmOpt) - .withMatchHost(matchHost) - .withHttpsOnly(httpsOnly) - } - - } else if (optional) - Nil - else - throw new Exception(s"Credential file $path not found") - } } object FileCredentials { diff --git a/project/Mima.scala b/project/Mima.scala index 8e338d2f9..258bc7831 100644 --- a/project/Mima.scala +++ b/project/Mima.scala @@ -37,6 +37,12 @@ object Mima { import com.typesafe.tools.mima.core._ Seq( + // Methods that shouldn't have been there + ProblemFilters.exclude[DirectMissingMethodProblem]("lmcoursier.credentials.FileCredentials.get"), + ProblemFilters.exclude[DirectMissingMethodProblem]("lmcoursier.credentials.DirectCredentials.matches"), + ProblemFilters.exclude[DirectMissingMethodProblem]("lmcoursier.credentials.DirectCredentials.get"), + ProblemFilters.exclude[DirectMissingMethodProblem]("lmcoursier.credentials.DirectCredentials.autoMatches"), + ProblemFilters.exclude[DirectMissingMethodProblem]("lmcoursier.credentials.Credentials.get"), // Removed unused method, shouldn't have been there in the first place ProblemFilters.exclude[DirectMissingMethodProblem]("lmcoursier.credentials.DirectCredentials.authentication"), // ignore shaded and internal stuff related errors