Skip to content

Commit

Permalink
PIN-4112 Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
nttdata-rtorsoli committed Oct 17, 2023
1 parent 8f94b8f commit fa66161
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ object KeyManagementErrors {
extends ComponentError("0031", s"Key $kid is invalid. Reason: $reason")

final case class InvalidKeys(errors: List[InvalidKey]) extends ComponentError("0032", errors.mkString("[", ",", "]"))

final case class MissingUserId(kid: String)
extends ComponentError("0033", s"Key $kid has not userId")

final case class MissingUserId(kid: String) extends ComponentError("0033", s"Key $kid has not userId")

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import it.pagopa.interop.authorizationmanagement.model.KeyUse.{ENC, SIG}
object KeyAdapters {

implicit class PersistentKeyWrapper(private val p: PersistentKey) extends AnyVal {
def toApi: Either[Throwable, Key] = for {
userId <- p.userId.toRight(MissingUserId(p.kid))
_ <- KeyConverter.fromBase64encodedPEMToAPIKey(p.kid, p.encodedPem, p.use.toJwk, p.algorithm)
} yield Key(userId, p.kid, p.name, p.encodedPem, p.algorithm, p.use.toApi, p.createdAt)
def toApi: Either[Throwable, Key] = for {
userId <- p.userId.toRight(MissingUserId(p.kid))
_ <- KeyConverter.fromBase64encodedPEMToAPIKey(p.kid, p.encodedPem, p.use.toJwk, p.algorithm)
} yield Key(userId, p.kid, p.name, p.encodedPem, p.algorithm, p.use.toApi, p.createdAt)
}

implicit class PersistentKeyObjectWrapper(private val p: PersistentKey.type) extends AnyVal {
Expand Down

0 comments on commit fa66161

Please sign in to comment.