- 浏览: 188370 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (321)
- eclipse (4)
- idea (2)
- Html (8)
- Css (14)
- Javascript (8)
- Jquery (6)
- Ajax Json (4)
- Bootstrap (0)
- EasyUI (0)
- Layui (0)
- 数据结构 (0)
- Java (46)
- DesPattern (24)
- Algorithm (2)
- Jdbc (8)
- Jsp servlet (13)
- Struts2 (17)
- Hibernate (11)
- Spring (5)
- S2SH (1)
- SpringMVC (4)
- SpringBoot (11)
- WebService CXF (4)
- Poi (2)
- JFreeChart (0)
- Shiro (6)
- Lucene (5)
- ElasticSearch (0)
- JMS ActiveMQ (3)
- HttpClient (5)
- Activiti (0)
- SpringCloud (11)
- Dubbo (6)
- Docker (0)
- MySQL (27)
- Oracle (18)
- Redis (5)
- Mybatis (11)
- SSM (1)
- CentOS (10)
- Ant (2)
- Maven (4)
- Log4j (7)
- XML (5)
最新评论
1. Shiro加密
2. Shiro支持特性
3. Shiro整合Spring
文档:http://shiro.apache.org/cryptography.html 1) shiro加密解密 2) shiro加密应用 CryptographyUtil.java package com.andrew.util; import org.apache.shiro.codec.Base64; import org.apache.shiro.crypto.hash.Md5Hash; public class CryptographyUtil { /** * base64加密 * * @param str * @return */ public static String encBase64(String str) { return Base64.encodeToString(str.getBytes()); } /** * base64解密 * * @param str * @return */ public static String decBase64(String str) { return Base64.decodeToString(str); } /** * Md5加密 * * @param str * @param salt * @return */ public static String md5(String str, String salt) { return new Md5Hash(str, salt).toString(); } public static void main(String[] args) { String password = "123456"; System.out.println("Base64加密:" + CryptographyUtil.encBase64(password)); System.out.println("Base64解密:" + CryptographyUtil.decBase64(CryptographyUtil.encBase64(password))); System.out.println("Md5加密:" + CryptographyUtil.md5(password, "andrew")); } } 运行结果: Base64加密:MTIzNDU2 Base64解密:123456 Md5加密:fe6bcd14f8e15e83a6b9593c2e8eba60
2. Shiro支持特性
1) Web支持 2) 缓存支持 3) 并发支持 4) 测试支持 5) "RunAs"支持 6) "RememberMe"支持 if (subject.isRemembered()) { System.out.println("---isRememberMe---"); } else { token.setRememberMe(true); }
3. Shiro整合Spring
官方文档:http://shiro.apache.org/spring.html create maven project --> maven-archetype-webapp --> GroupId: com.andrew.shiro Artifact Id: ShiroSpring Package: com.andrew.shiro jdk版本改为1.8
create table t_role ( id int(11) not null auto_increment, rolename varchar(20) default null, primary key (id) ) engine=innodb auto_increment=0 default charset=utf8; insert into t_role(id,roleName) values(1,'admin'); insert into t_role(id,roleName) values(2,'teacher'); create table t_permission ( id int(11) not null auto_increment, permissionname varchar(50) default null, roleid int(11) default null, primary key (id), constraint t_permission_ibfk_1 foreign key (roleid) references t_role (id) ) engine=innodb auto_increment=0 default charset=utf8; insert into t_permission(id, permissionName, roleId) values(1,'user:*',1); insert into t_permission(id, permissionName, roleId) values(2,'student:*',2); CREATE TABLE t_user ( id int(11) NOT NULL AUTO_INCREMENT, userName varchar(20) DEFAULT NULL, password varchar(20) DEFAULT NULL, roleId int(11) DEFAULT NULL, PRIMARY KEY (id), KEY roleId (roleId), CONSTRAINT t_user_ibfk_1 FOREIGN KEY (roleId) REFERENCES t_role (id) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; insert into t_user(id,userName,password,roleId) values (1,'andrew','123456',1); insert into t_user(id,userName,password,roleId) values (2,'jack','123',2); insert into t_user(id,userName,password,roleId) values (3,'marry','234',NULL); insert into t_user(id,userName,password,roleId) values (4,'json','345',NULL); CREATE TABLE users ( id int(11) NOT NULL AUTO_INCREMENT, userName varchar(20) DEFAULT NULL, password varchar(20) DEFAULT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; insert into users(id,userName,password) values (1,'java1234','123456'); src/main/java/com/andrew/controller/UserController.java package com.andrew.controller; import javax.servlet.http.HttpServletRequest; import org.apache.shiro.SecurityUtils; import org.apache.shiro.authc.UsernamePasswordToken; import org.apache.shiro.session.Session; import org.apache.shiro.subject.Subject; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.andrew.entity.User; /** * 用户Controller层 * * @author Administrator */ @Controller @RequestMapping("/user") public class UserController { /** * 用户登录 * * @param user * @param request * @return */ @RequestMapping("/login") public String login(User user, HttpServletRequest request) { Subject subject = SecurityUtils.getSubject(); UsernamePasswordToken token = new UsernamePasswordToken(user.getUserName(), user.getPassword()); try { subject.login(token); Session session = subject.getSession(); System.out.println("sessionId:" + session.getId()); System.out.println("sessionHost:" + session.getHost()); System.out.println("sessionTimeout:" + session.getTimeout()); session.setAttribute("info", "session的数据"); return "redirect:/success.jsp"; } catch (Exception e) { e.printStackTrace(); request.setAttribute("user", user); request.setAttribute("errorMsg", "用户名或密码错误!"); return "index"; } } } src/main/java/com/andrew/dao/UserDao.java package com.andrew.dao; import java.util.Set; import com.andrew.entity.User; public interface UserDao { /** * 通过用户名查询用户 * * @param userName * @return */ public User getByUserName(String userName); /** * 通过用户名查询角色信息 * * @param userName * @return */ public Set<String> getRoles(String userName); /** * 通过用户名查询权限信息 * * @param userName * @return */ public Set<String> getPermissions(String userName); } src/main/java/com/andrew/entity/User.java package com.andrew.entity; public class User { private Integer id; private String userName; private String password; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } } src/main/java/com/andrew/realm/MyRealm.java package com.andrew.realm; import javax.annotation.Resource; import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationInfo; import org.apache.shiro.authc.AuthenticationToken; import org.apache.shiro.authc.SimpleAuthenticationInfo; import org.apache.shiro.authz.AuthorizationInfo; import org.apache.shiro.authz.SimpleAuthorizationInfo; import org.apache.shiro.realm.AuthorizingRealm; import org.apache.shiro.subject.PrincipalCollection; import com.andrew.entity.User; import com.andrew.service.UserService; public class MyRealm extends AuthorizingRealm { @Resource private UserService userService; /** * 为当限前登录的用户授予角色和权 */ @Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { String userName = (String) principals.getPrimaryPrincipal(); SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo(); authorizationInfo.setRoles(userService.getRoles(userName)); authorizationInfo.setStringPermissions(userService.getPermissions(userName)); return authorizationInfo; } /** * 验证当前登录的用户 */ @Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { String userName = (String) token.getPrincipal(); User user = userService.getByUserName(userName); if (user != null) { AuthenticationInfo authcInfo = new SimpleAuthenticationInfo(user.getUserName(), user.getPassword(), "xx"); return authcInfo; } else { return null; } } } src/main/java/com/andrew/service/UserService.java package com.andrew.service; import java.util.Set; import com.andrew.entity.User; public interface UserService { /** * 通过用户名查询用户 * * @param userName * @return */ public User getByUserName(String userName); /** * 通过用户名查询角色信息 * * @param userName * @return */ public Set<String> getRoles(String userName); /** * 通过用户名查询权限信息 * * @param userName * @return */ public Set<String> getPermissions(String userName); } src/main/java/com/andrew/service/impl/UserServiceImpl.java package com.andrew.service.impl; import java.util.Set; import javax.annotation.Resource; import org.springframework.stereotype.Service; import com.andrew.dao.UserDao; import com.andrew.entity.User; import com.andrew.service.UserService; @Service("userService") public class UserServiceImpl implements UserService { @Resource private UserDao userDao; public User getByUserName(String userName) { return userDao.getByUserName(userName); } public Set<String> getRoles(String userName) { return userDao.getRoles(userName); } public Set<String> getPermissions(String userName) { return userDao.getPermissions(userName); } } src/main/resources/com/andrew/mappers/UserMapper.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.andrew.dao.UserDao"> <resultMap type="User" id="UserResult"> <result property="id" column="id"/> <result property="userName" column="userName"/> <result property="password" column="password"/> </resultMap> <select id="getByUserName" parameterType="String" resultMap="UserResult"> select * from t_user where userName=#{userName} </select> <select id="getRoles" parameterType="String" resultType="String"> select r.roleName from t_user u,t_role r where u.roleId=r.id and u.userName=#{userName} </select> <select id="getPermissions" parameterType="String" resultType="String"> select p.permissionName from t_user u,t_role r,t_permission p where u.roleId=r.id and p.roleId=r.id and u.userName=#{userName} </select> </mapper> src/main/resources/applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd 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.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd"> <!-- 自动扫描 --> <context:component-scan base-package="com.andrew.service" /> <!-- 配置数据源 --> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://localhost:3306/shiro"/> <property name="username" value="root"/> <property name="password" value="root"/> </bean> <!-- 配置mybatis的sqlSessionFactory --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <!-- 自动扫描mappers.xml文件 --> <property name="mapperLocations" value="classpath:com/andrew/mappers/*.xml"></property> <!-- mybatis配置文件 --> <property name="configLocation" value="classpath:mybatis-config.xml"></property> </bean> <!-- DAO接口所在包名,Spring会自动查找其下的类 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.andrew.dao" /> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property> </bean> <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> <!-- 自定义Realm --> <bean id="myRealm" class="com.andrew.realm.MyRealm"/> <!-- 安全管理器 --> <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"> <property name="realm" ref="myRealm"/> </bean> <!-- Shiro过滤器 --> <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"> <!-- Shiro的核心安全接口,这个属性是必须的 --> <property name="securityManager" ref="securityManager"/> <!-- 身份认证失败,则跳转到登录页面的配置 --> <property name="loginUrl" value="/index.jsp"/> <!-- 权限认证失败,则跳转到指定页面 --> <property name="unauthorizedUrl" value="/unauthor.jsp"/> <!-- Shiro连接约束配置,即过滤链的定义 --> <property name="filterChainDefinitions"> <value> /login=anon /admin*=authc /student=roles[teacher] /teacher=perms["user:create"] </value> </property> </bean> <!-- 保证实现了Shiro内部lifecycle函数的bean执行 --> <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/> <!-- 开启Shiro注解 --> <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor"/> <bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor"> <property name="securityManager" ref="securityManager"/> </bean> <!-- 配置事务通知属性 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <!-- 定义事务传播属性 --> <tx:attributes> <tx:method name="insert*" propagation="REQUIRED" /> <tx:method name="update*" propagation="REQUIRED" /> <tx:method name="edit*" propagation="REQUIRED" /> <tx:method name="save*" propagation="REQUIRED" /> <tx:method name="add*" propagation="REQUIRED" /> <tx:method name="new*" propagation="REQUIRED" /> <tx:method name="set*" propagation="REQUIRED" /> <tx:method name="remove*" propagation="REQUIRED" /> <tx:method name="delete*" propagation="REQUIRED" /> <tx:method name="change*" propagation="REQUIRED" /> <tx:method name="check*" propagation="REQUIRED" /> <tx:method name="get*" propagation="REQUIRED" read-only="true" /> <tx:method name="find*" propagation="REQUIRED" read-only="true" /> <tx:method name="load*" propagation="REQUIRED" read-only="true" /> <tx:method name="*" propagation="REQUIRED" read-only="true" /> </tx:attributes> </tx:advice> <!-- 配置事务切面 --> <aop:config> <aop:pointcut id="serviceOperation" expression="execution(* com.andrew.service.*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceOperation" /> </aop:config> </beans> src/main/resources/log4j.properties log4j.rootLogger=DEBUG, Console #Console log4j.appender.Console=org.apache.log4j.ConsoleAppender log4j.appender.Console.layout=org.apache.log4j.PatternLayout log4j.appender.Console.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n log4j.logger.java.sql.ResultSet=INFO log4j.logger.org.apache=INFO log4j.logger.java.sql.Connection=DEBUG log4j.logger.java.sql.Statement=DEBUG log4j.logger.java.sql.PreparedStatement=DEBUG src/main/resources/mybatis-config.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <!-- 别名 --> <typeAliases> <package name="com.andrew.entity"/> </typeAliases> </configuration> src/main/resources/spring-mvc.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd 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.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd"> <!-- 使用注解的包,包括子集 --> <context:component-scan base-package="com.andrew.controller" /> <!-- 视图解析器 --> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/" /> <property name="suffix" value=".jsp"></property> </bean> </beans> src/main/webapp/WEB-INF/web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance http://www.springmodules.org/schema/cache/springmodules-cache.xsd http://www.springmodules.org/schema/cache/springmodules-ehcache.xsd" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>ShiroSpring</display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <!-- shiro过滤器定义 --> <filter> <filter-name>shiroFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> <init-param> <!-- 该值缺省为false,表示生命周期由SpringApplicationContext管理,设置为true则表示由ServletContainer管理 --> <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> <!-- Spring配置文件 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <!-- 编码过滤器 --> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <async-supported>true</async-supported> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- Spring监听器 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 添加对springmvc的支持 --> <servlet> <servlet-name>springMVC</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> <async-supported>true</async-supported> </servlet> <servlet-mapping> <servlet-name>springMVC</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> </web-app> src/main/webapp/index.jsp <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <form action="${pageContext.request.contextPath}/user/login.do" method="post"> userName:<input type="text" name="userName" value="${user.userName}"/><br/> password:<input type="password" name="password" value="${user.password}"><br/> <input type="submit" value="login"/><font color="red">${errorMsg}</font> </form> </body> </html> src/main/webapp/success.jsp <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> ${info} 欢迎你! <shiro:hasRole name="admin"> 欢迎有admin角色的用户!<shiro:principal/> </shiro:hasRole> <shiro:hasPermission name="student:create"> 欢迎有student:create权限的用户!<shiro:principal/> </shiro:hasPermission> </body> </html> http://localhost:8080/ShiroSpring/index.jsp
发表评论
-
Shiro自定义Realm
2019-02-19 09:17 3901. Shiro自定义Realm create mave ... -
Shiro集成web
2019-02-18 09:51 3941. Shiro集成Web配置 <!-- 添加sh ... -
Shiro权限认证(授权)
2019-02-18 09:40 4381. 权限认证核心要素 权限认证,也就是访问控制,即在应 ... -
Shiro身份认证
2019-02-18 09:31 2941. Subject认证主体 Subject认证主体包含 ... -
Shiro简介与示例
2019-02-18 09:23 3201. Shiro简介 Shiro官方主页:http://sh ...
相关推荐
总结,这个"shiro整合spring项目实例"涵盖了Shiro与Spring的整合流程,包括核心组件配置、Realm实现、过滤器链设定、权限管理、Session操作以及测试验证。通过这个实例,开发者能够更好地理解和掌握Shiro在实际项目...
将Shiro 整合到Spring 和 Spring MVC 中,可以实现统一的身份验证和授权管理,简化安全控制逻辑。 1. **Shiro 基本概念**: - **认证(Authentication)**:验证用户身份的过程,即确认用户是谁。 - **授权...
将 Shiro 整合到 Spring 中,可以充分利用 Shiro 的安全特性和 Spring 的灵活性,实现高效、便捷的身份验证和授权管理。 **1. Shiro 基础** Shiro 提供了简单的 API 来处理用户认证和授权。它将安全逻辑与业务逻辑...
在IT行业中,Spring Shiro整合是一项常见的安全框架搭建技术,主要应用于Java Web开发。Spring MVC作为主流的MVC框架,负责处理HTTP请求和业务逻辑,MyBatis则为持久层框架,负责数据库交互,而Apache Shiro则是一个...
Apache Shiro 和 Spring 的整合是Java Web开发中常见的安全框架集成方式,这使得开发者能够利用Shiro的强大安全功能,同时享受Spring的灵活架构优势。在本文中,我们将深入探讨Shiro与Spring整合的关键知识点,包括...
《Shiro与Spring整合实战详解》 在Java Web开发领域,Apache Shiro和Spring框架的结合使用已经成为一种常见的安全解决方案。本示例项目"shiro+Spring的Demo"旨在展示如何将这两个强大的工具集整合,以实现高效、...
在实际开发中,这种整合使得开发者可以充分利用Spring的灵活性和扩展性,同时通过JPA和Hibernate简化数据库操作,而Shiro则提供了全面的安全保障。这样的组合为复杂的企业级应用提供了稳定、高效且易于维护的解决...
手把手教你集成spring cloud + shiro微服务框架;用最少的工作量,改造基于shiro安全框架的微服务项目,实现spring cloud + shiro 框架集成。博客地址:...
在 Spring 框架中整合 Shiro,首先需要在 `pom.xml` 文件中添加 Shiro 的依赖。接着,在 `Web.xml` 中配置 Shiro 过滤器,使用 `DelegatingFilterProxy` 来代理 Shiro 的 Filter,确保 Shiro 能够访问 Spring 容器...
Apache Shiro 和 Spring 的整合是 Java Web 开发中常见的安全框架集成方式,它们结合可以提供强大的权限管理和认证功能。Shiro 是一个轻量级的安全框架,而 Spring 是一个全面的企业级应用开发框架,两者整合能使得...
# Shiro与Spring整合:利用权限注解实现精细化控制 Shiro和Spring的整合是企业级应用中常见的安全框架组合,它们共同构建了一个强大的权限管理解决方案。本文将深入探讨如何在Spring AOP(面向切面编程)环境中集成...
《整合Shiro、Spring与SpringMVC:打造高效安全控制框架》 在现代Java Web开发中,安全性是不可或缺的一部分。Apache Shiro是一个强大且易用的Java安全框架,提供了认证、授权、加密和会话管理功能,使得开发者能够...
Spring Shiro 整合入门教程 ...最后,通过不断实践和学习,你将更深入地理解Spring Shiro整合的细节,从而更好地应用在实际项目中。参考链接中的博客文章会有更具体的步骤和示例代码,帮助你进一步掌握这一技术。
网上很多都是不全的,我看了都没太大用,最后还是自己写个demo,给初学者参考吧,用myeclipse8.6开发的,直接导入项目可用,稍配一下jdk,包括谁和授权,虽然没有跟后台交互,但是是模拟了一下数据库。...
Shiro与Spring Web项目的整合,首先需要在Spring项目中整合Shiro。整合的过程可以分为以下两个关键步骤: #### 1.1 添加Shiro依赖的jar包 为了将Shiro引入Spring项目,需要在项目中添加Shiro的依赖jar包。在项目的...
接下来,我们将深入探讨"shiro + spring + mybatis整合"的相关知识点。 首先,Shiro是Apache的一个开源安全框架,提供了认证、授权、加密和会话管理等功能,为Java应用提供了一站式的安全管理解决方案。在整合Shiro...
在SSO中,Spring可以帮助整合各种组件,如Shiro和Spring Data,同时管理会话状态。 **Spring Data** Spring Data是Spring的一个模块,它简化了数据访问层的开发,支持多种数据存储技术,如JPA、MongoDB、Redis等。...
将Shiro与Spring整合,可以充分利用两者的优点,实现更高效、更灵活的安全管理。 在"shiro与spring整合工程源代码"中,我们可以看到以下几个关键的知识点: 1. **Shiro的核心组件**: - **Authentication(认证)...
Apache Shiro 和 Spring 的整合是企业级应用中常见的安全框架集成方式,这使得开发者能够利用 Shiro 强大的权限管理功能,同时享受 Spring 提供的依赖注入和事务管理等服务。下面将详细介绍这个整合过程中的关键知识...