91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 5KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-17
  • 語言: 其他
  • 標簽: security??

資源簡介

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?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

評論

共有 條評論