Spring Security-用户密码自定义加密
public class SunPasswordEncoder implements PasswordEncoder{
//@实现加密的方法,既将明文转换为密文的方法
public String encodePassword(String rawPass, Object salt)
throws DataAccessException {
String pass = null;
try {
pass = Tools.encryptBasedDes(rawPass);
} catch (Exception e) {
e.printStackTrace();
}
return pass;
}
//@验证密码是否有效的方法,返回'true'则登录成功
public boolean isPasswordValid(String encPass, String rawPass, Object salt)
throws DataAccessException {
String pass1 = "" + encPass;
String pass2 = encodePassword(rawPass, salt);
return pass1.equals(pass2);
}
<bean id="myEncoder" class="com.xxx.common.SunPasswordEncoder" />
<!-- 后台管理权限认证 -->
<sec:authentication-provider user-service-ref="xxxxxxServiceImpl">
<!-- sec:password-encoder hash="md5" / -->
<sec:password-encoder ref="myEncoder" />
</sec:authentication-provider>
加密方式:http://blog.csdn.net/s445320/article/details/9897189
Spring Security-用户密码自定义加密的更多相关文章
- node.js中用户密码的加密
crypro实现用户密码的加密 在实际的项目中,只要涉及到用户的信息,就是十分重要的.设想一下数据库里面存放的用户的密码是明文的形式,后果是有多严重.所以今天给大家分享一下express中怎样实现用户 ...
- spring security 授权方式(自定义)及源码跟踪
spring security 授权方式(自定义)及源码跟踪 这节我们来看看spring security的几种授权方式,及简要的源码跟踪.在初步接触spring security时,为了实现它的 ...
- 255.Spring Boot+Spring Security:使用md5加密
说明 (1)JDK版本:1.8 (2)Spring Boot 2.0.6 (3)Spring Security 5.0.9 (4)Spring Data JPA 2.0.11.RELEASE (5)h ...
- spring security采用基于简单加密 token 的方法实现的remember me功能
记住我功能,相信大家在一些网站已经用过,一些安全要求不高的都可以使用这个功能,方便快捷. spring security针对该功能有两种实现方式,一种是简单的使用加密来保证基于 cookie 的 to ...
- spring security +MySQL + BCryptPasswordEncoder 单向加密验证 + 权限拦截 --- 心得
1.前言 前面学习了 security的登录与登出 , 但是用户信息 是 application 配置 或内存直接注入进去的 ,不具有实用性,实际上的使用还需要权限管理,有些 访问接口需要某些权限才可 ...
- Spring Security笔记:自定义Login/Logout Filter、AuthenticationProvider、AuthenticationToken
在前面的学习中,配置文件中的<http>...</http>都是采用的auto-config="true"这种自动配置模式,根据Spring Securit ...
- spring security方法一 自定义数据库表结构
Spring Security默认提供的表结构太过简单了,其实就算默认提供的表结构很复杂,也无法满足所有企业内部对用户信息和权限信息管理的要求.基本上每个企业内部都有一套自己的用户信息管理结构,同时也 ...
- Spring Security 入门(3-11)Spring Security 的使用-自定义登录验证和回调地址
配置文件 security-ns.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmln ...
- 获取spring security用户相关信息
在JSP中获得 使用spring security的标签库 在页面中引入标签 <%@ taglib prefix="sec" uri="http://www.spr ...
随机推荐
- 完全删除Postgresql
First: If your install isn't already damaged, you can drop unwanted PostgreSQL servers ("cluste ...
- 关于设置CFileDialog的默认路径
CFileDialog d_File(FRUE, NULL,NULL,NULL,szFilter,FromHandle(m_hWnd)); // 如果写了下面这句那么每次打开都是这个设置的默认路径 ...
- javaWEB总结(11):JSP简介及原理
前言 本文主要通过一个简单小例子,介绍JSP的原理. 1.项目结构 2.web.xml <?xml version="1.0" encoding="UTF-8&qu ...
- Google Dremel 原理 - 如何能3秒分析1PB
简介 Dremel 是Google 的“交互式”数据分析系统.可以组建成规模上千的集群,处理PB级别的数据.MapReduce处理一个数据,需要分钟级的时间.作为MapReduce的发起人,Googl ...
- mongodb部署单节点(一)
部署包:mongodb-linux-x86_64-rhel55-3.0.2.tgz(百度云盘下载地址:http://pan.baidu.com/s/1jIQAGlw 密码:l7pf) 第一步:上传该文 ...
- Apache httpd.conf配置详解
常用配置指令说明 1. ServerRoot:服务器的基础目录,一般来说它将包含conf/和logs/子目录,其它配置文件的相对路径即基于此目录.默认为安装目录,不需更改. 语法:ServerRoot ...
- FZU 1893 内存管理 模拟
比赛的时候队友要做这道题…… 他没做出来自己也被误导了…… 也算是个教训 自己还是要有自己的思路…… 又是模拟题…… 网上都是用vector做的 我最近才会stl 怎么会用那么高大上的的东西…… 强力 ...
- C# 验证码生成(MVC和非MVC两种方式)
/// <summary> /// 生成验证码 /// </summary> /// <param name="length">指定验证码的长度 ...
- 2015 ACM/ICPC Asia Regional Hefei Online
1001 Monitor the Alpacas 1002 The Relationship in Club 1003 Difference of Clustering 两边离散化.暴力扫C就过了. ...
- ural 1261. Tips(进制运算)
1261. Tips Time limit: 1.0 secondMemory limit: 64 MB The favorite resting place of the Ural programm ...