Spring boot整合shiro框架(2)
form提交
<form th:action="@{/login}" method="POST">
<div class="form-group has-feedback">
<input name="username" type="text" class="form-control"
placeholder="用户账户" required="" value="test"/><span
class="glyphicon glyphicon-envelope form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input name="password" type="password" class="form-control"
placeholder="用户密码" required="" value="test"/><span
class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="row">
<!-- /.col -->
<div class="col-xs-12">
<button class="btn btn-default submit">
<span>登录</span>
</button>
</div>
<!-- /.col -->
</div>
<div id="tips"></div>
</form>
注:input 属性使用name
后台登录验证代码
/**
* 认证信息(身份验证) Authentication 是用来验证用户身份
*/
@Override
protected AuthenticationInfo doGetAuthenticationInfo(
AuthenticationToken token) throws AuthenticationException {
System.out.println("身份认证-->MyShiroRealm.doGetAuthenticationInfo()");
// 获取用户的输入帐号
String username = (String) token.getPrincipal();
System.out.println("token.getCredentials():"+token.getCredentials());
// 通过username从数据库中查找 User对象,如果找到,没找到.
// 实际项目中,这里可以根据实际情况做缓存,
// 如果不做,Shiro自己也是有时间间隔机制,2分钟内不会重复执行该方法
SysRightUser sysRightUser = userInfoService.selectByAccount(username);
if (sysRightUser == null) {
return null;
}
SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(
sysRightUser, // 用户对象
sysRightUser.getPassword(), // 密码
getName() // realm name
);
Session session = SecurityUtils.getSubject().getSession();
session.setAttribute("userInfo",sysRightUser);
return authenticationInfo; }
Spring boot整合shiro框架(2)的更多相关文章
- Spring boot整合shiro框架
ShiroConfiguration package com.energy.common.config; import java.util.LinkedHashMap; import java.uti ...
- Spring Boot 整合 Shiro ,两种方式全总结!
在 Spring Boot 中做权限管理,一般来说,主流的方案是 Spring Security ,但是,仅仅从技术角度来说,也可以使用 Shiro. 今天松哥就来和大家聊聊 Spring Boot ...
- Spring Boot2 系列教程(三十二)Spring Boot 整合 Shiro
在 Spring Boot 中做权限管理,一般来说,主流的方案是 Spring Security ,但是,仅仅从技术角度来说,也可以使用 Shiro. 今天松哥就来和大家聊聊 Spring Boot ...
- 上手spring boot项目(二)之spring boot整合shiro安全框架
题记:在学习了springboot和thymeleaf之后,想完成一个项目练练手,于是使用springboot+mybatis和thymeleaf完成一个博客系统,在完成的过程中出现的一些问题,将这些 ...
- spring boot整合shiro出现UnavailableSecurityManagerException
spring boot自带spring security,spring security自然不用说是一个强大的安全框架,但是用惯了shiro,一时半会用不来spring security,所以要在sp ...
- spring boot整合shiro后,部分注解(Cache缓存、Transaction事务等)失效的问题
版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/elonpage/article/details/78965176 前言 整合有缓存.事务的sprin ...
- Spring Boot 整合 Shiro实现认证及授权管理
Spring Boot Shiro 本示例要内容 基于RBAC,授权.认证 加密.解密 统一异常处理 redis session支持 介绍 Apache Shiro 是一个功能强大且易于使用的Java ...
- spring boot整合mybatis框架及增删改查(jsp视图)
工具:idea.SQLyog 版本:springboot1.5.9版本.mysql5.1.62 第一步:新建项目 第二步:整合依赖(pom.xml) <dependencies> < ...
- Spring Boot整合Dubbo框架demo
Dubbo框架原理见之前的博文:http://www.cnblogs.com/umgsai/p/5836925.html 首先启动zookeeper Server端 Pom配置如下 <?xml ...
随机推荐
- Mycp补交作业
Mycp补交作业 代码 import java.io.; import java.lang.; import java.util.Scanner; public class MyCP { public ...
- 20155229实验三 《Java面向对象程序设计实验三 敏捷开发与XP实践 》实验报告
实验题目 1.在IDEA中使用工具(Code->Reformate Code)把下面代码重新格式化,再研究一下Code菜单,找出一项让自己感觉最好用的功能. 2.下载搭档实验二的Complex代 ...
- 20155306 实验二 Java面向对象程序设计
20155306 实验二 Java面向对象程序设计 实验内容 初步掌握单元测试和TDD 理解并掌握面向对象三要素:封装.继承.多态 初步掌握UML建模 熟悉S.O.L.I.D原则 了解设计模式 实验要 ...
- [agc004D]Teleporter
Description 传送门 Solution 依题意我们可以知道,以2-n为出发点的边和1号节点会构成一课树(不然2-n号节点无法都达到首都). 为了让2-n号节点中,离1号节点的距离<k的 ...
- CF 1083 B. The Fair Nut and Strings
B. The Fair Nut and Strings 题目链接 题意: 在给定的字符串a和字符串b中找到最多k个字符串,使得不同的前缀字符串的数量最多. 分析: 建出trie树,给定的两个字符串就 ...
- java list根据id获取子节点
工作中因业务需求,将数据库中的树状结构的数据根据父节点获取所有的子节点 实现思路 1.获取整个数据的list集合数据 2.将数据分组,java8 list有groupby分组,java8之前的自己遍历 ...
- Python range() 函数用法
函数语法 range(start, stop[, step]) 参数说明: start: 计数从 start 开始.默认是从 0 开始.例如range(5)等价于range(0, 5); stop: ...
- Raft 一致性协议算法 《In search of an Understandable Consensus Algorithm (Extended Version)》
<In search of an Understandable Consensus Algorithm (Extended Version)> Raft是一种用于管理日志复制的一致性算 ...
- jsp 修改页面感受
什么事情只有做过才知道. 最近在负责官网的开发,有一些页面需要和前端商量着修改,但是看到jsp那繁杂的标签和各种css,js混到一起,实在觉得jsp已经是一种落后的技术了,在修改过程中频频出现各种格式 ...
- access数据库频繁读取操作会出现 System.Data.OleDb.OleDbException 的异常解决
asp.net access数据库 本来想着打开一个access数据库连接后,不关闭,下次操作数据了,直接拿来用,谁知道连着测试64次后(大概这么多次),就会出现System.Data.OleDb.O ...