You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by bd...@apache.org on 2016/06/29 22:06:14 UTC
[5/6] shiro git commit: SHIRO-435: Fix the double SecurityManager
singleton. Also prevent the same issue on Environment. Update test cases of
ShiroWebModule accordingly. (Patch from
https://issues.apache.org/jira/browse/SHIRO-435)
SHIRO-435: Fix the double SecurityManager singleton. Also prevent the same issue on Environment. Update test cases of ShiroWebModule accordingly. (Patch from https://issues.apache.org/jira/browse/SHIRO-435)
Fixes #16
Project: http://git-wip-us.apache.org/repos/asf/shiro/repo
Commit: http://git-wip-us.apache.org/repos/asf/shiro/commit/dff6cc68
Tree: http://git-wip-us.apache.org/repos/asf/shiro/tree/dff6cc68
Diff: http://git-wip-us.apache.org/repos/asf/shiro/diff/dff6cc68
Branch: refs/heads/1.3.x
Commit: dff6cc689440a954a64335df52d390f4bbe98ef2
Parents: 3015cd0
Author: Johannes Schnatterer <jo...@triology.de>
Authored: Wed May 25 14:29:41 2016 +0200
Committer: Brian Demers <bd...@stormpath.com>
Committed: Wed Jun 29 14:59:59 2016 -0700
----------------------------------------------------------------------
.../java/org/apache/shiro/guice/web/ShiroWebModule.java | 4 ++--
.../java/org/apache/shiro/guice/web/ShiroWebModuleTest.java | 9 ++++++---
2 files changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/shiro/blob/dff6cc68/support/guice/src/main/java/org/apache/shiro/guice/web/ShiroWebModule.java
----------------------------------------------------------------------
diff --git a/support/guice/src/main/java/org/apache/shiro/guice/web/ShiroWebModule.java b/support/guice/src/main/java/org/apache/shiro/guice/web/ShiroWebModule.java
index 316958e..45bc916 100644
--- a/support/guice/src/main/java/org/apache/shiro/guice/web/ShiroWebModule.java
+++ b/support/guice/src/main/java/org/apache/shiro/guice/web/ShiroWebModule.java
@@ -179,7 +179,7 @@ public abstract class ShiroWebModule extends ShiroModule {
@SuppressWarnings({"unchecked"})
@Override
protected final void bindSecurityManager(AnnotatedBindingBuilder<? super SecurityManager> bind) {
- bindWebSecurityManager(bind);
+ bind.to(WebSecurityManager.class); // SHIRO-435
}
/**
@@ -211,7 +211,7 @@ public abstract class ShiroWebModule extends ShiroModule {
@Override
protected final void bindEnvironment(AnnotatedBindingBuilder<Environment> bind) {
- bindWebEnvironment(bind);
+ bind.to(WebEnvironment.class); // SHIRO-435
}
protected void bindWebEnvironment(AnnotatedBindingBuilder<? super WebEnvironment> bind) {
http://git-wip-us.apache.org/repos/asf/shiro/blob/dff6cc68/support/guice/src/test/java/org/apache/shiro/guice/web/ShiroWebModuleTest.java
----------------------------------------------------------------------
diff --git a/support/guice/src/test/java/org/apache/shiro/guice/web/ShiroWebModuleTest.java b/support/guice/src/test/java/org/apache/shiro/guice/web/ShiroWebModuleTest.java
index 908f322..a3a3f76 100644
--- a/support/guice/src/test/java/org/apache/shiro/guice/web/ShiroWebModuleTest.java
+++ b/support/guice/src/test/java/org/apache/shiro/guice/web/ShiroWebModuleTest.java
@@ -100,7 +100,7 @@ public class ShiroWebModuleTest {
@Override
protected void bindWebSecurityManager(AnnotatedBindingBuilder<? super WebSecurityManager> bind) {
- bind.to(MyDefaultWebSecurityManager.class);
+ bind.to(MyDefaultWebSecurityManager.class).asEagerSingleton();
}
});
SecurityManager securityManager = injector.getInstance(SecurityManager.class);
@@ -109,7 +109,8 @@ public class ShiroWebModuleTest {
WebSecurityManager webSecurityManager = injector.getInstance(WebSecurityManager.class);
assertNotNull(webSecurityManager);
assertTrue(webSecurityManager instanceof MyDefaultWebSecurityManager);
-
+ // SHIRO-435: Check both keys SecurityManager and WebSecurityManager are bound to the same instance
+ assertTrue( securityManager == webSecurityManager );
}
@Test
@@ -132,7 +133,7 @@ public class ShiroWebModuleTest {
@Override
protected void bindWebEnvironment(AnnotatedBindingBuilder<? super WebEnvironment> bind) {
- bind.to(MyWebEnvironment.class);
+ bind.to(MyWebEnvironment.class).asEagerSingleton();
}
});
Environment environment = injector.getInstance(Environment.class);
@@ -141,6 +142,8 @@ public class ShiroWebModuleTest {
WebEnvironment webEnvironment = injector.getInstance(WebEnvironment.class);
assertNotNull(webEnvironment);
assertTrue(webEnvironment instanceof MyWebEnvironment);
+ // SHIRO-435: Check both keys Environment and WebEnvironment are bound to the same instance
+ assertTrue( environment == webEnvironment );
}
public static class MyDefaultWebSecurityManager extends DefaultWebSecurityManager {