【发布时间】:2014-02-02 02:34:36
【问题描述】:
我的项目有两个模块 - web 和 buisness。
在 web 模块 中,有一个带有配置的 shiro.ini 文件(如教程中的 - https://github.com/lhazlewood/apache-shiro-tutorial-webapp/blob/step7/src/main/webapp/WEB-INF/shiro.ini - 带有我自己的属性)。
在业务模块中,有一个applicationContext.xml文件,代码如下:
<bean id="iniRealm" class="org.apache.shiro.realm.text.IniRealm">
<property name="resourcePath" value="file:C:\project\webmodule\src\main\webapp\WEB-INF\shiro.ini" />
</bean>
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor" />
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor" />
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<property name="realm" ref="iniRealm" />
</bean>
<bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
<property name="securityManager" ref="securityManager" />
</bean>
但是如果我想使用注解,比如@RequiresAuthentication,那就不行了。
applicationContext.xml中的配置够吗?哪里可能出错? web 模块 中的身份验证工作正常。
过滤器有问题吗?我是否必须定义两个过滤器,一个使用<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>,另一个使用<filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>?
谢谢你的建议。
【问题讨论】: