Tabnine Logo
ShiroModule
Code IndexAdd Tabnine to your IDE (free)

How to use
ShiroModule
in
org.apache.shiro.guice

Best Java code snippets using org.apache.shiro.guice.ShiroModule (Showing top 14 results out of 315)

origin: apache/shiro

public void configure() {
  // setup security manager
  bindSecurityManager(bind(SecurityManager.class));
  bindSessionManager(bind(SessionManager.class));
  bindEnvironment(bind(Environment.class));
  bindListener(BeanTypeListener.MATCHER, new BeanTypeListener());
  bindEventBus(bind(EventBus.class));
  bindListener(Matchers.any(), new SubscribedEventTypeListener());
  bindListener(Matchers.any(), new EventBusAwareTypeListener());
  final DestroyableInjectionListener.DestroyableRegistry registry = new DestroyableInjectionListener.DestroyableRegistry() {
    public void add(Destroyable destroyable) {
      ShiroModule.this.add(destroyable);
    }
    @PreDestroy
    public void destroy() {
      ShiroModule.this.destroy();
    }
  };
  bindListener(LifecycleTypeListener.MATCHER, new LifecycleTypeListener(registry));
  expose(SecurityManager.class);
  expose(EventBus.class);
  configureShiro();
  bind(realmCollectionKey())
      .to(realmSetKey());
  bind(DestroyableInjectionListener.DestroyableRegistry.class).toInstance(registry);
  BeanTypeListener.ensureBeanTypeMapExists(binder());
}
origin: apache/shiro

  @PreDestroy
  public void destroy() {
    ShiroModule.this.destroy();
  }
};
origin: apache/shiro

public void add(Destroyable destroyable) {
  ShiroModule.this.add(destroyable);
}
origin: killbill/killbill

@Override
protected void bindSecurityManager(final AnnotatedBindingBuilder<? super SecurityManager> bind) {
  super.bindSecurityManager(bind);
  final RedisCacheConfig redisCacheConfig = new ConfigurationObjectFactory(new ConfigSource() {
    @Override
    public String getString(final String propertyName) {
      return configSource.getString(propertyName);
    }
  }).build(RedisCacheConfig.class);
  // Magic provider to configure the cache manager
  if (redisCacheConfig.isRedisCachingEnabled()) {
    bind(CacheManager.class).toProvider(RedisShiroManagerProvider.class).asEagerSingleton();
  } else {
    bind(CacheManager.class).toProvider(EhcacheShiroManagerProvider.class).asEagerSingleton();
  }
}
origin: apache/shiro

/**
 * This is the preferred manner to bind a realm.  The {@link org.apache.shiro.mgt.SecurityManager} will be injected with any Realm bound
 * with this method.
 *
 * @return a binding builder for a realm
 */
protected final LinkedBindingBuilder<Realm> bindRealm() {
  Multibinder<Realm> multibinder = Multibinder.newSetBinder(binder(), Realm.class);
  return multibinder.addBinding();
}
origin: com.ning.billing/killbill-util

@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();
}
origin: apache/shiro

/**
 * Binds a key to use for injecting setters in shiro classes.
 * @param typeLiteral the bean property type
 * @param key the key to use to satisfy the bean property dependency
 * @param <T>
 */
protected final <T> void bindBeanType(TypeLiteral<T> typeLiteral, Key<? extends T> key) {
  BeanTypeListener.bindBeanType(binder(), typeLiteral, key);
}
origin: org.apache.shiro/shiro-guice

public void configure() {
  // setup security manager
  bindSecurityManager(bind(SecurityManager.class));
  bindSessionManager(bind(SessionManager.class));
  bindEnvironment(bind(Environment.class));
  bindListener(BeanTypeListener.MATCHER, new BeanTypeListener());
  bindEventBus(bind(EventBus.class));
  bindListener(Matchers.any(), new SubscribedEventTypeListener());
  bindListener(Matchers.any(), new EventBusAwareTypeListener());
  final DestroyableInjectionListener.DestroyableRegistry registry = new DestroyableInjectionListener.DestroyableRegistry() {
    public void add(Destroyable destroyable) {
      ShiroModule.this.add(destroyable);
    }
    @PreDestroy
    public void destroy() {
      ShiroModule.this.destroy();
    }
  };
  bindListener(LifecycleTypeListener.MATCHER, new LifecycleTypeListener(registry));
  expose(SecurityManager.class);
  expose(EventBus.class);
  configureShiro();
  bind(realmCollectionKey())
      .to(realmSetKey());
  bind(DestroyableInjectionListener.DestroyableRegistry.class).toInstance(registry);
  BeanTypeListener.ensureBeanTypeMapExists(binder());
}
origin: org.kill-bill.billing/killbill-util

