Author: bdemers Date: Thu Dec 15 23:05:59 2016 New Revision: 1774534 URL: http://svn.apache.org/viewvc?rev=1774534&view=rev Log: dark launching updated spring docs, for 1.4.0+ Added: shiro/site/publish/spring-boot.html shiro/site/publish/spring-framework.html shiro/site/publish/spring-xml.html Added: shiro/site/publish/spring-boot.html URL: http://svn.apache.org/viewvc/shiro/site/publish/spring-boot.html?rev=1774534&view=auto ============================================================================== --- shiro/site/publish/spring-boot.html (added) +++ shiro/site/publish/spring-boot.html Thu Dec 15 23:05:59 2016 @@ -0,0 +1,508 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Apache Shiro | Simple. Java. Security. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + Fork me on GitHub + + + +
+

+ + + + Simple. Java. Security. +

+
+ + + + + + + +

Integrating Apache Shiro into Spring-Boot Applications

+

Shiro’s Spring-Boot integration is the easiest way to integrate Shiro into a Spring-base application, for more general Spring Framework integration, take a the annotation or XML guides.

+ +

Standalone Applications

+

Include the Shiro Spring starter dependency in you application classpath (we recomend using a tool such as Apache Maven or Gradle to manage this).

+ +
+
+
<dependency>
+    <groupId>org.apache.shiro</groupId>
+    <artifactId>shiro-spring-boot-starter</artifactId>
+    <version>${earlyRelease}</version>
+</dependency>
+
+
+
+
compile 'org.apache.shiro:shiro-spring-boot-starter:${earlyRelease}'
+
+
+
+

The only thing that is left is to configure a realm:

+
@Bean
+public Realm realm() {
+  ...
+}
+
+

The easiest way to setup Shiro, so that all SecurityUtils.* methods work in all cases, is to make the SecurityManager bean a static singleton. DO NOT do this in web applications - see the Web Applications section below instead.

+
@Autowired
+private SecurityManager securityManager;
+    
+ @PostConstruct
+ private void initStaticSecurityManager() {
+     SecurityUtils.setSecurityManager(securityManager);
+ }
+
+

That is it, now you can get the current Subject using:

+
SecurityUtils.getSubject();
+
+

You can see a full example in our samples on Github.

+ +

Web Applications

+

Shiro has first-class support for Spring web applications. In a web application, all Shiro-accessible web requests must go through a master Shiro Filter. This filter itself is extremely powerful, allowing for ad-hoc custom filter chains to be executed based on any URL path expression.

+

First include the Shiro Spring web starter dependency in you application classpath (we recomend using a tool such as Apache Maven or Gradle to manage this).

+ +
+
+
<dependency>
+    <groupId>org.apache.shiro</groupId>
+    <artifactId>shiro-spring-boot-web-starter</artifactId>
+    <version>${earlyRelease}</version>
+</dependency>
+
+
+
+
compile 'org.apache.shiro:shiro-spring-boot-web-starter:${earlyRelease}'
+
+
+
+

Provide a Realm implementation:

+
@Bean
+public Realm realm() {
+  ...
+}
+
+

And finally a ShiroFilterChainDefinition which will map any application specific paths to a given filter, in order to allow different paths different levels of access.

+
@Bean
+public ShiroFilterChainDefinition shiroFilterChainDefinition() {
+    DefaultShiroFilterChainDefinition chainDefinition = new DefaultShiroFilterChainDefinition();
+    
+    // logged in users with the 'admin' role
+    chainDefinition.addPathDefinition("/admin/**", "authc, roles[admin]");
+    
+    // logged in users with the 'document:read' permission
+    chainDefinition.addPathDefinition("/docs/**", "authc, perms[document:read]");
+    
+    // all other paths require a logged in user
+    chainDefinition.addPathDefinition("/**", "authc");
+    return chainDefinition;
+}
+
+

If you are using Shiro’s annotations see the annotation section below.

+

You can see a full example in our samples on Github.

+ +

Enabling Shiro Annotations

+

In both standalone and web applications, you might want to use Shiro’s Annotations for security checks (for example, @RequiresRoles, @RequiresPermissions, etc.) These annotations are enabled automatically in both starters listed above.

+

Simply annotate your methods in order to use them:

