Skip to content
Snippets Groups Projects
Commit baea0341 authored by Paul-Christian Volkmer's avatar Paul-Christian Volkmer
Browse files

Added SessionRegistry bean to count active HTTP session principals

parent 8c3ea2f3
Branches
Tags
No related merge requests found
package de.thm.arsnova.services;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.session.SessionRegistry;
import org.springframework.stereotype.Service;
import de.thm.arsnova.dao.IDatabaseDao;
......@@ -17,6 +18,9 @@ public class StatisticsService implements IStatisticsService {
@Autowired
private IUserService userService;
@Autowired
private SessionRegistry sessionRegistry;
@Override
public final int countActiveUsers() {
long since = System.currentTimeMillis() - DURATION_IN_MILLIS;
......@@ -25,7 +29,7 @@ public class StatisticsService implements IStatisticsService {
@Override
public int countLoggedInUsers() {
return userService.loggedInUsers();
return sessionRegistry.getAllPrincipals().size();
}
@Override
......
......@@ -128,5 +128,7 @@
<bean id="failureHandler" class="de.thm.arsnova.LoginAuthenticationFailureHandler"
p:defaultFailureUrl="/index.html" />
<!-- Session Registry -->
<bean id="sessionRegistry" class="org.springframework.security.core.session.SessionRegistryImpl" />
</beans>
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment