JwtUtils

pdi.jwt.JwtUtils$
object JwtUtils

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
JwtUtils.type

Members list

Value members

Concrete methods

def bytify(str: String): Array[Byte]

Convert a string to its corresponding array of bytes using the default encoding.

Convert a string to its corresponding array of bytes using the default encoding.

Value parameters

str

the string to convert

Attributes

Returns

the final array of bytes

Returns the expected signature byte array length (R + S parts) for the specified ECDSA algorithm.

Returns the expected signature byte array length (R + S parts) for the specified ECDSA algorithm.

Value parameters

algorithm

The ECDSA algorithm. Must be supported and not { @code null}.

Attributes

Returns

The expected byte array length for the signature.

def hashToJson(hash: Seq[(String, Any)]): String

Convert a sequence of tuples to a JSON object

Convert a sequence of tuples to a JSON object

Attributes

def mergeJson(json: String, jsonSeq: String*): String

Merge multiple JSON strings to a unique one

Merge multiple JSON strings to a unique one

Attributes

def seqToJson(seq: Seq[Any]): String

Convert a sequence to a JSON array

Convert a sequence to a JSON array

Attributes

def sign(data: Array[Byte], key: SecretKey, algorithm: JwtHmacAlgorithm): Array[Byte]

Generate the signature for a given data using the key and HMAC algorithm provided.

Generate the signature for a given data using the key and HMAC algorithm provided.

Attributes

def sign(data: String, key: SecretKey, algorithm: JwtHmacAlgorithm): Array[Byte]
def sign(data: Array[Byte], key: PrivateKey, algorithm: JwtAsymmetricAlgorithm): Array[Byte]

Generate the signature for a given data using the key and RSA or ECDSA algorithm provided.

Generate the signature for a given data using the key and RSA or ECDSA algorithm provided.

Attributes

def sign(data: String, key: PrivateKey, algorithm: JwtAsymmetricAlgorithm): Array[Byte]
def sign(data: Array[Byte], key: String, algorithm: JwtAlgorithm): Array[Byte]

Will try to sign some given data by parsing the provided key, if parsing fail, please consider retrieving the SecretKey or the PrivateKey on your side and then use another "sign" method.

Will try to sign some given data by parsing the provided key, if parsing fail, please consider retrieving the SecretKey or the PrivateKey on your side and then use another "sign" method.

Attributes

def sign(data: String, key: String, algorithm: JwtAlgorithm): Array[Byte]

Alias to sign using a String data which will be converted to an array of bytes.

Alias to sign using a String data which will be converted to an array of bytes.

Attributes

def splitString(input: String, separator: Char): Array[String]
def stringify(arr: Array[Byte]): String

Convert an array of bytes to its corresponding string using the default encoding.

Convert an array of bytes to its corresponding string using the default encoding.

Value parameters

arr

the array of bytes to transform

Attributes

Returns

the final string

def transcodeSignatureToConcat(derSignature: Array[Byte], outputLength: Int): Array[Byte]

Transcodes the JCA ASN.1/DER-encoded signature into the concatenated R + S format expected by ECDSA JWS.

Transcodes the JCA ASN.1/DER-encoded signature into the concatenated R + S format expected by ECDSA JWS.

Value parameters

derSignature

The ASN1./DER-encoded. Must not be { @code null}.

outputLength

The expected length of the ECDSA JWS signature.

Attributes

Returns

The ECDSA JWS encoded signature.

Throws
JwtSignatureFormatException

If the ASN.1/DER signature format is invalid.

Transcodes the ECDSA JWS signature into ASN.1/DER format for use by the JCA verifier.

Transcodes the ECDSA JWS signature into ASN.1/DER format for use by the JCA verifier.

Value parameters

signature

The JWS signature, consisting of the concatenated R and S values. Must not be { @code null}.

Attributes

Returns

The ASN.1/DER encoded signature.

Throws
JwtSignatureFormatException

If the ECDSA JWS signature format is invalid.

def verify(data: Array[Byte], signature: Array[Byte], key: SecretKey, algorithm: JwtHmacAlgorithm): Boolean

Check if a signature is valid for a given data using the key and the HMAC algorithm provided.

Check if a signature is valid for a given data using the key and the HMAC algorithm provided.

Attributes

def verify(data: Array[Byte], signature: Array[Byte], key: PublicKey, algorithm: JwtAsymmetricAlgorithm): Boolean

Check if a signature is valid for a given data using the key and the RSA or ECDSA algorithm provided.

Check if a signature is valid for a given data using the key and the RSA or ECDSA algorithm provided.

Attributes

def verify(data: Array[Byte], signature: Array[Byte], key: String, algorithm: JwtAlgorithm): Boolean

Will try to check if a signature is valid for a given data by parsing the provided key, if parsing fail, please consider retrieving the SecretKey or the PublicKey on your side and then use another "verify" method.

Will try to check if a signature is valid for a given data by parsing the provided key, if parsing fail, please consider retrieving the SecretKey or the PublicKey on your side and then use another "verify" method.

Attributes

def verify(data: String, signature: String, key: String, algorithm: JwtAlgorithm): Boolean

Alias for verify

Alias for verify

Attributes

Concrete fields

val ECDSA: String
val ENCODING: String
val EdDSA: String
val RSA: String