use of org.springframework.security.core.session.SessionInformation in project OpenClinica by OpenClinica.
the class OpenClinicaSessionRegistryImpl method removeSessionInformation.
@Override
public void removeSessionInformation(String sessionId) {
SessionInformation info = getSessionInformation(sessionId);
if (info != null) {
User u = (User) info.getPrincipal();
auditLogout(u.getUsername());
}
super.removeSessionInformation(sessionId);
}
use of org.springframework.security.core.session.SessionInformation in project midpoint by Evolveum.
the class GuiProfiledPrincipalManagerImpl method terminateLocalSessions.
@Override
public void terminateLocalSessions(TerminateSessionEvent terminateSessionEvent) {
List<String> principalOids = terminateSessionEvent.getPrincipalOids();
if (sessionRegistry != null && CollectionUtils.isNotEmpty(principalOids)) {
List<Object> loggedInUsers = sessionRegistry.getAllPrincipals();
for (Object principal : loggedInUsers) {
if (!(principal instanceof GuiProfiledPrincipal)) {
continue;
}
GuiProfiledPrincipal midPointPrincipal = (GuiProfiledPrincipal) principal;
if (!principalOids.contains(midPointPrincipal.getOid())) {
continue;
}
List<SessionInformation> sessionInfos = sessionRegistry.getAllSessions(principal, false);
if (sessionInfos == null || sessionInfos.isEmpty()) {
continue;
}
for (SessionInformation sessionInfo : sessionInfos) {
sessionInfo.expireNow();
}
}
}
}
use of org.springframework.security.core.session.SessionInformation in project midpoint by Evolveum.
the class GuiProfiledPrincipalManagerImpl method getLocalLoggedInPrincipals.
@Override
public List<UserSessionManagementType> getLocalLoggedInPrincipals() {
String currentNodeId = taskManager.getNodeId();
if (sessionRegistry != null) {
List<Object> loggedInUsers = sessionRegistry.getAllPrincipals();
List<UserSessionManagementType> loggedPrincipals = new ArrayList<>();
for (Object principal : loggedInUsers) {
if (!(principal instanceof GuiProfiledPrincipal)) {
continue;
}
List<SessionInformation> sessionInfos = sessionRegistry.getAllSessions(principal, false);
if (sessionInfos == null || sessionInfos.isEmpty()) {
continue;
}
GuiProfiledPrincipal midPointPrincipal = (GuiProfiledPrincipal) principal;
UserSessionManagementType userSessionManagementType = new UserSessionManagementType();
userSessionManagementType.setFocus(midPointPrincipal.getFocus());
userSessionManagementType.setActiveSessions(sessionInfos.size());
userSessionManagementType.getNode().add(currentNodeId);
loggedPrincipals.add(userSessionManagementType);
}
return loggedPrincipals;
} else {
return emptyList();
}
}
use of org.springframework.security.core.session.SessionInformation in project spring-security by spring-projects.
the class ConcurrentSessionControlAuthenticationStrategyTests method maxSessionsExpireLeastRecentExistingUser.
@Test
public void maxSessionsExpireLeastRecentExistingUser() {
SessionInformation moreRecentSessionInfo = new SessionInformation(this.authentication.getPrincipal(), "unique", new Date(1374766999999L));
given(this.sessionRegistry.getAllSessions(any(), anyBoolean())).willReturn(Arrays.<SessionInformation>asList(moreRecentSessionInfo, this.sessionInformation));
this.strategy.setMaximumSessions(2);
this.strategy.onAuthentication(this.authentication, this.request, this.response);
assertThat(this.sessionInformation.isExpired()).isTrue();
}
use of org.springframework.security.core.session.SessionInformation in project spring-security by spring-projects.
the class ConcurrentSessionControlAuthenticationStrategyTests method setup.
@BeforeEach
public void setup() {
this.authentication = new TestingAuthenticationToken("user", "password", "ROLE_USER");
this.request = new MockHttpServletRequest();
this.response = new MockHttpServletResponse();
this.sessionInformation = new SessionInformation(this.authentication.getPrincipal(), "unique", new Date(1374766134216L));
this.strategy = new ConcurrentSessionControlAuthenticationStrategy(this.sessionRegistry);
}
Aggregations