|
@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import me.zhengjie.annotation.Log;
|
|
import me.zhengjie.annotation.Log;
|
|
import me.zhengjie.annotation.rest.AnonymousGetMapping;
|
|
import me.zhengjie.annotation.rest.AnonymousGetMapping;
|
|
import me.zhengjie.annotation.rest.AnonymousPostMapping;
|
|
import me.zhengjie.annotation.rest.AnonymousPostMapping;
|
|
@@ -50,6 +51,7 @@ import java.io.IOException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
|
|
+@Slf4j
|
|
@RestController
|
|
@RestController
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
@Api(tags = "用户接口")
|
|
@Api(tags = "用户接口")
|
|
@@ -142,7 +144,7 @@ public class UserApiController {
|
|
@Log("单点登录")
|
|
@Log("单点登录")
|
|
@ApiOperation("单点登录")
|
|
@ApiOperation("单点登录")
|
|
@AnonymousGetMapping(value = "/sso11")
|
|
@AnonymousGetMapping(value = "/sso11")
|
|
- public BaseResponse<Object> sso11(String token) {
|
|
|
|
|
|
+ public BaseResponse<Object> sso11(String token) throws Exception {
|
|
Map<String,Object> newToken = SecurityUtils.getToken(key);
|
|
Map<String,Object> newToken = SecurityUtils.getToken(key);
|
|
UserDto userDto = userService.findByName("chaoshengqin");
|
|
UserDto userDto = userService.findByName("chaoshengqin");
|
|
//组装返回值
|
|
//组装返回值
|
|
@@ -150,6 +152,9 @@ public class UserApiController {
|
|
returnData.put("nonce",newToken.get("nonce"));
|
|
returnData.put("nonce",newToken.get("nonce"));
|
|
returnData.put("timestamp",newToken.get("timestamp"));
|
|
returnData.put("timestamp",newToken.get("timestamp"));
|
|
returnData.put("token",newToken.get("token"));
|
|
returnData.put("token",newToken.get("token"));
|
|
|
|
+ returnData.put("userId",userDto.getId());
|
|
|
|
+ String cipher = EncryptUtils.desEncrypt(returnData.toJSONString());
|
|
|
|
+ returnData.put("cipher", cipher);
|
|
returnData.put("user", userDto);
|
|
returnData.put("user", userDto);
|
|
Map<String, Object> authInfo = new HashMap<String, Object>(1) {{
|
|
Map<String, Object> authInfo = new HashMap<String, Object>(1) {{
|
|
put("data", returnData);
|
|
put("data", returnData);
|
|
@@ -160,7 +165,7 @@ public class UserApiController {
|
|
@Log("单点登录")
|
|
@Log("单点登录")
|
|
@ApiOperation("单点登录")
|
|
@ApiOperation("单点登录")
|
|
@AnonymousGetMapping(value = "/sso")
|
|
@AnonymousGetMapping(value = "/sso")
|
|
- public BaseResponse<Object> sso(String token) {
|
|
|
|
|
|
+ public BaseResponse<Object> sso(String token) throws Exception {
|
|
if (StringUtils.isBlank(token)) {
|
|
if (StringUtils.isBlank(token)) {
|
|
throw new BadRequestException("参数错误");
|
|
throw new BadRequestException("参数错误");
|
|
}
|
|
}
|
|
@@ -177,6 +182,9 @@ public class UserApiController {
|
|
returnData.put("nonce",newToken.get("nonce"));
|
|
returnData.put("nonce",newToken.get("nonce"));
|
|
returnData.put("timestamp",newToken.get("timestamp"));
|
|
returnData.put("timestamp",newToken.get("timestamp"));
|
|
returnData.put("token",newToken.get("token"));
|
|
returnData.put("token",newToken.get("token"));
|
|
|
|
+ returnData.put("userId",userDto.getId());
|
|
|
|
+ String cipher = EncryptUtils.desEncrypt(returnData.toJSONString());
|
|
|
|
+ returnData.put("cipher", cipher);
|
|
returnData.put("user", userDto);
|
|
returnData.put("user", userDto);
|
|
Map<String, Object> authInfo = new HashMap<String, Object>(1) {{
|
|
Map<String, Object> authInfo = new HashMap<String, Object>(1) {{
|
|
put("data", returnData);
|
|
put("data", returnData);
|
|
@@ -198,6 +206,34 @@ public class UserApiController {
|
|
return new BaseResponse<>(list);
|
|
return new BaseResponse<>(list);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Log("根据密文获取用户信息")
|
|
|
|
+ @ApiOperation("根据密文获取用户信息")
|
|
|
|
+ @AnonymousGetMapping(value = "/getZkUserByCipher")
|
|
|
|
+ public BaseResponse<Object> getZkUserByCipher(String cipher) throws Exception {
|
|
|
|
+ String dataStr = EncryptUtils.desDecrypt(cipher);
|
|
|
|
+ JSONObject data = JSONObject.parseObject(dataStr);
|
|
|
|
+ String token = data.getString("token");
|
|
|
|
+ log.info("token:"+token);
|
|
|
|
+ String timestamp = data.getString("timestamp");
|
|
|
|
+ log.info("timestamp:"+timestamp);
|
|
|
|
+ String nonce = data.getString("nonce");
|
|
|
|
+ log.info("nonce:"+nonce);
|
|
|
|
+ String userId = data.getString("userId");
|
|
|
|
+ log.info("userId:"+userId);
|
|
|
|
+ String[] arr = {"DMERPYT!@#$QWER2021+{:>", timestamp,nonce};
|
|
|
|
+ Arrays.sort(arr);
|
|
|
|
+ String str = "";
|
|
|
|
+ for (int i = 0; i < arr.length; i++) {
|
|
|
|
+ str += arr[i];
|
|
|
|
+ }
|
|
|
|
+ String newtoken = EncryptUtils.sha1(str);
|
|
|
|
+ if (!token.equals(newtoken)) {
|
|
|
|
+ throw new BadRequestException(HttpStatus.UNAUTHORIZED, "认证失败");
|
|
|
|
+ }
|
|
|
|
+ DmUserDto dmUser = dmUserService.findById(userId);
|
|
|
|
+ return new BaseResponse<>(dmUser);
|
|
|
|
+ }
|
|
|
|
+
|
|
@Log("获取部门数据")
|
|
@Log("获取部门数据")
|
|
@ApiOperation("获取部门数据")
|
|
@ApiOperation("获取部门数据")
|
|
@AnonymousPostMapping(value = "/getzkdeps")
|
|
@AnonymousPostMapping(value = "/getzkdeps")
|