You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by bd...@apache.org on 2016/12/15 23:06:12 UTC

shiro-site git commit: Adding first pass at updated spring documentation

Repository: shiro-site
Updated Branches:
  refs/heads/master 4db17c848 -> c23d04094


Adding first pass at updated spring documentation

NOTE: the spring.md will ALSO be updated to link to these new file,


Project: http://git-wip-us.apache.org/repos/asf/shiro-site/repo
Commit: http://git-wip-us.apache.org/repos/asf/shiro-site/commit/c23d0409
Tree: http://git-wip-us.apache.org/repos/asf/shiro-site/tree/c23d0409
Diff: http://git-wip-us.apache.org/repos/asf/shiro-site/diff/c23d0409

Branch: refs/heads/master
Commit: c23d04094feb466fe08e7f50ba2f2d9ca8b45a4c
Parents: 4db17c8
Author: Brian Demers <bd...@apache.org>
Authored: Thu Dec 15 15:04:39 2016 -0800
Committer: Brian Demers <bd...@apache.org>
Committed: Thu Dec 15 15:04:39 2016 -0800

----------------------------------------------------------------------
 spring-boot.md.vtl                | 172 +++++++++++++++++++++++++++
 spring-framework.md.vtl           | 211 +++++++++++++++++++++++++++++++++
 spring-xml.md                     | 205 ++++++++++++++++++++++++++++++++
 templates/macros/dependencies.vtl |  24 ++++
 4 files changed, 612 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/shiro-site/blob/c23d0409/spring-boot.md.vtl
