shiro

Spring MVC and Shiro Configuration using ini files

若如初见. 提交于 2019-12-07 02:24:01
问题 I'm trying to set up an environment with Spring MVC and Apache Shiro. I'm following articles mentioned in shiro.apache.org. I'm using Spring's DelegatingFilterProxy as Shiro Filter in web.xml. The current filtering is done using : <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"> <property name="securityManager" ref="securityManager"/> <property name="loginUrl" value="/login"/> <property name="successUrl" value="/dashboard"/> <property name="unauthorizedUrl"

用户角色权限管理系统-----java web 脚手架搭建(一)

僤鯓⒐⒋嵵緔 提交于 2019-12-06 23:00:25
用户角色权限管理系统—–java web 脚手架搭建(一) 项目地址 JavaEEScaffold 用户名:admin 密码:1111 项目介绍 在开发中经常会遇到需要设计不同用户的权限,为了方便使用,这个通用java web开发的框架就诞生了。本项目参考了 开涛的blog 中介绍的一些技术,如shiro,es项目。 该项目实现了对用户的管理,角色管理,资源(权限)管理,以及对用户进行分配角色,对角色分配资源(权限)。 采用shiro来做权限验证,采用Druid来做数据库的监控 基本框架spring+springmvc+spring-jpa,几乎用的都是spring。 前端还是使用的jsp页面 项目预览 用户管理界面 上传用户 角色管理界面 绑定资源 资源管理界面 技术选型 容器框架:spring mvc:spring mvc 持久层:spring data jpa+hibernate jpa 数据库:mysql 数据库连接池、监控:druid 安全框架:shiro 前端:bootstrap,ZTree,Jquery,主题采用 adminLTE json框架:fastjson 数据校验框架:jquery-validate 日志系统:门面slf4j,实现log4j 代码构建工具:gradle 版本控制:git excel解析:jxl 功能设计 实现用户角色权限管理(基于资源(权限

netbeans 8.0.1 cant find shiro.ini

99封情书 提交于 2019-12-06 19:21:38
I added this shir.ini under web pages under WEB-INF: [main] # Objects and their properties are defined here, # Such as the securityManager, Realms and anything # else needed to build the SecurityManager shiro.loginUrl = /index.jsp [users] root = 12345,admin guest = 12345,guest [roles] admin = * [urls] /index.xhtml = authc /login.xhtml = authc /info.xhtml = anon /logout = logout /admin/** = authc, roles[admin] but in glassfish server 4.1 window, I got this error: SEVERE: [admin-listener(5)] INFO org.apache.shiro.web.env.EnvironmentLoader - Starting Shiro environment initialization. SEVERE:

shiro的代理过滤器

孤者浪人 提交于 2019-12-06 19:06:22
在配置shiro的时候第一件事情就是在web.xml文件中配置一个由spring提供的类:org.springframework.web.filter.DelegatingFilterProxy 按照字面的翻译这应该是一个代理过滤器的策略。 <filter> <filter-name>shiroFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> <async-supported>true</async-supported> <init-param> <param-name>targetFilterLifecycle</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>shiroFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> </filter-mapping> 这个类其实是将上下文中名称为shiroFilter的类做成一个代理过滤器

Apache Shiro 使用手册(二)Shiro 认证

孤街醉人 提交于 2019-12-06 15:55:33
一、Shiro认证过程 1、收集实体/凭据信息 //Example using most common scenario of username/password pair: UsernamePasswordToken token = new UsernamePasswordToken(username, password); //”Remember Me” built-in: token.setRememberMe(true); UsernamePasswordToken支持最常见的用户名/密码的认证机制。同时,由于它实现了RememberMeAuthenticationToken接口,我们可以通过令牌设置“记住我”的功能。 但是,“已记住”和“已认证”是有区别的: 已记住的用户仅仅是非匿名用户,你可以通过subject.getPrincipals()获取用户信息。但是它并非是完全认证通过的用户,当你访问需要认证用户的功能时,你仍然需要重新提交认证信息 。 这一区别可以参考亚马逊网站 ,网站会默认记住登录的用户,再次访问网站时,对于非敏感的页面功能,页面上会显示记住的用户信息,但是当你访问网站账户信息时仍然需要再次进行登录认证。 2、提交实体/凭据信息 Subject currentUser = SecurityUtils.getSubject(); currentUser

JFinal 整合 Shiro

大城市里の小女人 提交于 2019-12-06 15:53:53
(例子+源码 http://my.oschina.net/smile622/blog/203459) 最近整合JFinal和Shiro遇到的问题,希望能给你们提示与帮助。 首先,JFinal和Shiro本人都是刚刚接触,JFinal上手很快,但Shiro上手比较费劲,看了很长时间的文档。 下面说一下整合JFinal配置这里就不说了。 按照官方Shiro配置 1、添加shiro-all-1.2.1.jar 包括Shiro所依赖的jar包commons-beanutils-1.8.3.jar、commons-logging-1.1.3.jar和ehcache-core-2.6.6.jar 2、配置web.xml ? 1 2 3 4 5 6 7 8 9 10 11 12 13 <listener> <listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class> </listener> <filter> <filter-name>ShiroFilter</filter-name> <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class> </filter> <filter-mapping> <filter

带你揭秘Shiro(二)

无人久伴 提交于 2019-12-06 15:07:44
授权流程 1、对subject进行授权,调用方法isPermitted("permission串") 2、SecurityManager执行授权,通过ModularRealmAuthorizer执行授权 3、ModularRealmAuthorizer执行realm(自定义的Realm)从数据库查询权限数据,调用realm的doGetAuthorizationInfo授权方法 4、realm从数据库查询权限数据,返回ModularRealmAuthorizer 5、ModularRealmAuthorizer调用PermissionResolver进行权限串比对 6、如果比对后,isPermitted中"permission串"在realm查询到权限数据中,说明用户访问permission串有权限,否则 没有权限,抛出异常。 修改之前realmDemo.java中的doGetAuthorizationInfo方法 // 用于授权 @Override protected AuthorizationInfo doGetAuthorizationInfo( PrincipalCollection principals) { // 从 principals获取主身份信息 // 将getPrimaryPrincipal方法返回值转为真实身份类型

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

痞子三分冷 提交于 2019-12-06 14:47:57
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(一)

蹲街弑〆低调 提交于 2019-12-06 13:11:40
提到Shiro,不得不先介绍RBAC介绍 RBAC介绍:   RBAC是基于角色的访问控制(Role-Based Access Control )在 RBAC 中,权限与角色相关联,用户通过成为适当角色的成员而得到这些角色的权限。这就极大地简化了权限的管理。这样管理都是层级相互依赖的,权限赋予给角色,而把角色又赋予用户,这样的权限设计很清楚,管理起来很方便。 在RBAC模型里面,有3个基础组成部分,分别是:用户、角色和权限。 RBAC通过定义角色的权限,并对用户授予某个角色从而来控制用户的权限,实现了用户和权限的逻辑分离,极大地方便了权限的管理,在讲解之前,先介绍一些名词: User(用户):每个用户都有唯一的UID识别,并被授予不同的角色 Role(角色):不同角色具有不同的权限 Permission(权限):访问权限 用户-角色映射:用户和角色之间的映射关系 角色-权限映射:角色和权限之间的映射 权限管理:(包含两部分:用户认证,用户授权)   只要有用户参与的管理系统一般都有权限管理,权限管理实现对用户访问系统的控制,按照安全规则实现用户可以访问自己被授权的资源。 用户认证: 关键对象: subject:主体,理解为用户,可能是程序,都要去访问系统的资源,系统需要对subject进行身份认证。 principal:身份信息,通常是唯一的,一个主体还有多个身份信息

Spring MVC + Shiro + Junit Testing

雨燕双飞 提交于 2019-12-06 10:21:18
问题 Hello I am working on Spring MVC application. Shiro is the security framework for my application. Now I want to write unit tests for my application. I am facing some issues with getting shiro's SecurityUtils class in my controllers while testing. I am pasting my code snippets below. I am re-using my bean definitions for both testing and development. import org.apache.shiro.SecurityUtils; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org