1. 名词解释

  2. 权限认证

  3. 授权

  4. ini文件配置

  5. jsp标签授权

  6. Shiro会话机制

  7. 自定义Realm

  8. 加密、解密

  9. 特性

  10. 与spring整合

名词解释

Subject:认证主体

Reaml:认证来源[jdbc、property、text、jndi]

权限认证

谁访问什么资源

权限:页面

角色:权限的集合

用户:subject

授权

为角色分配权限

例如:admin = user : *

ini文件配置

[main]

authc.loginUrl = /login

roles.unauthorizedUrl = /unauthorized

perms.unauthorizedUrl = /unauthorized.jsp

[users]

jack = 123,admin

[roles]

admin = user : *

[urls]

/login = anon

/admin = authc

/student = roles[teacher]

/teacher = perms["user:create"]

Url匹配规则

/admin        匹配/admin

/admin?      匹配/admin1

/admin*       匹配/admin123

/admin/**    匹配/admin/1/2/3

jsp标签授权

依赖

  • shiro-web.jar

  • <%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>

例如:

<shiro:guest>    Hi there!  Please

<a href="login.jsp">Login</a> or

<a href="signup.jsp">Signup</a> today!

</shiro:guest>

Shiro会话机制

Subject currentUser = SecurityUtils.getSubject();

Session session = currentUser.getSession();

session.setAttribute( "someKey", someValue);

getSession calls work in any application, even non-web applications.

自定义Realm

Most people choose to subclass the AuthorizingRealm abstract class instead of starting from scratch. This class implements common authentication and authorization workflow to save you time and effort.

加密、解密

例如:

new Md5Hash(data)

特性

  • Web Support: Shiro’s web support APIs help easily secure web applications.

  • Caching: Caching is a first-tier citizen in Apache Shiro’s API to ensure that security operations remain fast and efficient.

  • Concurrency: Apache Shiro supports multi-threaded applications with its concurrency features.

  • Testing: Test support exists to help you write unit and integration tests and ensure your code will be secured as expected.

  • “Run As”: A feature that allows users to assume the identity of another user (if they are allowed), sometimes useful in administrative scenarios.

  • “Remember Me”: Remember users’ identities across sessions so they only need to log in when mandatory.

与spring整合

web.xml

<!-- The filter-name matches name of a 'shiroFilter' bean inside applicationContext.xml -->

<filter>

<filter-name>shiroFilter</filter-name>

<filter-class>

org.springframework.web.filter.DelegatingFilterProxy

</filter-class>

<init-param>

<param-name>targetFilterLifecycle</param-name>

<param-value>true</param-value>

</init-param>

</filter>...

<!-- Make sure any request you want accessible to Shiro is filtered. /* catches all --><!-- requests.  Usually this filter mapping is defined first (before all others) to --><!-- ensure that Shiro works in subsequent filters in the filter chain:             -->

<filter-mapping>

<filter-name>shiroFilter</filter-name>

<url-pattern>/*</url-pattern>

</filter-mapping>

applicationContext.xml

<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">

<property name="securityManager" ref="securityManager"/>

<property name="loginUrl" value="/login.jsp"/>

<property name="successUrl" value="/home.jsp"/>

<property name="unauthorizedUrl" value="/unauthorized.jsp"/>

<property name="filterChainDefinitions">

<value>

# some example chain definitions:

/admin/** = authc, roles[admin]

/docs/** = authc, perms[document:read]

/** = authc

# more URL-to-FilterChain definitions here

</value>

</property>

</bean>

<bean id="someFilter" class="..."/>

<bean id="anotherFilter" class="..."> ...

</bean>...

<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">

<property name="realm" ref="myRealm"/>

</bean>

<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>

<bean id="myRealm" class="...">    ...

</bean>

Apache Shiro知识点总览的更多相关文章

  1. Apache Shiro系列四,概述 —— Shiro的架构

    Shiro的设计目标就是让应用程序的安全管理更简单.更直观.     软件系统一般是基于用户故事来做设计.也就是我们会基于一个客户如何与这个软件系统交互来设计用户界面和服务接口.比如,你可能会说:“如 ...

  2. Apache Shiro(六)-基于URL配置权限

    数据库 先准备数据库啦. DROP DATABASE IF EXISTS shiro; CREATE DATABASE shiro DEFAULT CHARACTER SET utf8; USE sh ...

  3. Apache Shiro(四)-登录认证和权限管理WEB支持(Servlet)

    新建web项目 web.xml 修改web.xml,在里面加了个过滤器. 这个过滤器的作用,简单的说,就是 Shiro 入门里的TestShiro 这部分的工作,悄悄的干了. //加载配置文件,并获取 ...

  4. Apache Shiro(二)-登录认证和权限管理数据库操作

    数据库支持 在上一篇中使用ini 配置文件进行了相关权限数据的配置. 但是实际工作中,我们都会把权限相关的内容放在数据库里. 所以本知识点讲解如何放在数据库里来撸. RBAC 概念 RBAC 是当下权 ...

  5. Apache Shiro 反序列化漏洞复现(CVE-2016-4437)

    漏洞描述 Apache Shiro是一个Java安全框架,执行身份验证.授权.密码和会话管理.只要rememberMe的AES加密密钥泄露,无论shiro是什么版本都会导致反序列化漏洞. 漏洞原理 A ...

  6. Apache Shiro 学习记录5

    本来这篇文章是想写从Factory加载ini配置到生成securityManager的过程的....但是貌似涉及的东西有点多...我学的又比较慢...很多类都来不及研究,我又怕等我后面的研究了前面的都 ...

  7. Apache Shiro 学习记录2

    写完上篇随笔以后(链接).....我也想自己尝试一下写一个Strategy.....Shiro自带了3个Strategy,教程(链接)里作者也给了2个.....我想写个都不一样的策略.....看来看去 ...

  8. Apache Shiro系列(1)

    Apache Shiro是啥呢,安全框架. 360百科是这么描述的:        Apache Shiro(日语"堡垒(Castle)"的意思)是一个强大易用的Java安全框架, ...

  9. Apache Shiro系列之五,概述 —— 配置

    Shiro设计的初衷就是可以运行于任何环境:无论是简单的命令行应用程序还是复杂的企业集群应用.由于运行环境的多样性,所以有多种配置机制可用于配置,本节我们将介绍Shiro内核支持的这几种配置机制.   ...

随机推荐

  1. mysql系列之9.mysql日志&存储引擎

    mysqlbinlog 是什么? 数据目录下的如下文件: mysql-bin.xxxxxx 作用? 记录数据库内部增删改查对mysql数据库有更新的内容的记录 三种模式? statement leve ...

  2. 一文快速搞懂MySQL InnoDB事务ACID实现原理(转)

    这一篇主要讲一下 InnoDB 中的事务到底是如何实现 ACID 的: 原子性(atomicity) 一致性(consistency) 隔离性(isolation) 持久性(durability) 隔 ...

  3. 韩国版微信Kakao推出公链,能否用区块链实现全球扩张?

    2018年是属于区块链的一年,国内外巨头们纷纷布局区块链产业,前不久韩国最大的移动社交平台Kakao集团正式启动了旗下的第一个公链Klaytn的测试网. 此次宣布只是一次试探性举措,旨在对外公布Kla ...

  4. 【Leetcode-easy】Remove Duplicates from Sorted Array

    题目要求:删除排好序的含有重复元素的数组.返回去除重复后的数组长度,并更新原始数组.不能使用额外空间. 思路:要不额外的使用内存空间,那么只有遍历数组,count保持下一个不重复的数字,遍历过程中如果 ...

  5. 【Leetcode-easy】Longest Common Prefix

    思路:每次从字符数组中读取两个字符串比较.需要注意输入字符串为空,等细节. public String longestCommonPrefix(String[] strs) { if(strs==nu ...

  6. EASYARM-IMX283 nfs启动内核和根文件系统

    EASYARM-IMX283(以下简称IMX283)默认采用从nand flash启动,但是在开发过程中因为要频繁的替换内核,我们更倾向于从nfs启动. 先看看IMX283中uboot中默认采用的启动 ...

  7. SQLSERVER2008 R2的端口设置

    通过存储过程查看 我们首先打开sqlserver连接sqlserver2008的数据库实例,然后执行如下存储过程: --查询端口号 exec sys.sp_readerrorlog 0, 1, 'li ...

  8. .NET ViewState对于画面的速度影响

    最近开发一个.NET网站,发现有一个画面的交互特别缓慢,查了很多原因都没查到 最后终于知道,是因为画面的ViewState用的过多,其中有一个ViewState保存的数据相对而言比较大,导致了画面的运 ...

  9. 9.2 NOIP提高组试题精解(1)

    9-16 poise.c #include <stdio.h> #define MAXN 1001 int main() { ], flag[MAXN] = { }; //保存6种砝码的数 ...

  10. iOS实时监控网络状态的改变

    在网络应用中,有的时候需要对用户设备的网络状态进行实时监控,有两个目的: (1)让用户了解自己的网络状态,防止一些误会(比如怪应用无能) (2)根据用户的网络状态进行智能处理,节省用户流量,提高用户体 ...