刘光辉
15 小时以前 34981c30a78e8bbd7791131059a9210f9928b62c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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() {
    }
}