资源简介
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实现登录-注册等功能
相关资源
- SOUGDay_Oracle18cNewSecurity_SOE(Oracle s
- Spring Security架构以及源码详析
- springBoot+security+oauth2 资源和认证分离
- Spring Boot和Spring Security4最新整合
- spring_gateway_security_webflux.rar
- renren-security最新的开发文档
- Hacking Exposed: Mobile Security Secrets & Sol
- HCIP-Security试题03带解析.pdf
- wdsecuritysetup
- CRYPTOGRAPHY AND NETWORK SECURITY PRINCIPLES A
- spring security教程
- Windows Security Monitoring Scenarios and Patt
- Mastering AWS Security Create and maintain a s
- CompTIA Security+ Study Guide Exam SY0-501(7
- 华为HCNA-Security题库
- SIP Security - Wiley 出版的好書!
- SELinux by Example Using Security Enhanced Lin
- H3C se 安全 Security 视频
- SAE_J3061_Cybersecurity Guidebook for Cyber-Ph
- Network Security: Private Communication in a P
- Cryptography and Network Security Principles a
- Hadoop Security Protecting Your Big Data Platf
- SpringBoot+Vue前后端分离,使用SpringSe
- security+安全管理员全息教程
- 网络入侵检测系统的设计与实现PDF版
- Deep_Security__with_NSX_ 部署文档(NSX环境
- Cryptography network security 7th [PDF]
- Security Reference Manual for i.MX
- Cryptography and Network Security Principles a
- 信息安全管理手册Information Security M
评论
共有 条评论