Visual FoxPro
Visual FoxPro
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 Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loJws
LOCAL lcJwsCompact
LOCAL loJson
lnSuccess = 0
loJws = CreateObject('Chilkat.Jws')
* Load the JWS compact serialization.
lcJwsCompact = "eyJhbGciOiJIUzI1NiJ9.VGhpcyBpcyB0aGUgY29udGVudCB0byBzaWduLg.<signature>"
lnSuccess = loJws.LoadJws(lcJwsCompact)
IF (lnSuccess = 0) THEN
? loJws.LastErrorText
RELEASE loJws
CANCEL
ENDIF
* Copy the decoded protected header of signature 0 into a JsonObject.
loJson = CreateObject('Chilkat.JsonObject')
lnSuccess = loJws.GetProtectedH(0,loJson)
IF (lnSuccess = 0) THEN
? loJws.LastErrorText
RELEASE loJws
RELEASE loJson
CANCEL
ENDIF
loJson.EmitCompact = 0
? loJson.Emit()
RELEASE loJws
RELEASE loJson