6069a8a85b5e692b7d036b9ea7dd67bee7f76cbd.svn-base 1.6 KB

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