Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Are you using the Spring framework? Normally, you should define the Shiro filter in Web.xml and initialize Shiro components in applicationContext.xml (as beans).</p> <p>You can do for instance as follows:</p> <p><strong>Web.xml</strong></p> <pre><code>&lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:web="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"&gt; &lt;display-name&gt;LoginTutorial&lt;/display-name&gt; &lt;!-- Shiro filter--&gt; &lt;filter&gt; &lt;filter-name&gt;ShiroFilter&lt;/filter-name&gt; &lt;filter-class&gt; org.springframework.web.filter.DelegatingFilterProxy &lt;/filter-class&gt; &lt;init-param&gt; &lt;param-name&gt;targetFilterLifecycle&lt;/param-name&gt; &lt;param-value&gt;true&lt;/param-value&gt; &lt;/init-param&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;ShiroFilter&lt;/filter-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;/filter-mapping&gt; ... </code></pre> <p><strong>applicationContext.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util" xmlns:couchdb="http://www.ektorp.org/schema/couchdb" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.ektorp.org/schema/couchdb http://www.ektorp.org/schema/couchdb/couchdb.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"&gt; &lt;!-- Scans within the base package of the application for @Components to configure as beans --&gt; &lt;!-- Apache Shiro customized classes are defined in the package com.6.0.shiro --&gt; &lt;context:component-scan base-package="com.6.0.shiro" /&gt; ... &lt;!-- Shiro filter --&gt; &lt;bean id="ShiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"&gt; &lt;property name="securityManager" ref="securityManager"/&gt; &lt;property name="filters"&gt; &lt;util:map&gt; &lt;entry key="myAuthcBasic"&gt; &lt;bean class="org.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilter"/&gt; &lt;/entry&gt; &lt;/util:map&gt; &lt;/property&gt; &lt;property name="filterChainDefinitions"&gt; &lt;value&gt; /safe/** = myAuthcBasic &lt;/value&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"&gt; &lt;!-- Single realm app. If you have multiple realms, use the 'realms' property instead. --&gt; &lt;property name="realm" ref="StaticRealm"/&gt; &lt;property name="cacheManager" ref="cacheManager"/&gt; &lt;!-- By default the servlet container sessions will be used. Uncomment this line to use shiro's native sessions (see the JavaDoc for more): --&gt; &lt;!-- &lt;property name="sessionMode" value="native"/&gt; --&gt; &lt;/bean&gt; &lt;bean id="cacheManager" class="org.apache.shiro.cache.MemoryConstrainedCacheManager"&gt; &lt;!--property name="cacheManager" ref="ehCacheManager" /--&gt; &lt;/bean&gt; &lt;!-- Define the Shiro Realm implementation you want to use to connect to your back-end --&gt; &lt;!-- StaticRealm: --&gt; &lt;bean id="StaticRealm" class="com.6.0.shiro.StaticRealm"&gt; &lt;property name="credentialsMatcher" ref="credMatcher"&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="credMatcher" class="com.example.shiro.ReverseCredentialsMatcher"/&gt; ... </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload