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
Modifier and TypeFieldDescriptionprotected Config
protected final WebContext
protected final org.slf4j.Logger
protected SessionStore
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionRetrieve the first user profile if it exists, ignoring anyAnonymousProfile
if possible.<U extends UserProfile>
Optional<U>getProfile
(Class<U> clazz) Retrieve all user profiles.boolean
Tests if the current user is authenticated (meaning a user profile exists which is not anAnonymousProfile
).protected void
removeOrRenewExpiredProfiles
(LinkedHashMap<String, UserProfile> profiles, boolean readFromSession) void
Remove the current user profile(s).protected LinkedHashMap<String,
UserProfile> retrieveAll
(boolean readFromSession) Retrieve the map of profiles from the session or the request.protected String
retrieveClientName
(UserProfile profile) void
save
(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 void
saveAll
(LinkedHashMap<String, UserProfile> profiles, boolean saveInSession)
-
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 anyAnonymousProfile
if 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
-