diff --git a/.scalafmt.conf b/.scalafmt.conf new file mode 100644 index 0000000..b03af25 --- /dev/null +++ b/.scalafmt.conf @@ -0,0 +1,7 @@ +version = 2.7.5 + +maxColumn=120 + +align.tokens=[] + +spaces.inImportCurlyBraces=true diff --git a/build.sbt b/build.sbt index c0a59db..c750ae3 100644 --- a/build.sbt +++ b/build.sbt @@ -1,13 +1,12 @@ name := "aws-v4-signer-scala" organization := "com.github.jkugiya" -version := "0.13" +version := "0.14" -scalaVersion := "2.11.8" - -crossScalaVersions := Seq("2.11.8", "2.12.0") +scalaVersion := "2.13.10" +crossScalaVersions := Seq("2.11.8", "2.12.17", "2.13.10", "3.2.1") libraryDependencies ++= Seq( - "org.scalatest" %% "scalatest" % "3.0.1" % "test", - "org.mockito" % "mockito-core" % "2.2.26" % "test" + "org.scalatest" %% "scalatest" % "3.2.14" % "test", + "org.mockito" % "mockito-core" % "4.10.0" % "test" ) diff --git a/project/build.properties b/project/build.properties index e0cbc71..9a19778 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version = 0.13.13 \ No newline at end of file +sbt.version = 1.8.0 diff --git a/project/plugins.sbt b/project/plugins.sbt index e651fd9..1662385 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,7 +1,7 @@ logLevel := Level.Warn -addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.6.0") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0") -addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0") +addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1") -addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1") \ No newline at end of file +addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.15") diff --git a/publish.sbt b/publish.sbt index a842fbf..94d3c34 100644 --- a/publish.sbt +++ b/publish.sbt @@ -11,7 +11,7 @@ publishTo := { } publishMavenStyle := true -publishArtifact in Test := false +Test / publishArtifact := false pomIncludeRepository := { _ => false } pomExtra := ( diff --git a/src/main/scala/jkugiya/awstools/signer/v4/CanonicalHeaders.scala b/src/main/scala/jkugiya/awstools/signer/v4/CanonicalHeaders.scala index 4417eca..807cf5b 100644 --- a/src/main/scala/jkugiya/awstools/signer/v4/CanonicalHeaders.scala +++ b/src/main/scala/jkugiya/awstools/signer/v4/CanonicalHeaders.scala @@ -41,9 +41,10 @@ object CanonicalHeaders { x.toLowerCase().compareTo(y.toLowerCase()) } val internalMap = - headers.foldLeft(TreeMap.empty[String, Vector[String]]) { - case (acc, Header(k, v)) => - acc.get(k).fold { + headers.foldLeft(TreeMap.empty[String, Vector[String]]) { case (acc, Header(k, v)) => + acc + .get(k) + .fold { acc + (k -> Vector(v)) } { values => acc + (k -> (values :+ v)) diff --git a/src/main/scala/jkugiya/awstools/signer/v4/HttpRequest.scala b/src/main/scala/jkugiya/awstools/signer/v4/HttpRequest.scala index dcf1805..b8eebb6 100644 --- a/src/main/scala/jkugiya/awstools/signer/v4/HttpRequest.scala +++ b/src/main/scala/jkugiya/awstools/signer/v4/HttpRequest.scala @@ -8,7 +8,8 @@ case class HttpRequest(method: String, uri: URI) { if (uri.getPath.isEmpty) "/" else { val path = - uri.getPath.substring(1, uri.getPath.length) + uri.getPath + .substring(1, uri.getPath.length) .split("/") .map(URLEncoder.encode(_, "UTF-8").replaceAll("\\*", "%2A")) .mkString("/") diff --git a/src/main/scala/jkugiya/awstools/signer/v4/Signer.scala b/src/main/scala/jkugiya/awstools/signer/v4/Signer.scala index a4a79a2..7ed1ba7 100644 --- a/src/main/scala/jkugiya/awstools/signer/v4/Signer.scala +++ b/src/main/scala/jkugiya/awstools/signer/v4/Signer.scala @@ -27,10 +27,10 @@ object Signer { private[this] val Algorithm = AuthTag + "-HMAC-SHA256" private def signInternal( - region: String, - service: String, - request: CanonicalRequest, - credentials: AwsCredentials + region: String, + service: String, + request: CanonicalRequest, + credentials: AwsCredentials ): String = { val headers = request.headers @@ -58,11 +58,11 @@ object Signer { } private[this] def buildSignature( - secretKey: String, - dateWithoutTimestamp: String, - stringToSign: String, - service: String, - region: String + secretKey: String, + dateWithoutTimestamp: String, + stringToSign: String, + service: String, + region: String ) = { val kSecret = (AuthTag + secretKey).getBytes("UTF-8") val kDate = HmacSha256.encode(kSecret, dateWithoutTimestamp) @@ -72,8 +72,13 @@ object Signer { Base16.encode(HmacSha256.encode(kSigning, stringToSign)).toLowerCase } - private[this] def buildAuthHeader(accessKey: String, credentialScope: String, signedHeaders: String, signature: String) = { + private[this] def buildAuthHeader( + accessKey: String, + credentialScope: String, + signedHeaders: String, + signature: String + ) = { Algorithm + " " + "Credential=" + accessKey + "/" + credentialScope + ", " + "SignedHeaders=" + signedHeaders + ", " + "Signature=" + signature } -} \ No newline at end of file +} diff --git a/src/main/scala/jkugiya/awstools/signer/v4/SigningException.scala b/src/main/scala/jkugiya/awstools/signer/v4/SigningException.scala index 271d669..fd3bf8c 100644 --- a/src/main/scala/jkugiya/awstools/signer/v4/SigningException.scala +++ b/src/main/scala/jkugiya/awstools/signer/v4/SigningException.scala @@ -14,4 +14,4 @@ private object SigningException { if (msg != null) msg else if (cause != null) cause.getMessage else null -} \ No newline at end of file +} diff --git a/src/main/scala/jkugiya/awstools/signer/v4/credentials/AwsCredentialsProviderChain.scala b/src/main/scala/jkugiya/awstools/signer/v4/credentials/AwsCredentialsProviderChain.scala index 85cb629..a0b3e86 100644 --- a/src/main/scala/jkugiya/awstools/signer/v4/credentials/AwsCredentialsProviderChain.scala +++ b/src/main/scala/jkugiya/awstools/signer/v4/credentials/AwsCredentialsProviderChain.scala @@ -37,4 +37,4 @@ object EnvironmentVarResolver { implicit val resolver: EnvironmentVarResolver = new EnvironmentVarResolver { override def get(key: String): Option[String] = sys.env.get(key) } -} \ No newline at end of file +} diff --git a/src/main/scala/jkugiya/awstools/signer/v4/hash/Base16.scala b/src/main/scala/jkugiya/awstools/signer/v4/hash/Base16.scala index 2ab1e7a..d8f3cfd 100644 --- a/src/main/scala/jkugiya/awstools/signer/v4/hash/Base16.scala +++ b/src/main/scala/jkugiya/awstools/signer/v4/hash/Base16.scala @@ -7,8 +7,8 @@ private[v4] object Base16 { def encode(data: Array[Byte]): String = { val sb = StringBuilder.newBuilder data foreach { d => - sb.append(EncTab((d & 0xF0) >> 4)) - sb.append(EncTab(d & 0x0F)) + sb.append(EncTab((d & 0xf0) >> 4)) + sb.append(EncTab(d & 0x0f)) } sb.toString() }