public final <T> T claim(String claimName, Class<T> type) throws OAuthBearerIllegalTokenException {
        Object value = rawClaim(claimName);
        try {
            return Objects.requireNonNull(type).cast(value);
        } catch (ClassCastException e) {
            throw new OAuthBearerIllegalTokenException(
                    OAuthBearerValidationResult.newFailure(String.format("The '%s' claim was not of type %s: %s",
                            claimName, type.getSimpleName(), value.getClass().getSimpleName())));
        }
    }
Extract a claim of the given type

@param claimName
           the mandatory JWT claim name
@param type
           the mandatory type, which must either be String.class,
           Number.class, or List.class
@return the claim if it exists, otherwise null
@throws OAuthBearerIllegalTokenException
            if the claim exists but is not the given type
clients/src/main/java/org/apache/kafka/common/security/oauthbearer/internals/unsecured/OAuthBearerUnsecuredJws.java