protected void configureShiro() { final RbacConfig config = new ConfigurationObjectFactory(configSource).build(RbacConfig.class); bind(RbacConfig.class).toInstance(config); bindRealm().toProvider(IniRealmProvider.class).asEagerSingleton(); if (isLDAPEnabled()) { bindRealm().to(KillBillJndiLdapRealm.class).asEagerSingleton(); } }
@Test(groups = "fast") public void testAOPForClass() throws Exception { // Make sure it works as expected without any AOP magic final IAopTester simpleTester = new AopTester(); try { simpleTester.createRefund(); } catch (Exception e) { Assert.fail(e.getLocalizedMessage()); } // Now, verify the interception works configureShiro(); // Shutdown the cache manager to avoid duplicate exceptions CacheManager.getInstance().shutdown(); final Injector injector = Guice.createInjector(Stage.PRODUCTION, new KillBillShiroModule(configSource), new KillBillShiroAopModule(), new SecurityModule(), new AbstractModule() { @Override protected void configure() { bind(IDBI.class).toInstance(Mockito.mock(IDBI.class)); } }); final AopTester aopedTester = injector.getInstance(AopTester.class); verifyAopedTester(aopedTester); }
@Override protected void bindSessionManager(final AnnotatedBindingBuilder<SessionManager> bind) { bind.to(DefaultSessionManager.class).asEagerSingleton(); // Magic provider to configure the session DAO bind(JDBCSessionDao.class).toProvider(JDBCSessionDaoProvider.class).asEagerSingleton(); } }
@Override protected void configureInterceptors(final AnnotationResolver resolver) { super.configureInterceptors(resolver); if (!KillBillShiroModule.isRBACEnabled()) { return; } final PermissionAnnotationHandler permissionAnnotationHandler = new PermissionAnnotationHandler(); // Inject the Security API requestInjection(permissionAnnotationHandler); final PermissionAnnotationMethodInterceptor methodInterceptor = new PermissionAnnotationMethodInterceptor(permissionAnnotationHandler, resolver); bindShiroInterceptorWithHierarchy(methodInterceptor); }
@Test(groups = "fast") public void testAOPForInterface() throws Exception { // Make sure it works as expected without any AOP magic final IAopTester simpleTester = new AopTesterImpl(); try { simpleTester.createRefund(); } catch (Exception e) { Assert.fail(e.getLocalizedMessage()); } // Now, verify the interception works configureShiro(); // Shutdown the cache manager to avoid duplicate exceptions CacheManager.getInstance().shutdown(); final Injector injector = Guice.createInjector(Stage.PRODUCTION, new KillBillShiroModule(configSource), new KillBillShiroAopModule(), new SecurityModule(), new AbstractModule() { @Override public void configure() { bind(IDBI.class).toInstance(Mockito.mock(IDBI.class)); bind(IAopTester.class).to(AopTesterImpl.class).asEagerSingleton(); } }); final IAopTester aopedTester = injector.getInstance(IAopTester.class); verifyAopedTester(aopedTester); }
@Override protected void bindSecurityManager(final AnnotatedBindingBuilder<? super SecurityManager> bind) { super.bindSecurityManager(bind); // Magic provider to configure the cache manager bind(CacheManager.class).toProvider(EhCacheManagerProvider.class).asEagerSingleton(); }
@Override protected void configure() { super.configure(); install(new GuicyKillbillTestNoDBModule()); install(new MockNonEntityDaoModule()); install(new MockGlobalLockerModule()); install(new InMemoryBusModule(configSource)); install(new MockNotificationQueueModule(configSource)); installAuditMock(); install(new KillBillShiroModule(configSource)); install(new KillBillShiroAopModule()); install(new SecurityModule()); } }