1 package cn.home1.oss.lib.common.crypto;
2
3 import lombok.Getter;
4
5 @SuppressWarnings("serial")
6 public class AesException extends RuntimeException {
7
8 @Getter
9 private final AesError aesError;
10
11 AesException(final AesError aesError) {
12 super(aesError.getMessage());
13 this.aesError = aesError;
14 }
15
16 AesException(final AesError aesError, final Throwable cause) {
17 super(aesError.getMessage(), cause);
18 this.aesError = aesError;
19 }
20
21
22
23
24
25
26 @SuppressWarnings("PMD.SingularField")
27 @Getter
28 public enum AesError {
29
30 OK(0, ""),
31 VALIDATE_SIGNATURE_ERROR(-40001, "签名验证错误"),
32 PARSE_XML_ERROR(-40002, "XML解析失败"),
33 COMPUTE_SIGNATURE_ERROR(-40003, "SHA加密生成签名失败"),
34 ILLEGAL_AES_KEY(-40004, "SymmetricKey非法"),
35 VALIDATE_CORP_ID_ERROR(-40005, "corpid校验失败"),
36 ENCRYPT_AES_ERROR(-40006, "AES加密失败"),
37 DECRYPT_AES_ERROR(-40007, "AES解密失败"),
38 ILLEGAL_BUFFER(-40008, "解密后得到的buffer非法");
39
40 private final int code;
41 private final String message;
42
43 AesError(final int code, final String message) {
44 this.code = code;
45 this.message = message;
46 }
47 }
48 }