Example usage for org.springframework.security.core.session SessionRegistry getAllPrincipals

List of usage examples for org.springframework.security.core.session SessionRegistry getAllPrincipals

Introduction

In this page you can find the example usage for org.springframework.security.core.session SessionRegistry getAllPrincipals.

Prototype

List<Object> getAllPrincipals();

Source Link

Document

Obtains all the known principals in the SessionRegistry.

Usage

From source file:org.schedoscope.metascope.service.MetascopeUserService.java

public void logoutUser(SessionRegistry sessionRegistry, String username) {
    final List<Object> allPrincipals = sessionRegistry.getAllPrincipals();
    for (final Object principal : allPrincipals) {
        if (principal instanceof User) {
            User springUserDetails = (User) principal;
            if (springUserDetails.getUsername().equals(username)) {
                for (SessionInformation sessionInformation : sessionRegistry.getAllSessions(principal, true)) {
                    sessionInformation.expireNow();
                }//from w w w  .  ja va2 s . c o  m
            }
        }
    }
}