@Override
protected void bindSecurityManager(final AnnotatedBindingBuilder<? super SecurityManager> bind) {
  super.bindSecurityManager(bind);
  final RedisCacheConfig redisCacheConfig = new ConfigurationObjectFactory(new ConfigSource() {
    @Override
    public String getString(final String propertyName) {
      return configSource.getString(propertyName);
    }
  }).build(RedisCacheConfig.class);
  // Magic provider to configure the cache manager
  if (redisCacheConfig.isRedisCachingEnabled()) {
    bind(CacheManager.class).toProvider(RedisShiroManagerProvider.class).asEagerSingleton();
  } else {
    bind(CacheManager.class).toProvider(EhcacheShiroManagerProvider.class).asEagerSingleton();
  }
}
origin: apache/shiro

@Test
public void testDestroy() throws Exception {
  final MockRealm mockRealm = createMock(MockRealm.class);
  final MyDestroyable myDestroyable = createMock(MyDestroyable.class);
  myDestroyable.destroy();
  replay(myDestroyable);
  final ShiroModule shiroModule = new ShiroModule() {
    @Override
    protected void configureShiro() {
      bindRealm().to(MockRealm.class);
      bind(MyDestroyable.class).toInstance(myDestroyable);
      expose(MyDestroyable.class);
    }
    @Provides
    public MockRealm createRealm() {
      return mockRealm;
    }
  };
  Injector injector = Guice.createInjector(shiroModule);
  injector.getInstance(MyDestroyable.class);
  shiroModule.destroy();
  verify(myDestroyable);
}
origin: org.apache.shiro/shiro-guice

/**
 * This is the preferred manner to bind a realm.  The {@link org.apache.shiro.mgt.SecurityManager} will be injected with any Realm bound
 * with this method.
 *
 * @return a binding builder for a realm
 */
protected final LinkedBindingBuilder<Realm> bindRealm() {
  Multibinder<Realm> multibinder = Multibinder.newSetBinder(binder(), Realm.class);
  return multibinder.addBinding();
}
origin: org.apache.shiro/shiro-guice

public void add(Destroyable destroyable) {
  ShiroModule.this.add(destroyable);
}
origin: org.apache.shiro/shiro-guice

  @PreDestroy
  public void destroy() {
    ShiroModule.this.destroy();
  }
};
origin: org.apache.shiro/shiro-guice

/**
 * Binds a key to use for injecting setters in shiro classes.
 * @param typeLiteral the bean property type
 * @param key the key to use to satisfy the bean property dependency
 * @param <T>
 */
protected final <T> void bindBeanType(TypeLiteral<T> typeLiteral, Key<? extends T> key) {
  BeanTypeListener.bindBeanType(binder(), typeLiteral, key);
}
org.apache.shiro.guiceShiroModule

Javadoc

Sets up Shiro lifecycles within Guice, enables the injecting of Shiro objects, and binds a default org.apache.shiro.mgt.SecurityManager and org.apache.shiro.session.mgt.SessionManager. At least one realm must be added by using #bindRealm().

Most used methods

  • bindSecurityManager
    Binds the security manager. Override this method in order to provide your own security manager bindi
  • destroy
    Destroys all beans created within this module that implement org.apache.shiro.util.Destroyable. Shou
  • add
  • bind
  • bindEnvironment
    Binds the environment. Override this method in order to provide your own environment binding. By def
  • bindEventBus
    Binds the EventBus. Override this method in order to provide your own EventBus binding.
  • bindListener
  • bindSessionManager
    Binds the session manager. Override this method in order to provide your own session manager binding
  • binder
  • configureShiro
    Implement this method in order to configure your realms and any other Shiro customization you may ne
  • expose
  • realmCollectionKey
  • expose,
  • realmCollectionKey,
  • realmSetKey

Popular in Java

  • Making http post requests using okhttp
  • getApplicationContext (Context)
  • getResourceAsStream (ClassLoader)
  • startActivity (Activity)
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • Runner (org.openjdk.jmh.runner)
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now