public void save(final boolean saveInSession, final UserProfile profile, final boolean multiProfile) {
        final LinkedHashMap<String, UserProfile> profiles;

        val clientName = retrieveClientName(profile);
        if (multiProfile) {
            profiles = retrieveAll(saveInSession);
            profiles.remove(clientName);
        } else {
            profiles = new LinkedHashMap<>();
        }
        profiles.put(clientName, profile);

        saveAll(profiles, saveInSession);
    }
Save the given user profile (replace the current one if multi profiles are not supported, add it otherwise).

@param saveInSession if the user profile must be saved in session
@param profile a given user profile
@param multiProfile whether multiple profiles are supported
pac4j-core/src/main/java/org/pac4j/core/profile/ProfileManager.java