You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
857 B
27 lines
857 B
3 years ago
|
package com.fr.plugin;
|
||
|
|
||
|
import com.fr.third.springframework.util.DigestUtils;
|
||
|
import com.fr.third.springframework.util.StringUtils;
|
||
|
|
||
|
import java.nio.charset.StandardCharsets;
|
||
|
|
||
|
public class SafeCheckUtils {
|
||
|
public static boolean checkSafe(String body, String appId, String time, String key) {
|
||
|
ZtgtConfig ztgtConfig = ZtgtConfig.getInstance();
|
||
|
String tmp = body + time + appId + ztgtConfig.getSynKey();
|
||
|
String md5 = DigestUtils.md5DigestAsHex(tmp.getBytes(StandardCharsets.UTF_8));
|
||
|
if (StringUtils.endsWithIgnoreCase(md5, key)) {
|
||
|
long d = Long.parseLong(time);
|
||
|
long left = System.currentTimeMillis() + 30000;
|
||
|
long right = System.currentTimeMillis() - 30000;
|
||
|
if (d <= left && d >= right) {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|