Package org.pac4j.core.profile
Class ProfileManager
java.lang.Object
org.pac4j.core.profile.ProfileManager
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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Configprotected final WebContextprotected final org.slf4j.Loggerprotected SessionStore -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRetrieve the first user profile if it exists, ignoring anyAnonymousProfileif possible.<U extends UserProfile>
Optional<U>getProfile(Class<U> clazz) Retrieve all user profiles.booleanTests if the current user is authenticated (meaning a user profile exists which is not anAnonymousProfile).protected voidremoveOrRenewExpiredProfiles(LinkedHashMap<String, UserProfile> profiles, boolean readFromSession) voidRemove the current user profile(s).protected LinkedHashMap<String,UserProfile> retrieveAll(boolean readFromSession) Retrieve the map of profiles from the session or the request.protected StringretrieveClientName(UserProfile profile) voidsave(boolean saveInSession, UserProfile profile, boolean multiProfile) Save the given user profile (replace the current one if multi profiles are not supported, add it otherwise).protected voidsaveAll(LinkedHashMap<String, UserProfile> profiles, boolean saveInSession) void
-
Field Details
-
logger
protected final org.slf4j.Logger logger -
context
-
sessionStore
-
config
-
-
Constructor Details
-
ProfileManager
-
-
Method Details
-
getProfile
Retrieve the first user profile if it exists, ignoring anyAnonymousProfileif possible.- Returns:
- the user profile
-
getProfile
-
getProfiles
Retrieve all user profiles.- Returns:
- the user profiles
-
retrieveAll
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, UserProfile> profiles, boolean readFromSession) -
removeProfiles
public void removeProfiles()Remove the current user profile(s). -
save
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 sessionprofile- a given user profilemultiProfile- whether multiple profiles are supported
-
retrieveClientName
-
saveAll
-
isAuthenticated
public boolean isAuthenticated()Tests if the current user is authenticated (meaning a user profile exists which is not anAnonymousProfile).- Returns:
- whether the current user is authenticated
-
getConfig
-
setConfig
-