资源简介
SpringBoot之整合Spring Security,SpringBoot之整合Spring SecuritySpringBoot之整合Spring SecuritySpringBoot之整合Spring Security
代码片段和文件信息
package com.yangle.security;
import com.yangle.util.GuavaDataCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.stereotype.Component;
import java.util.Collection;
/**
* Created by yangle on 2017/10/9.
*/
@Component
public class CustAuthenticationProvider implements AuthenticationProvider {
@Autowired
private SnailUserDetailsService userService;
@Autowired
private GuavaDataCache guavaDataCache;
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
String username = authentication.getName();
String password = (String) authentication.getCredentials();
CustUserDetails userDetials = (CustUserDetails) userService.loadUserByUsername(username);
CustomWebAuthenticationDetails details = (CustomWebAuthenticationDetails) authentication.getDetails();
String code=details.getCode();
String kapacode=details.getKapacode();
String value=guavaDataCache.getPropertyValue(“randcode““on“);
if(value.equals(“on“)){
if(!kapacode.equals(code)){
throw new BadCredentialsException(“验证码不正确“);
}
}
if(userDetials == null){
throw new BadCredentialsException(“没有这个用户.“);
}
//加密过程在这里体现
if (!password.equals(userDetials.getPassword())) {
throw new BadCredentialsException(“密码错误“);
}
Collection extends GrantedAuthority> authorities = userDetials.getAuthorities();
return new UsernamePasswordAuthenticationToken(userDetials password authorities);
}
@Override
public boolean supports(Class> arg0) {
return true;
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-05-08 16:17 security\
文件 2265 2018-01-11 15:04 security\CustAuthenticationProvider.java
文件 688 2018-05-08 15:11 security\CustomAuthenticationDetailsSource.java
文件 1123 2018-05-08 15:11 security\CustomWebAuthenticationDetails.java
文件 2033 2018-01-03 20:46 security\CustUserDetails.java
文件 1015 2018-01-11 10:44 security\SnailUserDetailsService.java
文件 2712 2018-01-13 15:57 security\WebSecurityConfig.java
- 上一篇:STM8Rs485通信历程
- 下一篇:Django实现登录-注册等功能
相关资源
- Spring Security技术栈开发企业级认证与
- springsecurity实战教学视频.txt
- SpringSecurity 之自定义用户权限信息的
- 禁用Security Centerwscsvc服务
- 华为HCIP认证,2020年10月27日最新题库
- security.js 实现前台加密
- Lora 安全白皮书
- HCIE-Security视频教程全套安全课程视频
- SpringSecurity开发安全的REST服务.txt
- Spring Security 3.1.0 官方文档中文.chm
- ccan_Security.rar
- spring-security-oauth2详细配置demo
- SpringSecurity开发企业级认证与授权全套
- ISO_SAE 21434 DIS版本 _ 信息安全设计要求
- 英文原版-Practical Information Security Ma
- Elcomsoft Wireless Security Auditor 最新版+注
- SpringSecurity_day04.pdf
- Spring Boot视频教程大合集,完美帮助你
- 英文原版-SSCP ISC2 Systems Security Certif
- springmvc4.1.1集成spring-security3.2.10
- cryptography network security 7th pdf
- spring-security-samples-tutorial-3.0.2.RELEASE
- SpringBoot+SpringSecurity+WebSocket
- security-sm2-sm3.zip
- spring boot+mybatis+shiro+spring security权限管
- activiti-springboot.zip
- springMVC注解+ security + redis
- Microsoft.Samples.ReportingServices.AnonymousS
- 网络安全原理与实践Network.Security.Pr
- HCNA-SecurityHC-711-CHS最新题库
评论
共有 条评论