|
@@ -0,0 +1,48 @@
|
|
|
+package com.ym.mec.auth.service.impl;
|
|
|
+
|
|
|
+import com.dayaedu.cbs.openfeign.service.CbsQrCodeScanService;
|
|
|
+import com.dayaedu.cbs.openfeign.wrapper.qrcode.CbsQrCodeScanWrapper;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
+import com.ym.mec.auth.core.service.CustomTokenServices;
|
|
|
+import com.ym.mec.common.exception.BizException;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.security.oauth2.common.OAuth2AccessToken;
|
|
|
+import org.springframework.security.oauth2.provider.OAuth2Authentication;
|
|
|
+import org.springframework.security.oauth2.provider.token.ResourceServerTokenServices;
|
|
|
+import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.HashMap;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class CbsQrCodeScanServiceImpl implements CbsQrCodeScanService {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private CustomTokenServices customTokenServices;
|
|
|
+ @Resource
|
|
|
+ private SysUserFeignService sysUserFeignService;
|
|
|
+ @Resource
|
|
|
+ private RedisTokenStore redisTokenStore;
|
|
|
+ @Resource
|
|
|
+ private ObjectMapper objectMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CbsQrCodeScanWrapper.UserInfo userInfo(CbsQrCodeScanWrapper.QrCodeScanUserInfoReq req) {
|
|
|
+ CbsQrCodeScanWrapper.UserInfo userInfo = new CbsQrCodeScanWrapper.UserInfo();
|
|
|
+ userInfo.setUsername(customTokenServices.loadAuthentication(req.getToken()).getName());
|
|
|
+ return userInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CbsQrCodeScanWrapper.QrCodeScanToken login(CbsQrCodeScanWrapper.QrCodeScanReq req) {
|
|
|
+ OAuth2AccessToken oAuth2AccessToken = redisTokenStore.readAccessToken(req.getPassword());
|
|
|
+ if (oAuth2AccessToken != null) {
|
|
|
+ OAuth2Authentication authentication = redisTokenStore.readAuthentication(req.getPassword());
|
|
|
+ HashMap<String,String> hashMap = objectMapper.convertValue(authentication.getDetails(), HashMap.class);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+}
|