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权限框架

    评论

报告相同问题?

悬赏问题

  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划