版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Mr_yangzc/article/details/81019657
今天介绍一个 框架 shiro ,什么是shiro?用shiro可以解决那些问题?
好,接下来 就说说 shiro
现在市面上主流的安全(权限)框架 有 shiro 、spring security。。。
那我们应该选择哪一款呢?
我们先比较一下 这2个框架的优缺点
主流权限框架 Shiro和Spring Security比较
1.社区支持:Shiro ===>>Apache ,Spring Security ===>>Spring
2. shiro 比Spring Security 简单 、易上手
3.spring security 对 spring 完美融合 脱离spring 就废了
4.shiro
不跟任何的框架或者容器捆绑 做到可插拔的效果
好,今天我们先拿shiro来练手。学习一门框架,首先应该先到官网去溜达溜达,
我们今天是入门到精通,而不是入门到放弃。
废话不多说,来看一看 到底什么是shiro呢?
Apache Shiro是一个强大且易用的Java安全框架,执行身份验证、授权、密码学和会话管理。使用Shiro的易于理解的API,您可以快速、轻松地获得任何应用程序,从最小的移动应用程序到最大的网络和企业应用程序。
Apache Shiro™
is a powerful and easy-to-use Java security framework that performs authentication, authorization, cryptography, and session management. With Shiro’s easy-to-understand API, you can quickly and easily secure any application – from the smallest mobile applications to the largest web and enterprise applications.
- Authentication - proving user identity, often called user ‘login’.
- Authorization - access control
- Cryptography - protecting or hiding data from prying eyes
- Session Management - per-user time-sensitive state
Shiro also supports some auxiliary features, such as web application security,
unit testing, and multithreading support
, but these exist to reinforce the above four primary concerns.
Apache Shiro是一个强大而灵活的开源安全框架,它干净地处理身份验证、授权、企业会话管理和加密。
Apache Shiro is a powerful and flexible open-source security framework that cleanly handles authentication, authorization, enterprise session management and cryptography.
上面说到 shiro是强大 灵活 的框架 那到底他哪里强大、灵活了,接下来让我们看一看他的强大之处:
Apache Shiro旨在成为最全面的,但也是最容易使用的Java安全框架。
- 在任何地方最容易理解Java安全API。类和接口名称直观且有意义。任何东西都是可插拔的,但是对于一切都存在良好的默认设置。
- 跨一个或多个可插入数据源(LDAP,JDBC,ActiveDirectory等)支持身份验证('登录')。
- 根据角色或细粒度权限执行授权('访问控制'),同时使用可插拔数据源。
- 一流的缓存支持提高了应用程序的性能。
- 内置基于POJO的企业会话管理。在Web和非Web环境中使用,或者在任何需要单点登录(SSO)或群集或分布式会话的环境中使用。
- 多种客户端会话访问。您不再被迫使用httpSession或有状态会话Bean,这通常会将不必要地应用程序绑定到特定环境。无论部署环境如何,Flash小程序,C#应用程序,Java Web Start和Web应用程序等现在都可以共享会话状态。
- 简单 单一登录(SSO)支持搭载上述企业会话管理。如果会话跨多个应用程序联合,则用户的身份验证状态也可以共享。登录一次到任何应用程序,其他人都可以识别登录。
- 使用最简单可用的加密 API提供安全数据,为您提供超越Java默认提供的密码和哈希的功能和简单性。
- 一个令人难以置信的强大,但低配置的 Web框架,可以保护任何网址或资源,自动处理登录和注销,执行记住我的服务,等等。
- 极低数量的必需依赖项。独立配置仅需要slf4j-api.jar和slf4j的绑定.jars之一。Web配置还需要commons-beanutils-core.jar。需要时可以添加基于功能的依赖项(Ehcache缓存,基于Quartz的会话验证,Spring依赖注入等)。
那么这么强大的框架到底出自哪位高人只手呢?,故事从这里开始
很久以前,开发者都是用JAAS来进行安全操作的 ,但是
JAAS 使用是比较麻烦,后来
Les Hazlewood and Jeremy Haile (
https://en.wikipedia.org/wiki/Apache_Shiro
)要为政府开发项目,
使用JAAS不仅麻烦而且还不满足业务需求 ,因此
JSecurity
在
2004诞生了, 并与 2008 加入Apache ,
2010-09-22 成为apache 顶级项目
Les Hazlewood