### Question:
AuthenticationJsonWebToken implements Authentication, JwtAuthentication { @Override public String getKeyId() { return decoded.getKeyId(); } AuthenticationJsonWebToken(String token, JWTVerifier verifier); @Override String getToken(); @Override String getKeyId(); @Override Authentication verify(JWTVerifier verifier); @Override Collection<? extends GrantedAuthority> getAuthorities(); @Override Object getCredentials(); @Override Object getDetails(); @Override Object getPrincipal(); @Override boolean isAuthenticated(); @Override void setAuthenticated(boolean isAuthenticated); @Override String getName();  }### Answer:
@Test public void shouldGetKeyId() throws Exception { Map<String, Object> keyIdHeader = Collections.singletonMap("kid", (Object) "key-id"); String token = JWT.create() .withHeader(keyIdHeader) .sign(hmacAlgorithm); AuthenticationJsonWebToken auth = new AuthenticationJsonWebToken(token, verifier); assertThat(auth, is(notNullValue())); assertThat(auth.getKeyId(), is("key-id")); }
@Test public void shouldGetNullKeyIdOnMissingKeyIdClaim() throws Exception { String token = JWT.create() .sign(hmacAlgorithm); AuthenticationJsonWebToken auth = new AuthenticationJsonWebToken(token, verifier); assertThat(auth, is(notNullValue())); assertThat(auth.getKeyId(), is(nullValue())); }