在使用Shiro框架进行项目整合时,使用注解在使用Shiro框架进行项目整合时,使用注解在使用Shiro框架进行项目整合时,使用注解@RequiresPermissions为方法提供是需要的权限,但是根本没有进行验证,后面发现在自己的Realm中只执行了doGetAuthenticationInfo(登录验证)方法而没有执行doGetAuthorizationInfo(权限验证)的方法。

查看相关资料后发现是因为在Springmvc的配置文件中(我的名字是spring-servlet.xml)没有加入

<aop:config proxy-target-class="true"/>

<!-- 开启shiro注解 -->
<bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
    <property name="securityManager" ref="securityManager" />
</bean>

加入后解决问题.

也可以使用:

<!-- 支持Shiro对Controller的方法级AOP安全控制 begin-->
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor">
  <property name="proxyTargetClass" value="true" />
</bean>

<bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
    <property name="securityManager" ref="securityManager" />
</bean>
<!-- 保证实现了Shiro内部lifecycle函数的bean执行 -->
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>

但是一定要记住是把以下配置放在SpringMvc的配置文件中。

<aop:config proxy-target-class="true"/>

<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor">
  <property name="proxyTargetClass" value="true" />
</bean>

shiro和Spring整合使用注解时没有执行realm的doGetAuthorizationInfo回调方法的解决(XML配置)的更多相关文章

  1. Spring整合quartz2.2.3总结,quartz动态定时任务,Quartz定时任务集群配置

    Spring整合quartz2.2.3总结,quartz动态定时任务,Quartz定时任务集群配置 >>>>>>>>>>>>&g ...

  2. 安全框架 - Shiro与springMVC整合的注解以及JSP标签

    Shiro想必大家都知道了,之前的文章我也有提过,是目前使用率要比spring security都要多的一个权限框架,本身spring自己都在用shiro,之前的文章有兴趣可以去扒一下 最近正好用到s ...

  3. Shiro第四篇【Shiro与Spring整合、快速入门、Shiro过滤器、登陆认证】

    Spring与Shiro整合 导入jar包 shiro-web的jar. shiro-spring的jar shiro-code的jar 快速入门 shiro也通过filter进行拦截.filter拦 ...

  4. 零基础学习java------40---------Maven(maven的概念,安装,maven在eclipse中使用),springboot(spring整合springmvc(注解),spring整合mybatis(常见的配置文件)),前端页面(bootstrap软件)

    一 maven 1. Maven的相关概念 1.1 项目开发中遇到的问题 (1)都是同样的代码,为什么在我的机器上可以编译执行,而在他的机器上就不行? (2)为什么在我的机器上可以正常打包,而配置管理 ...

  5. Shiro与Spring整合

    Shiro引入Spring 添加jar包/maven配置 <!-- shiro支持 --> <dependency> <groupId>org.apache.shi ...

  6. spring 整合hibernate注解时候,出现“Unknown entity: com.ssh.entry.Admin; nested exception is org.hibernate.MappingException: Unknown entity: com.ssh.entry.Admin”异常的问题

    今天学习使用ssh框架的时候,出现一个异常,弄了好久才找到,在这记录一下,我的sb错误1.spring整合hibernate,取代*.hbm.xml配置文件   在applicationContext ...

  7. Hibernate Validation与Spring整合各注解的用法Demo

    转自:https://www.aliyun.com/jiaocheng/1315650.html <dependency> <groupId>org.hibernate< ...

  8. Spring中使用注解时启用<context:component-scan/>

    在spring中使用注解方式时需要在spring配置文件中配置组件扫描器:http://blog.csdn.net/j080624/article/details/56277315 <conte ...

  9. Spring @Scheduler使用cron时的执行问题

    主要想弄清使用Spring @Scheduler cron表达式时的两个问题: 同一定时任务,第二次触发时间到了,第一次还没有执行完成时会执行吗? 不同的定时任务,相互之间是否有影响? 结论写在前面: ...

随机推荐

  1. 用IdHTTPServer搞个简单的WEB服务器下载文件

    放在公司共享盘中的文件,不时就被其他人剪切走了,本想用Apache搭个服务端,提供文件下载的功能,写php脚本时碰到点问题,没折腾出来,一狠心,用Indy的IdHttpServer写.不过中间也碰到了 ...

  2. SQl_update,case_when,end

    627.Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and ...

  3. 用eclipse运行java程序显示找不到main class,网上的方法都试了,还是不行,有没有知道怎么解决的呀!

    编译器问题,jdk版本不对,Window --> Preferences -->Java --> compiler中的compiler compliance level,这里选你当前 ...

  4. Kubernetes Helm

    Helm is a tool for managing Kubernetes charts. Charts are packages of pre-configured Kubernetes reso ...

  5. cocostudio ui编辑器 使用心得

    1 c++包含路径 2九宫格设置 cocostudio ui编辑器设置九宫格x,y,w,h是从图片左上角开始测量,然后调整尺寸就行了. 2.  如果点了自适应  panel会在加载json的时候被设置 ...

  6. FastAdmin 线上部署流程 (2018-05-03 更新)

    FastAdmin 线上部署流程 首次部署 建立 git 环境. 建立 composer 环境. 建立 bower 环境. 将远程项目代码 git clone 到服务器上. 执行 composer i ...

  7. bzoj2442[Usaco2011 Open]修剪草坪——单调队列优化

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2442 考虑记录前 i 个.末尾 j 个连续选上的最大值.发现时空会爆. 又发现大量的转移形如 ...

  8. sphinx-1.3.0扩展在pPHP 7.0.7版本编译不通过

    在这个网友也是在php7上面编译插件不通过 https://bugs.php.net/bug.php?id=71586 下php7对应的扩展文件即可 http://git.php.net/?p=pec ...

  9. 老齐python-基础3(列表)

    1.定义一个列表 >>> a = [] #创建一个空列表 >>> type(a) #查看数据类型 <class 'list'> >>> ...

  10. jeecg中List页面的高级查询

    1.普通的高级查询 <t:datagrid name="orderworthList" title="订单价值统计" actionUrl="or ...