gitee-webhook 部署测试

This commit is contained in:
cuizhibin 2025-06-25 13:25:27 +08:00
parent 2c7a88f900
commit 84348d3ee8
1 changed files with 5 additions and 2 deletions

View File

@ -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;
}
}