shiro

shiro自定义Realm(数据源)

 ̄綄美尐妖づ 提交于 2019-12-05 10:54:10
2.1一样先导包 <!--使用shiro需要先导包--> <dependencies> <!--shiro的核心包--> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-core</artifactId> <version>1.4.0</version> </dependency> <!--日志包--> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.2</version> </dependency> <!--测试包--> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.9</version> </dependency> </dependencies> 2.2准备自定义Realm 写一个Realm,继承 AuthorizingRealm 提供了两个方法,一个是授权 doGetAuthorizationInfo ,一个是身份认证 doGetAuthenticationInfo (准备个MyRealm.java文件,填写如下内容 )

Apache Shiro 使用手册

倖福魔咒の 提交于 2019-12-05 07:28:13
很好的学习资源,谢谢kdboy博主! Apache Shiro 使用手册(一)Shiro架构介绍 http://kdboy.iteye.com/blog/1154644 Apache Shiro 使用手册(二)Shiro架构介绍 http://kdboy.iteye.com/blog/1154652 Apache Shiro 使用手册(三)Shiro架构介绍 http://kdboy.iteye.com/blog/1155450 Apache Shiro 使用手册(四)Shiro架构介绍 http://kdboy.iteye.com/blog/1169631 Apache Shiro 使用手册(五)Shiro架构介绍 http://kdboy.iteye.com/blog/1169637 来源: oschina 链接: https://my.oschina.net/u/2347196/blog/518641

shiro学习(五、springboot+shiro+mybatis+thymeleaf)

廉价感情. 提交于 2019-12-05 07:27:56
入门shiro(感觉成功了)首先感谢狂神,然后我就一本正经的复制代码了 项目结构 运行效果 数据库 <dependencies> <!-- thymeleaf-shiro整合包 --> <dependency> <groupId>com.github.theborakompanioni</groupId> <artifactId>thymeleaf-extras-shiro</artifactId> <version>2.0.0</version> </dependency> <!--快速生成pojo的方法有关的lombok--> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.16.10</version> </dependency> <!-- 引入 myBatis,这是 MyBatis官方提供的适配 Spring Boot 的,而不是Spring Boot自己的--> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.1.0</version> <

Spring is ignoring @Transactional annotations in Apache Shiro Realm class

左心房为你撑大大i 提交于 2019-12-05 06:25:54
I am using Spring for IOC and transaction management, and am planning to use Apache Shiro as the security library. Whenever I want to check a user's permissions, I call subject.isPermitted("right") , whereupon Shiro checks for the permission using a datastore. Within these calls, a database connection is established, and I have annotated the method with @Transactional . However, I always receive an error that there is no Hibernate session bound to the thread whenever I execute the permission check. The method is in the Realm class. I defined a custom Shiro Realm class: @Component public class

Spring boot 加入shiro支持

本秂侑毒 提交于 2019-12-05 04:57:44
在项目添加依赖 <!-- shiro spring. --> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-spring</artifactId> <version>1.4.0</version> </dependency> <!-- shiro core --> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-core</artifactId> <version>1.4.0</version> </dependency> 配置文件目录下新建spring文件夹,在文件夹内新建spring-shiro.xml文件 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema

Please ensure that at least one realm can authenticate these tokens

微笑、不失礼 提交于 2019-12-05 02:29:30
问题 So I have set up my shiro to have two Realms. A Username and Password Realm, using the standard UsernamePasswordToken. I have also set up a Custom Bearer Authentication Token that works off a token passed in from the user. If i just use my passwordValidatorRealm it works find, if no user is found throws unknown account, if password doesn’t match throws incorrect credentials, perfect. But as soon as i put in my tokenValidatorRealm it throws a org.apache.shiro.authc.AuthenticationException:

2019-11-20 Java项目实战-shiro框架使用

人走茶凉 提交于 2019-12-05 02:15:13
shiro主要处理项目中用户模块、角色模块、菜单模块、权限模块功能,非常实用。 学习点一: 构建数据库表结构(通用) 1.用户表 (可根据角色,添加相应字段) -- ---------------------------- -- Table structure for sys_user -- ---------------------------- DROP TABLE IF EXISTS `sys_user`; CREATE TABLE `sys_user` ( `user_id` bigint(20) NOT NULL AUTO_INCREMENT, `name` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '姓名', `account` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '登录账户(8位字母)', `password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '密码', `status` tinyint(4) NOT NULL DEFAULT 0 COMMENT

shiro常见的异常以及处理方法

旧城冷巷雨未停 提交于 2019-12-05 02:11:06
1.shiro的常见异常 1.1 AuthenticationException 异常是Shiro在登录认证过程中,认证失败需要抛出的异常。 AuthenticationException包含以下子类: 1.1.1 CredentitalsException 凭证异常 IncorrectCredentialsException 不正确的凭证 ExpiredCredentialsException 凭证过期 1.1.2 AccountException 账号异常 ConcurrentAccessException 并发访问异常(多个用户同时登录时抛出) UnknownAccountException 未知的账号 ExcessiveAttemptsException 认证次数超过限制 DisabledAccountException 禁用的账号 LockedAccountException 账号被锁定 pportedTokenException 使用了不支持的Token 1.2AuthorizationException: 子类: 1.2.1 UnauthorizedException: 抛出以指示请求的操作或对请求的资源的访问是不允许的。 1.2.2 UnanthenticatedException:当尚未完成成功认证时,尝试执行授权操作时引发异常。 来源: https://www

How to use separate realms for authentication and authorization with Shiro and CAS?

六月ゝ 毕业季﹏ 提交于 2019-12-05 01:35:45
问题 I'm working on a web application where multiple applications authenticates through a CAS SSO Server. Howerver, each application should maintain their respective roles and these roles are stored in a database specific to the application. So, I need to have 2 realms, one for CAS (for authc) and another for DB (for authz). This is my current shiro config. I'm getting the redirection to the CAS working properly, but the logged in user (Subject) doesn't seems to have the roles/permission loaded in