+
@RequiresPermissions("document:read")
+public void readDocument() {
+    ...
+}
+
+ +

Annotations and Web Applications

+

Shiro annotations are fully supported for use in @Controller classes, for example:

+
@Controller
+public class AccountInfoController {
+
+    @RequiresRoles("admin")
+    @RequestMapping("/admin/config")
+    public String adminConfig(Model model) {
+        return "view";
+    }
+}
+
+

A ShiroFilterChainDefinition bean with at least one definition is still required for this to work, either configure all paths to be accessable via the anon filter or a filter in ‘permissive’ mode, for example: authcBasic[permissive].

+
@Bean
+public ShiroFilterChainDefinition shiroFilterChainDefinition() {
+    DefaultShiroFilterChainDefinition chainDefinition = new DefaultShiroFilterChainDefinition();
+    chainDefinition.addPathDefinition("/**", "anon"); // all paths are managed via annotations
+    
+    // or allow basic authentication, but NOT require it.
+    // chainDefinition.addPathDefinition("/**", "authcBasic[permissive]"); 
+    return chainDefinition;
+}
+
+ +

Caching

+

Enabling caching is as simple as providing a CacheManager bean:

+
@Bean
+protected CacheManager cacheManager() {
+    return new MemoryConstrainedCacheManager();
+}
+
+ + +

Configuration Properties

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Key Default Value Description
shiro.enabled true Enables Shiro’s Spring module
shiro.web.enabled true Enables Shiro’s Spring web module
shiro.annotations.enabled true Enables Spring support for Shiro’s annotations
shiro.sessionManager.deleteInvalidSessions true Remove invalid session from session storage
shiro.sessionManager.sessionIdCookieEnabled true Enable session ID to cookie, for session tracking
shiro.sessionManager.sessionIdUrlRewritingEnabled true Enable session URL rewriting support
shiro.userNativeSessionManager false If enabled Shiro will manage the HTTP sessions instead of the container
shiro.sessionManager.cookie.name JSESSIONID Session cookie name
shiro.sessionManager.cookie.maxAge -1 Session cookie max age
shiro.sessionManager.cookie.domain null Session cookie domain
shiro.sessionManager.cookie.path null Session cookie path
shiro.sessionManager.cookie.secure false Session cookie secure flag
shiro.rememberMeManager.cookie.name rememberMe RememberMe cookie name
shiro.rememberMeManager.cookie.maxAge one year RememberMe cookie max age
shiro.rememberMeManager.cookie.domain null RememberMe cookie domain
shiro.rememberMeManager.cookie.path null RememberMe cookie path
shiro.rememberMeManager.cookie.secure false RememberMe cookie secure flag
shiro.loginUrl /login.jsp Login URL used when unauthenticated users are redirected to login page
shiro.successUrl / Default landing page after a user logs in (if alternative cannot be found in the current session)
shiro.unauthorizedUrl null Page to redirect user to if they are unauthorized (403 page)
+ + +
+ + + + + + Added: shiro/site/publish/spring-framework.html URL: http://svn.apache.org/viewvc/shiro/site/publish/spring-framework.html?rev=1774534&view=auto ============================================================================== --- shiro/site/publish/spring-framework.html (added) +++ shiro/site/publish/spring-framework.html Thu Dec 15 23:05:59 2016 @@ -0,0 +1,580 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Apache Shiro | Simple. Java. Security. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + Fork me on GitHub + + + +
+

+ + + + Simple. Java. Security. +

+
+ + + + + + + +

Integrating Apache Shiro into Spring-based Applications

+

This page covers the ways to integrate Shiro into Spring-based applications.

+ +

Standalone Applications

+

Include the Shiro Spring dependency in you application classpath (we recomend using a tool such as Apache Maven or Gradle to manage this).

+ +
+
+
<dependency>
+    <groupId>org.apache.shiro</groupId>
+    <artifactId>shiro-spring</artifactId>
+    <version>${earlyRelease}</version>
+</dependency>
+<dependency>
+    <groupId>org.springframework</groupId>
+    <artifactId>spring-context</artifactId>
+    <version>${spring.version}</version>
+</dependency>
+
+
+
+
compile 'org.apache.shiro:shiro-spring:${earlyRelease}'
+compile 'org.springframework:spring-context:${spring.version}'
+
+
+
+

