com.fortysevendeg.intools.jwt.models.JWTTokenRaw.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of intools-jwt_3 Show documentation
Show all versions of intools-jwt_3 Show documentation
A simple library for decoding the JWT header for the InTools environment
package com.fortysevendeg.intools.jwt.models
import scala.util.matching.Regex
import com.fortysevendeg.intools.jwt.models.Types.{JWTClaim, JWTHeader, JWTSignature}
final case class JWTTokenRaw private (jwtHeader: JWTHeader, jwtClaim: JWTClaim, jwtSigantureOpt: Option[JWTSignature])
object JWTTokenRaw:
private val jwtRegex: Regex = "^([A-Za-z0-9-_=]+)\\.([A-Za-z0-9-_=]+)\\.?([A-Za-z0-9-_+/=]*)$".r
def fromString: String => Option[JWTTokenRaw] = _ match {
case jwtRegex(header, claim, signature) =>
val sign = if signature == "" then None else Some(JWTSignature(signature))
Some(JWTTokenRaw(JWTHeader(header), JWTClaim(claim), sign))
case _ => None
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy