【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 }
有志者,事竟成,破釜沉舟,百二秦关终属楚; 苦心人,天不负,卧薪尝胆,三千越甲可吞吴。