|
@@ -215,6 +215,42 @@ public class UserApiController {
|
|
|
throw new BadRequestException("认证失败");
|
|
|
}
|
|
|
|
|
|
+ @Log("单点登录")
|
|
|
+ @ApiOperation("单点登录")
|
|
|
+ @AnonymousGetMapping(value = "/sso22")
|
|
|
+ public BaseResponse<Object> sso22(String token) throws Exception {
|
|
|
+ if (StringUtils.isBlank(token)) {
|
|
|
+ throw new BadRequestException("参数错误");
|
|
|
+ }
|
|
|
+ String res = HttpRequest.get("https://imtest1.caih.com/api-third-party/busi/comm/authLogin/api/verifyToken?token=" + token).method(Method.POST).execute().body();
|
|
|
+ System.out.println("res:"+res);
|
|
|
+ JSONObject json = JSONObject.parseObject(res);
|
|
|
+ if (json != null) {
|
|
|
+ JSONObject data = json.getJSONObject("data");
|
|
|
+ if (data != null) {
|
|
|
+ UserDto userDto = userService.findByName(data.getString("username"));
|
|
|
+ if (userDto != null) {
|
|
|
+ Map<String,Object> newToken = SecurityUtils.getToken(key);
|
|
|
+ //组装返回值
|
|
|
+ JSONObject returnData = new JSONObject();
|
|
|
+ returnData.put("nonce",newToken.get("nonce"));
|
|
|
+ returnData.put("timestamp",newToken.get("timestamp"));
|
|
|
+ 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);
|
|
|
+ Map<String, Object> authInfo = new HashMap<String, Object>(1) {{
|
|
|
+ put("data", returnData);
|
|
|
+ }};
|
|
|
+ System.out.println("returnData:"+returnData.toJSONString());
|
|
|
+ return new BaseResponse<>(authInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ throw new BadRequestException("认证失败");
|
|
|
+ }
|
|
|
+
|
|
|
@Log("app登录")
|
|
|
@ApiOperation("app登录")
|
|
|
@AnonymousGetMapping(value = "/appLogin")
|