Class ProfileManager<U extends UserProfile>


  • public class ProfileManager<U extends UserProfile>
    extends Object
    This class is a generic way to manage the current user profile(s), i.e. the one(s) of the current authenticated user.
    Since:
    1.8.0
    Author:
    Jerome Leleu
    • Method Detail

      • get

        public Optional<U> get​(boolean readFromSession)
        Retrieve the first user profile if it exists, ignoring any AnonymousProfile if possible.
        Parameters:
        readFromSession - if the user profile must be read from session
        Returns:
        the user profile
      • getAll

        public List<U> getAll​(boolean readFromSession)
        Retrieve all user profiles.
        Parameters:
        readFromSession - if the user profiles must be read from session
        Returns:
        the user profiles
      • retrieveAll

        protected LinkedHashMap<String,​U> retrieveAll​(boolean readFromSession)
        Retrieve the map of profiles from the session or the request.
        Parameters:
        readFromSession - if the user profiles must be read from session
        Returns:
        the map of profiles
      • removeOrRenewExpiredProfiles

        protected void removeOrRenewExpiredProfiles​(LinkedHashMap<String,​U> profiles)
      • remove

        public void remove​(boolean removeFromSession)
        Remove the current user profile(s).
        Parameters:
        removeFromSession - if the user profile(s) must be removed from session
      • save

        public void save​(boolean saveInSession,
                         U profile,
                         boolean multiProfile)
        Save the given user profile (replace the current one if multi profiles are not supported, add it otherwise).
        Parameters:
        saveInSession - if the user profile must be saved in session
        profile - a given user profile
        multiProfile - whether multiple profiles are supported
      • retrieveClientName

        protected String retrieveClientName​(U profile)
      • logout

        public void logout()
        Perform a logout by removing the current user profile(s).
      • isAuthenticated

        public boolean isAuthenticated()
        Tests if the current user is authenticated (meaning a user profile exists which is not an AnonymousProfile).
        Returns:
        whether the current user is authenticated
      • getConfig

        public Config getConfig()
      • setConfig

        public void setConfig​(Config config)