List of usage examples for org.apache.shiro.guice.aop ShiroAopModule ShiroAopModule
ShiroAopModule
From source file:com.blazarquant.bfp.BlazarFixParser.java
License:Apache License
@Override protected Injector getInjector() { return Guice.createInjector(new DatabaseModule(), new ServiceModule(), new SecurityModule(servletContext), new ShiroAopModule(), new WebModule()); }
From source file:com.github.richardwilly98.esdms.inject.ProviderModule.java
License:Open Source License
@Override protected void configure() { log.info("*** configure ***"); install(new BootstrapModule()); install(new EsClientModule()); install(new ServicesModule()); install(new ShiroAopModule()); }
From source file:com.github.richardwilly98.esdms.inject.TestProviderModule.java
License:Open Source License
@Override protected void configure() { install(new BootstrapModule()); install(new TestEsClientModule()); install(new ServicesModule()); install(new ShiroAopModule()); install(new EsShiroModule()); Injector injector = Guice.createInjector(new CloseableModule(), new Jsr250Module(), new BootstrapModule(), new TestEsClientModule(), new ServicesModule(), new EsShiroModule()); org.apache.shiro.mgt.SecurityManager securityManager = injector .getInstance(org.apache.shiro.mgt.SecurityManager.class); SecurityUtils.setSecurityManager(securityManager); }
From source file:com.github.richardwilly98.esdms.web.RestGuiceServletConfig.java
License:Open Source License
@Override protected Injector getInjector() { log.debug("*** getInjector ***"); String securityFilterPath = "/api/*"; injector = Guice.createInjector(new CloseableModule(), new Jsr250Module(), new EsShiroWebModule(servletContext, securityFilterPath), new ShiroAopModule(), new EsJerseyServletModule(securityFilterPath)); return injector; }
From source file:org.apache.aurora.scheduler.http.api.security.ApiSecurityModule.java
License:Apache License
private void doConfigureServlets() { install(ShiroWebModule.guiceFilterModule(ApiModule.API_PATH)); install(new ShiroWebModule(getServletContext()) { @Override/*www . jav a 2s . co m*/ @SuppressWarnings("unchecked") protected void configureShiroWeb() { for (Module module : shiroConfigurationModules) { // We can't wrap this in a PrivateModule because Guice Multibindings don't work with them // and we need a Set<Realm>. install(module); } switch (HTTP_AUTHENTICATION_MECHANISM.get()) { case BASIC: addFilterChain("/**", ShiroWebModule.NO_SESSION_CREATION, config(ShiroWebModule.AUTHC_BASIC, BasicHttpAuthenticationFilter.PERMISSIVE)); break; case NEGOTIATE: addFilterChain("/**", ShiroWebModule.NO_SESSION_CREATION, Key.get(ShiroKerberosAuthenticationFilter.class)); break; default: addError("Unrecognized HTTP authentication mechanism."); break; } } }); bindConstant().annotatedWith(Names.named("shiro.applicationName")).to(HTTP_REALM_NAME); // TODO(ksweeney): Disable session cookie. // TODO(ksweeney): Disable RememberMe cookie. install(new ShiroAopModule()); // It is important that authentication happen before authorization is attempted, otherwise // the authorizing interceptor will always fail. MethodInterceptor authenticatingInterceptor = new ShiroAuthenticatingThriftInterceptor(); requestInjection(authenticatingInterceptor); bindInterceptor(Matchers.subclassesOf(AuroraSchedulerManager.Iface.class), AURORA_SCHEDULER_MANAGER_SERVICE.or(AURORA_ADMIN_SERVICE), authenticatingInterceptor); MethodInterceptor apiInterceptor = new ShiroAuthorizingParamInterceptor(THRIFT_AURORA_SCHEDULER_MANAGER); requestInjection(apiInterceptor); bindInterceptor(Matchers.subclassesOf(AuroraSchedulerManager.Iface.class), AURORA_SCHEDULER_MANAGER_SERVICE, apiInterceptor); MethodInterceptor adminInterceptor = new ShiroAuthorizingInterceptor(THRIFT_AURORA_ADMIN); requestInjection(adminInterceptor); bindInterceptor(Matchers.subclassesOf(AnnotatedAuroraAdmin.class), AURORA_ADMIN_SERVICE, adminInterceptor); }
From source file:org.apache.aurora.scheduler.http.api.security.HttpSecurityModule.java
License:Apache License
private void doConfigureServlets() { bind(Subject.class).toProvider(SecurityUtils::getSubject).in(RequestScoped.class); install(new AbstractModule() { @Override//from w w w.j a v a 2 s . c o m protected void configure() { // Provides-only module to provide Optional<Subject>. // TODO(ksweeney): Use an OptionalBinder here once we're on Guice 4.0. } @Provides Optional<Subject> provideOptionalSubject(Subject subject) { return Optional.of(subject); } }); install(guiceFilterModule(API_PATH)); install(guiceFilterModule(H2_PATH)); install(guiceFilterModule(H2_PATH + "/*")); install(new ShiroWebModule(getServletContext()) { // Replace the ServletContainerSessionManager which causes subject.runAs(...) in a // downstream user-defined filter to fail. See also: SHIRO-554 @Override protected void bindSessionManager(AnnotatedBindingBuilder<SessionManager> bind) { bind.to(DefaultSessionManager.class).asEagerSingleton(); } @Override @SuppressWarnings("unchecked") protected void configureShiroWeb() { for (Module module : shiroConfigurationModules) { // We can't wrap this in a PrivateModule because Guice Multibindings don't work with them // and we need a Set<Realm>. install(module); } // Filter registration order is important here and is defined by the matching pattern: // more specific pattern first. switch (mechanism) { case BASIC: addFilterChain(H2_PATTERN, NO_SESSION_CREATION, AUTHC_BASIC, config(PERMS, H2_PERM)); addFilterChainWithAfterAuthFilter(config(AUTHC_BASIC, PERMISSIVE)); break; case NEGOTIATE: addFilterChain(H2_PATTERN, NO_SESSION_CREATION, K_STRICT, config(PERMS, H2_PERM)); addFilterChainWithAfterAuthFilter(K_PERMISSIVE); break; default: addError("Unrecognized HTTP authentication mechanism: " + mechanism); break; } } private void addFilterChainWithAfterAuthFilter(Key<? extends Filter> filter) { if (shiroAfterAuthFilterKey.isPresent()) { addFilterChain(filter, shiroAfterAuthFilterKey.get()); } else { addFilterChain(filter); } } @SuppressWarnings("unchecked") private void addFilterChain(Key<? extends Filter> filter) { addFilterChain(ALL_PATTERN, NO_SESSION_CREATION, filter); } @SuppressWarnings("unchecked") private void addFilterChain(Key<? extends Filter> filter1, Key<? extends Filter> filter2) { addFilterChain(ALL_PATTERN, NO_SESSION_CREATION, filter1, filter2); } }); bindConstant().annotatedWith(Names.named("shiro.applicationName")).to(HTTP_REALM_NAME); // TODO(ksweeney): Disable session cookie. // TODO(ksweeney): Disable RememberMe cookie. install(new ShiroAopModule()); // It is important that authentication happen before authorization is attempted, otherwise // the authorizing interceptor will always fail. MethodInterceptor authenticatingInterceptor = new ShiroAuthenticatingThriftInterceptor(); requestInjection(authenticatingInterceptor); bindInterceptor(Matchers.subclassesOf(AuroraSchedulerManager.Iface.class), AURORA_SCHEDULER_MANAGER_SERVICE.or(AURORA_ADMIN_SERVICE), authenticatingInterceptor); MethodInterceptor apiInterceptor = new ShiroAuthorizingParamInterceptor(); requestInjection(apiInterceptor); bindInterceptor(Matchers.subclassesOf(AuroraSchedulerManager.Iface.class), AURORA_SCHEDULER_MANAGER_SERVICE, apiInterceptor); MethodInterceptor adminInterceptor = new ShiroAuthorizingInterceptor(THRIFT_AURORA_ADMIN); requestInjection(adminInterceptor); bindInterceptor(Matchers.subclassesOf(AnnotatedAuroraAdmin.class), AURORA_ADMIN_SERVICE, adminInterceptor); }
From source file:org.apache.usergrid.chop.webapp.ChopUiConfig.java
License:Apache License
@Override protected Injector getInjector() { if (injector != null) { return injector; }/*from w w w .j av a 2s.co m*/ injector = Guice.createInjector(new CustomShiroWebModule(context), new ShiroAopModule(), new ChopUiModule()); InjectorFactory.setInjector(injector); return injector; }
From source file:org.atteo.moonshine.shiro.ShiroService.java
License:Apache License
@Override public Module configure() { return new PrivateModule() { @Override/* w ww. j a va 2s.c om*/ protected void configure() { install(new ShiroModule() { @Override protected void configureShiro() { Multibinder<Realm> setBinder = Multibinder.newSetBinder(binder(), Realm.class); for (RealmService realm : realms) { if (realm.getId() == null) { setBinder.addBinding().to(Realm.class); } else { setBinder.addBinding().to(Key.get(Realm.class, Names.named(realm.getId()))); } } try { // Guice will initialize manager with list of realms bind(WebSecurityManager.class) .toConstructor(DefaultWebSecurityManager.class.getConstructor(Collection.class)) .asEagerSingleton(); } catch (NoSuchMethodException e) { addError(e); } expose(WebSecurityManager.class); } @Override protected void bindSessionManager(AnnotatedBindingBuilder<SessionManager> bind) { // make configurable bind.to(DefaultWebSessionManager.class).asEagerSingleton(); } }); FilterChainResolver filterChainResolver = new FilterChainResolver() { @Override public FilterChain getChain(ServletRequest request, ServletResponse response, FilterChain chain) { return null; } }; bind(FilterChainResolver.class).toInstance(filterChainResolver); bind(GuiceShiroFilter.class).asEagerSingleton(); install(ShiroWebModule.guiceFilterModule(prefix)); if (aop) { install(new ShiroAopModule()); } expose(SecurityManager.class); expose(WebSecurityManager.class); } }; }
From source file:uk.co.q3c.v7.base.guice.BaseGuiceServletInjector.java
License:Apache License
private List<Module> getModules() { // ini load is handled by the provider V7Ini ini = injector.getInstance(V7Ini.class); List<Module> baseModules = new ArrayList<>(); if (ini.optionReadSiteMap()) { log.debug("ini sitemap option is true, loading sitemap"); Provider<Sitemap> sitemapPro = injector.getInstance(SitemapProvider.class); Sitemap sitemap = sitemapPro.get(); baseModules.add(new ApplicationViewModule(sitemap)); } else {//w ww .j a v a 2s . c o m // module for Views must be in addAppModules() log.debug("ini sitemap option is false, not loading sitemap"); } baseModules.add(new ThreadScopeModule()); baseModules.add(new UIScopeModule()); baseModules.add(shiroWebModule(ctx.get(), ini)); baseModules.add(shiroVaadinModule()); baseModules.add(new ShiroAopModule()); baseModules.add(userOptionsModule(ini)); baseModules.add(baseModule()); baseModules.add(standardViewModule()); addAppModules(baseModules, ini); return baseModules; }