603803瑞斯康达:基于Spring框架的Shiro配置
来源:百度文库 编辑:中财网 时间:2024/04/29 05:46:44
基于Spring框架的Shiro配置
- 博客分类:
- 开发
Xml代码
-
shiroFilter -
- org.springframework.web.filter.DelegatingFilterProxy
-
shiroFilter -
/*
二、在Spring的applicationContext.xml中添加shiro配置
1、添加shiroFilter定义
Xml代码
-
-
-
-
-
-
- /login = anon
- /user/** = authc
- /role/edit/* = perms[role:edit]
- /role/save = perms[role:edit]
- /role/list = perms[role:view]
- /** = authc
2、添加securityManager定义
Xml代码
3、添加realm定义
Xml代码
三、实现MyRealm:继承AuthorizingRealm,并重写认证授权方法
Java代码
- public class MyRealm extends AuthorizingRealm{
- private AccountManager accountManager;
- public void setAccountManager(AccountManager accountManager) {
- this.accountManager = accountManager;
- }
- /**
- * 授权信息
- */
- protected AuthorizationInfo doGetAuthorizationInfo(
- PrincipalCollection principals) {
- String username=(String)principals.fromRealm(getName()).iterator().next();
- if( username != null ){
- User user = accountManager.get( username );
- if( user != null && user.getRoles() != null ){
- SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
- for( SecurityRole each: user.getRoles() ){
- info.addRole(each.getName());
- info.addStringPermissions(each.getPermissionsAsString());
- }
- return info;
- }
- }
- return null;
- }
- /**
- * 认证信息
- */
- protected AuthenticationInfo doGetAuthenticationInfo(
- AuthenticationToken authcToken ) throws AuthenticationException {
- UsernamePasswordToken token = (UsernamePasswordToken) authcToken;
- String userName = token.getUsername();
- if( userName != null && !"".equals(userName) ){
- User user = accountManager.login(token.getUsername(),
- String.valueOf(token.getPassword()));
- if( user != null )
- return new SimpleAuthenticationInfo(
- user.getLoginName(),user.getPassword(), getName());
- }
- return null;
- }
- }
spring 框架的介绍和好处?
使用spring框架的好处和不足?
找一首歌shiro的pearl
Spring的ACEGI框架,使用连接数据库的方式,是如果认证的?
哪儿有shiro petto的图图?
谁知道hibernate3的与spring的详细配置
基于windows的apache 怎么配置php
在spring的mvc框架中,如何在画面绑定link方式的参数传递(不采用hidden)
配置基于Linux平台的Netfilter-iptables防火墙
配置基于Linux平台的Netfilter-iptables防火墙
配置基于Linux平台的Netfilter-iptables防火墙
基于的intel core2 wxtrem x6800最佳配置?
久石让spring的钢琴谱
Thomas Nashe 的诗歌spring,the sweet spring 诗歌赏析
有关Spring的英语短文
spring outlook 的中文含意
关于 spring 的 小文章
死神原声shiro sagisu
基于J2EE的JSP环境的配置,谁能给个详细点的方案?谢
论文 \"微观经济学研究资源有效配置的框架\"
框架网页中框架内容的控制
浏览器怎么样配置为显示嵌入式框架。
浏览器怎么样配置才能显示嵌入框架
基于构件的软件工程