|
@@ -130,12 +130,14 @@ public class SysLoginController
|
|
|
|| !org.springframework.util.StringUtils.hasText(workSpaceCode)
|
|
|| !org.springframework.util.StringUtils.hasText(workSpaceCode)
|
|
|
|| !StringUtils.hasText(clientId)
|
|
|| !StringUtils.hasText(clientId)
|
|
|
|| timestamp == null) {
|
|
|| timestamp == null) {
|
|
|
|
|
+ log.info("无效的参数");
|
|
|
return AjaxResult.error(HttpStatus.BAD_REQUEST.value(),"无效的参数");
|
|
return AjaxResult.error(HttpStatus.BAD_REQUEST.value(),"无效的参数");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//检查ClientId是否存在
|
|
//检查ClientId是否存在
|
|
|
SysClient client = clientService.selectSysClientById(loginBody.getClientId());
|
|
SysClient client = clientService.selectSysClientById(loginBody.getClientId());
|
|
|
if(client == null) {
|
|
if(client == null) {
|
|
|
|
|
+ log.info("无效的client_id");
|
|
|
return AjaxResult.error(HttpStatus.BAD_REQUEST.value(),"无效的client_id");
|
|
return AjaxResult.error(HttpStatus.BAD_REQUEST.value(),"无效的client_id");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -144,15 +146,18 @@ public class SysLoginController
|
|
|
// Step 3: Check if the difference is greater than 5 minutes
|
|
// Step 3: Check if the difference is greater than 5 minutes
|
|
|
boolean isMoreThanFiveMinutes = btwTime > 5 * 1000 * 60;
|
|
boolean isMoreThanFiveMinutes = btwTime > 5 * 1000 * 60;
|
|
|
if (isMoreThanFiveMinutes) {
|
|
if (isMoreThanFiveMinutes) {
|
|
|
|
|
+ log.info("请求已过期,请重新发起请求");
|
|
|
return AjaxResult.error(HttpStatus.BAD_REQUEST.value(),"请求已过期,请重新发起请求");
|
|
return AjaxResult.error(HttpStatus.BAD_REQUEST.value(),"请求已过期,请重新发起请求");
|
|
|
}
|
|
}
|
|
|
if (sign != null) {
|
|
if (sign != null) {
|
|
|
String dataInput = clientId+timestamp+username+workSpaceId+workSpaceName+workSpaceCode;
|
|
String dataInput = clientId+timestamp+username+workSpaceId+workSpaceName+workSpaceCode;
|
|
|
String generatedHash = DigestUtil.sha256Hex(dataInput.toUpperCase()+client.getClientSecret());
|
|
String generatedHash = DigestUtil.sha256Hex(dataInput.toUpperCase()+client.getClientSecret());
|
|
|
if(!StrUtil.equals(generatedHash, sign)) {
|
|
if(!StrUtil.equals(generatedHash, sign)) {
|
|
|
|
|
+ log.info("签名验证失败");
|
|
|
return AjaxResult.error(HttpStatus.UNAUTHORIZED.value(),"签名验证失败");
|
|
return AjaxResult.error(HttpStatus.UNAUTHORIZED.value(),"签名验证失败");
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ log.info("无效的签名");
|
|
|
return AjaxResult.error(HttpStatus.UNAUTHORIZED.value(),"无效的签名");
|
|
return AjaxResult.error(HttpStatus.UNAUTHORIZED.value(),"无效的签名");
|
|
|
}
|
|
}
|
|
|
Map<String, Object> map = frameLoginService.login(loginBody);
|
|
Map<String, Object> map = frameLoginService.login(loginBody);
|
|
@@ -161,11 +166,44 @@ public class SysLoginController
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
|
|
|
+// FrameLoginBody(
|
|
|
|
|
+// userName=zhangsurong,
|
|
|
|
|
+// workspaceId=12f9e646-9f95-42f6-bb44-a5cdf2019a2c,
|
|
|
|
|
+// workspaceCode=XM0272024000898,
|
|
|
|
|
+// workspaceName=上海国际旅游度假区北片区01-06地块新建项目,
|
|
|
|
|
+// clientId=a34851c530ee0d07d1154beb47bb93dd,
|
|
|
|
|
+// timestamp=1770361996152,
|
|
|
|
|
+// signature=683a7d8dc655612ef9dbd2729e0c081d1ef7226b176b5b43211301e1db8e6c40,
|
|
|
|
|
+// userType=null)
|
|
|
//String dataInput = clientId+timestamp+username+workSpaceId+workSpaceName;
|
|
//String dataInput = clientId+timestamp+username+workSpaceId+workSpaceName;
|
|
|
- String timestamp = String.valueOf(System.currentTimeMillis());
|
|
|
|
|
- System.out.println(timestamp);
|
|
|
|
|
- String dataInput = "a34851c530ee0d07d1154beb47bb93dd" + timestamp + "admin" + "123456" + "测试项目";
|
|
|
|
|
- String generatedHash = DigestUtil.sha256Hex(dataInput.toUpperCase()+"ac0cbba971ab11f089870250f2000002");
|
|
|
|
|
|
|
+ //String timestamp = String.valueOf(System.currentTimeMillis());
|
|
|
|
|
+ //System.out.println(timestamp);
|
|
|
|
|
+
|
|
|
|
|
+// 登录请求参数:FrameLoginBody(userName=zhangsurong,
|
|
|
|
|
+// workspaceId=E227B32E1D8145F09EDE0FC9ECD4E554,
|
|
|
|
|
+// workspaceCode=23206550,
|
|
|
|
|
+// workspaceName=上海建科慧项管培训演示项目,
|
|
|
|
|
+// clientId=f47ac10b58cc4372a5670e06f141669d,
|
|
|
|
|
+// timestamp=1770622624358,
|
|
|
|
|
+// signature=2df17a8d8f665f7f3fb6a85e10a138fbdfab639d492be05f180c1e4b13dca21a,
|
|
|
|
|
+// userType=null)
|
|
|
|
|
+
|
|
|
|
|
+ //https://llm.jkec.info:11432?frame=Y&
|
|
|
|
|
+ // workspace_id=7C3C2B6B4E3A4CB8966285C167A386EB
|
|
|
|
|
+ // &workspace_name=建科咨询系统演示项目
|
|
|
|
|
+ // &username=zhangsurong
|
|
|
|
|
+ // &client_id=f47ac10b58cc4372a5670e06f141669d
|
|
|
|
|
+ // ×tamp=1770624770523
|
|
|
|
|
+ // &signature=5e16184cb489f33d25ebdb61681465b54cf77c1c39bc6af5af3ef8f8ef1635d9
|
|
|
|
|
+ // &workspace_code=28fe7c69
|
|
|
|
|
+ //clientId+timestamp+username+workSpaceId+workSpaceName+workSpaceCode;
|
|
|
|
|
+ String dataInput = "f47ac10b58cc4372a5670e06f141669d"
|
|
|
|
|
+ + "1770624770523"
|
|
|
|
|
+ + "zhangsurong"
|
|
|
|
|
+ + "7C3C2B6B4E3A4CB8966285C167A386EB"
|
|
|
|
|
+ + "建科咨询系统演示项目"
|
|
|
|
|
+ + "28fe7c69";
|
|
|
|
|
+ String generatedHash = DigestUtil.sha256Hex(dataInput.toUpperCase()+"8b26eaba75ea11f083b30250f2000001");
|
|
|
System.out.println(generatedHash);
|
|
System.out.println(generatedHash);
|
|
|
}
|
|
}
|
|
|
|
|
|