Shiro框架详解

这篇博客详细介绍了Apache Shiro的基础知识,包括Shiro的作用、核心组件,以及如何搭建Shiro项目。此外,还提供了项目代码参考和针对Shiro开发中可能遇到的问题的分析。
摘要由CSDN通过智能技术生成

(注:初始登录账号:admin 密码:123456)
简介:本篇博客讲解了关于Shiro的四个部分

       一:Shiro的基本介绍

       二:Shiro的项目搭建

       三:Shiro代码下载参考(项目+sql文件)

       四:关于Shrio的问题分析

	   五:数据库表设计

一:Shiro的基本介绍

1:什么是Shiro、有什么用、什么时候使用?

  shiro是一个安全框架,可以集成spring框架,

  主要功能:认证、授权、加密、回话管理

  一般在进行权限分配的项目中使用(总监、经理、员工...)

2:三大核心组件(缺一不可)

  subject:用户

  SecurityManager:安全管理

  Realm:充当Shiro与安全数据间的桥梁(最少配置一个)

二:Shiro的项目搭建

  项目流程介绍

                web.xml中配置 ----> applicationContext-shiro.xml ----> 相应类

   流程详解:

   1:在web.xml中配置两处

   1.1:过滤器代理(不配置则Shiro不生效)
<filter>

<!-- 此处的name 要和配置文件中 filter工厂的id一样 -->

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

<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>

<init-param>

<!-- 让shiro过滤器的生命周期 交给web容器管理 -->

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

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

</init-param>

</filter>

<filter-mapping>

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

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

</filter-mapping>
     1.2:在配置懒加载和监听器(已配置就不要重复配置)
<param-name>contextConfigLocation</param-name>

<param-value>classpath:spring/applicationContext*.xml</param-value>

org.springframework.web.context.ContextLoaderListener

2:在pom.xml导入相应jar
<dependency>

	<groupId>org.apache.shiro</groupId>
	
	<artifactId>shiro-all</artifactId>
	
	<version>1.2.3</version>

</dependency>
3:新建applicationContext-shiro.xml,并进行相关配置
<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"

xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd

http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值