Skip to content

Commit

Permalink
hunting the session error
Browse files Browse the repository at this point in the history
  • Loading branch information
hazendaz committed Sep 14, 2024
1 parent 55cdbd5 commit 8cb2b79
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
12 changes: 12 additions & 0 deletions psi-probe-core/src/main/java/psiprobe/ProbeSecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.springframework.security.access.vote.RoleVoter;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.ProviderManager;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.core.authority.mapping.SimpleAttributes2GrantedAuthoritiesMapper;
import org.springframework.security.web.DefaultSecurityFilterChain;
Expand Down Expand Up @@ -306,4 +308,14 @@ public XStream getXstream() {
return xstream;
}

@Override
protected void configure(HttpSecurity http) throws Exception {
http.sessionManagement().disable();
}

@Override
public void configure(WebSecurity web) throws Exception {
web.debug(true);
}

}
38 changes: 38 additions & 0 deletions psi-probe-core/src/main/java/psiprobe/SessionCounterListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Licensed under the GPL License. You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
* WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
* PURPOSE.
*/
package psiprobe;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

@WebListener
public class SessionCounterListener implements HttpSessionListener {

private static int totalActiveSessions;

public static int getTotalActiveSession(){
return totalActiveSessions;
}

@Override
public void sessionCreated(HttpSessionEvent arg0) {
totalActiveSessions++;
System.out.println("sessionCreated - add one session into counter");
}

@Override
public void sessionDestroyed(HttpSessionEvent arg0) {
totalActiveSessions--;
System.out.println("sessionDestroyed - deduct one session from counter");
}

}

0 comments on commit 8cb2b79

Please sign in to comment.