shiro+spring认证
来源:互联网 发布:天津二手房成交量数据 编辑:程序博客网 时间:2024/06/05 09:52
*/public class CustomRealm extends AuthorizingRealm{ @Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection){ String username = (String) principalCollection.getPrimaryPrincipal(); /* User user = new User(); user.setUsername(username);*/ //查询角色信息 /*List<Role> roles = ser.queryRoleByUsername(username);*/ /** *List<Role> roles = userService.queryRoleByUsername(username); * a.select id from t_user where username='zhangsan' * b.select role_id from t_user_role where user_id=(a.select id from t_user where username='zhangsan') * c.select * from t_role where id in (select role_id from t_user_role where user_id=(a.select id from t_user where username='zhangsan')) */ SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); if (roles!=null){ /** * for (Role role: roles) { String rolename = role.getRoleName(); info.addRole(roleName); a. select permission_id from t_role_permisson where role_id=1 b. select * from t_permission where id in (select permission_id from t_role_permisson where role_id=1) List<Permission> permission = userService.queryPermissionByRoleId(role.getId()); for(Permission permisseion :permissions){ //封装权限信息 info.addStringPermission(permission.getPermissionname()); } } * */ for (Role role: roles ) { String rolename = role.getRoleName(); info.addRole(rolename); List<Permission> permissions = ser.queryPermissionByRoleId(role.getId()); for (Permission permission: permissions ) { //封装权限信息 info.addStringPermission(permission.getPermissionname()); } } } return null; } /** * 获取认证信息 * @param token * @return * @throws AuthenticationException */ @Override protected AuthenticationInfo doGetAuthenticationInfo( AuthenticationToken token) throws AuthenticationException{ String username = (String) token.getPrincipal(); //查询数据库 User user = ser.queryUserByUsername(username); if(user!=null){ return new SimpleAuthenticationInfo(user.getUsername(),user.getPassword(),user.getSale()); } return null; }}
阅读全文
0 0
- shiro+spring认证
- 为什么使用spring Shiro去做安全认证
- spring-shiro(权限、用户认证配置)
- 关于spring mvc + shiro 的登陆认证
- spring整合shiro认证和授权
- shiro认证
- shiro认证
- shiro认证
- Shiro 认证
- Shiro 认证
- 【Shiro】认证
- shiro初步 shiro认证
- Shiro第四篇【Shiro与Spring整合、快速入门、Shiro过滤器、登陆认证】
- apache shiro与spring整合、动态filterChainDefinitions、以及认证、授权
- apache shiro与spring整合、动态filterChainDefinitions、以及认证、授权
- Spring Shiro配置实现用户认证和授权
- apache shiro与spring整合、动态filterChainDefinitions、以及认证、授权
- apache shiro与spring整合、动态filterChainDefinitions、以及认证、授权
- shiro_spring.xml
- 位运算符
- 最完整的Windows下React Native开发环境搭建与第一个程序HelloWorld
- shiro_web.xml
- shiro+spring.pom
- shiro+spring认证
- windows 下编译log4cxx
- shiro java项目核心
- 前缀、中缀、后缀的相互转换
- 打乱数组排序的算法shuffle
- Candence/Allegro启动找不到cdn_XXXX.dll文件解决方法
- 内存处理
- 学习笔记TF050:TensorFlow源代码解析
- 结构体及共用体的大小