|
@@ -1,10 +1,17 @@
|
|
package com.fdkankan.ucenter.service.impl;
|
|
package com.fdkankan.ucenter.service.impl;
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.HexUtil;
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
|
+import cn.hutool.crypto.SecureUtil;
|
|
|
|
+import cn.hutool.crypto.SmUtil;
|
|
|
|
+import cn.hutool.crypto.asymmetric.KeyType;
|
|
|
|
+import cn.hutool.crypto.asymmetric.SM2;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.util.JwtUtil;
|
|
import com.fdkankan.common.util.JwtUtil;
|
|
|
|
+import com.fdkankan.common.util.SecurityUtil;
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
@@ -14,13 +21,18 @@ import com.fdkankan.ucenter.common.constants.ResultCode;
|
|
import com.fdkankan.ucenter.constant.LoginConstant;
|
|
import com.fdkankan.ucenter.constant.LoginConstant;
|
|
import com.fdkankan.ucenter.entity.*;
|
|
import com.fdkankan.ucenter.entity.*;
|
|
import com.fdkankan.ucenter.service.*;
|
|
import com.fdkankan.ucenter.service.*;
|
|
|
|
+import com.fdkankan.ucenter.util.RsaUtils;
|
|
import com.fdkankan.ucenter.vo.response.LaserSceneInfoVo;
|
|
import com.fdkankan.ucenter.vo.response.LaserSceneInfoVo;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
|
+import java.security.KeyPair;
|
|
|
|
+import java.security.PrivateKey;
|
|
|
|
+import java.util.Date;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -214,4 +226,43 @@ public class InnerServiceImpl implements IInnerService {
|
|
}
|
|
}
|
|
return cameraDetailService.getByCameraId(camera.getId());
|
|
return cameraDetailService.getByCameraId(camera.getId());
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Boolean checkSign(String sign) {
|
|
|
|
+ try {
|
|
|
|
+ if(StringUtils.isBlank(sign)){
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ String deTxt = RsaUtils.decipher(sign, RsaUtils.privateKey);
|
|
|
|
+ if(StringUtils.isBlank(deTxt)){
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(deTxt);
|
|
|
|
+ String appId = jsonObject.getString("appId");
|
|
|
|
+ Long timestamp = jsonObject.getLong("timestamp");
|
|
|
|
+ if(StringUtils.isBlank(appId) || timestamp == null){
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ if(!appId.equals("ucenter")){
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ Long time = new Date().getTime();
|
|
|
|
+ if(time -timestamp >1000 * 30){
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ log.info("checkSign-error:{}",sign,e);
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
+ jsonObject.put("appId","ucenter");
|
|
|
|
+ jsonObject.put("timestamp",new Date().getTime());
|
|
|
|
+ System.out.println(jsonObject);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|