|
@@ -1,9 +1,17 @@
|
|
|
package com.boman.web.core.utils;
|
|
|
|
|
|
|
|
|
+import cn.hutool.extra.spring.SpringUtil;
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.boman.common.core.utils.StringUtils;
|
|
|
import com.boman.common.redis.service.RedisService;
|
|
|
+import org.springframework.beans.BeansException;
|
|
|
+import org.springframework.context.ApplicationContext;
|
|
|
+import org.springframework.context.ApplicationContextAware;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import javax.annotation.PostConstruct;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
/**
|
|
@@ -11,10 +19,22 @@ import java.util.concurrent.TimeUnit;
|
|
|
* @author 86150
|
|
|
*
|
|
|
*/
|
|
|
+@Component
|
|
|
public class GjzwfwptSignUtil {
|
|
|
|
|
|
@Resource
|
|
|
- static RedisService redisService;
|
|
|
+ private RedisService redisService;
|
|
|
+
|
|
|
+ private static GjzwfwptSignUtil gjzwfwptSignUtil;
|
|
|
+
|
|
|
+ @PostConstruct
|
|
|
+ public void init(){
|
|
|
+ gjzwfwptSignUtil= this;
|
|
|
+ gjzwfwptSignUtil.redisService = this.redisService;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 获取签名
|
|
|
* 1、sid+rid+rtime+appkey 加密生成gjzwfwpt_sign
|
|
@@ -29,8 +49,8 @@ public class GjzwfwptSignUtil {
|
|
|
public static String getGjzwfwptSign(String sid, String rid,
|
|
|
String appkey) {
|
|
|
|
|
|
- String gjzwfwpt_sign = redisService.getCacheObject(appkey + ":gjzwfwpt_sign");
|
|
|
- if (null == gjzwfwpt_sign) {
|
|
|
+ String gjzwfwpt_sign = gjzwfwptSignUtil.redisService.getCacheObject(appkey + ":gjzwfwpt_sign");
|
|
|
+ if (StringUtils.isEmpty(gjzwfwpt_sign)) {
|
|
|
// 1、sid+rid+rtime+appkey 加密生成gjzwfwpt_sign
|
|
|
Long rtime = System.currentTimeMillis();
|
|
|
String content = sid + rid + rtime; // 内容拼接
|
|
@@ -60,8 +80,8 @@ public class GjzwfwptSignUtil {
|
|
|
gjzwfwpt_sign = AESUtil.sign(content, appsecret);
|
|
|
}
|
|
|
// Tips:gjzwfwpt_sign有效期10分钟
|
|
|
- redisService.setCacheObject(appkey + ":gjzwfwpt_sign",gjzwfwpt_sign, 600L, TimeUnit.SECONDS );
|
|
|
- redisService.setCacheObject(appkey + ":gjzwfwpt_rtime",rtime.toString(), 600L, TimeUnit.SECONDS);
|
|
|
+ gjzwfwptSignUtil.redisService.setCacheObject(appkey + ":gjzwfwpt_sign",gjzwfwpt_sign, 600L, TimeUnit.SECONDS );
|
|
|
+ gjzwfwptSignUtil.redisService.setCacheObject(appkey + ":gjzwfwpt_rtime",rtime.toString(), 600L, TimeUnit.SECONDS);
|
|
|
System.out.println("最终签名"+gjzwfwpt_sign);
|
|
|
return gjzwfwpt_sign;
|
|
|
} else {
|
|
@@ -75,8 +95,10 @@ public class GjzwfwptSignUtil {
|
|
|
}
|
|
|
|
|
|
public static String getGjzwfwptRtime(String appkey) {
|
|
|
- String gjzwfwpt_rtime = redisService.getCacheObject(appkey + ":gjzwfwpt_rtime");
|
|
|
+ String gjzwfwpt_rtime = gjzwfwptSignUtil.redisService.getCacheObject(appkey + ":gjzwfwpt_rtime");
|
|
|
System.out.println(gjzwfwpt_rtime);
|
|
|
return gjzwfwpt_rtime;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|