@Test
public void anonymousUserToken() throws Exception{

    j.jenkins.setSecurityRealm(j.createDummySecurityRealm());
    JenkinsRule.WebClient webClient = j.createWebClient();
    String token = getToken(webClient);
    Assert.assertNotNull(token);
    JsonWebStructure jsonWebStructure = JsonWebStructure.fromCompactSerialization(token);
    Assert.assertTrue(jsonWebStructure instanceof JsonWebSignature);
    JsonWebSignature jsw = (JsonWebSignature) jsonWebStructure;
    String kid = jsw.getHeader("kid");
    Assert.assertNotNull(kid);
    Page page = webClient.goTo("jwt-auth/jwks/"+kid+"/", "application/json");
      for(NameValuePair valuePair: page.getWebResponse().getResponseHeaders()){
          System.out.println(valuePair);
      }
    JSONObject jsonObject = JSONObject.fromObject(page.getWebResponse().getContentAsString());
    RsaJsonWebKey rsaJsonWebKey = new RsaJsonWebKey(jsonObject,null);
    JwtConsumer jwtConsumer = new JwtConsumerBuilder()
        .setRequireExpirationTime() // the JWT must have an expiration time
        .setAllowedClockSkewInSeconds(30) // allow some leeway in validating time based claims to account for clock skew
        .setRequireSubject() // the JWT must have a subject claim
        .setVerificationKey(rsaJsonWebKey.getKey()) // verify the sign with the public key
        .build(); // create the JwtConsumer instance
    JwtClaims claims = jwtConsumer.processToClaims(token);
    Assert.assertEquals("anonymous",claims.getSubject());
    Map<String,Object> claimMap = claims.getClaimsMap();
    Map<String,Object> context = (Map<String, Object>) claimMap.get("context");
    Map<String,String> userContext = (Map<String, String>) context.get("user");
    Assert.assertEquals("anonymous", userContext.get("id"));
}