shiro

Retrieving Shiro Principals

元气小坏坏 提交于 2019-12-10 17:14:01
问题 NOTE: Due to subsequent research this question has been completely restructured. I am trying to retrieve values from Shiro's subject PrincipalCollection. I have added two principals to the collection. 'Username' and 'UUID'. When I try to recall these I get a SimplePrincipalCollection of size = 1 and this in turn has the principals as a LinkedHashMap of size = 2. Question is how can I retrieve the principals directly? 回答1: There is no need two add multiple principles for this purpose. You can

springoot shiro 整合的问题一例

戏子无情 提交于 2019-12-10 14:18:06
springboot + shiro 查了百度,都说是比较简单的配置。 但是感觉也不是那么容易。总是些奇奇怪怪的报错。 刚又报错了:Error creating bean with name 'methodValidationPostProcessor' 查了半天,好像这样的也有但是很少。正在一筹莫展中。看log到最后,发现。是 @Value 的问题。和shiro 的配置没有半毛钱关系。 总结一下:看日志要有耐性的看到底。看完。 来源: oschina 链接: https://my.oschina.net/macleo/blog/3140640

Shiro complaining “There is no session with id xxx” with DefaultSecurityManager

青春壹個敷衍的年華 提交于 2019-12-10 02:09:33
问题 I'm using Apache Shiro 1.2.0 in a long-running application that reads messages from a queue and and takes action. The action taken requires a Shiro authenticated session, so I've implemented an "ActAsAuthenticationToken" and custom credentials matcher which allows us to login in with only the username. I'm using the DefaultSecurityManager with only my custom realm and subject factory injected. Everything else should be default. As it is configured, everything worked fine for a while, but as

吃透Shiro源码第三天

