Objective-C
Objective-C
Get the Entire Loaded JWE Structure
See more JSON Web Encryption (JWE) Examples
Demonstrates Jwe.GetHeader, which copies the entire currently loaded JWE structure into a JsonObject.
Background. This is the full JWE representation, not a decoded or merged JOSE header. It can contain the protected, unprotected, and per-recipient header material.
Chilkat Objective-C Downloads
#import <CkoJwe.h>
#import <NSString.h>
#import <CkoJsonObject.h>
BOOL success = NO;
CkoJwe *jwe = [[CkoJwe alloc] init];
// Load the JWE.
NSString *jweCompact = @"eyJhbGciOiJBMjU2S1ciLCJlbmMiOiJBMjU2R0NNIn0.<...>.<iv>.<ciphertext>.<tag>";
success = [jwe LoadJwe: jweCompact];
if (success == NO) {
NSLog(@"%@",jwe.LastErrorText);
return;
}
// Copy the entire loaded JWE structure into a JsonObject. This is the full JWE representation, not a
// decoded or merged JOSE header.
CkoJsonObject *json = [[CkoJsonObject alloc] init];
success = [jwe GetHeader: json];
if (success == NO) {
NSLog(@"%@",jwe.LastErrorText);
return;
}
json.EmitCompact = NO;
NSLog(@"%@",[json Emit]);