Import the Shiro Spring configurations:

+
@Configuration
+@Import({ShiroBeanConfiguration.class,
+         ShiroConfiguration.class,
+         ShiroAnnotationProcessorConfiguration.class})
+public class CliAppConfig {
+   ...
+}
+
+

The above configurations do the following:

+ + + + + + + + + + + + + + + + + + + + + +
Configuration Class Description
org.apache.shiro.spring.config.ShiroBeanConfiguration Configures Shiro’s lifecycle and events
org.apache.shiro.spring.config.ShiroConfiguration Configures Shiro Beans (SecurityManager, SessionManager, etc)
org.apache.shiro.spring.config.ShiroAnnotationProcessorConfiguration Enables Shiro’s annotation processing
+

The only thing that is left is to configure a realm:

+
@Bean
+public Realm realm() {
+  ...
+}
+
+

The easiest way to setup Shiro, so that all SecurityUtils.* methods work in all cases, is to make the SecurityManager bean a static singleton. DO NOT do this in web applications - see the Web Applications section below instead.

+
@Autowired
+private SecurityManager securityManager;
+    
+ @PostConstruct
+ private void initStaticSecurityManager() {
+     SecurityUtils.setSecurityManager(securityManager);
+ }
+
+

That is it, now you can get the current Subject using:

+
SecurityUtils.getSubject();
+
+

You can see a full example in our samples on Github.

+ +

Web Applications

+

Shiro has first-class support for Spring web applications. In a web application, all Shiro-accessible web requests must go through a master Shiro Filter. This filter itself is extremely powerful, allowing for ad-hoc custom filter chains to be executed based on any URL path expression.

+

Include the Shiro Spring web dependencies in you application classpath (we recomend using a tool such as Apache Maven or Gradle to manage this).

+ +
+
+
<dependency>
+    <groupId>org.apache.shiro</groupId>
+    <artifactId>shiro-spring</artifactId>
+    <version>${earlyRelease}</version>
+</dependency>
+<dependency>
+    <groupId>org.apache.shiro</groupId>
+    <artifactId>shiro-web</artifactId>
+    <version>${earlyRelease}</version>
+</dependency>
+<dependency>
+    <groupId>org.springframework</groupId>
+    <artifactId>spring-webmvc</artifactId>
+    <version>${spring.version}</version>
+</dependency>
+
+
+
+
compile 'org.apache.shiro:shiro-spring:${earlyRelease}'
+compile 'org.apache.shiro:shiro-web:${earlyRelease}'
+compile 'org.springframework:spring-webmvc:${spring.version}'
+
+
+
+

Import the Shiro Spring configurations:

+
@Configuration
+@Import({ShiroBeanConfiguration.class,
+        ShiroAnnotationProcessorConfiguration.class,
+        ShiroWebConfiguration.class,
+        ShiroWebFilterConfiguration.class})
+public class ApplicationConfig {
+  ...
+}
+
+

The above configurations do the following:

+ + + + + + + + + + + + + + + + + + + + + + + + + +
Configuration Class Description
org.apache.shiro.spring.config.ShiroBeanConfiguration Configures Shiro’s lifecycle and events
org.apache.shiro.spring.config.ShiroAnnotationProcessorConfiguration Enables Shiro’s annotation processing
org.apache.shiro.spring.web.config.ShiroWebConfiguration Configures Shiro Beans for web usage (SecurityManager, SessionManager, etc)
org.apache.shiro.spring.web.config.ShiroWebFilterConfiguration Configures Shiro’s web filter
+

Provide a Realm implementation:

+
@Bean
+public Realm realm() {
+  ...
+}
+
+

And finally a ShiroFilterChainDefinition which will map any application specific paths to a given filter, in order to allow different paths different levels of access.

+
@Bean
+public ShiroFilterChainDefinition shiroFilterChainDefinition() {
+    DefaultShiroFilterChainDefinition chainDefinition = new DefaultShiroFilterChainDefinition();
+    
+    // logged in users with the 'admin' role
+    chainDefinition.addPathDefinition("/admin/**", "authc, roles[admin]");
+    
+    // logged in users with the 'document:read' permission
+    chainDefinition.addPathDefinition("/docs/**", "authc, perms[document:read]");
+    
+    // all other paths require a logged in user
+    chainDefinition.addPathDefinition("/**", "authc");
+    return chainDefinition;
+}
+
+

