MrSummer33 2016-12-07 08:22 采纳率: 0%
浏览 2851

spring集成shiro不执行realm

<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<bean id="myrealm" class="com.ss.shiro.realm.MyRealm"></bean>

<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
    <property name="authenticator" ref="modelAuthricator" />
    <property name="cacheManager" ref="cacheManager"/>
    <property name="realms">
        <list>
            <ref bean="myrealm"/>
        </list>
    </property>
</bean>

<bean id="modelAuthricator" class="org.apache.shiro.authc.pam.ModularRealmAuthenticator">
    <property name="authenticationStrategy" ref="firstSuccess"/>
    <property name="realms">
        <list>
            <ref bean="myrealm"/>
        </list>
    </property>
</bean>

<bean id="firstSuccess" class="org.apache.shiro.authc.pam.FirstSuccessfulStrategy"/>

<!--缓存管理-->
<bean id="cacheManager" class="org.apache.shiro.cache.MemoryConstrainedCacheManager"/>

<!-- 将shiro与spring集合 -->
<bean id="shiroSecurityFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
    <!--<property name="filters">-->
        <!--<map>-->
            <!--<entry key="captchaAuthc" value-ref="captchaAuthenticationFilter" />-->
            <!--<entry key="kickout" value-ref="kickoutSessionControlFilter" />-->
            <!--<entry key="noaccess" value-ref="noAccessControlFilter"/>-->
            <!--<entry key="pmlogout" value-ref="pmLogoutFilter"/>-->
            <!--<entry key="authc" value-ref="pmAuthcFilter"/>-->
        <!--</map>-->
    <!--</property>-->
    <!-- shiro的核心安全接口 -->
    <property name="securityManager" ref="securityManager" />
    <property name="loginUrl" value="/login" />
    <property name="successUrl" value="/index" />
    <property name="unauthorizedUrl" value="/unauthorized" />
    <!-- shiro连接约束配置,在这里使用自定义的动态获取资源类 -->
    <!--<property name="filterChainDefinitionMap" ref="chainDefinitionSectionMetaSource" />-->
    <property name="filterChainDefinitions">
        <value>
            /login = anon
            /hello = anon
            /** = authc
        </value>
    </property>
</bean>

求大神指教 谢谢

  • 写回答

2条回答

  • GrayHJX 2016-12-07 09:36
    关注

    你是不是没在web.xml里配过滤器?具体整合shiro框架可以参考我的博客:SpringMVC整合Shiro权限框架

    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大