org.apache.shiro.guice.web
Class ShiroWebModule

java.lang.Object
  extended by com.google.inject.PrivateModule
      extended by org.apache.shiro.guice.ShiroModule
          extended by org.apache.shiro.guice.web.ShiroWebModule
All Implemented Interfaces:
com.google.inject.Module, Destroyable

public abstract class ShiroWebModule
extends ShiroModule

Sets up Shiro lifecycles within Guice, enables the injecting of Shiro objects, and binds a default WebSecurityManager, SecurityManager and SessionManager. At least one realm must be added by using bindRealm.

Also provides for the configuring of filter chains and binds a FilterChainResolver with that information.


Field Summary
static com.google.inject.Key<AnonymousFilter> ANON
           
static com.google.inject.Key<FormAuthenticationFilter> AUTHC
           
static com.google.inject.Key<BasicHttpAuthenticationFilter> AUTHC_BASIC
           
static com.google.inject.Key<LogoutFilter> LOGOUT
           
static com.google.inject.Key<NoSessionCreationFilter> NO_SESSION_CREATION
           
static com.google.inject.Key<PermissionsAuthorizationFilter> PERMS
           
static com.google.inject.Key<PortFilter> PORT
           
static com.google.inject.Key<HttpMethodPermissionFilter> REST
           
static com.google.inject.Key<RolesAuthorizationFilter> ROLES
           
static com.google.inject.Key<SslFilter> SSL
           
static com.google.inject.Key<UserFilter> USER
           
 
Constructor Summary
ShiroWebModule(ServletContext servletContext)
           
 
Method Summary
protected  void addFilterChain(String pattern, com.google.inject.Key<? extends Filter>... keys)
          Adds a filter chain to the shiro configuration.
protected  void bindEnvironment(com.google.inject.binder.AnnotatedBindingBuilder<Environment> bind)
          Binds the environment.
static void bindGuiceFilter(com.google.inject.Binder binder)
           
static void bindGuiceFilter(String pattern, com.google.inject.Binder binder)
           
protected  void bindSecurityManager(com.google.inject.binder.AnnotatedBindingBuilder<? super SecurityManager> bind)
          Binds the security manager.
protected  void bindSessionManager(com.google.inject.binder.AnnotatedBindingBuilder<SessionManager> bind)
          Binds the session manager.
protected  void bindWebEnvironment(com.google.inject.binder.AnnotatedBindingBuilder<? super WebEnvironment> bind)
           
protected  void bindWebSecurityManager(com.google.inject.binder.AnnotatedBindingBuilder<? super WebSecurityManager> bind)
          Binds the security manager.
protected static
<T extends PathMatchingFilter>
com.google.inject.Key<T>
config(Class<T> type, String configValue)
           
protected static
<T extends PathMatchingFilter>
com.google.inject.Key<T>
config(com.google.inject.Key<T> baseKey, String configValue)
           
protected static
<T extends PathMatchingFilter>
com.google.inject.Key<T>
config(com.google.inject.TypeLiteral<T> typeLiteral, String configValue)
           
protected  void configureShiro()
          Implement this method in order to configure your realms and any other Shiro customization you may need.
protected abstract  void configureShiroWeb()
           
static com.google.inject.servlet.ServletModule guiceFilterModule()
           
static com.google.inject.servlet.ServletModule guiceFilterModule(String pattern)
           
 
Methods inherited from class org.apache.shiro.guice.ShiroModule
add, bindBeanType, bindRealm, configure, destroy
 
Methods inherited from class com.google.inject.PrivateModule
addError, addError, addError, bind, bind, bind, bindConstant, binder, bindInterceptor, bindListener, bindScope, configure, convertToTypes, currentStage, expose, expose, expose, getMembersInjector, getMembersInjector, getProvider, getProvider, install, requestInjection, requestStaticInjection, requireBinding, requireBinding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANON

public static final com.google.inject.Key<AnonymousFilter> ANON

AUTHC

public static final com.google.inject.Key<FormAuthenticationFilter> AUTHC

