Take the 2-minute tour ×

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|improve this question
add comment

1 Answer

up vote 0 down vote accepted

You're talking about SessionRegistry and in the API there is getAllSessions(Object principal, boolean includeExpiredSessions) method you can use. For example:

List<Object> allPrincipals = getAllPrincipals();
Object principal = allPrincipals.get(0); // change this to way you want
List<SessionInformation> principalSessions = getAllSessions(principal, false);

Just remember that principal object can be anything, like User or your own implementation, but it has to define equals() and hashCode properly.

share|improve this answer
Right on the money, thanks for the input!! –  user1332868 Sep 12 '12 at 17:48
add comment

Your Answer


