|
19 | 19 | import javax.servlet.ServletContextEvent;
|
20 | 20 | import javax.servlet.ServletContextListener;
|
21 | 21 |
|
22 |
| -import static javax.servlet.SessionTrackingMode.COOKIE; |
23 |
| - |
| 22 | +import javax.servlet.SessionTrackingMode; |
24 | 23 | import javax.servlet.annotation.WebListener;
|
25 | 24 |
|
26 | 25 | import org.apache.shiro.web.env.EnvironmentLoader;
|
|
34 | 33 | public class EnvironmentLoaderListener extends EnvironmentLoader implements ServletContextListener {
|
35 | 34 | private static final String SHIRO_EE_DISABLED_PARAM = "org.apache.shiro.ee.disabled";
|
36 | 35 | private static final String SHIRO_EE_REDIRECT_DISABLED_PARAM = "org.apache.shiro.ee.redirect.disabled";
|
| 36 | + private static final String SHIRO_EE_ENABLE_URL_SESSION_TRACKING_PARAM = "org.apache.shiro.ee.enable-url-session-tracking"; |
| 37 | + private static final String SHIRO_EE_SESSION_TRACKING_CONFIGURATION_DISABLED_PARAM = |
| 38 | + "org.apache.shiro.ee.session-tracking-configuration.disabled"; |
37 | 39 | private static final String FORM_RESUBMIT_DISABLED_PARAM = "org.apache.shiro.form-resubmit.disabled";
|
38 | 40 | private static final String FORM_RESUBMIT_SECURE_COOKIES = "org.apache.shiro.form-resubmit.secure-cookies";
|
39 | 41 | private static final String SHIRO_WEB_DISABLE_PRINCIPAL_PARAM = "org.apache.shiro.web.disable-principal";
|
@@ -80,7 +82,18 @@ public void contextInitialized(ServletContextEvent sce) {
|
80 | 82 | sce.getServletContext().setAttribute(SHIRO_WEB_DISABLE_PRINCIPAL_PARAM, Boolean.TRUE);
|
81 | 83 | }
|
82 | 84 | if (!isShiroEEDisabled(sce.getServletContext())) {
|
83 |
| - sce.getServletContext().setSessionTrackingModes(Set.of(COOKIE)); |
| 85 | + if (!Boolean.parseBoolean(sce.getServletContext() |
| 86 | + .getInitParameter(SHIRO_EE_SESSION_TRACKING_CONFIGURATION_DISABLED_PARAM))) { |
| 87 | + Set<SessionTrackingMode> effectiveModes = sce.getServletContext().getEffectiveSessionTrackingModes(); |
| 88 | + if(Boolean.parseBoolean(sce.getServletContext() |
| 89 | + .getInitParameter(SHIRO_EE_ENABLE_URL_SESSION_TRACKING_PARAM))) { |
| 90 | + effectiveModes.add(SessionTrackingMode.URL); |
| 91 | + } else { |
| 92 | + effectiveModes.remove(SessionTrackingMode.URL); |
| 93 | + } |
| 94 | + sce.getServletContext().setSessionTrackingModes(effectiveModes); |
| 95 | + } |
| 96 | + |
84 | 97 | initEnvironment(sce.getServletContext());
|
85 | 98 | }
|
86 | 99 | }
|
|
0 commit comments