- edited description
Upon Obtaining Custom Claim from a Signed and Encrypted JWT, Custom Claim, returned with no Data.
Upon Obtaining Custom Claim from a Signed and Encrypted JWT, Custom Claim, returned with no Data.
Using Maven Artifact: nimbus-jose-jwt with version 4.22,
A custom Claim added to a JWT which adds a named claim and that Object being a simple POJO that wraps the Map class. Debugging shows custom claim in the Token.
However, when i decrypt the payload, all other claims are correct, except the custom claim which should point to a valid Map, points to a property key, but it's claim value is of a zero length?
// Retrieve the JWT claims...
System.out.println(" Validating Claims...");
if (!signedJWT.getJWTClaimsSet().getSubject().equalsIgnoreCase("jeff@skyward.io")) {
System.out.println("JWT Subject Claim did not Verify");
}
Map<String,Object> claims = signedJWT.getJWTClaimsSet().getClaims();
System.out.println(signedJWT.getJWTClaimsSet().getClaim("sky"));
// This claim will have no value?
Please advise if there is a work around.
Many Thanks, Jeff Schenk Senior Architect Skyward IO, Inc.
Comments (4)
-
reporter -
reporter - changed status to resolved
User error. Pojo was defined without any setters, so the POJO in question would not be rendered.
-
Just double checked that we have a test for this in the suite - we do, so custom claim retrieval should work.
In a separate ticket there is a discussion about adding support for a @JWTClaim annotation, to enable objects with fields annotated with it to be converted automatically to a JWT claims set. Is such an annotation going to be of use in your project? I'm trying to get developer feedback on this.
Thanks,
-
reporter Yes I would be very interested in the @JWTClaim Annotation. Many Thanks, Jeff
- Log in to comment