壁挂身份证读取、社保卡读取
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
package com.dpkj.modules.cardReader.utils;
|
||||
|
||||
import com.dpkj.modules.autoReplyPrint.utils.AutoReplyPrint;
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Platform;
|
||||
|
||||
public interface CardReaderSdk extends Library {
|
||||
CardReaderSdk INSTANCE = (CardReaderSdk) Native.loadLibrary("SSSE32", CardReaderSdk.class);
|
||||
CardReaderSdk INSTANCE = (CardReaderSdk) Native.loadLibrary(GetLibraryPath_Helper.GetLibraryPath(), CardReaderSdk.class);
|
||||
|
||||
/**
|
||||
* 连接指定设备与电脑端口,即打开端口
|
||||
@@ -12,7 +14,7 @@ public interface CardReaderSdk extends Library {
|
||||
* @param devName 接口名称,如”USB1”
|
||||
* @return >0成功,<=0失败
|
||||
*/
|
||||
Long ICC_Reader_Open(String devName);
|
||||
int ICC_Reader_Open(String devName);
|
||||
|
||||
|
||||
/**
|
||||
@@ -21,7 +23,7 @@ public interface CardReaderSdk extends Library {
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @return =0成功,非0失败
|
||||
*/
|
||||
Long ICC_Reader_Close(Long ReaderHandle);
|
||||
int ICC_Reader_Close(int ReaderHandle);
|
||||
|
||||
|
||||
/**
|
||||
@@ -31,7 +33,7 @@ public interface CardReaderSdk extends Library {
|
||||
* @param time 蜂鸣时间,以毫秒为单位
|
||||
* @return =0成功,非0失败
|
||||
*/
|
||||
Long ICC_PosBeep(Long ReaderHandle, Long time);
|
||||
int ICC_PosBeep(int ReaderHandle, int time);
|
||||
|
||||
|
||||
/**
|
||||
@@ -39,7 +41,7 @@ public interface CardReaderSdk extends Library {
|
||||
*
|
||||
* @return 设备及动态库版本信息 =0成功,非0失败
|
||||
*/
|
||||
Long ICC_Reader_Libinfo();
|
||||
int ICC_Reader_Libinfo();
|
||||
|
||||
|
||||
/**
|
||||
@@ -50,7 +52,7 @@ public interface CardReaderSdk extends Library {
|
||||
* @param length 要读取的数据的长度
|
||||
* @return 读取的数据 =0成功,非0失败
|
||||
*/
|
||||
Long ICC_Reader_ReadEEPROM(Long ReaderHandle, int offset, int length);
|
||||
int ICC_Reader_ReadEEPROM(int ReaderHandle, int offset, int length);
|
||||
|
||||
|
||||
/**
|
||||
@@ -62,7 +64,7 @@ public interface CardReaderSdk extends Library {
|
||||
* @param buffer 待写入的数据
|
||||
* @return =0成功,非0失败
|
||||
*/
|
||||
Long ICC_Reader_WriteEEPROM(Long ReaderHandle, int offset, int length, String buffer);
|
||||
int ICC_Reader_WriteEEPROM(int ReaderHandle, int offset, int length, String buffer);
|
||||
|
||||
|
||||
/**
|
||||
@@ -87,7 +89,7 @@ public interface CardReaderSdk extends Library {
|
||||
* @return =0成功,非0失败
|
||||
*/
|
||||
@Deprecated
|
||||
Long ICC_Reader_DispSound(Long ReaderHandle, String voiceType);
|
||||
int ICC_Reader_DispSound(int ReaderHandle, String voiceType);
|
||||
|
||||
|
||||
/**
|
||||
@@ -103,7 +105,7 @@ public interface CardReaderSdk extends Library {
|
||||
* 0x3x:非接CPU卡
|
||||
* @return 上电返回ATR值,数据格式为十六进制字符串
|
||||
*/
|
||||
Long ICC_Reader_PowerOnHEX(Long ReaderHandle, String ICCSlotNo);
|
||||
int ICC_Reader_PowerOnHEX(int ReaderHandle, String ICCSlotNo);
|
||||
|
||||
|
||||
/**
|
||||
@@ -119,7 +121,7 @@ public interface CardReaderSdk extends Library {
|
||||
* 0x3x:非接CPU卡
|
||||
* @return =0成功,非0失败
|
||||
*/
|
||||
Long ICC_Reader_PowerOff(Long ReaderHandle, String ICCSlotNo);
|
||||
int ICC_Reader_PowerOff(int ReaderHandle, String ICCSlotNo);
|
||||
|
||||
|
||||
/**
|
||||
@@ -135,7 +137,7 @@ public interface CardReaderSdk extends Library {
|
||||
* 0x3x:非接CPU卡
|
||||
* @return = 0 表示卡座有卡,其他见状态码
|
||||
*/
|
||||
Long ICC_Reader_GetStatus(Long ReaderHandle, String ICCSlotNo);
|
||||
int ICC_Reader_GetStatus(int ReaderHandle, String ICCSlotNo);
|
||||
|
||||
|
||||
/**
|
||||
@@ -152,7 +154,7 @@ public interface CardReaderSdk extends Library {
|
||||
* @param CommandAPDU APDU命令数据,以十六进制字符串形式输入
|
||||
* @return 大于 0 表示执行成功,其值为 Response_APDU 的数据长度.否则表示执行失败
|
||||
*/
|
||||
Long ICC_Reader_ApplicationHEX(Long ReaderHandle, String ICCSlotNo, String CommandAPDU);
|
||||
int ICC_Reader_ApplicationHEX(int ReaderHandle, String ICCSlotNo, String CommandAPDU);
|
||||
|
||||
|
||||
/**
|
||||
@@ -161,7 +163,7 @@ public interface CardReaderSdk extends Library {
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @return 返回卡片上电信息 = 0 表示成功,非0失败
|
||||
*/
|
||||
Long ICC_Reader_4428_PowerOnHEX(Long ReaderHandle);
|
||||
int ICC_Reader_4428_PowerOnHEX(int ReaderHandle);
|
||||
|
||||
|
||||
/**
|
||||
@@ -170,7 +172,7 @@ public interface CardReaderSdk extends Library {
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @return = 0 表示成功,非0失败
|
||||
*/
|
||||
Long ICC_Reader_4442_PowerOff(Long ReaderHandle);
|
||||
int ICC_Reader_4442_PowerOff(int ReaderHandle);
|
||||
|
||||
|
||||
/**
|
||||
@@ -181,7 +183,7 @@ public interface CardReaderSdk extends Library {
|
||||
* @param len 数据长度,offset+len需小于256
|
||||
* @return 返回卡片读取信息 = 0 表示成功,非0失败
|
||||
*/
|
||||
Long ICC_Reader_4428_ReadHEX(Long ReaderHandle, int offset, int len);
|
||||
int ICC_Reader_4428_ReadHEX(int ReaderHandle, int offset, int len);
|
||||
|
||||
|
||||
/**
|
||||
@@ -193,7 +195,7 @@ public interface CardReaderSdk extends Library {
|
||||
* @param data 待写入卡片数据
|
||||
* @return 返回卡片读取信息 = 0 表示成功,非0失败
|
||||
*/
|
||||
Long ICC_Reader_4428_WriteHEX(Long ReaderHandle, int offset, int len, String data);
|
||||
int ICC_Reader_4428_WriteHEX(int ReaderHandle, int offset, int len, String data);
|
||||
|
||||
|
||||
/**
|
||||
@@ -203,7 +205,7 @@ public interface CardReaderSdk extends Library {
|
||||
* @param keyHex 卡密钥
|
||||
* @return = 0 表示成功,非0失败
|
||||
*/
|
||||
Long ICC_Reader_4442_Verify(Long ReaderHandle, String keyHex);
|
||||
int ICC_Reader_4442_Verify(int ReaderHandle, String keyHex);
|
||||
|
||||
/** ----- 非接触操作函数 -------------- */
|
||||
/**
|
||||
@@ -212,7 +214,7 @@ public interface CardReaderSdk extends Library {
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @return = 0 表示成功,非0失败
|
||||
*/
|
||||
Long PICC_Reader_Request(Long ReaderHandle);
|
||||
int PICC_Reader_Request(int ReaderHandle);
|
||||
|
||||
|
||||
/**
|
||||
@@ -222,7 +224,7 @@ public interface CardReaderSdk extends Library {
|
||||
* @param flag 00-关场强 01-开场强
|
||||
* @return = 0 表示成功,非0失败
|
||||
*/
|
||||
Long PICC_Reader_RFControl(Long ReaderHandle, String flag);
|
||||
int PICC_Reader_RFControl(int ReaderHandle, String flag);
|
||||
|
||||
|
||||
/** --------------- 非接 CPU 卡操作函数 ------------ */
|
||||
@@ -233,7 +235,7 @@ public interface CardReaderSdk extends Library {
|
||||
* @return 输出上电成功返回的卡片复位信息(ATS) 返回ATS长度,大于0 表示成功,其他失败
|
||||
*/
|
||||
@Deprecated
|
||||
Long PICC_Reader_PowerOnTypeAHEX(Long ReaderHandle);
|
||||
int PICC_Reader_PowerOnTypeAHEX(int ReaderHandle);
|
||||
|
||||
|
||||
/**
|
||||
@@ -243,7 +245,7 @@ public interface CardReaderSdk extends Library {
|
||||
* @return 输出上电成功返回的卡片复位信息(ATS) 返回ATS长度,大于0 表示成功,其他失败
|
||||
*/
|
||||
@Deprecated
|
||||
Long PICC_Reader_PowerOnTypeBHEX(Long ReaderHandle);
|
||||
int PICC_Reader_PowerOnTypeBHEX(int ReaderHandle);
|
||||
|
||||
/**
|
||||
* 非接触 CPU 卡执行APDU命令,命令以十六进制字符串传输(SSSE32.dll暴露函数中未发现该函数,但是文档中有)
|
||||
@@ -254,7 +256,7 @@ public interface CardReaderSdk extends Library {
|
||||
* 大于 0 表示执行成功,其值为 Response_APDU 的数据长度.否则表示执行失败
|
||||
*/
|
||||
@Deprecated
|
||||
Long PICC_Reader_ApplicationHEX(Long ReaderHandle, String CommandAPDU);
|
||||
int PICC_Reader_ApplicationHEX(int ReaderHandle, String CommandAPDU);
|
||||
|
||||
|
||||
/** ---------------- 二代证/外国人居留证/港澳台居住证 --------------- */
|
||||
@@ -264,7 +266,7 @@ public interface CardReaderSdk extends Library {
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @return 返回身份证物理ID信息 = 0 表示成功,非0失败
|
||||
*/
|
||||
Long PICC_Reader_Read_CardID(Long ReaderHandle, byte[] response);
|
||||
int PICC_Reader_Read_CardID(int ReaderHandle, byte[] response);
|
||||
|
||||
|
||||
/**
|
||||
@@ -273,7 +275,7 @@ public interface CardReaderSdk extends Library {
|
||||
* @param ReaderHandle ICCReaderOpen函数所返回的值
|
||||
* @return 返回错误信息 = 0 表示成功,非0失败
|
||||
*/
|
||||
Long PICC_Reader_ReadIDCard(Long ReaderHandle);
|
||||
int PICC_Reader_ReadIDCard(int ReaderHandle, byte[] response);
|
||||
|
||||
/** 以下函数须在 “PICC_Reader_ReadIDCard” 函数执行成功之后调用,否则获取不到有效信息 */
|
||||
/**
|
||||
@@ -284,99 +286,99 @@ public interface CardReaderSdk extends Library {
|
||||
* 2:港澳台居民居住证
|
||||
* 4:新外国人永久居留证
|
||||
*/
|
||||
Integer GetCardType();
|
||||
int GetCardType();
|
||||
|
||||
/**
|
||||
* 姓名(类型为 1 时表示:外国人中文姓名)
|
||||
*/
|
||||
Integer GetName(byte[] outParam);
|
||||
int GetName(byte[] outParam);
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
Integer GetSex(byte[] outParam);
|
||||
int GetSex(byte[] outParam);
|
||||
|
||||
/**
|
||||
* 民族
|
||||
*/
|
||||
Integer GetNation(byte[] outParam);
|
||||
int GetNation(byte[] outParam);
|
||||
|
||||
/**
|
||||
* 出生日期
|
||||
*/
|
||||
Integer GetBirth(byte[] outParam);
|
||||
int GetBirth(byte[] outParam);
|
||||
|
||||
/**
|
||||
* 住址
|
||||
*/
|
||||
Integer GetAddress(byte[] outParam);
|
||||
int GetAddress(byte[] outParam);
|
||||
|
||||
/**
|
||||
* 公民身份证号码(类型为 1时表示:外国人居留证号码)
|
||||
*/
|
||||
Integer GetCertNo(byte[] outParam);
|
||||
int GetCertNo(byte[] outParam);
|
||||
|
||||
/**
|
||||
* 签发机关
|
||||
*/
|
||||
Integer GetDepartemt(byte[] outParam);
|
||||
int GetDepartemt(byte[] outParam);
|
||||
|
||||
/**
|
||||
* 有效起始日期
|
||||
*/
|
||||
Integer GetEffectDate(byte[] outParam);
|
||||
int GetEffectDate(byte[] outParam);
|
||||
|
||||
/**
|
||||
* 有效截止日期
|
||||
*/
|
||||
Integer GetExpireDate(byte[] outParam);
|
||||
int GetExpireDate(byte[] outParam);
|
||||
|
||||
/**
|
||||
* bmp 格式照片数据
|
||||
*/
|
||||
String GetBmpFileData(byte[] outParam);
|
||||
int GetBmpFileData(byte[] outParam);
|
||||
|
||||
/**
|
||||
* 生成照片
|
||||
* TODO 入参参考文中3.4.1
|
||||
*/
|
||||
Integer GetBmpFile(byte[] outParam);
|
||||
int GetBmpFile(byte[] outParam);
|
||||
|
||||
/**
|
||||
* 是否含存在指纹信息:存在时返回 512 或者 1024
|
||||
* 不存在时返回 0
|
||||
*/
|
||||
Integer IsFingerExist();
|
||||
int IsFingerExist();
|
||||
|
||||
/**
|
||||
* 获取指纹数据:成功时返回获取到的字节长度
|
||||
*/
|
||||
Integer GetFingerprint(byte[] outParam);
|
||||
int GetFingerprint(byte[] outParam);
|
||||
|
||||
/**
|
||||
* 外国人英文姓名
|
||||
*/
|
||||
Integer GetEnName(byte[] outParam);
|
||||
int GetEnName(byte[] outParam);
|
||||
|
||||
/**
|
||||
* 外国人国籍代码,符合GB/T2659-2000规定
|
||||
*/
|
||||
Integer GetNationalityCode(byte[] outParam);
|
||||
int GetNationalityCode(byte[] outParam);
|
||||
|
||||
/**
|
||||
* 港澳台通行证号码
|
||||
*/
|
||||
Integer GetTXZHM(byte[] outParam);
|
||||
int GetTXZHM(byte[] outParam);
|
||||
|
||||
/**
|
||||
* 港澳台通行证签发次数
|
||||
*/
|
||||
Integer GetTXZQFCS(byte[] outParam);
|
||||
int GetTXZQFCS(byte[] outParam);
|
||||
|
||||
/**
|
||||
* 外国人换证次数
|
||||
*/
|
||||
Integer GetHZCS(byte[] outParam);
|
||||
int GetHZCS(byte[] outParam);
|
||||
|
||||
/** ------------ 社保卡 ---------*/
|
||||
/**
|
||||
@@ -389,7 +391,7 @@ public interface CardReaderSdk extends Library {
|
||||
* 4-自动寻卡,非接触式操作卡优先
|
||||
* @return
|
||||
*/
|
||||
String iReadCardBas(Integer iType);
|
||||
int iReadCardBas(int iType, byte[] data);
|
||||
|
||||
/**
|
||||
* 基于加密机的读基本信息(步骤一)
|
||||
@@ -402,7 +404,7 @@ public interface CardReaderSdk extends Library {
|
||||
* 4-自动寻卡,非接触式操作卡优先
|
||||
* @return
|
||||
*/
|
||||
Long iReadCardBas_HSM_Step1(Integer iType);
|
||||
int iReadCardBas_HSM_Step1(int iType, byte[] data);
|
||||
|
||||
/**
|
||||
* 基于加密机的读基本信息(步骤二)
|
||||
@@ -414,5 +416,51 @@ public interface CardReaderSdk extends Library {
|
||||
* 原始信息(16 位)拼接组成)。各数据项之间以“|”分割,且最后一个数据项以“|”结尾。
|
||||
* @return
|
||||
*/
|
||||
Long iReadCardBas_HSM_Step2(String pKey, byte[] outParam);
|
||||
public int iReadCardBas_HSM_Step2(byte[] pKey, byte[] pOutInfo);
|
||||
|
||||
public static class GetLibraryPath_Helper {
|
||||
public GetLibraryPath_Helper() {
|
||||
}
|
||||
|
||||
private static String GetLibraryPath() {
|
||||
// if (Platform.isWindows()) {
|
||||
// return Platform.is64Bit() ? "/win32-x86-64/QXSSSE32_x64.dll" : "/win32-x86-64/QXSSSE32_x64.dll";
|
||||
// } else if (Platform.isLinux()) {
|
||||
// return Platform.is64Bit() ? "/win32-x86-64/QXSSSE32_x64.so" : "/win32-x86-64/QXSSSE32_x64.so";
|
||||
// } else {
|
||||
// return Platform.isMac() ? "/win32-x86-64/QXSSSE32_x64.so" : "/win32-x86-64/QXSSSE32_x64.so";
|
||||
// }
|
||||
return "/win32-x86-64/SSSE32.dll";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//社保卡
|
||||
public int PICC_Reader_SSCardInfo1(int ReaderHandle,
|
||||
byte[] SBKH,
|
||||
byte[] SHBZHM,
|
||||
byte[] XM,
|
||||
byte[] XB,
|
||||
byte[] CSRQ
|
||||
|
||||
);
|
||||
|
||||
//身份证
|
||||
public int PICC_Reader_ReadIDInfo(int ReaderHandle,
|
||||
String filepath,
|
||||
byte[] pName,
|
||||
byte[] pSex,
|
||||
byte[] pNation,
|
||||
byte[] pBirth,
|
||||
byte[] pAddress,
|
||||
byte[] pCertNo,
|
||||
byte[] pDepartment ,
|
||||
byte[] pEffectData,
|
||||
byte[] pExpire,
|
||||
byte[] pErrMsg);
|
||||
|
||||
public int ICC_SelscetScan(int ReaderHandle, byte[] pCodeInfo , int [] lent);
|
||||
|
||||
|
||||
public int iGetDevUID(byte[] pOutInfo);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user