Accessing JWT nested claims with jose4j
<p>I am having trouble accessing nested claims from a JWT using jose4j.  I have a JWT whose claim set looks like this:</p>

<pre><code>{
    "iss": "awesome.issuer",
    "iat": 1300819370,
    "exp": 1300819380,
    "clm": "string claim",
    "sub": "batman",
    "context": {
        "username": "mpdavis",
        "firstName": "Michael",
        "lastName": "Davis
    }
}
</code></pre>

<p>I am running into issues when I try to access and of the nested claims inside the <code>context</code> claim.  I can access top level claims easily with the <code>getClaimValue</code>.</p>

<pre><code>private String qsh;

qsh = jwtClaims.getClaimValue("qsh", String.class);
</code></pre>

<p>It seems like I have two options if I want to get a nested claim.</p>

<p>The first option is to find a way to return the <code>context</code> claim as a <code>Map&lt;String,Object&gt;</code> and pull each claim out of that object.  The other option is to use <code>flattenClaims</code> to flatten all of the claims into a <code>Map&lt;String,List&lt;Object&gt;&gt;</code> and grab the first object off of the map for the nested claims.</p>

<p>Neither one of these options seem particularly resilient if the service granting these JWTs alters the schema very much.  </p>

<p>Is there a better way?</p>