PowerBuilder
PowerBuilder
Get the JWE Protected Header
See more JSON Web Encryption (JWE) Examples
Demonstrates Jwe.GetProtectedHeader, which copies the decoded shared JWE protected header into a JsonObject.
Background. Only the protected header is returned; it is not merged with the shared unprotected header or any per-recipient header.
Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Jwe
string ls_JweCompact
oleobject loo_Json
li_Success = 0
loo_Jwe = create oleobject
li_rc = loo_Jwe.ConnectToNewObject("Chilkat.Jwe")
if li_rc < 0 then
destroy loo_Jwe
MessageBox("Error","Connecting to COM object failed")
return
end if
// Load the JWE.
ls_JweCompact = "eyJhbGciOiJBMjU2S1ciLCJlbmMiOiJBMjU2R0NNIn0.<...>.<iv>.<ciphertext>.<tag>"
li_Success = loo_Jwe.LoadJwe(ls_JweCompact)
if li_Success = 0 then
Write-Debug loo_Jwe.LastErrorText
destroy loo_Jwe
return
end if
// Copy the decoded shared JWE protected header into a JsonObject. Only the protected header is
// returned; it is not merged with the unprotected or per-recipient headers.
loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
li_Success = loo_Jwe.GetProtectedHeader(loo_Json)
if li_Success = 0 then
Write-Debug loo_Jwe.LastErrorText
destroy loo_Jwe
destroy loo_Json
return
end if
loo_Json.EmitCompact = 0
Write-Debug loo_Json.Emit()
destroy loo_Jwe
destroy loo_Json