【Shiro】14.开启注解支持

 1 /**
 2  * 开启Shiro的注解,
 3  * (如@RequiresRoles,@RequiresPermissions),需借助SpringAOP扫描使用Shiro注解的类,
 4  * 并在必要时进行安全逻辑验证 * 配置以下两个bean(DefaultAdvisorAutoProxyCreator(可选)
 5  * 和AuthorizationAttributeSourceAdvisor)即可实现此功能
 6  *
 7  * @return
 8  */
 9 @Bean
10 public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
11     DefaultAdvisorAutoProxyCreator proxyCreator = new DefaultAdvisorAutoProxyCreator();
12     proxyCreator.setProxyTargetClass(true);
13     return proxyCreator;
14 }
15 
16 /**
17  * 开启 shiro aop注解支持.
18  *
19  * @param securityManager
20  * @return
21  */
22 @Bean
23 public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) {
24     AuthorizationAttributeSourceAdvisor advisor = new AuthorizationAttributeSourceAdvisor();
25     advisor.setSecurityManager(securityManager);
26     return advisor;
27 }

 

posted @ 2024-10-25 09:48  陆陆无为而治者  阅读(4)  评论(0编辑  收藏  举报