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配置的更多相关文章

  1. 【Shiro】Apache Shiro架构之集成web

    Shiro系列文章: [Shiro]Apache Shiro架构之身份认证(Authentication) [Shiro]Apache Shiro架构之权限认证(Authorization) [Shi ...

  2. 【Shiro】Apache Shiro架构之自定义realm

    [Shiro]Apache Shiro架构之身份认证(Authentication) [Shiro]Apache Shiro架构之权限认证(Authorization) [Shiro]Apache S ...

  3. 【Shiro】Apache Shiro架构之权限认证(Authorization)

    Shiro系列文章: [Shiro]Apache Shiro架构之身份认证(Authentication) [Shiro]Apache Shiro架构之集成web [Shiro]Apache Shir ...

  4. 【Shiro】Apache Shiro架构之身份认证(Authentication)

    Shiro系列文章: [Shiro]Apache Shiro架构之权限认证(Authorization) [Shiro]Apache Shiro架构之集成web [Shiro]Apache Shiro ...

  5. [转载] 【Shiro】Apache Shiro架构之实际运用(整合到Spring中)

    写在前面:前面陆陆续续对Shiro的使用做了一些总结,如题,这篇博文主要是总结一下如何将Shiro运用到实际项目中,也就是将Shiro整到Spring中进行开发.后来想想既然要整,就索性把Spring ...

  6. SpringBoot整合Shiro 二:Shiro配置类

    环境搭建见上篇:SpringBoot整合Shiro 一:搭建环境 Shiro配置类配置 shiro的配置主要集中在 ShiroFilterFactoryBean 中 关于权限: anon:无需认证就可 ...

  7. Apache Shiro 手册

    (一)Shiro架构介绍 一.什么是Shiro Apache Shiro是一个强大易用的Java安全框架,提供了认证.授权.加密和会话管理等功能: 认证 - 用户身份识别,常被称为用户"登录 ...

  8. Apache Shiro 使用手册---转载

    原文地址:http://www.360doc.com/content/12/0104/13/834950_177177202.shtml (一)Shiro架构介绍 一.什么是Shiro Apache ...

  9. Apache Shiro 使用手册

    http://kdboy.iteye.com/blog/1154644 (一)Shiro架构介绍 一.什么是Shiro  Apache Shiro是一个强大易用的Java安全框架,提供了认证.授权.加 ...

  10. apache shiro整合spring(一)

    apache shiro整合spring 将shiro配置文件整合到spring体系中 方式一:直接在spring的配置文件中import shiro的配置文件 方式二:直接在web.xml中配置sh ...

随机推荐

  1. 2018-2019 ACM-ICPC Brazil Subregional Programming Contest F. Music Festival

    题目:https://codeforces.com/gym/101908/problem/F 题意:给你n个舞台,每个舞台有很多个节目,每个节目有个开始时间,结束时间,价值,每个舞台至少出演过一个节目 ...

  2. Navicat for Mysql 连接报错1251[已解决]

    因为mysql是8.0.11的版本,比较新的mysql采用新的保密方式所以旧的修改密码的方式似乎不能用, 新版本改密码方式: use mysql; ALTER USER 'root'@'localho ...

  3. Linux:主设备号和次设备号

    http://www.linuxidc.com/Linux/2011-03/33863.htm     Linux的设备管理是和文件系统紧密结合的,各种设备都以文件的形式存放在/dev目录下,称为设备 ...

  4. U-Boot是什么

    U-Boot U-Boot,全称 Universal Boot Loader,是遵循GPL条款的开放源码项目.U-Boot的作用是系统引导.U-Boot从FADSROM.8xxROM.PPCBOOT逐 ...

  5. xshell链接linux出现SSH服务器拒绝了密码 的解决方案

    参考文章:https://blog.csdn.net/weixin_38554662/article/details/80589852 但是需要注意的是,ssh_config文件本来是没有权限修改的, ...

  6. C++中的智能指针类模板

    1,智能指针本质上是一个对象,这个对象可以像原生的指针一样使用,因为智能指 针相关的类通过重载的技术将指针相关的操作符都进行了重载,所以智能指针对象可以像原生指针一样操作,今天学习智能指针类模板,通过 ...

  7. 淘汰赛制_NOI导刊2010提高(01)

    题目描述 淘汰赛制是一种极其残酷的比赛制度.2n名选手分别标号1,2,3,…,2^n-1,2^n,他们将要参加n轮的激烈角逐.每一轮中,将所有参加该轮的选手按标号从小到大排序后,第1位与第2位比赛,第 ...

  8. Https 代理 sslsocket

    1. 什么是SSLSocket JDK文档指出,SSLSocket扩展Socket并提供使用SSL或TLS协议的安全套接字. 这种套接字是正常的流套接字,但是它们在基础网络传输协议(如TCP)上添加了 ...

  9. SpringBoot2.x整合Shiro(一)

    一:什么是ACL和RBAC: ACL: Access Control List 访问控制列表 以前盛行的一种权限设计,它的核心在于用户直接和权限挂钩 优点:简单易用,开发便捷 缺点:用户和权限直接挂钩 ...

  10. Centos7下源码编译安装与配置redis5.0

    1.下载redis5.0源码包 wget http://download.redis.io/releases/redis-5.0.5.tar.gz 2.检查是否安装过之前的历史版本 rpm -qa|g ...