Skip to content

Commit

Permalink
chore: updates language versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jkugiya committed Dec 25, 2022
1 parent 5c9968b commit 41620a0
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 30 deletions.
7 changes: 7 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version = 2.7.5

maxColumn=120

align.tokens=[]

spaces.inImportCurlyBraces=true
11 changes: 5 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -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"
)
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 0.13.13
sbt.version = 1.8.0
6 changes: 3 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -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")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.15")
2 changes: 1 addition & 1 deletion publish.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ publishTo := {
}

publishMavenStyle := true
publishArtifact in Test := false
Test / publishArtifact := false
pomIncludeRepository := { _ => false }

pomExtra := (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/jkugiya/awstools/signer/v4/HttpRequest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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("/")
Expand Down
27 changes: 16 additions & 11 deletions src/main/scala/jkugiya/awstools/signer/v4/Signer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand All @@ -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
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ private object SigningException {
if (msg != null) msg
else if (cause != null) cause.getMessage
else null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ object EnvironmentVarResolver {
implicit val resolver: EnvironmentVarResolver = new EnvironmentVarResolver {
override def get(key: String): Option[String] = sys.env.get(key)
}
}
}
4 changes: 2 additions & 2 deletions src/main/scala/jkugiya/awstools/signer/v4/hash/Base16.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit 41620a0

Please sign in to comment.