|
@@ -70,32 +70,39 @@ public class GeoHazardMonitorTokenController {
|
|
|
// 生成令牌
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
LambdaQueryWrapper<SvcAddress> lw = new LambdaQueryWrapper<SvcAddress>();
|
|
|
- if (!ObjectUtils.isEmpty(svcAddress.getGrantType())) {
|
|
|
- lw.eq(SvcAddress::getGrantType, svcAddress.getGrantType());
|
|
|
- }
|
|
|
if (!ObjectUtils.isEmpty(svcAddress.getClientId())) {
|
|
|
lw.eq(SvcAddress::getClientId, svcAddress.getClientId());
|
|
|
+ }else {
|
|
|
+ jsonObject.put("resultCode", 2);
|
|
|
+ jsonObject.put("message", "失败");
|
|
|
+ jsonObject.put("data", "客户端编号不能为空");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), "4370780c9a8c43e5");
|
|
|
}
|
|
|
- if (!ObjectUtils.isEmpty(svcAddress.getClientSecret())) {
|
|
|
- lw.eq(SvcAddress::getClientSecret, svcAddress.getClientSecret());
|
|
|
- }
|
|
|
- List<SvcAddress> list = svcAddressService.list(lw);
|
|
|
- if (list.size() > 0) {
|
|
|
- ArrayList<String> objects = apiTokenUtils.createGeoHazardMonitorToken(svcAddress.getGrantType(), svcAddress.getClientId(), svcAddress.getClientSecret());
|
|
|
- if (objects.size() > 0) {
|
|
|
- RespGeoHazardMonitorVo respGeoHazardMonitorVo = new RespGeoHazardMonitorVo();
|
|
|
- respGeoHazardMonitorVo.setAccessToken(objects.get(1));
|
|
|
- Long l = Long.valueOf(objects.get(0));
|
|
|
- respGeoHazardMonitorVo.setExpiresIn(l / 1000);
|
|
|
- respGeoHazardMonitorVo.setTokenType("令牌类型");
|
|
|
- jsonObject.put("resultCode", 1);
|
|
|
- jsonObject.put("message", "成功");
|
|
|
- jsonObject.put("data", respGeoHazardMonitorVo);
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), "4370780c9a8c43e5");
|
|
|
- } else {
|
|
|
+ SvcAddress serviceOne = svcAddressService.getOne(lw);
|
|
|
+ if (!ObjectUtils.isEmpty(serviceOne)) {
|
|
|
+ String clientSecret = SM4Utils.decryptData_ECB(serviceOne.getClientSecret(), "4370780c9a8c43e5");
|
|
|
+ if (clientSecret.equals(svcAddress.getClientSecret())) {
|
|
|
+ ArrayList<String> objects = apiTokenUtils.createGeoHazardMonitorToken(svcAddress.getGrantType(), svcAddress.getClientId(), svcAddress.getClientSecret());
|
|
|
+ if (objects.size() > 0) {
|
|
|
+ RespGeoHazardMonitorVo respGeoHazardMonitorVo = new RespGeoHazardMonitorVo();
|
|
|
+ respGeoHazardMonitorVo.setAccessToken(objects.get(1));
|
|
|
+ Long l = Long.valueOf(objects.get(0));
|
|
|
+ respGeoHazardMonitorVo.setExpiresIn(l / 1000);
|
|
|
+ respGeoHazardMonitorVo.setTokenType("令牌类型");
|
|
|
+ jsonObject.put("resultCode", 1);
|
|
|
+ jsonObject.put("message", "成功");
|
|
|
+ jsonObject.put("data", respGeoHazardMonitorVo);
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), "4370780c9a8c43e5");
|
|
|
+ } else {
|
|
|
+ jsonObject.put("resultCode", 2);
|
|
|
+ jsonObject.put("message", "失败");
|
|
|
+ jsonObject.put("data", "生成token失败");
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), "4370780c9a8c43e5");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
jsonObject.put("resultCode", 2);
|
|
|
jsonObject.put("message", "失败");
|
|
|
- jsonObject.put("data", "生成token失败");
|
|
|
+ jsonObject.put("data", "客户端密钥错误");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), "4370780c9a8c43e5");
|
|
|
}
|
|
|
} else {
|