AUTHC_BASIC

public static final com.google.inject.Key<BasicHttpAuthenticationFilter> AUTHC_BASIC

NO_SESSION_CREATION

public static final com.google.inject.Key<NoSessionCreationFilter> NO_SESSION_CREATION

LOGOUT

public static final com.google.inject.Key<LogoutFilter> LOGOUT

PERMS

public static final com.google.inject.Key<PermissionsAuthorizationFilter> PERMS

PORT

public static final com.google.inject.Key<PortFilter> PORT

REST

public static final com.google.inject.Key<HttpMethodPermissionFilter> REST

ROLES

public static final com.google.inject.Key<RolesAuthorizationFilter> ROLES

SSL

public static final com.google.inject.Key<SslFilter> SSL

USER

public static final com.google.inject.Key<UserFilter> USER
Constructor Detail

ShiroWebModule

public ShiroWebModule(ServletContext servletContext)
Method Detail

bindGuiceFilter

public static void bindGuiceFilter(com.google.inject.Binder binder)

bindGuiceFilter

public static void bindGuiceFilter(String pattern,
                                   com.google.inject.Binder binder)

guiceFilterModule

public static com.google.inject.servlet.ServletModule guiceFilterModule()

guiceFilterModule

public static com.google.inject.servlet.ServletModule guiceFilterModule(String pattern)

configureShiro

protected final void configureShiro()
Description copied from class: ShiroModule
Implement this method in order to configure your realms and any other Shiro customization you may need.

Specified by:
configureShiro in class ShiroModule

configureShiroWeb

protected abstract void configureShiroWeb()

bindSecurityManager

protected final void bindSecurityManager(com.google.inject.binder.AnnotatedBindingBuilder<? super SecurityManager> bind)
Description copied from class: ShiroModule
Binds the security manager. Override this method in order to provide your own security manager binding.

By default, a DefaultSecurityManager is bound as an eager singleton.

Overrides:
bindSecurityManager in class ShiroModule

bindWebSecurityManager

protected void bindWebSecurityManager(com.google.inject.binder.AnnotatedBindingBuilder<? super WebSecurityManager> bind)
Binds the security manager. Override this method in order to provide your own security manager binding.

By default, a DefaultWebSecurityManager is bound as an eager singleton.

Parameters:
bind -

bindSessionManager

protected void bindSessionManager(com.google.inject.binder.AnnotatedBindingBuilder<SessionManager> bind)
Binds the session manager. Override this method in order to provide your own session manager binding.

By default, a DefaultWebSessionManager is bound as an eager singleton.

Overrides:
bindSessionManager in class ShiroModule
Parameters:
bind -

bindEnvironment

protected final void bindEnvironment(com.google.inject.binder.AnnotatedBindingBuilder<Environment> bind)
Description copied from class: ShiroModule
Binds the environment. Override this method in order to provide your own environment binding.

By default, a GuiceEnvironment is bound as an eager singleton.

Overrides:
bindEnvironment in class ShiroModule

bindWebEnvironment

protected void bindWebEnvironment(com.google.inject.binder.AnnotatedBindingBuilder<? super WebEnvironment> bind)

addFilterChain

protected final void addFilterChain(String pattern,
                                    com.google.inject.Key<? extends Filter>... keys)
Adds a filter chain to the shiro configuration.

NOTE: If the provided key is for a subclass of PathMatchingFilter, it will be registered with a proper provider.

Parameters:
pattern -
keys -

config

protected static <T extends PathMatchingFilter> com.google.inject.Key<T> config(com.google.inject.Key<T> baseKey,
                                                                                String configValue)

config

protected static <T extends PathMatchingFilter> com.google.inject.Key<T> config(com.google.inject.TypeLiteral<T> typeLiteral,
                                                                                String configValue)

config

protected static <T extends PathMatchingFilter> com.google.inject.Key<T> config(Class<T> type,
                                                                                String configValue)


Copyright © 2004-2014 The Apache Software Foundation. All Rights Reserved.