<commit_before>package org.pac4j.vertx.auth;

import io.vertx.core.AsyncResult;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.json.JsonObject;
import io.vertx.core.shareddata.impl.ClusterSerializable;
import io.vertx.ext.auth.AuthProvider;
import io.vertx.ext.auth.User;
import io.vertx.ext.auth.authorization.Authorization;
import io.vertx.ext.auth.impl.UserImpl;
import org.pac4j.core.profile.UserProfile;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;

/**
 * @author <NAME>
 * @since 2.0.0
 */
public class Pac4jUser extends UserImpl implements User, ClusterSerializable {

    private final Map<String, UserProfile> profiles = new LinkedHashMap<>();
    private JsonObject principal;

    public Pac4jUser() {
        // I think this noop default constructor is required for deserialization from a clustered session
    }

    @Override
    public JsonObject attributes() {
        return null;
    }

    @Override
    public User isAuthorized(Authorization authorization, Handler<AsyncResult<Boolean>> resultHandler) {
        resultHandler.handle(Future.succeededFuture(
                profiles.values().stream()
                        .anyMatch(p -> p.getPermissions().contains(authorization))
        ));
        return this;
    }

    @Override
    public JsonObject principal() {
        return principal;
    }<commit_msg>check on roles instead of permissions<commit_after>package org.pac4j.vertx.auth;

import io.vertx.core.AsyncResult;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.json.JsonObject;
import io.vertx.core.shareddata.impl.ClusterSerializable;
import io.vertx.ext.auth.AuthProvider;
import io.vertx.ext.auth.User;
import io.vertx.ext.auth.authorization.Authorization;
import io.vertx.ext.auth.impl.UserImpl;
import org.pac4j.core.profile.UserProfile;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;

/**
 * @author <NAME>
 * @since 2.0.0
 */
public class Pac4jUser extends UserImpl implements User, ClusterSerializable {

    private final Map<String, UserProfile> profiles = new LinkedHashMap<>();
    private JsonObject principal;

    public Pac4jUser() {
        // I think this noop default constructor is required for deserialization from a clustered session
    }

    @Override
    public JsonObject attributes() {
        return null;
    }

    @Override
    public User isAuthorized(Authorization authorization, Handler<AsyncResult<Boolean>> resultHandler) {
        resultHandler.handle(Future.succeededFuture(
                profiles.values().stream()
                        .anyMatch(p -> p.getRoles().contains(authorization))
        ));
        return this;
    }

    @Override
    public JsonObject principal() {
        return principal;
    }
{'fraction_non_alphanumeric': 0.10176678445229682, 'fraction_numerical': 0.0049469964664310955, 'mean_word_length': 3.368827160493827, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5005635', 'n_tokens_mistral': 837, 'n_tokens_neox': 810, 'n_words': 187}