001/* 002 * =========================================================================================== 003 * = COPYRIGHT 004 * PAX Computer Technology (Shenzhen) Co., Ltd. PROPRIETARY INFORMATION 005 * This software is supplied under the terms of a license agreement or nondisclosure 006 * agreement with PAX Computer Technology (Shenzhen) Co., Ltd. and may not be copied or 007 * disclosed except in accordance with the terms in that agreement. 008 * Copyright (C) 2017-2023 PAX Computer Technology (Shenzhen) Co., Ltd. All rights reserved. 009 * Description: // Detail description about the function of this module, 010 * // interfaces with the other modules, and dependencies. 011 * Revision History: 012 * Date Author Action 013 * 2017/04/01 PAX Create/Add/Modify/Delete 014 * =========================================================================================== 015 */ 016package com.pax.dal.exceptions; 017 018import com.pax.dal.utils.Utils; 019 020/** 021 * <div class="zh">P2PE异常类。</div> 022 * <div class="en">P2PE exception.</div> 023 */ 024public enum EP2PEException { 025 /** 026 * <div class="zh"> 未知异常 </div> <div class="en"> unexpected error </div> 027 */ 028 DEVICES_ERR_UNEXPECTED(97, "未知异常", "unexpected error"), 029 030 /** 031 * <div class="zh"> 参数错误 </div> <div class="en"> invalid argument error </div> 032 */ 033 DEVICES_ERR_INVALID_ARGUMENT(98, "参数错误", "invalid argument error"), 034 /** 035 * <div class="zh"> RPC I/O 连接异常 </div> <div class="en"> connect error </div> 036 */ 037 DEVICES_ERR_CONNECT(99, "RPC I/O 连接异常", "connect error"), 038 /** 039 * <div class="zh"> 不支持 </div> <div class="en"> not support error </div> 040 */ 041 DEVICES_ERR_NO_SUPPORT(100, "不支持", "not support error"), 042 /** 043 * <div class="zh"> 无权限异常</div> <div class="en"> no permission error </div> 044 */ 045 DEVICES_ERR_NO_PERMISSION(101,"no permission error","无权限异常"), 046 /** 047 * <div class="zh"> RPC忙 </div> <div class="en"> Rpc busy </div> 048 */ 049 RPC_BUSY(102, "RPC忙", "Rpc busy"), 050 051 /** 052 * <div class="zh"> 无效的加密数据长度 </div> <div class="en"> Invalid clear data length </div> 053 */ 054 P2PE_TA_ERR_INVALID_CARD_DATA_LEN(-1023, "无效的加密数据长度", "Invalid clear data length"), 055 056 /** 057 * <div class="zh"> 无效的X509公钥 </div> <div class="en"> Invalid X509 public key </div> 058 */ 059 P2PE_TA_ERR_INVALID_PUB_KEY(-1024, "无效的X509公钥", "Invalid X509 public key"), 060 061 /** 062 * <div class="zh"> 缓冲区太小 </div> <div class="en"> Buffer is too small </div> 063 */ 064 P2PE_VP_ERR_BUFFER_TOO_SMALL(-1008, "缓冲区太小", "Buffer is too small"), 065 066 /** 067 * <div class="zh"> 文件认证失败 </div> <div class="en"> File authentication failed </div> 068 */ 069 P2PE_VP_ERR_FILE_AUTHENTICATE_FAIL(-1015, "文件认证失败", "File authentication failed"), 070 071 /** 072 * <div class="zh"> 文件不存在 </div> <div class="en">File not exist </div> 073 */ 074 P2PE_VP_ERR_FILE_NOT_EXIST(-1010, "文件不存在", "File not exist"), 075 076 /** 077 * <div class="zh"> 读取或写入文件时出错 </div> <div class="en"> Error when reading from or writing into file </div> 078 */ 079 P2PE_VP_ERR_FILE_RW_ERROR(-1011, "读取或写入文件时出错", "Error when reading from or writing into file"), 080 081 /** 082 * <div class="zh"> 内部错误 </div> <div class="en"> Internal error. </div> 083 */ 084 P2PE_VP_ERR_INTERNAL_ERROR(-1020, "内部错误", "Internal error."), 085 086 /** 087 * <div class="zh"> BIN 异常范围数据无效 </div> <div class="en"> Invalid BIN exception ranges data </div> 088 */ 089 P2PE_VP_ERR_INVALID_BIN_EXCEPTIONS(-1016, "BIN 异常范围数据无效", "Invalid BIN exception ranges data"), 090 091 /** 092 * <div class="zh"> BIN 异常表无效 </div> <div class="en"> Invalid BIN exception table </div> 093 */ 094 P2PE_VP_ERR_INVALID_BIN_TABLE(-1003, "BIN 异常表无效", "Invalid BIN exception table"), 095 096 /** 097 * <div class="zh"> 无效的清除卡数据,不对应正确的格式 </div> <div class="en"> Invalid clear card data, does not correspond to proper format </div> 098 */ 099 P2PE_VP_ERR_INVALID_CARD_DATA(-1022, "无效的清除卡数据,不对应正确的格式", "Invalid clear card data, does not correspond to proper format"), 100 101 /** 102 * <div class="zh"> 无效的数据类型 </div> <div class="en"> Invalid data type </div> 103 */ 104 P2PE_VP_ERR_INVALID_DATA_TYPE(-1009, "无效的数据类型", "Invalid data type"), 105 106 /** 107 * <div class="zh"> 无效的加密标志 </div> <div class="en"> Invalid encryption flag </div> 108 */ 109 P2PE_VP_ERR_INVALID_ENCRYPT_FLAG(-1004, "无效的加密标志", "Invalid encryption flag"), 110 111 /** 112 * <div class="zh"> 使用的身份日期无效 </div> <div class="en"> Invalid identity date used </div> 113 */ 114 P2PE_VP_ERR_INVALID_IDENTITY_DATE(-1013, "使用的身份日期无效", "Invalid identity date used"), 115 116 /** 117 * <div class="zh"> 长度超过 255 个字符的标识字符串 </div> <div class="en"> Identity string longer than 255 chars </div> 118 */ 119 P2PE_VP_ERR_INVALID_IDENTITY_STRING(-1012, "长度超过 255 个字符的标识字符串", "Identity string longer than 255 chars"), 120 121 /** 122 * <div class="zh"> 给出了错误的 FPE 密钥 </div> <div class="en"> Bad FPE key given </div> 123 */ 124 P2PE_VP_ERR_INVALID_KEY(-1007, "给出了错误的 FPE 密钥", "Bad FPE key given"), 125 126 /** 127 * <div class="zh"> 无效的键索引 </div> <div class="en"> Invalid key index </div> 128 */ 129 P2PE_VP_ERR_INVALID_KEY_INDEX(-1005, "无效的键索引", "Invalid key index"), 130 131 /** 132 * <div class="zh"> 无效的 BB 参数数据 </div> <div class="en"> Invalid BB params data </div> 133 */ 134 P2PE_VP_ERR_INVALID_PARAMS_DATA(-1014, "无效的 BB 参数数据", "Invalid BB params data"), 135 136 /** 137 * <div class="zh"> MSR工作模式无效 </div> <div class="en"> Invalid work mode of MSR </div> 138 */ 139 P2PE_VP_ERR_INVALID_WORK_MODE(-1002, "MSR工作模式无效", "Invalid work mode of MSR"), 140 141 /** 142 * <div class="zh"> 密钥不存在 </div> <div class="en"> The Key is not exist </div> 143 */ 144 P2PE_VP_ERR_KEY_NOT_EXIST(-1006, "密钥不存在", "The Key is not exist"), 145 146 /** 147 * <div class="zh"> 意外的空参数 </div> <div class="en"> Unexpected null argument </div> 148 */ 149 P2PE_VP_ERR_NULL_ARG(-1001, "意外的空参数", "Unexpected null argument"), 150 151 /** 152 * <div class="zh"> 用户取消 PAN 条目 </div> <div class="en"> User cancels the PAN entry </div> 153 */ 154 P2PE_VP_ERR_PAN_INPUT_CANCEL(-1019, "用户取消 PAN 条目", "User cancels the PAN entry"), 155 156 /** 157 * <div class="zh"> 进入 PAN 时超时</div> <div class="en"> Time out when entering PAN </div> 158 */ 159 P2PE_VP_ERR_PAN_TIME_OUT(-1018, "进入 PAN 时超时", "Time out when entering PAN"), 160 161 /** 162 * <div class="zh"> 读磁卡时出错 </div> <div class="en"> Error when reading magnetic card </div> 163 */ 164 P2PE_VP_ERR_READ_TRACK_DATA(-1017, "读磁卡时出错", "Error when reading magnetic card"), 165 166 /** 167 * <div class="zh"> 应该在加密之前初始化一个 E2EE 上下文 </div> <div class="en"> should initialize an E2EE context before encryption </div> 168 */ 169 P2PE_VP_ERR_SHOULD_INIT_CONTEXT(-1021, "应该在加密之前初始化一个 E2EE 上下文", "should initialize an E2EE context before encryptiony"), 170 171 172 ; 173 private int errCodeFromBasement; 174 private String errMsgCn; 175 private String errMsgEn; 176 177 EP2PEException(int errCodeFromBasement, String errMsnCn, String errMsgEn) { 178 this.errCodeFromBasement = errCodeFromBasement; 179 this.errMsgCn = errMsnCn; 180 this.errMsgEn = errMsgEn; 181 } 182 183 public int getErrCodeFromBasement() { 184 return errCodeFromBasement; 185 } 186 187 public String getErrMsg() { 188 if (Utils.isZh()) { 189 return errMsgCn; 190 } else { 191 return errMsgEn; 192 } 193 } 194}