If you are using Shiro’s annotations see the annotation section below.

+

You can see a full example in our samples on Github.

+ +

Enabling Shiro Annotations

+

In both standalone and web applications, you might want to use Shiro’s Annotations for security checks (for example, @RequiresRoles, @RequiresPermissions, etc.) These annotations are enabled by importing the ShiroAnnotationProcessorConfiguration Spring configuration in both sections above.

+

Simply annotate your methods in order to use them:

+
@RequiresPermissions("document:read")
+public void readDocument() {
+    ...
+}
+
+ +

Annotations and Web Applications

+

Shiro annotations are fully supported for use in @Controller classes, for example:

+
@Controller
+public class AccountInfoController {
+
+    @RequiresRoles("admin")
+    @RequestMapping("/admin/config")
+    public String adminConfig(Model model) {
+        return "view";
+    }
+}
+
+

A ShiroFilterChainDefinition bean with at least one definition is still required for this to work, either configure all paths to be accessable via the anon filter or a filter in ‘permissive’ mode, for example: authcBasic[permissive].

+
@Bean
+public ShiroFilterChainDefinition shiroFilterChainDefinition() {
+    DefaultShiroFilterChainDefinition chainDefinition = new DefaultShiroFilterChainDefinition();
+    chainDefinition.addPathDefinition("/**", "anon"); // all paths are managed via annotations
+    
+    // or allow basic authentication, but NOT require it.
+    // chainDefinition.addPathDefinition("/**", "authcBasic[permissive]"); 
+    return chainDefinition;
+}
+
+ +

Caching

+

Enabling caching is as simple as providing a CacheManager bean:

+
@Bean
+protected CacheManager cacheManager() {
+    return new MemoryConstrainedCacheManager();
+}
+
+ + +

Configuration Properties

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Key Default Value Description
shiro.sessionManager.deleteInvalidSessions true Remove invalid session from session storage
shiro.sessionManager.sessionIdCookieEnabled true Enable session ID to cookie, for session tracking
shiro.sessionManager.sessionIdUrlRewritingEnabled true Enable session URL rewriting support
shiro.userNativeSessionManager false If enabled Shiro will manage the HTTP sessions instead of the container
shiro.sessionManager.cookie.name JSESSIONID Session cookie name
shiro.sessionManager.cookie.maxAge -1 Session cookie max age
shiro.sessionManager.cookie.domain null Session cookie domain
shiro.sessionManager.cookie.path null Session cookie path
shiro.sessionManager.cookie.secure false Session cookie secure flag
shiro.rememberMeManager.cookie.name rememberMe RememberMe cookie name
shiro.rememberMeManager.cookie.maxAge one year RememberMe cookie max age
shiro.rememberMeManager.cookie.domain null RememberMe cookie domain
shiro.rememberMeManager.cookie.path null RememberMe cookie path
shiro.rememberMeManager.cookie.secure false RememberMe cookie secure flag
shiro.loginUrl /login.jsp Login URL used when unauthenticated users are redirected to login page
shiro.successUrl / Default landing page after a user logs in (if alternative cannot be found in the current session)
shiro.unauthorizedUrl null Page to redirect user to if they are unauthorized (403 page)
+ + +
+ + + + + + Added: shiro/site/publish/spring-xml.html URL: http://svn.apache.org/viewvc/shiro/site/publish/spring-xml.html?rev=1774534&view=auto ============================================================================== --- shiro/site/publish/spring-xml.html (added) +++ shiro/site/publish/spring-xml.html Thu Dec 15 23:05:59 2016 @@ -0,0 +1,405 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Apache Shiro | Simple. Java. Security. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + Fork me on GitHub + + + +
+

+ + + + Simple. Java. Security. +

+
+ + + + + + + +

Integrating Apache Shiro into Spring-based Applications

+

This page covers the ways to integrate Shiro into Spring-based applications.

+

Shiro’s JavaBeans compatibility makes it perfectly suited to be configured via Spring XML or other Spring-based configuration mechanisms. Shiro applications need an application singleton SecurityManager instance. Note that this does not have to be a static singleton, but there should only be a single instance used by the application, whether its a static singleton or not.

