I can't seem to find how to get a reference to the Spring Security (V3) SessionRegistry inside of a struts action.
I've configured the listener inside of my web.xml file:
<listener>
<listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
</listener>
And I've tried to use the @Autowired annotation to bring it into an action:
@Autowired
private SessionRegistry sessionRegistry;
@Override
public String execute() throws Exception {
numberOfUsersLoggedin= sessionRegistry.getAllPrincipals().size();
return SUCCESS;
}
public SessionRegistry getSessionRegistry() {
return sessionRegistry;
}
public void setSessionRegistry(SessionRegistry sessionRegistry) {
this.sessionRegistry = sessionRegistry;
}
The http configuration looks like this:
<session-management invalid-session-url="/public/login.do?login_error=expired"
session-authentication-error-url="/public/login.do"
session-fixation-protection="newSession">
<concurrency-control max-sessions="1" error-if-maximum-exceeded="true"/>
</session-management>
Generally I am more comfortable wiring the spring bean myself, buy not sure how this is exposed using the namespace. Each time the action executes, the session registry is null.
Can anyone point out what I am doing wrong here, or show me the way to an example?
Thanks in advance for any/all replies!