Skip to content

Commit

Permalink
BDOG-3112 Drops Scala 2.12
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-lamed committed May 14, 2024
1 parent dfdfd49 commit cb43e70
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 23 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ val optValue: Option[T] = decrypter.reads(encryptedValue).asOpt.map(_.decryptedV

## Changes

### Version 8.0.0

Built for Scala 3 and Scala 2.13 - drops Scala 2.12.

### Version 7.6.0

Adds support for Play 2.9 and Play 3.0
Expand Down
13 changes: 4 additions & 9 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
val scala2_12 = "2.12.18"
val scala2_13 = "2.13.12"
val scala3 = "3.3.3"

ThisBuild / majorVersion := 7
ThisBuild / majorVersion := 8
ThisBuild / scalaVersion := scala2_13
ThisBuild / isPublicArtefact := true
ThisBuild / scalacOptions ++= Seq("-feature") ++
(CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _ )) => Seq("-explain")
case _ => Seq.empty
})
ThisBuild / scalacOptions ++= Seq("-feature")

lazy val library = Project("library", file("."))
.settings(publish / skip := true)
Expand All @@ -22,7 +17,7 @@ lazy val library = Project("library", file("."))

lazy val crypto = Project("crypto", file("crypto"))
.settings(
crossScalaVersions := Seq(scala2_12, scala2_13, scala3),
crossScalaVersions := Seq(scala2_13, scala3),
libraryDependencies ++= LibDependencies.cryptoCompile ++ LibDependencies.cryptoTest
)

Expand All @@ -35,7 +30,7 @@ def shareSources(location: String) = Seq(

lazy val cryptoJsonPlay28 = Project("crypto-json-play-28", file("crypto-json-play-28"))
.settings(
crossScalaVersions := Seq(scala2_12, scala2_13),
crossScalaVersions := Seq(scala2_13),
shareSources("crypto-json"),
libraryDependencies ++= LibDependencies.cryptoJsonPlay28Compile ++ LibDependencies.cryptoTest
).dependsOn(crypto)
Expand Down
1 change: 0 additions & 1 deletion crypto/src/main/scala/uk/gov/hmrc/crypto/AesCrypto.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ trait AesCrypto extends Encrypter with Decrypter {
plain match {
case PlainBytes(bytes) => Crypted(encrypter.encrypt(bytes))
case PlainText(text) => Crypted(encrypter.encrypt(text))
case _ => throw new Exception(s"Unable to encrypt unkown message type: $plain")
}

override def decrypt(encrypted: Crypted): PlainText =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ trait AesGCMCrypto extends Encrypter with Decrypter {
plain match {
case PlainBytes(bytes) => Crypted(fromEncryptedValue(crypto.encrypt(bytes , emptyAssociatedData)))
case PlainText(text) => Crypted(fromEncryptedValue(crypto.encrypt(text.getBytes, emptyAssociatedData)))
case _ => throw new RuntimeException(s"Unable to encrypt unknown message type: $plain")
}

private def fromEncryptedValue(ev: EncryptedBytes): String = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ trait CompositeSymmetricCrypto extends Encrypter with Decrypter {
decrypt(d => Try(d.decryptAsBytes(scrambled)))

private def decrypt[T <: PlainContent](tryDecryption: Decrypter => Try[T]): T = {
val decrypterStream = (currentCrypto +: previousCryptos).toStream
val decrypterStream = (currentCrypto +: previousCryptos).to(LazyList)

val message =
decrypterStream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ object SymmetricCryptoFactory {
decrypt(d => Try(d.decryptAsBytes(scrambled)))

private def decrypt[T <: PlainContent](tryDecryption: Decrypter => Try[T]): T = {
val decrypterStream = (currentCrypto +: previousDecrypters).toStream
val decrypterStream = (currentCrypto +: previousDecrypters).to(LazyList)
decrypterStream
.map(tryDecryption)
.collectFirst { case Success(msg) => msg }
Expand Down Expand Up @@ -95,7 +95,7 @@ object SymmetricCryptoFactory {
currentCrypto.encrypt(valueToEncrypt, associatedText)

override def decrypt(valueToDecrypt: EncryptedValue, associatedText: String): String = {
val decrypterStream = (currentCrypto +: previousDecrypters).toStream
val decrypterStream = (currentCrypto +: previousDecrypters).to(LazyList)
decrypterStream
.map(crypter => Try(crypter.decrypt(valueToDecrypt, associatedText)))
.collectFirst { case Success(msg) => msg }
Expand Down
2 changes: 1 addition & 1 deletion crypto/src/main/scala/uk/gov/hmrc/crypto/ValueFinder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package uk.gov.hmrc.crypto

import com.typesafe.config.Config
import collection.JavaConverters._
import scala.jdk.CollectionConverters._

import scala.util.Try

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import com.typesafe.config.ConfigFactory
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpecLike

import collection.JavaConverters._
import scala.jdk.CollectionConverters._

class ApplicationCryptoSpec extends AnyWordSpecLike with Matchers {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import org.scalatest.wordspec.AnyWordSpecLike
import org.scalatestplus.mockito.MockitoSugar

import java.util.Base64
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

@annotation.nowarn("msg=deprecated")
class CompositeOneWayCryptoSpec extends AnyWordSpecLike with Matchers with MockitoSugar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import org.scalatestplus.mockito.MockitoSugar

import java.security.SecureRandom
import java.util.Base64
import collection.JavaConverters._
import scala.jdk.CollectionConverters._

@annotation.nowarn("msg=deprecated")
class CryptoGCMWithKeysFromConfigSpec extends AnyWordSpecLike with Matchers with MockitoSugar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import org.scalatest.wordspec.AnyWordSpecLike
import org.scalatestplus.mockito.MockitoSugar

import java.util.Base64
import collection.JavaConverters._
import scala.jdk.CollectionConverters._

@annotation.nowarn("msg=deprecated")
class CryptoWithKeysFromConfigSpec extends AnyWordSpecLike with Matchers with MockitoSugar {
Expand Down
6 changes: 3 additions & 3 deletions project/LibDependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ object LibDependencies {
)

val cryptoJsonPlay28Compile = Seq(
"com.typesafe.play" %% "play-json" % "2.8.1" // version provided by Play 2.8
"com.typesafe.play" %% "play-json" % "2.8.2" // version provided by Play 2.8
)

val cryptoJsonPlay29Compile = Seq(
"com.typesafe.play" %% "play-json" % "2.10.2" // version provided by Play 2.9
"com.typesafe.play" %% "play-json" % "2.10.5" // version provided by Play 2.9
)

val cryptoJsonPlay30Compile = Seq(
"org.playframework" %% "play-json" % "3.0.2" // version provided by Play 3.0
"org.playframework" %% "play-json" % "3.0.3" // version provided by Play 3.0
)
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.9.7
sbt.version=1.9.9

0 comments on commit cb43e70

Please sign in to comment.