You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by lp...@apache.org on 2023/01/27 02:56:16 UTC
[shiro] branch main updated: bugfix: when Shiro-EE is disabled, use the "standard" default ini environment instead of custom
This is an automated email from the ASF dual-hosted git repository.
lprimak pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/shiro.git
The following commit(s) were added to refs/heads/main by this push:
new 5c905162 bugfix: when Shiro-EE is disabled, use the "standard" default ini environment instead of custom
new af095003 Merge pull request #690 from lprimak/fix-default-webenv-init-when-ee-disabled
5c905162 is described below
commit 5c905162ebf3550146adbaa84cf08799e22600e7
Author: lprimak <le...@flowlogix.com>
AuthorDate: Thu Jan 26 18:22:50 2023 -0800
bugfix: when Shiro-EE is disabled, use the "standard" default ini environment instead of custom
---
.../apache/shiro/ee/listeners/EnvironmentLoaderListener.java | 8 ++++++--
.../main/java/org/apache/shiro/web/env/EnvironmentLoader.java | 11 ++++++-----
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/support/jakarta-ee/src/main/java/org/apache/shiro/ee/listeners/EnvironmentLoaderListener.java b/support/jakarta-ee/src/main/java/org/apache/shiro/ee/listeners/EnvironmentLoaderListener.java
index ee552bc7..83d5ef49 100644
--- a/support/jakarta-ee/src/main/java/org/apache/shiro/ee/listeners/EnvironmentLoaderListener.java
+++ b/support/jakarta-ee/src/main/java/org/apache/shiro/ee/listeners/EnvironmentLoaderListener.java
@@ -58,7 +58,11 @@ public class EnvironmentLoaderListener extends EnvironmentLoader implements Serv
}
@Override
- protected Class<? extends WebEnvironment> getDefaultWebEnvironmentClass() {
- return IniEnvironment.class;
+ protected Class<? extends WebEnvironment> getDefaultWebEnvironmentClass(ServletContext ctx) {
+ if (isShiroEEDisabled(ctx)) {
+ return super.getDefaultWebEnvironmentClass(ctx);
+ } else {
+ return IniEnvironment.class;
+ }
}
}
diff --git a/web/src/main/java/org/apache/shiro/web/env/EnvironmentLoader.java b/web/src/main/java/org/apache/shiro/web/env/EnvironmentLoader.java
index 3ee752bc..d61a0797 100644
--- a/web/src/main/java/org/apache/shiro/web/env/EnvironmentLoader.java
+++ b/web/src/main/java/org/apache/shiro/web/env/EnvironmentLoader.java
@@ -168,7 +168,7 @@ public class EnvironmentLoader {
* @see #ENVIRONMENT_CLASS_PARAM
* @see IniWebEnvironment
* @see #determineWebEnvironment(ServletContext)
- * @see #getDefaultWebEnvironmentClass()
+ * @see #getDefaultWebEnvironmentClass(ServletContext)
* @deprecated This method is not longer used by Shiro, and will be removed in future versions,
* use {@link #determineWebEnvironment(ServletContext)} or {@link #determineWebEnvironment(ServletContext)}
*/
@@ -179,7 +179,7 @@ public class EnvironmentLoader {
return webEnvironmentClass;
} else {
- return getDefaultWebEnvironmentClass();
+ return getDefaultWebEnvironmentClass(servletContext);
}
}
@@ -230,9 +230,10 @@ public class EnvironmentLoader {
/**
* Returns the default WebEnvironment class, which is unless overridden: {@link IniWebEnvironment}.
+ * @param ctx servlet context
* @return the default WebEnvironment class.
*/
- protected Class<? extends WebEnvironment> getDefaultWebEnvironmentClass() {
+ protected Class<? extends WebEnvironment> getDefaultWebEnvironmentClass(ServletContext ctx) {
return IniWebEnvironment.class;
}
@@ -241,7 +242,7 @@ public class EnvironmentLoader {
* <ul>
* <li>A custom WebEnvironment class - specified in the {@code servletContext} {@link #ENVIRONMENT_ATTRIBUTE_KEY} property</li>
* <li>{@code ServiceLoader.load(WebEnvironment.class)} - (if more then one instance is found a {@link ConfigurationException} will be thrown</li>
- * <li>A call to {@link #getDefaultWebEnvironmentClass()} (default: {@link IniWebEnvironment})</li>
+ * <li>A call to {@link #getDefaultWebEnvironmentClass(ServletContext)} (default: {@link IniWebEnvironment})</li>
* </ul>
*
* @param servletContext current servlet context
@@ -262,7 +263,7 @@ public class EnvironmentLoader {
// if webEnvironment is not set, and ENVIRONMENT_CLASS_PARAM prop was not set, use the default
if (webEnvironmentClass == null && webEnvironment == null) {
- webEnvironmentClass = getDefaultWebEnvironmentClass();
+ webEnvironmentClass = getDefaultWebEnvironmentClass(servletContext);
}
// at this point, we anything is set for the webEnvironmentClass, load it.