Class ShiroModule
java.lang.Object
com.google.inject.PrivateModule
org.apache.shiro.guice.ShiroModule
- All Implemented Interfaces:
com.google.inject.Module,org.apache.shiro.lang.util.Destroyable
- Direct Known Subclasses:
ShiroWebModule
public abstract class ShiroModule
extends com.google.inject.PrivateModule
implements org.apache.shiro.lang.util.Destroyable
Sets up Shiro lifecycles within Guice, enables the injecting of Shiro objects, and binds a default
SecurityManager and SessionManager.
At least one realm must be added by using
bindRealm.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(org.apache.shiro.lang.util.Destroyable destroyable) protected final <T> voidbindBeanType(com.google.inject.TypeLiteral<T> typeLiteral, com.google.inject.Key<? extends T> key) Binds a key to use for injecting setters in shiro classes.protected voidbindEnvironment(com.google.inject.binder.AnnotatedBindingBuilder<org.apache.shiro.env.Environment> bind) Binds the environment.protected voidbindEventBus(com.google.inject.binder.AnnotatedBindingBuilder<org.apache.shiro.event.EventBus> bind) Binds the EventBus.protected final com.google.inject.binder.LinkedBindingBuilder<org.apache.shiro.realm.Realm> This is the preferred manner to bind a realm.protected voidbindSecurityManager(com.google.inject.binder.AnnotatedBindingBuilder<? super org.apache.shiro.mgt.SecurityManager> bind) Binds the security manager.protected voidbindSessionManager(com.google.inject.binder.AnnotatedBindingBuilder<org.apache.shiro.session.mgt.SessionManager> bind) Binds the session manager.voidprotected abstract voidImplement this method in order to configure your realms and any other Shiro customization you may need.final voiddestroy()Destroys all beans created within this module that implementDestroyable.Methods inherited from class com.google.inject.PrivateModule
addError, addError, addError, bind, bind, bind, bindConstant, binder, bindInterceptor, bindListener, bindListener, bindScope, configure, convertToTypes, currentStage, expose, expose, expose, getMembersInjector, getMembersInjector, getProvider, getProvider, install, requestInjection, requestStaticInjection, requireBinding, requireBinding
-
Constructor Details
-
ShiroModule
public ShiroModule()
-
-
Method Details
-
configure
- Specified by:
configurein classcom.google.inject.PrivateModule
-
configureShiro
Implement this method in order to configure your realms and any other Shiro customization you may need. -
bindRealm
protected final com.google.inject.binder.LinkedBindingBuilder<org.apache.shiro.realm.Realm> bindRealm()This is the preferred manner to bind a realm. TheSecurityManagerwill be injected with any Realm bound with this method.- Returns:
- a binding builder for a realm
-
bindSecurityManager
protected void bindSecurityManager(com.google.inject.binder.AnnotatedBindingBuilder<? super org.apache.shiro.mgt.SecurityManager> bind) Binds the security manager. Override this method in order to provide your own security manager binding. By default, aDefaultSecurityManageris bound as an eager singleton.- Parameters:
bind-
-
bindSessionManager
protected void bindSessionManager(com.google.inject.binder.AnnotatedBindingBuilder<org.apache.shiro.session.mgt.SessionManager> bind) Binds the session manager. Override this method in order to provide your own session manager binding. By default, aDefaultSessionManageris bound as an eager singleton.- Parameters:
bind-
-
bindEnvironment
protected void bindEnvironment(com.google.inject.binder.AnnotatedBindingBuilder<org.apache.shiro.env.Environment> bind) Binds the environment. Override this method in order to provide your own environment binding. By default, aGuiceEnvironmentis bound as an eager singleton.- Parameters:
bind-
-
bindBeanType
protected final <T> void bindBeanType(com.google.inject.TypeLiteral<T> typeLiteral, com.google.inject.Key<? extends T> key) Binds a key to use for injecting setters in shiro classes.- Type Parameters:
T-- Parameters:
typeLiteral- the bean property typekey- the key to use to satisfy the bean property dependency
-
bindEventBus
protected void bindEventBus(com.google.inject.binder.AnnotatedBindingBuilder<org.apache.shiro.event.EventBus> bind) Binds the EventBus. Override this method in order to provide your ownEventBusbinding.- Parameters:
bind-- Since:
- 1.4
-
destroy
-
add
-