package jnpf.audit;
|
|
/** 由后端签发的 biz_sign 派生稳定的审计操作分组键。 */
|
public final class AuditOperationIds {
|
|
private static final String PREFIX = "BS-";
|
private static final int MAX_SIGN_LENGTH = 40;
|
|
public static String correlation(String bizSign) {
|
String normalized = normalize(bizSign);
|
return normalized == null ? null : PREFIX + normalized;
|
}
|
|
private static String normalize(String bizSign) {
|
if (bizSign == null) {
|
return null;
|
}
|
String value = bizSign.trim();
|
if (value.isEmpty() || value.length() > MAX_SIGN_LENGTH) {
|
return null;
|
}
|
for (int i = 0; i < value.length(); i++) {
|
char ch = value.charAt(i);
|
boolean asciiLetter = (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z');
|
if (!asciiLetter && (ch < '0' || ch > '9') && ch != '-' && ch != '_') {
|
return null;
|
}
|
}
|
return value;
|
}
|
|
private AuditOperationIds() {
|
}
|
}
|