家住魔仙堡 提交于 2019-12-10 01:54:58
文章目录 技术手法 (1)接口的代理 (2)接口作为方法参数 (3)生命周期的使用工具 重点研究类 技术手法 (1)接口的代理 Shiro自己也实现了会话机制。Shiro创建了自己的Session接口。为了拦截某些Session调用并执行其他逻辑,创建了一个简单的Session代理。如何扩展呢?可以继承ProxiedSession这个类,重写某个function(),并调用super.function()立即调用代理对象的方法,在此之前可编写其他代码以执行其他逻辑。此实现思路可以应用到任何已经创建的接口上。 /** * 简单的代理Session实现 * 立即将调用转给代理实例 * 此类对于框架子类继承很有用, * 以拦截某些Session调用并执行其他逻辑。 */ public class ProxiedSession implements Session . . . /** * 代理实例 */ protected final Session delegate ; /** * @param target 要被代理的Session对象 */ public ProxiedSession ( Session target ) { this . delegate = target ; } @Override public Serializable getId ( ) { /

Spring Boot with Apache Shiro

时间秒杀一切 提交于 2019-12-09 23:31:30
问题 I'm currently trying to integrate Apache Shiro to my Spring Boot restful API, but am experiencing some issues and was wondering if anyone could help. My Application.class: @Configuration @EnableTransactionManagement @EnableAutoConfiguration @ComponentScan(basePackages = "org.xelamitchell.sophia.server") public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } My WebConfig.class: @Configuration @EnableWebMvc public class WebConfig

Shiro doesn't redirect to unauthorizedUrl w/invalid login - Shiro with Spring and Tiles

懵懂的女人 提交于 2019-12-09 22:34:56
问题 I'm using Spring MVC, Tiles and Shiro. This is how my unauthorizedUrl property is configured: <property name="unauthorizedUrl" value="/unauthorized"/> My expectation is that when MyAuthorizingRealm finds invalid credentials, that Shiro will redirect to /unauthorized . But, that doesn't happen for me on form submission. I have a login @Controller that is mapped to handle GET and POST actions for /login . For accesses to the url /lists the login form is displayed. So it seems to work in one

SSM框架整合Shiro后的开发

冷暖自知 提交于 2019-12-09 21:34:40
手摸手教你SSM框架整合Shiro后的开发 前面,我们学习了 Shiro实现权限管理之表结构设计 以及 JQuery-Ztree.js使用范例 ,接下来就详细介绍一下SSM框架整合Shiro框架后的开发。同样推荐大家参看张开涛老师的 跟我学Shiro ,或者可以看我的笔记: Shiro实现授权 、 Shiro实现身份认证 。 如果你对SSM框架的整合不是很熟悉,你或许可以参看我的这个项目 SSM框架整合 。 下面我们就开始实现一个SSM+Shiro的权限管理项目吧! <!--more--> 测试环境 IDEA + Tomcat8 + Maven 起步 初始化数据库,请参考 /db 中的代码 导入依赖 导入Shiro框架需要的依赖: shiro-core-1.3.2.jar shiro-ehcache-1.3.2.jar shiro-quartz-1.3.2.jar shiro-spring-1.3.2.jar shiro-web-1.3.2.jar 其他依赖请参看项目中的 pom.xml 文件 搭建SSM框架 搭建SSM框架的过程这里不再详细说了,可以参看我的 SSM框架整合案例 <br/> SSM框架整合Shiro 环境配置 1.在web.xml中配置Shiro的过滤器 与Spring集成: <filter> <filter-name>shiroFilter</filter

将 Shiro 作为应用的权限基础 五:密码的加密/解密在Spring中的应用

夙愿已清 提交于 2019-12-09 21:25:42
考虑系统密码的安全,目前大多数系统都不会把密码以明文的形式存放到数据库中。 一把会采取以下几种方式对密码进行处理 密码的存储 “编码”存储 Shiro 提供了 base64和 16 进制字符串编码/解码的 API支持,方便一些编码解码操作。 Shiro内部的一些数据的存储/表示都使用了 base64和 16 进制字符串。 下面两端代码分别对其进行演示 Stringstr = "hello"; Stringbase64Encoded = Base64.encodeToString(str.getBytes()); Stringstr2 = Base64.decodeToString(base64Encoded); Assert.assertEquals(str,str2); 通过如上方式可以进行 base64编码/解码操作 Stringstr = "hello"; Stringbase64Encoded = Hex.encodeToString(str.getBytes()); Stringstr2 =newString(Hex.decode(base64Encoded.getBytes())); Assert.assertEquals(str,str2); 通过如上方式可以进行 16 进制字符串编码/解码操作。 Hash存储 散列算法一般用于生成数据的摘要信息,是一种不可逆的算法

软件工程个人总结

混江龙づ霸主 提交于 2019-12-09 20:54:13
软件工程个人总结 一、引言 1.1 项目介绍——社团管理系统 1.1.1 项目背景 在当代大学生的日常生活中,社团是必不可少的一个部分。如果仅仅是通过纸质文档进行管理的话,不但需要耗费大量的人力和资源,也会给管理造成不便。为了提升社团组织者对社团管理的便利性,我们小组选择社团管理这一主题,开发一款便于社团管理的系统。 1.1.2 系统简介 社团管理系统的操作角色分为游客、学生、管理员三种类型,集成了社团浏览、活动浏览、社团申请、活动创建、活动审批、入社申请审批、社团内部事务管理等功能模块,为社团管理者与学生提供一个方便的数字化管理平台。 1.2 相关文档汇总 社团管理系统需求分析 社团管理系统设计图 社团管理系统原型阶段 社团管理系统接口文档 github前后端代码 二、项目制作过程——个人分工 2.1 起步 2.1.1 需求分析 参与组内讨论,根据学生、普通社员、社长、管理员4种角色来提出需求 2.1.2 墨刀原型 两项简易墨刀原型 web端原型 app端原型 2.2 设计图 详见 设计图文档 2.2.1 用例图 全部用例图 2.2.2 顺序图 仅参与确认 2.2.3 类图 整个类图的绘制与类图说明 2.3 技术选型 2.3.1 查阅与学习 由于组内成员没有相关项目开发经验,如前端框架、路由、接口信息接受发送,后端框架、信息接受与发送。因此学习、试错花费大量时间。 查找资料

How to use cache permissions in grails shiro

倖福魔咒の 提交于 2019-12-09 18:40:24
问题 Everytime i call subject.isPermitted() , it sends a sql to db. How can i cache it? Any example? Thanks. I read the doc of shiro grails plugin, but cant solove it. DataSource: hibernate { cache.use_second_level_cache = true cache.use_query_cache = true cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider' } How to set the cachemanager to shiro? I try spring.resource,throw an error. What's the instance bean name of cachemanager? Do i need to config sth else? 回答1: You'll need to