All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.pac4j.vertx.VertxProfileManager Maven / Gradle / Ivy

The newest version!
package org.pac4j.vertx;

import org.pac4j.core.profile.ProfileManager;
import org.pac4j.core.profile.UserProfile;
import org.pac4j.vertx.auth.Pac4jUser;
import org.pac4j.vertx.context.session.VertxSessionStore;

import java.util.LinkedHashMap;
import java.util.Optional;

/**
 * @author Jeremy Prime
 * @since 2.0.0
 */
public class VertxProfileManager extends ProfileManager {

    private final VertxWebContext vertxWebContext;

    public VertxProfileManager(final VertxWebContext context, final VertxSessionStore sessionStore) {
        super(context, sessionStore);
        this.vertxWebContext = context;
    }

    @Override
    protected void saveAll(final LinkedHashMap profiles, final boolean saveInSession) {
        super.saveAll(profiles, saveInSession);

        final Pac4jUser vertxUser = Optional.ofNullable(vertxWebContext.getVertxUser()).orElse(new Pac4jUser());
        vertxUser.setUserProfiles(profiles);
        vertxWebContext.setVertxUser(vertxUser);
    }

    @Override
    public void removeOrRenewExpiredProfiles(final LinkedHashMap profiles, final boolean readFromSession) {
        super.removeOrRenewExpiredProfiles(profiles, readFromSession);

        vertxWebContext.removeVertxUser();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy