I know that I can getAllSessions for user with current active session, and I know I can getAllPrincipals that will show all users with active sessions. But I want to know if it is possible to getAllSessions for a specific user. So say I am userA with current active session and I want to getAllPrincipals and then choose one of the principals and then getAllSessions for that specific principal. Is this possible? If so how?
Share
You’re talking about
SessionRegistryand in the API there isgetAllSessions(Object principal, boolean includeExpiredSessions)method you can use. For example:Just remember that principal object can be anything, like
Useror your own implementation, but it has to defineequals()andhashCodeproperly.