+

Standalone Applications

+

Here is the simplest way to enable an application singleton SecurityManager in Spring applications:

+
<!-- Define the realm you want to use to connect to your back-end security datasource: -->
+<bean id="myRealm" class="...">
+    ...
+</bean>
+
+<bean id="securityManager" class="org.apache.shiro.mgt.DefaultSecurityManager">
+    <!-- Single realm app.  If you have multiple realms, use the 'realms' property instead. -->
+    <property name="realm" ref="myRealm"/>
+</bean>
+
+<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>
+
+<!-- For simplest integration, so that all SecurityUtils.* methods work in all cases, -->
+<!-- make the securityManager bean a static singleton.  DO NOT do this in web         -->
+<!-- applications - see the 'Web Applications' section below instead.                 -->
+<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
+    <property name="staticMethod" value="org.apache.shiro.SecurityUtils.setSecurityManager"/>
+    <property name="arguments" ref="securityManager"/>
+</bean>
+
+ +

Web Applications

+

Shiro has first-rate support for Spring web applications. In a web application, all Shiro-accessible web requests must go through a master Shiro Filter. This filter itself is extremely powerful, allowing for
ad-hoc custom filter chains to be executed based on any URL path expression.

+

Prior to Shiro 1.0, you had to use a hybrid approach in Spring web applications, defining the Shiro filter and
all of its configuration properties in web.xml but define the SecurityManager in Spring XML. This was a little frustrating since you couldn’t 1) consolidate your configuration in one place and 2) leverage the configuration power of the more advanced Spring features, like the PropertyPlaceholderConfigurer or abstract beans to consolidate common configuration.

+

Now in Shiro 1.0 and later, all Shiro configuration is done in Spring XML providing access to the more robust Spring configuration mechanisms.

+

Here is how to configure Shiro in a Spring-based web application:

+ +

web.xml

+

In addition to your other Spring web.xml elements (ContextLoaderListener, Log4jConfigListener, etc), define the following filter and filter mapping:

