PowerBuilder
PowerBuilder
Get the JWS Payload into a StringBuilder
See more JSON Web Signatures (JWS) Examples
Demonstrates Jws.GetPayloadSb, which writes the payload of a loaded JWS as text into a StringBuilder, decoded using the given charset.
Background. 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_SbPayload
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 text into a StringBuilder, decoded using the given charset.
loo_SbPayload = create oleobject
li_rc = loo_SbPayload.ConnectToNewObject("Chilkat.StringBuilder")
li_Success = loo_Jws.GetPayloadSb("utf-8",loo_SbPayload)
if li_Success = 0 then
Write-Debug loo_Jws.LastErrorText
destroy loo_Jws
destroy loo_SbPayload
return
end if
Write-Debug loo_SbPayload.GetAsString()
destroy loo_Jws
destroy loo_SbPayload