@Test public void testBindWebSecurityManager() throws Exception { final ShiroModuleTest.MockRealm mockRealm = createMock(ShiroModuleTest.MockRealm.class); ServletContext servletContext = createMock(ServletContext.class); Injector injector = Guice.createInjector(new ShiroWebModule(servletContext) { @Override protected void configureShiroWeb() { bindRealm().to(ShiroModuleTest.MockRealm.class); expose(WebSecurityManager.class); } @Provides public ShiroModuleTest.MockRealm createRealm() { return mockRealm; } @Override protected void bindWebSecurityManager(AnnotatedBindingBuilder<? super WebSecurityManager> bind) { bind.to(MyDefaultWebSecurityManager.class).asEagerSingleton(); } }); SecurityManager securityManager = injector.getInstance(SecurityManager.class); assertNotNull(securityManager); assertTrue(securityManager instanceof MyDefaultWebSecurityManager); WebSecurityManager webSecurityManager = injector.getInstance(WebSecurityManager.class); assertNotNull(webSecurityManager); assertTrue(webSecurityManager instanceof MyDefaultWebSecurityManager); assertTrue( securityManager == webSecurityManager ); }
protected void bindWebSecurityManager(AnnotatedBindingBuilder<? super WebSecurityManager> bind) { try { bind.toConstructor(DefaultWebSecurityManager.class.getConstructor(Collection.class)).asEagerSingleton(); } catch (NoSuchMethodException e) { throw new ConfigurationException("This really shouldn't happen. Either something has changed in Shiro, or there's a bug in ShiroModule.", e); } }
ShiroWebModule extends ShiroModule { protected void bindWebSecurityManager(AnnotatedBindingBuilder<? super WebSecurityManager> bind) { try { bind.toConstructor(DefaultWebSecurityManager.class.getConstructor(Collection.class)).asEagerSingleton(); } catch (NoSuchMethodException e) { throw new ConfigurationException("This really shouldn't happen. Either something has changed in Shiro, or there's a bug in ShiroModule.", e); } } }
ShiroWebModule extends ShiroModule { protected void bindWebSecurityManager(AnnotatedBindingBuilder<? super WebSecurityManager> bind) { try { bind.toConstructor(DefaultWebSecurityManager.class.getConstructor(Collection.class)).asEagerSingleton(); } catch (NoSuchMethodException e) { throw new ConfigurationException("This really shouldn't happen. Either something has changed in Shiro, or there's a bug in ShiroModule.", e); } } ShiroWebModule(ServletContext servletContext); }
ShiroWebModule extends ShiroModule { protected void bindWebSecurityManager(AnnotatedBindingBuilder<? super WebSecurityManager> bind) { try { bind.toConstructor(DefaultWebSecurityManager.class.getConstructor(Collection.class)).asEagerSingleton(); } catch (NoSuchMethodException e) { throw new ConfigurationException("This really shouldn't happen. Either something has changed in Shiro, or there's a bug in ShiroModule.", e); } } ShiroWebModule(ServletContext servletContext); static void bindGuiceFilter(Binder binder); @SuppressWarnings({"UnusedDeclaration"}) static void bindGuiceFilter(final String pattern, Binder binder); static ServletModule guiceFilterModule(); static ServletModule guiceFilterModule(final String pattern); List<FilterConfig<? extends Filter>> globalFilters(); }
ShiroWebModule extends ShiroModule { protected void bindWebSecurityManager(AnnotatedBindingBuilder<? super WebSecurityManager> bind) { try { bind.toConstructor(DefaultWebSecurityManager.class.getConstructor(Collection.class)).asEagerSingleton(); } catch (NoSuchMethodException e) { throw new ConfigurationException("This really shouldn't happen. Either something has changed in Shiro, or there's a bug in ShiroModule.", e); } } ShiroWebModule(ServletContext servletContext); static void bindGuiceFilter(Binder binder); @SuppressWarnings({"UnusedDeclaration"}) static void bindGuiceFilter(final String pattern, Binder binder); static ServletModule guiceFilterModule(); static ServletModule guiceFilterModule(final String pattern); List<FilterConfig<? extends Filter>> globalFilters(); @SuppressWarnings({"UnusedDeclaration"})
    static final Key<AnonymousFilter> ANON; @SuppressWarnings({"UnusedDeclaration"})
    static final Key<FormAuthenticationFilter> AUTHC; @SuppressWarnings({"UnusedDeclaration"})
    static final Key<BasicHttpAuthenticationFilter> AUTHC_BASIC; @SuppressWarnings({"UnusedDeclaration"})
    static final Key<BearerHttpAuthenticationFilter> AUTHC_BEARER; @SuppressWarnings({"UnusedDeclaration"})
    static final Key<NoSessionCreationFilter> NO_SESSION_CREATION; @SuppressWarnings({"UnusedDeclaration"})
    static final Key<LogoutFilter> LOGOUT; @SuppressWarnings({"UnusedDeclaration"})
    static final Key<PermissionsAuthorizationFilter> PERMS; @SuppressWarnings({"UnusedDeclaration"})
    static final Key<PortFilter> PORT; @SuppressWarnings({"UnusedDeclaration"})
    static final Key<HttpMethodPermissionFilter> REST; @SuppressWarnings({"UnusedDeclaration"})
    static final Key<RolesAuthorizationFilter> ROLES; @SuppressWarnings({"UnusedDeclaration"})
    static final Key<SslFilter> SSL; @SuppressWarnings({"UnusedDeclaration"})
    static final Key<IpFilter> IP; @SuppressWarnings({"UnusedDeclaration"})
    static final Key<UserFilter> USER; @SuppressWarnings({"UnusedDeclaration"})
    static final Key<InvalidRequestFilter> INVALID_REQUEST; }