+
<!-- The filter-name matches name of a 'shiroFilter' bean inside applicationContext.xml -->
+<filter>
+    <filter-name>shiroFilter</filter-name>
+    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
+    <init-param>
+        <param-name>targetFilterLifecycle</param-name>
+        <param-value>true</param-value>
+    </init-param>
+</filter>
+
+...
+
+<!-- Make sure any request you want accessible to Shiro is filtered. /* catches all -->
+<!-- requests.  Usually this filter mapping is defined first (before all others) to -->
+<!-- ensure that Shiro works in subsequent filters in the filter chain:             -->
+<filter-mapping>
+    <filter-name>shiroFilter</filter-name>
+    <url-pattern>/*</url-pattern>
+</filter-mapping>
+
+

You can see a full example in our samples on Github.

+ +

applicationContext.xml

+

In your applicationContext.xml file, define the web-enabled SecurityManager and the ‘shiroFilter’ bean that will be referenced from web.xml.

+
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
+    <property name="securityManager" ref="securityManager"/>
+    <!-- override these for application-specific URLs if you like:
+    <property name="loginUrl" value="/login.jsp"/>
+    <property name="successUrl" value="/home.jsp"/>
+    <property name="unauthorizedUrl" value="/unauthorized.jsp"/> -->
+    <!-- The 'filters' property is not necessary since any declared javax.servlet.Filter bean  -->
+    <!-- defined will be automatically acquired and available via its beanName in chain        -->
+    <!-- definitions, but you can perform instance overrides or name aliases here if you like: -->
+    <!-- <property name="filters">
+        <util:map>
+            <entry key="anAlias" value-ref="someFilter"/>
+        </util:map>
+    </property> -->
+    <property name="filterChainDefinitions">
+        <value>
+            # some example chain definitions:
+            /admin/** = authc, roles[admin]
+            /docs/** = authc, perms[document:read]
+            /** = authc
+            # more URL-to-FilterChain definitions here
+        </value>
+    </property>
+</bean>
+
+<!-- Define any javax.servlet.Filter beans you want anywhere in this application context.   -->
+<!-- They will automatically be acquired by the 'shiroFilter' bean above and made available -->
+<!-- to the 'filterChainDefinitions' property.  Or you can manually/explicitly add them     -->
+<!-- to the shiroFilter's 'filters' Map if desired. See its JavaDoc for more details.       -->
+<bean id="someFilter" class="..."/>
+<bean id="anotherFilter" class="..."> ... </bean>
+...
+
+<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
+    <!-- Single realm app.  If you have multiple realms, use the 'realms' property instead. -->
+    <property name="realm" ref="myRealm"/>
+    <!-- By default the servlet container sessions will be used.  Uncomment this line
+         to use shiro's native sessions (see the JavaDoc for more): -->
+    <!-- <property name="sessionMode" value="native"/> -->
+</bean>
+<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>
+
+<!-- Define the Shiro Realm implementation you want to use to connect to your back-end -->
+<!-- security datasource: -->
+<bean id="myRealm" class="...">
+    ...
+</bean>
+
+ +

Enabling Shiro Annotations

+

In both standalone and web applications, you might want to use Shiro’s Annotations for security checks (for example, @RequiresRoles, @RequiresPermissions, etc. This requires Shiro’s Spring AOP integration to scan for the appropriate annotated classes and perform security logic as necessary.

+

Here is how to enable these annotations. Just add these two bean definitions to applicationContext.xml:

+
<!-- Enable Shiro Annotations for Spring-configured beans.  Only run after -->
+<!-- the lifecycleBeanProcessor has run: -->
+<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor"/>
+    <bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
+    <property name="securityManager" ref="securityManager"/>
+</bean>
+
+ +

Secure Spring Remoting

+

There are two parts to Shiro’s Spring remoting support: Configuration for the client making the remoting call and configuration for the server receiving and processing the remoting call.

+ +

Server-side Configuration

+

When a remote method invocation comes in to a Shiro-enabled server, the Subject associated with that RPC call must be bound to the receiving thread for access during the thread’s execution. This is done by defining Shiro’s SecureRemoteInvocationExecutor bean in applicationContext.xml:

+
<!-- Secure Spring remoting:  Ensure any Spring Remoting method invocations -->
+<!-- can be associated with a Subject for security checks. -->
+<bean id="secureRemoteInvocationExecutor" class="org.apache.shiro.spring.remoting.SecureRemoteInvocationExecutor">
+    <property name="securityManager" ref="securityManager"/>
+</bean>
+
+

Once you have defined this bean, you must plug it in to whatever remoting Exporter you are using to export/expose your services. Exporter implementations are defined according to the remoting mechanism/protocol in use. See Spring’s Remoting chapter on defining Exporter beans.

+

For example, if using HTTP-based remoting (notice the property reference to the secureRemoteInvocationExecutor bean):

+
<bean name="/someService" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
+    <property name="service" ref="someService"/>
+    <property name="serviceInterface" value="com.pkg.service.SomeService"/>
+    <property name="remoteInvocationExecutor" ref="secureRemoteInvocationExecutor"/>
+</bean>
+
+ +

Client-side Configuration

+

When a remote call is being executed, the Subject identifying information must be attached to the remoting payload to let the server know who is making the call. If the client is a Spring-based client, that association is done via Shiro’s SecureRemoteInvocationFactory:

+
<bean id="secureRemoteInvocationFactory" class="org.apache.shiro.spring.remoting.SecureRemoteInvocationFactory"/>
+
+

Then after you’ve defined this bean, you need to plug it in to the protocol-specific Spring remoting ProxyFactoryBean you’re using.

+

For example, if you were using HTTP-based remoting (notice the property reference to the secureRemoteInvocationFactory bean defined above):

+
<bean id="someService" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
+    <property name="serviceUrl" value="http://host:port/remoting/someService"/>
+    <property name="serviceInterface" value="com.pkg.service.SomeService"/>
+    <property name="remoteInvocationFactory" ref="secureRemoteInvocationFactory"/>
+</bean>
+
+ +

Lend a hand with documentation

+

While we hope this documentation helps you with the work you’re doing with Apache Shiro, the community is improving and expanding the documentation all the time. If you’d like to help the Shiro project, please consider corrected, expanding, or adding documentation where you see a need. Every little bit of help you provide expands the community and in turn improves Shiro.

+

The easiest way to contribute your documentation is to send it to the User Forum or the User Mailing List.

+ +
+ + + + + +