【Shiro】二、Apache Shiro配置
1、配置
使用配置获得SecurityManager,SecurityManager是核心,配置好并获取到SecurityManager,Shiro就算正式运行起来了。
两种方式:通过ini文件;通过ini实例
ini文件的格式
段:一个ini文件分为4段内容,段用[]表示;每段用键值对来进行配置
[main]:SecurityManager相关对象及其属性
[users]:静态定义的用户信息
[roles]:静态定义的角色信息
[urls]:Web应用中基于URL的安全控制
[main]
#定义对象
sha256Matcher = org.apache.shiro.authc.credential.Sha256CredentialsMatcher #定义对象及其属性
myRealm = com.company.security.shiro.DatabaseRealm
myRealm.connectionTimeout = 30000
myRealm.username = jsmith
myRealm.password = secret
#引用对象
myRealm.credentialsMatcher = $sha256Matcher #定义嵌套属性
securityManager.sessionManager.globalSessionTimeout = 1800000 #集合属性
securityManager.sessionManager.sessionListeners = $listen1,$listen2
anObject = some.class.with.a.Map.property
anObject.mapProperty = key1:$obj1,key2:$obj2 #重写覆盖
myRealm = com.company.security.MyRealm
myRealm = com.company.security.DatabaseRealm #自定义SecurityManager
securityManager = com....MyCustomerSecurityManager [users]
#格式:用户名 = 密码,角色1,角色2,角色3...
admin = secret
louis = 520,admin
yang = 1234,customer,controller [roles]
#格式:角色名 = 权限表达式1,权限表达式2.....
#权限表达式的格式:类型:操作:id,使用*通配符
#admin角色拥有所有权限
admin = *
#louis角色可以做sale类型的任何事
louis = sale:*
#yang角色可以做sale类型下confirm事件,且只能操作0001id
yang = sale:confirm:0001 [urls]
后面再讲
一般使用ini的方式配置,除非运行环境内存小,有限制,才用编程模式
2、术语
了解一下Shiro中用到的一些英文术语
Authentication:认证
Authorization:授权
Credential:用户凭证,如密码、token
Principal:用户标识,如用户名
Subject:用户
Role:角色
Permission:功能权限
Session:会话
Realm:安全DAO
Cryptography:密码术
Cipher:加密算法
Hash:散列算法
【Shiro】二、Apache Shiro配置的更多相关文章
- 【Shiro】Apache Shiro架构之集成web
Shiro系列文章: [Shiro]Apache Shiro架构之身份认证(Authentication) [Shiro]Apache Shiro架构之权限认证(Authorization) [Shi ...
- 【Shiro】Apache Shiro架构之自定义realm
[Shiro]Apache Shiro架构之身份认证(Authentication) [Shiro]Apache Shiro架构之权限认证(Authorization) [Shiro]Apache S ...
- 【Shiro】Apache Shiro架构之权限认证(Authorization)
Shiro系列文章: [Shiro]Apache Shiro架构之身份认证(Authentication) [Shiro]Apache Shiro架构之集成web [Shiro]Apache Shir ...
- 【Shiro】Apache Shiro架构之身份认证(Authentication)
Shiro系列文章: [Shiro]Apache Shiro架构之权限认证(Authorization) [Shiro]Apache Shiro架构之集成web [Shiro]Apache Shiro ...
- [转载] 【Shiro】Apache Shiro架构之实际运用(整合到Spring中)
写在前面:前面陆陆续续对Shiro的使用做了一些总结,如题,这篇博文主要是总结一下如何将Shiro运用到实际项目中,也就是将Shiro整到Spring中进行开发.后来想想既然要整,就索性把Spring ...
- SpringBoot整合Shiro 二:Shiro配置类
环境搭建见上篇:SpringBoot整合Shiro 一:搭建环境 Shiro配置类配置 shiro的配置主要集中在 ShiroFilterFactoryBean 中 关于权限: anon:无需认证就可 ...
- Apache Shiro 手册
(一)Shiro架构介绍 一.什么是Shiro Apache Shiro是一个强大易用的Java安全框架,提供了认证.授权.加密和会话管理等功能: 认证 - 用户身份识别,常被称为用户"登录 ...
- Apache Shiro 使用手册---转载
原文地址:http://www.360doc.com/content/12/0104/13/834950_177177202.shtml (一)Shiro架构介绍 一.什么是Shiro Apache ...
- Apache Shiro 使用手册
http://kdboy.iteye.com/blog/1154644 (一)Shiro架构介绍 一.什么是Shiro Apache Shiro是一个强大易用的Java安全框架,提供了认证.授权.加 ...
- apache shiro整合spring(一)
apache shiro整合spring 将shiro配置文件整合到spring体系中 方式一:直接在spring的配置文件中import shiro的配置文件 方式二:直接在web.xml中配置sh ...
随机推荐
- Autoresize UIView to fit subviews
@interface UIView (resizeToFit) -(void)resizeToFitSubviews; -(void)resizeHightToFitSubviews; -(void) ...
- 2018-2019-2 《Java程序设计》第11周学习总结
20175319 2018-2019-2 <Java程序设计>第11周学习总结 教材学习内容总结 本周学习<Java程序设计>第十三章java网络编程: - URL类 URL类 ...
- 建站手册-浏览器信息:Mozilla Firefox 浏览器
ylbtech-建站手册-浏览器信息:Mozilla Firefox 浏览器 1.返回顶部 1. http://www.w3school.com.cn/browsers/browsers_firefo ...
- 基于Java Agent的premain方式实现方法耗时监控(转),为了找到结论执行:premain在jvm启动的时候执行,所有方法前,会执行MyAgent的premain方法
Java Agent是依附于java应用程序并能对其字节码做相关更改的一项技术,它也是一个Jar包,但并不能独立运行,有点像寄生虫的感觉.当今的许多开源工具尤其是监控和诊断工具,很多都是基于Java ...
- day 107radis非关系型数据库
http://www.cnblogs.com/wupeiqi/articles/5132791.html 参考邮件. radis : 1. NoSql 2. 缓存在内存中 3.支持数据持久化 二. ...
- Cocos2d-x之Array
| 版权声明:本文为博主原创文章,未经博主允许不得转载. Array是一个列表类容器,是一种线性序列结构:列表容器中的元素是有序的,可以通过下标来访问,就和数组一样.其中Vector也是一种列表容 ...
- 基于名称快速定位文件和文件夹的搜索工具Everything和dll依赖查询工具Dependency Walker
在工作中有时需要定位头文件.lib库文件.dll文件等的路径,自己去一个个盘符查找实在太麻烦,最近发现使用Everything这款工具很方便,下载地址为:下载 Everything 1.4.1.935 ...
- 初识Flink广播变量broadcast
Broadcast 广播变量:可以理解为是一个公共的共享变量,我们可以把一个dataset 或者不变的缓存对象(例如map list集合对象等)数据集广播出去,然后不同的任务在节点上都能够获取到,并在 ...
- nowcoder A hard problem /// 数位DP
题目大意: 称一个数x的各个数位之和为f(x) 求区间L R之间 有多少个数x%f(x)==0 #include <bits/stdc++.h> using namespace std; ...
- 牛客网练习赛 2 烟花(概率dp)
题目传送门 烟花 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言524288K Special Judge, 64bit IO Format: %lld 题目 ...