@Test public void testBindWebEnvironment() 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(WebEnvironment.class); expose(Environment.class); } @Provides public ShiroModuleTest.MockRealm createRealm() { return mockRealm; } @Override protected void bindWebEnvironment(AnnotatedBindingBuilder<? super WebEnvironment> bind) { bind.to(MyWebEnvironment.class).asEagerSingleton(); } }); Environment environment = injector.getInstance(Environment.class); assertNotNull(environment); assertTrue(environment instanceof MyWebEnvironment); WebEnvironment webEnvironment = injector.getInstance(WebEnvironment.class); assertNotNull(webEnvironment); assertTrue(webEnvironment instanceof MyWebEnvironment); assertTrue( environment == webEnvironment ); }
protected void bindWebEnvironment(AnnotatedBindingBuilder<? super WebEnvironment> bind) { bind.to(WebGuiceEnvironment.class).asEagerSingleton(); }
ShiroWebModule extends ShiroModule { protected void bindWebEnvironment(AnnotatedBindingBuilder<? super WebEnvironment> bind) { bind.to(WebGuiceEnvironment.class).asEagerSingleton(); } }
ShiroWebModule extends ShiroModule { protected void bindWebEnvironment(AnnotatedBindingBuilder<? super WebEnvironment> bind) { bind.to(WebGuiceEnvironment.class).asEagerSingleton(); } ShiroWebModule(ServletContext servletContext); }
ShiroWebModule extends ShiroModule { protected void bindWebEnvironment(AnnotatedBindingBuilder<? super WebEnvironment> bind) { bind.to(WebGuiceEnvironment.class).asEagerSingleton(); } 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 bindWebEnvironment(AnnotatedBindingBuilder<? super WebEnvironment> bind) { bind.to(WebGuiceEnvironment.class).asEagerSingleton(); } 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; }