gitee-webhook 部署测试
This commit is contained in:
parent
2c7a88f900
commit
84348d3ee8
|
@ -1,5 +1,7 @@
|
|||
package com.dite.znpt.web.build;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.net.URLEncoder;
|
||||
|
@ -7,6 +9,7 @@ import java.nio.charset.StandardCharsets;
|
|||
import java.time.Instant;
|
||||
import java.util.Base64;
|
||||
|
||||
@Slf4j
|
||||
public class GiteeSignatureVerifier {
|
||||
|
||||
private static final long MAX_TIME_DIFF = 3600 * 1000; // 1小时(毫秒)
|
||||
|
@ -17,7 +20,7 @@ public class GiteeSignatureVerifier {
|
|||
String secret) {
|
||||
// 1. 验证时间有效性(避免重放攻击)
|
||||
if (!validateTimestamp(receivedTimestamp)) {
|
||||
System.out.println("时间戳超出允许范围");
|
||||
log.debug("时间戳超出允许范围");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -38,7 +41,7 @@ public class GiteeSignatureVerifier {
|
|||
long currentTime = Instant.now().toEpochMilli();
|
||||
return Math.abs(currentTime - timestamp) < MAX_TIME_DIFF;
|
||||
} catch (NumberFormatException e) {
|
||||
System.err.println("无效的时间戳格式: " + timestampStr);
|
||||
log.debug("无效的时间戳格式: {}", timestampStr);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue