| | |
| | | package com.panzhihua.auth.handel; |
| | | |
| | | import java.security.InvalidKeyException; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.crypto.BadPaddingException; |
| | | import javax.crypto.IllegalBlockSizeException; |
| | | import javax.crypto.NoSuchPaddingException; |
| | | |
| | | import com.panzhihua.auth.config.MyAESUtil; |
| | | import com.panzhihua.common.model.helper.AESUtil; |
| | | import com.panzhihua.common.utlis.AES; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.security.authentication.AuthenticationProvider; |
| | | import org.springframework.security.authentication.BadCredentialsException; |
| | | import org.springframework.security.authentication.LockedException; |
| | |
| | | public class UserAuthenticationProvider implements AuthenticationProvider { |
| | | @Resource |
| | | private UserService userService; |
| | | @Resource |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | @Override |
| | | public Authentication authenticate(Authentication authentication) throws AuthenticationException { |
| | | // 获取表单输入中返回的用户名 |
| | | String userName = (String)authentication.getPrincipal(); |
| | | // 获取表单中输入的密码 |
| | | String password = (String)authentication.getCredentials(); |
| | | String password =(String)authentication.getCredentials(); |
| | | try { |
| | | password = MyAESUtil.Decrypt((String)authentication.getCredentials(),"Ryo7M3n8loC5Abcd"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | // 查询用户是否存在 |
| | | R<LoginUserInfoVO> r = userService.getUserInfo(userName); |
| | | if (r.getCode() != 200) { |