PowerBuilder
PowerBuilder
Get the JWS Payload into BinData
See more JSON Web Signatures (JWS) Examples
Demonstrates Jws.GetPayloadBd, which writes the payload of a loaded JWS as raw bytes into a BinData.
Background. This is used when the payload is binary. In practice, validate the signature before trusting the payload.
Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Jws
string ls_JwsCompact
oleobject loo_BdPayload
li_Success = 0
loo_Jws = create oleobject
li_rc = loo_Jws.ConnectToNewObject("Chilkat.Jws")
if li_rc < 0 then
destroy loo_Jws
MessageBox("Error","Connecting to COM object failed")
return
end if
// Load the JWS compact serialization.
ls_JwsCompact = "eyJhbGciOiJIUzI1NiJ9.VGhpcyBpcyB0aGUgY29udGVudCB0byBzaWduLg.<signature>"
li_Success = loo_Jws.LoadJws(ls_JwsCompact)
if li_Success = 0 then
Write-Debug loo_Jws.LastErrorText
destroy loo_Jws
return
end if
// Get the JWS payload as raw bytes into a BinData.
loo_BdPayload = create oleobject
li_rc = loo_BdPayload.ConnectToNewObject("Chilkat.BinData")
li_Success = loo_Jws.GetPayloadBd(loo_BdPayload)
if li_Success = 0 then
Write-Debug loo_Jws.LastErrorText
destroy loo_Jws
destroy loo_BdPayload
return
end if
Write-Debug "Payload is " + string(loo_BdPayload.NumBytes) + " bytes."
destroy loo_Jws
destroy loo_BdPayload