Apache Shiro是Java的一个安全框架。
官网对shiro的介绍: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.
翻译一下:Apache Shiro™是强大且易于使用的Java安全框架,可执行认证,授权,加密和会话管理。借助Shiro易于理解的API,您可以快速轻松地确保任何应用程序 - 从最小的移动应用程序到最大的Web和企业应用程序。
本篇介绍shiro进行登陆认证和权限授权,并与web集成。
1、在pom.xml中引入shiro的jar包
<!-- shiro -->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-web</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-ehcache</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring</artifactId>
<version>1.2.1</version>
</dependency>
2、在web.xml中添加shiro过滤器(启动web程序的时候,javaweb会自动读取web.xml文件,创建servelet上下文并共享