class JwtClaimSubject implements EntitlementSubject {

    @Override
    public SubjectDecision evaluate(final String realm, final SubjectAttributesManager mgr, final Subject subject,
                                    final String resourceName, final Map<String, Set<String>> environment)
            throws EntitlementException {

        final Set<JwtPrincipal> jwts = subject.getPrincipals(JwtPrincipal.class);

        if (jwts.isEmpty()) {
            DEBUG.message("No JWT principal in subject");
            return new SubjectDecision(false, NO_ADVICE);
        }

        final JwtPrincipal jwt = jwts.iterator().next();
        final String value = jwt.getClaim(claimName);

        final boolean match = StringUtils.equals(claimValue, value);
        return new SubjectDecision(match, NO_ADVICE);
    }

}