Lianja
Lianja
Get a JWS Protected Header
See more JSON Web Signatures (JWS) Examples
Demonstrates Jws.GetProtectedH, which copies the decoded protected header of a signature into a JsonObject.
Background. The protected header is integrity-protected by the signature. Inspecting it (for example the
alg value) is useful before deciding how to validate.Chilkat Lianja Downloads
llSuccess = .F.
loJws = createobject("CkJws")
// Load the JWS compact serialization.
lcJwsCompact = "eyJhbGciOiJIUzI1NiJ9.VGhpcyBpcyB0aGUgY29udGVudCB0byBzaWduLg.<signature>"
llSuccess = loJws.LoadJws(lcJwsCompact)
if (llSuccess = .F.) then
? loJws.LastErrorText
release loJws
return
endif
// Copy the decoded protected header of signature 0 into a JsonObject.
loJson = createobject("CkJsonObject")
llSuccess = loJws.GetProtectedH(0,loJson)
if (llSuccess = .F.) then
? loJws.LastErrorText
release loJws
release loJson
return
endif
loJson.EmitCompact = .F.
? loJson.Emit()
release loJws
release loJson