提交 | 用户 | age
|
5c5945
|
1 |
package com.qq.weixin.mp.aes; |
E |
2 |
|
|
3 |
@SuppressWarnings("serial") |
|
4 |
public class AesException extends Exception { |
|
5 |
|
|
6 |
public final static int OK = 0; |
|
7 |
public final static int ValidateSignatureError = -40001; |
|
8 |
public final static int ParseXmlError = -40002; |
|
9 |
public final static int ComputeSignatureError = -40003; |
|
10 |
public final static int IllegalAesKey = -40004; |
|
11 |
public final static int ValidateCorpidError = -40005; |
|
12 |
public final static int EncryptAESError = -40006; |
|
13 |
public final static int DecryptAESError = -40007; |
|
14 |
public final static int IllegalBuffer = -40008; |
|
15 |
//public final static int EncodeBase64Error = -40009; |
|
16 |
//public final static int DecodeBase64Error = -40010; |
|
17 |
//public final static int GenReturnXmlError = -40011; |
|
18 |
|
|
19 |
private int code; |
|
20 |
|
|
21 |
private static String getMessage(int code) { |
|
22 |
switch (code) { |
|
23 |
case ValidateSignatureError: |
|
24 |
return "签名验证错误"; |
|
25 |
case ParseXmlError: |
|
26 |
return "xml解析失败"; |
|
27 |
case ComputeSignatureError: |
|
28 |
return "sha加密生成签名失败"; |
|
29 |
case IllegalAesKey: |
|
30 |
return "SymmetricKey非法"; |
|
31 |
case ValidateCorpidError: |
|
32 |
return "corpid校验失败"; |
|
33 |
case EncryptAESError: |
|
34 |
return "aes加密失败"; |
|
35 |
case DecryptAESError: |
|
36 |
return "aes解密失败"; |
|
37 |
case IllegalBuffer: |
|
38 |
return "解密后得到的buffer非法"; |
|
39 |
// case EncodeBase64Error: |
|
40 |
// return "base64加密错误"; |
|
41 |
// case DecodeBase64Error: |
|
42 |
// return "base64解密错误"; |
|
43 |
// case GenReturnXmlError: |
|
44 |
// return "xml生成失败"; |
|
45 |
default: |
|
46 |
return null; // cannot be |
|
47 |
} |
|
48 |
} |
|
49 |
|
|
50 |
public int getCode() { |
|
51 |
return code; |
|
52 |
} |
|
53 |
|
|
54 |
AesException(int code) { |
|
55 |
super(getMessage(code)); |
|
56 |
this.code = code; |
|
57 |
} |
|
58 |
|
|
59 |
} |