|
@@ -1,16 +1,20 @@
|
|
|
package com.tofly.auth.oauth;
|
|
|
|
|
|
+import com.tofly.auth.util.AESUtil;
|
|
|
import com.tofly.auth.util.RSAUtils;
|
|
|
import com.tofly.common.core.constant.CommonConstants;
|
|
|
import com.tofly.common.core.constant.SecurityConstants;
|
|
|
import com.tofly.common.core.entity.ResultRespone;
|
|
|
import com.tofly.common.core.util.IpUtil;
|
|
|
+import com.tofly.common.core.util.PasswordUtil;
|
|
|
import com.tofly.common.core.util.SpringContextHolder;
|
|
|
import com.tofly.common.core.util.StringUtil;
|
|
|
import com.tofly.common.oauth.auth.ToflyUser;
|
|
|
import com.tofly.entity.pojo.User;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.cache.Cache;
|
|
|
import org.springframework.cache.CacheManager;
|
|
|
import org.springframework.security.authentication.AuthenticationProvider;
|
|
@@ -34,17 +38,23 @@ import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
|
|
|
@Component
|
|
|
-@AllArgsConstructor
|
|
|
@Slf4j
|
|
|
public class ToflyAuthenticationProvider implements AuthenticationProvider {
|
|
|
- private final UserDetailsService userDetailService;
|
|
|
+ @Autowired
|
|
|
+ private UserDetailsService userDetailService;
|
|
|
|
|
|
-
|
|
|
- private final CacheManager cacheManager;
|
|
|
+ @Autowired
|
|
|
+ private CacheManager cacheManager;
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TokenStore tokenStore;
|
|
|
+
|
|
|
+ @Value("${aes.key}")
|
|
|
+ private String key;
|
|
|
+ @Value("${aes.iv}")
|
|
|
+ private String iv;
|
|
|
|
|
|
- private final TokenStore tokenStore;
|
|
|
|
|
|
* 进行身份认证
|
|
|
*
|
|
@@ -81,7 +91,7 @@ public class ToflyAuthenticationProvider implements AuthenticationProvider {
|
|
|
log.info("界面传过来的password:{}",password);
|
|
|
log.info("数据库查询出来的password:{}",userDetails.getPassword());
|
|
|
try {
|
|
|
- password = RSAUtils.priKeyDecryption(password);
|
|
|
+ password = AESUtil.decryptData(password,key,iv);
|
|
|
} catch (Exception exception) {
|
|
|
exception.printStackTrace();
|
|
|
}
|
|
@@ -125,11 +135,11 @@ public class ToflyAuthenticationProvider implements AuthenticationProvider {
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ RedisTokenStore redisTokenStore=(RedisTokenStore)tokenStore;
|
|
|
+ Collection<OAuth2AccessToken> client_id = redisTokenStore.findTokensByClientIdAndUserName((String)((Map) authentication.getDetails()).get("client_id"), authentication.getName());
|
|
|
+ client_id.forEach(oAuth2AccessToken -> {
|
|
|
+ tokenStore.removeAccessToken(oAuth2AccessToken);
|
|
|
+ });
|
|
|
|
|
|
|
|
|
if(pwdt!=0){
|
|
@@ -188,4 +198,18 @@ public class ToflyAuthenticationProvider implements AuthenticationProvider {
|
|
|
super(msg);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|