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
ConstructorDescriptionProfileManager
(WebContext context, SessionStore sessionStore) Constructor for ProfileManager. -
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) getProfile.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) removeOrRenewExpiredProfiles.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) retrieveClientName.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) saveAll.
-
Field Details
-
logger
protected final org.slf4j.Logger logger -
context
-
sessionStore
-
config
-
-
Constructor Details
-
ProfileManager
Constructor for ProfileManager.
- Parameters:
context
- aWebContext
objectsessionStore
- aSessionStore
object
-
-
Method Details
-
getProfile
Retrieve the first user profile if it exists, ignoring anyAnonymousProfile
if possible.- Returns:
- the user profile
-
getProfile
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) removeOrRenewExpiredProfiles.
- Parameters:
profiles
- aLinkedHashMap
objectreadFromSession
- a boolean
-
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
retrieveClientName.
- Parameters:
profile
- aUserProfile
object- Returns:
- a
String
object
-
saveAll
saveAll.
- Parameters:
profiles
- aLinkedHashMap
objectsaveInSession
- a boolean
-
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
-