Get All Connected Users

Sometimes you may be wanna get all users who connected to your server in order to manage them, such as force to kill someone’s session. When sessionRegistry.getAllPrincipals() methods will get it’s play show, this method could get all the connetced users, although that implementation would prevent simultaneous logins with the same credentials.

Following is the example code to kill all connetced users sission:

1
2
3
4
5
Object[] principals = sessionRegistery.getAllPrincipals();
for(Object principal : principals) {
SessionInformations[] sis = sessionRegistery.getAllSessions(principal, true);
sis[0].expireNow();
}