----------------------------------------------------------------------
diff --git a/spring-boot.md.vtl b/spring-boot.md.vtl
new file mode 100644
index 0000000..a10a65a
--- /dev/null
+++ b/spring-boot.md.vtl
@@ -0,0 +1,172 @@
+#parse('templates/macros/dependencies.vtl')
+
+<a name="Spring-IntegratingApacheShirointoSpringbasedApplications"></a>
+#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](spring-framework.html) or [XML](spring-xml.html) guides.  
+
+<a name="Spring-StandaloneApplications"></a>
+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).
+
+#dependencies('cli', [['org.apache.shiro', 'shiro-spring-boot-starter', "${earlyRelease}"]])
+
+The only thing that is left is to configure a [realm](realm.html):
+
+``` java
+@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](#Spring-WebApplications) section below instead.
+ 
+``` java
+@Autowired
+private SecurityManager securityManager;
+    
+ @PostConstruct
+ private void initStaticSecurityManager() {
+     SecurityUtils.setSecurityManager(securityManager);
+ }
+```
+
+That is it, now you can get the current `Subject` using:
+
+``` java
+SecurityUtils.getSubject();
+```
+
+You can see a full example in our [samples on Github](https://github.com/apache/shiro/tree/master/samples/spring-boot).
+
+<a name="Spring-WebApplications"></a>
+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).
+
+#dependencies('web', [['org.apache.shiro', 'shiro-spring-boot-web-starter', "${earlyRelease}"]])
+
+Provide a Realm implementation:
+``` java
+@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. 
+
+``` java
+@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](#Spring-annotations-web) section below.
+
+You can see a full example in our [samples on Github](https://github.com/apache/shiro/tree/master/samples/spring-boot-web).
+
+<a name="Spring-annotations"></a>
+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:
+
+``` java
+@RequiresPermissions("document:read")
+public void readDocument() {
+    ...
+}
+```
+
+<a name="Spring-annotations-web"></a>
+#[[###]]# Annotations and Web Applications
+
+Shiro annotations are fully supported for use in `@Controller` classes, for example:
+
+``` java
+@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]`.
+
+``` java
+@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;
+}
+```
+
+<a name="Spring-caching"></a>
+# Caching 
+
+Enabling caching is as simple as providing a [CacheManager](http://shiro.apache.org/caching.html) bean:
+
+``` java
+@Bean
+protected CacheManager cacheManager() {
+    return new MemoryConstrainedCacheManager();
+}
+```
+
+<!-- Work around for table styling until, all pages are updated. -->
+#mdStyle()
+
+# 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) |
+
+<input type="hidden" id="ghEditPage" value="spring-boot.md.vtl"></input>

http://git-wip-us.apache.org/repos/asf/shiro-site/blob/c23d0409/spring-framework.md.vtl
----------------------------------------------------------------------
diff --git a/spring-framework.md.vtl b/spring-framework.md.vtl
new file mode 100644
index 0000000..193b14a
--- /dev/null
+++ b/spring-framework.md.vtl
@@ -0,0 +1,211 @@
+#parse('templates/macros/dependencies.vtl')
+
+<a name="SpringFramework-IntegratingApacheShirointoSpringbasedApplications"></a>
+Integrating Apache Shiro into Spring-based Applications
+===
+
+This page covers the ways to integrate Shiro into [Spring](http://spring.io)-based applications.
+
+<a name="SpringFramework-StandaloneApplications"></a>
+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).
+
+#dependencies('cli', [['org.apache.shiro', 'shiro-spring', "${earlyRelease}"],['org.springframework', 'spring-context', '${spring.version}']])
+
+Import the Shiro Spring configurations:
+
+``` java
+@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](realm.html):
+
+``` java
+@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](#Spring-WebApplications) section below instead.
+
+``` java
+@Autowired
+private SecurityManager securityManager;
+    
+ @PostConstruct
+ private void initStaticSecurityManager() {
+     SecurityUtils.setSecurityManager(securityManager);
+ }
+```
+
+That is it, now you can get the current `Subject` using:
+``` java
+SecurityUtils.getSubject();
+```
+
+You can see a full example in our [samples on Github](https://github.com/apache/shiro/tree/master/samples/spring).
+
+<a name="SpringFramework-WebApplications"></a>
+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).
+
+#dependencies('web', [['org.apache.shiro', 'shiro-spring', "${earlyRelease}"], ['org.apache.shiro', 'shiro-web', "${earlyRelease}"],['org.springframework', 'spring-webmvc', '${spring.version}']])
+
+Import the Shiro Spring configurations:
+
+``` java
+@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:
+``` java
+@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. 
+
+``` java
+@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](#Spring-annotations-web) section below.
+
+You can see a full example in our [samples on Github](https://github.com/apache/shiro/tree/master/samples/spring-mvc).
+
+<a name="Spring-annotations"></a>
+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:
+
+``` java
+@RequiresPermissions("document:read")
+public void readDocument() {
+    ...
+}
+```
+
+<a name="Spring-annotations-web"></a>
+#[[###]]# Annotations and Web Applications
+
+Shiro annotations are fully supported for use in `@Controller` classes, for example:
+
+``` java
+@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]`.
+
+``` java
+@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;
+}
+```
+
+<a name="Spring-caching"></a>
+# Caching 
+
+Enabling caching is as simple as providing a [CacheManager](http://shiro.apache.org/caching.html) bean:
+
+``` java
+@Bean
+protected CacheManager cacheManager() {
+    return new MemoryConstrainedCacheManager();
+}
+```
+
+<!-- Work around for table styling until, all pages are updated. -->
+#mdStyle()
+
+# 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) |
+
+<input type="hidden" id="ghEditPage" value="spring-framework.md.vtl"></input>

http://git-wip-us.apache.org/repos/asf/shiro-site/blob/c23d0409/spring-xml.md
----------------------------------------------------------------------
diff --git a/spring-xml.md b/spring-xml.md
new file mode 100644
index 0000000..b914945
--- /dev/null
+++ b/spring-xml.md
@@ -0,0 +1,205 @@
+<a name="SpringXml-IntegratingApacheShirointoSpringbasedApplications"></a>
+#Integrating Apache Shiro into Spring-based Applications
+
+This page covers the ways to integrate Shiro into [Spring](http://spring.io)-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.
+
+## <a name="SpringXml-StandaloneApplications"></a>Standalone Applications
+
+Here is the simplest way to enable an application singleton `SecurityManager` in Spring applications:
+
+
+``` xml
+<!-- 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>
+```
+
+<a name="SpringXml-WebApplications"></a>
+## 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:
+
+<a name="SpringXml-web.xml"></a>
+### web.xml
+
+In addition to your other Spring web.xml elements (`ContextLoaderListener`, `Log4jConfigListener`, etc), define the following filter and filter mapping:
+
+``` xml
+<!-- 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](https://github.com/apache/shiro/tree/master/samples/spring-xml).
+
+<a name="SpringXml-applicationContext.xml"></a>
+###applicationContext.xml
+
+In your applicationContext.xml file, define the web-enabled `SecurityManager` and the 'shiroFilter' bean that will be referenced from `web.xml`.
+
+``` 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>
+```
+
+<a name="SpringXml-EnablingShiroAnnotations"></a>
+##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`:
+
+``` 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>
+```
+
+<a name="SpringXml-SecureSpringRemoting"></a>
+##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.
+
+<a name="SpringXml-ServersideConfiguration"></a>
+###Server-side Configuration
+
+When a remote method invocation comes in to a Shiro-enabled server, the [Subject](subject.html "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`:
+
+``` 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](http://docs.spring.io/spring/docs/2.5.x/reference/remoting.html) on defining `Exporter` beans.
+
+For example, if using HTTP-based remoting (notice the property reference to the `secureRemoteInvocationExecutor` bean):
+
+``` xml
+<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>
+```
+
+<a name="SpringXml-ClientsideConfiguration"></a>
+###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`:
+
+``` xml
+<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):
+
+``` xml
+<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>
+```
+
+<a name="SpringXml-Lendahandwithdocumentation"></a>
+##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](http://shiro-user.582556.n2.nabble.com/) or the [User Mailing List](mailing-lists.html "Mailing Lists").
+<input type="hidden" id="ghEditPage" value="spring-xml.md"></input>

http://git-wip-us.apache.org/repos/asf/shiro-site/blob/c23d0409/templates/macros/dependencies.vtl
----------------------------------------------------------------------
diff --git a/templates/macros/dependencies.vtl b/templates/macros/dependencies.vtl
new file mode 100644
index 0000000..5e6f71d
--- /dev/null
+++ b/templates/macros/dependencies.vtl
@@ -0,0 +1,24 @@
+#macro(dependencies, $anchorId, $deps)
+
+<ul class="nav nav-tabs">
+    <li class="active"><a data-toggle="tab" href="#maven-$anchorId">Apache Maven</a></li>
+    <li><a data-toggle="tab" href="#gradle-$anchorId">Gradle</a></li>
+</ul>
+
+<div class="tab-content">
+    <div id="maven-$anchorId" class="tab-pane fade in active">
+    <pre><code class='xml'>#foreach($item in $deps)&lt;dependency&gt;
+    &lt;groupId&gt;$item[0]&lt;/groupId&gt;
+    &lt;artifactId&gt;$item[1]&lt;/artifactId&gt;
+    &lt;version&gt;$item[2]&lt;/version&gt;
+&lt;/dependency&gt;
+#end
+</code></pre>
+    </div>
+    <div id="gradle-$anchorId" class="tab-pane fade">
+        <pre><code class='groovy'>#foreach($item in $deps)
+compile '$item[0]:$item[1]:$item[2]'
+#end</code></pre>
+    </div>
+</div>
+#end
\ No newline at end of file