I want to be able to log out all logged in users programmatically. How do you force logout all users on some event?
Ketan gives you the answer that you are looking for, if you change the second for block and use session.expireNow(); instead activeSessions.add(session); you will end up with all active sessions expired.
session.expireNow();
activeSessions.add(session);