shiro

Apache Shiro with Embedded-Jetty or Spark-Java - Is it possible?

主宰稳场 提交于 2019-12-23 02:44:09
问题 Does anyone have an example project on how I could integrate Shiro with Spark-Java/Jetty(embedded) please? I can see from http://sparkjava.com/documentation#filters that it must be the way. But not sure what would be the smartest way to do this according to https://shiro.apache.org/web.html If you may have any examples, appreciate much! 来源: https://stackoverflow.com/questions/54835994/apache-shiro-with-embedded-jetty-or-spark-java-is-it-possible

Shiro-菜鸟实战篇-shiro集成spring

一个人想着一个人 提交于 2019-12-23 02:22:54
环境搭建 创建Maven工程,导入坐标 < dependencies > < dependency > < groupId > junit < / groupId > < artifactId > junit < / artifactId > < version > 4.12 < / version > < scope > test < / scope > < / dependency > < dependency > < groupId > org . apache . logging . log4j < / groupId > < artifactId > log4j - web < / artifactId > < version > 2.12 .1 < / version > < / dependency > < dependency > < groupId > org . springframework < / groupId > < artifactId > spring - test < / artifactId > < version > 5.1 .10 . RELEASE < / version > < / dependency > < dependency > < groupId > org . apache . logging . log4j < /

Shiro Demo 示例(SpringMVC-Mybatis-Shiro-redis)

二次信任 提交于 2019-12-22 16:56:25
Shiro Demo 准备工作 运行前申明 请看完本页面的所有细节,对你掌握这个项目来说很重要,别一上来就搞,你不爽,我也不爽。 本项目需要一定的Java功底,需要对 SpringMvc , Mybatis ,有基本的了解,其次对 Redis 有了解和使用更佳。 本项目理论上,只需要一个 Redis ,然后一个 Mysql 和一个有 Maven 环境的开发工具即可运行起来。 对Reids没有了解,请看这里: 对Redis的理解,Redis是什么,Redis和Memcache谁快? 。 运行步骤 从 Github 下载源码(不定期更新和修复BUG),导入到 Eclipse 、 MyEclipes 、 Idea 类似开发工具。 解决编译错误,修改 JDK 为 1.7 以上(请勿使用工具自带 JDK )。 在 Mysql 数据库中创建一个数据库,库名随便。 从项目 /init/sql/ 下,先执行 tables.sql 创建表,再运行 init.data.sql 插入初始化数据。 再修改配置 jdbc.properties 把数据库链接改成您的。 安装Redis 服务,如果您没用过,或者没安装,请看这里==> Redis 安装 ,以及注意事项都在里面有说明。Redis启动报错请看这里: Please see the documentation included with the

Shiro UnknownSessionException after logout

感情迁移 提交于 2019-12-22 10:29:49
问题 I'm currently working on a web application in JavaEE6 stack and I've integrated Shiro for security. I think the authentication and authorization is working properly now and I have 1 last problem. When I logout, I'm encountering UnknownSessionException, here are my config and codes for inspection: web.xml <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns

Apache Shiro & Java Security for Novices

放肆的年华 提交于 2019-12-22 04:32:29
问题 I know next-to-nothing about Java's security model, including XML configuration, policy-setting, any security framework components, tools (such as keystore, etc.) and everything in between. Although I understand it will eventually become essential for me to roll up my sleeves and learn Java security in-depth, I was wondering if using something like Apache Shiro would help ease the transition a bit. As such, I have a few concerns with it. Is Shiro, essentially, a "turnkey, catchall wrapper"

Shiro-菜鸟实战篇-缓存管理

我只是一个虾纸丫 提交于 2019-12-22 00:43:55
先看下面的测试类及测试结果 @Test public void bufferTest ( ) { Subject subject = ShiroUtil . login ( "zhangsan" , "123456" ) ; subject . isPermitted ( "sys:user:list" ) ; subject . isPermitted ( "sys:user:list" ) ; subject . isPermitted ( "sys:user:list" ) ; } } 我们会发现授权完成运行了3次,这并不是我们想看到的。 为什么要使用缓存? 在没有使用缓存的情况下,每发送一次请求都会调用一次doGetAuthorizationInfo方法来进行用户的授权操作,但是我们知道,一个用户具有的权限一般不会频繁的修改,也就是每次授权的内容都是一样的,所以我们希望在用户登录成功的第一次授权成功后将用户的权限保存在缓存中,下一次请求授权的话就直接从缓存中获取,这样效率会更高一些。 下面说几种缓存办法。 使用内置缓存 在shiro系列文章第一篇我们就已经提及到了 CacheManager(缓存管理器) ,这是shiro封装好的内置缓存器,现在我们来使用一下它。 看下我们的自定义的工具类 其实只要创建一个缓存管理器,并放入我们的安全管理器中就可以了。

shiro with jdbc and hashed passwords

眉间皱痕 提交于 2019-12-21 20:54:55
问题 Here is my shiro config [main] authc.loginUrl = /site/index.jsp authc.usernameParam = user authc.passwordParam = pass authc.rememberMeParam = remember authc.successUrl = /site/home.jsp jdbcRealm=org.apache.shiro.realm.jdbc.JdbcRealm jdbcRealm.permissionsLookupEnabled=true jdbcRealm.authenticationQuery = select password from users where username = ? jdbcRealm.userRolesQuery = select role from users where username = ? credentialsMatcher = org.apache.shiro.authc.credential

吃透Shiro源码第五天

孤街浪徒 提交于 2019-12-21 20:18:38
文章目录 技术手法 (1)AuthenticationRealm设计思路 重点研究源码 技术手法 (1)AuthenticationRealm设计思路 AuthenticationRealm这个类我看了好久,实际上最最核心的方法就是提供:如何通过用户传递的AuthenticationToken来获取AuthentioncationInfo的方法。 @Override public final AuthenticationInfo getAuthenticationInfo ( AuthenticationToken token ) throws AuthenticationException { AuthenticationInfo info = getCachedAuthenticationInfo ( token ) ; if ( info == null ) { //核心:让子类通过token获取到info,这也是要强制重写的方法 info = doGetAuthenticationInfo ( token ) ; //尝试缓存 if ( token != null && info != null ) { LOGGER . debug ( "无缓存,尝试做token与info的缓存" ) ; //尝试缓存一下info

Spring service with cacheable methods gets initialized without cache when autowired in Shiro realm

本小妞迷上赌 提交于 2019-12-21 18:01:24
问题 After spending 2 days on this issue I really can't make any more progress on my own. I am working on a standard web application with Spring for dependency injection and the likes. I am also using Spring to cache several expensive methods I use a lot. After I introduced Apache Shiro for the security layer, I was experiencing a strange issue where @Cacheable methods in a certain service no longer got cached. To this point, I was able to strip the problem down to its core, but there's still a

【Shiro】- 认证授权过程源码分析

前提是你 提交于 2019-12-21 15:14:32
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> shiro: apahce的开源安全框架,因其强大、灵活的特点,则we在应用中经常使用,shiro认证和授权过程是分开的,下面从shiro的源码解析shiro的认证过程 subject.login(token); DelegatingSubject public void login(AuthenticationToken token) throws AuthenticationException { clearRunAsIdentitiesInternal(); Subject subject = securityManager.login(this, token); PrincipalCollection principals; String host = null; if (subject instanceof DelegatingSubject) { DelegatingSubject delegating = (DelegatingSubject) subject; //we have to do this in case there are assumed identities - we don't want to lose the 'real' principals: principals =