Java 使用万能键5022读取PACS(原始Wiegand)数据

Java 使用万能键5022读取PACS(原始Wiegand)数据,java,.net,smartcard,contactless-smartcard,omnikey,Java,.net,Smartcard,Contactless Smartcard,Omnikey,我正在开发一个连接到HID Omnikey 5022读卡器的Java应用程序。我需要的是读取PACS位(原始Wiegand数据) 我对这个问题有完全相同的问题,我还可以通过PACS Probe应用程序查看数据: 不幸的是,提供的答案对我来说并不适用 这是我从PACS Probe获得的信息: 读卡器:HID全球万能钥匙5022智能读卡器0 卡类型:PicoPass 32KS(8x2+16) 卡序列号(CSN,UID):32966202F8FF12E0(十六进制) PACS位(原始Wiegand

我正在开发一个连接到HID Omnikey 5022读卡器的Java应用程序。我需要的是读取PACS位(原始Wiegand数据)

我对这个问题有完全相同的问题,我还可以通过PACS Probe应用程序查看数据:

不幸的是,提供的答案对我来说并不适用

这是我从PACS Probe获得的信息:

  • 读卡器:HID全球万能钥匙5022智能读卡器0
  • 卡类型:PicoPass 32KS(8x2+16)
  • 卡序列号(CSN,UID):32966202F8FF12E0(十六进制)
  • PACS位(原始Wiegand)数据:000000 310BC53938(十六进制)
我已经尝试了在Omnikey5023指南中找到的命令,令人惊讶的是它返回了一些数据,但这不是我需要的

该命令是:

commandAPDU=newcommandapdu(新字节[]{(字节)0xFF,(字节)0x70,(字节)0x07,(字节)0x6B,(字节)0x07,
(字节)0xA0,(字节)0x05,(字节)0xBE,(字节)0x03,(字节)0x80,(字节)0x01,(字节)0x04,(字节)0x00});//阅读PACS 5023
它返回以下内容:

9E020003
//我需要000000310BC53938

感谢您的帮助,因为我是智能卡开发新手。
提前感谢。

您从读卡器得到的APDU响应是不受支持的专有命令的错误代码

您需要一个安全会话来使用OMNIKEY 5022或OMNIKEY 5023读卡器访问PACS位数据

除非您有此读卡器的适当文档,否则我可能会坚持使用卡序列号(UID、CSN),并使用PC/SC(或pcsclite)的Java包装器连接到读卡器和卡

然后发出(通过SCardTransmit(FFCA0000 APDU)以获取样本输出中显示的UID(32966202F8FF12E0)

至于Java:使用smartcardio lib。这是本机PC/SC的一个很好的包装器


将安全通道协议移植到Java需要大量工作。调用第三方库可能更容易。

您从读取器获得的响应APDU是不受支持的专有命令的错误代码

您需要一个安全会话来使用OMNIKEY 5022或OMNIKEY 5023读卡器访问PACS位数据

除非您有此读卡器的适当文档,否则我可能会坚持使用卡序列号(UID、CSN),并使用PC/SC(或pcsclite)的Java包装器连接到读卡器和卡

然后发出(通过SCardTransmit(FFCA0000 APDU)以获取样本输出中显示的UID(32966202F8FF12E0)

至于Java:使用smartcardio lib。这是本机PC/SC的一个很好的包装器


将安全通道协议移植到Java需要大量工作。调用第三方库可能更容易。

我能够使用javax.smartcardio,并使用下面的代码获取Wiegand数据。最后,您可以看到设备代码和卡号被打印出来

TerminalFactory terminalFactory = TerminalFactory.getDefault();

CardTerminals cardTerminals = terminalFactory.terminals();

List<CardTerminal> terminalList = cardTerminals.list();

CardTerminal cardTerminal = terminalList.get(0);
cardTerminal.waitForCardPresent(10 * 1000); // wait 10 seconds
Card card = cardTerminal.connect("*");
System.out.println("Card: " + card);
CardChannel channel = card.getBasicChannel();

byte[] aid = { (byte) 0xA0, (byte) 0x05, (byte) 0xA1, (byte) 0x03, (byte) 0x80, (byte) 0x01, (byte) 0x04 };
CommandAPDU apdu = new CommandAPDU(0xFF, (byte) 112, (byte) 7, (byte) 107, aid, 256);
ResponseAPDU r = channel.transmit(apdu);
byte[] bytesOut = r.getBytes();

int num1 = (int) bytesOut[3];
if (bytesOut.length - 6 != num1)
System.out.println("problem");

int numberOfBitsShifted = (int) bytesOut[4];
int num2 = num1 - 1;

byte[] newBytesArr = Arrays.copyOfRange(bytesOut, 5, 5 + num2);
if (newBytesArr.length != num2)
    System.out.println("problem");

ByteBuffer wrapped = ByteBuffer.wrap(newBytesArr);
int num = wrapped.getInt();
int first26 = num >> 6;
int withoutParity = first26 >> 1;

int cardNumber = withoutParity & 0xffff;
int facilityCode = (withoutParity >> 16) & 0xff;

System.out.println(facilityCode);
System.out.println(cardNumber);

TerminalFactory TerminalFactory=TerminalFactory.getDefault();
CardTerminals CardTerminals=terminalFactory.terminals();
List terminalList=cardTerminals.List();
CardTerminal CardTerminal=terminalList.get(0);
cardTerminal.waitForCardPresent(10*1000);//等待10秒
卡片=卡片终端。连接(“*”);
System.out.println(“卡:+卡”);
CardChannel=card.getBasicChannel();
字节[]aid={(字节)0xA0,(字节)0x05,(字节)0xA1,(字节)0x03,(字节)0x80,(字节)0x01,(字节)0x04};
CommandAPDU apdu=新的CommandAPDU(0xFF,(字节)112,(字节)7,(字节)107,aid,256);
ResponseADU r=信道传输(apdu);
byte[]bytesOut=r.getBytes();
int num1=(int)字节输出[3];
if(bytesOut.length-6!=num1)
System.out.println(“问题”);
int numberOfBitsShifted=(int)字节输出[4];
int num2=num1-1;
byte[]newBytesArr=Arrays.copyOfRange(bytesOut,5,5+num2);
如果(新字节长度!=num2)
System.out.println(“问题”);
ByteBuffer wrapped=ByteBuffer.wrapp(新字节数);
int num=wrapped.getInt();
int first26=num>>6;
int withoutprity=first26>>1;
int cardNumber=withoutprity&0xffff;
int facilityCode=(无输出>>16)和0xff;
系统输出打印LN(设备代码);
系统输出打印项次(卡号);

我能够使用javax.smartcardio,并使用如下代码获取Wiegand数据。最后,您可以看到打印的设施代码和卡号

TerminalFactory terminalFactory = TerminalFactory.getDefault();

CardTerminals cardTerminals = terminalFactory.terminals();

List<CardTerminal> terminalList = cardTerminals.list();

CardTerminal cardTerminal = terminalList.get(0);
cardTerminal.waitForCardPresent(10 * 1000); // wait 10 seconds
Card card = cardTerminal.connect("*");
System.out.println("Card: " + card);
CardChannel channel = card.getBasicChannel();

byte[] aid = { (byte) 0xA0, (byte) 0x05, (byte) 0xA1, (byte) 0x03, (byte) 0x80, (byte) 0x01, (byte) 0x04 };
CommandAPDU apdu = new CommandAPDU(0xFF, (byte) 112, (byte) 7, (byte) 107, aid, 256);
ResponseAPDU r = channel.transmit(apdu);
byte[] bytesOut = r.getBytes();

int num1 = (int) bytesOut[3];
if (bytesOut.length - 6 != num1)
System.out.println("problem");

int numberOfBitsShifted = (int) bytesOut[4];
int num2 = num1 - 1;

byte[] newBytesArr = Arrays.copyOfRange(bytesOut, 5, 5 + num2);
if (newBytesArr.length != num2)
    System.out.println("problem");

ByteBuffer wrapped = ByteBuffer.wrap(newBytesArr);
int num = wrapped.getInt();
int first26 = num >> 6;
int withoutParity = first26 >> 1;

int cardNumber = withoutParity & 0xffff;
int facilityCode = (withoutParity >> 16) & 0xff;

System.out.println(facilityCode);
System.out.println(cardNumber);

TerminalFactory TerminalFactory=TerminalFactory.getDefault();
CardTerminals CardTerminals=terminalFactory.terminals();
List terminalList=cardTerminals.List();
CardTerminal CardTerminal=terminalList.get(0);
cardTerminal.waitForCardPresent(10*1000);//等待10秒
卡片=卡片终端。连接(“*”);
System.out.println(“卡:+卡”);
CardChannel=card.getBasicChannel();
字节[]aid={(字节)0xA0,(字节)0x05,(字节)0xA1,(字节)0x03,(字节)0x80,(字节)0x01,(字节)0x04};
CommandAPDU apdu=新的CommandAPDU(0xFF,(字节)112,(字节)7,(字节)107,aid,256);
ResponseADU r=信道传输(apdu);
byte[]bytesOut=r.getBytes();
int num1=(int)字节输出[3];
if(bytesOut.length-6!=num1)
System.out.println(“问题”);
int numberOfBitsShifted=(int)字节输出[4];
int num2=num1-1;
byte[]newBytesArr=Arrays.copyOfRange(bytesOut,5,5+num2);
如果(新字节长度!=num2)
System.out.println(“问题”);
ByteBuffer wrapped=ByteBuffer.wrapp(新字节数);
int num=wrapped.getInt();
int first26=num>>6;
int withoutprity=first26>>1;
int cardNumber=withoutprity&0xffff;
int facilityCode=(无输出>>16)和0xff;
系统输出打印LN(设备代码);
系统输出打印项次(卡号);

Hi Marc,谢谢你的回答。我已经在使用smartcardio lib了。我已经可以使用该库获取UID和ATR,但坚持其中一个对我来说不是选项,因为我们需要设施代码(FAC)和卡号(CN)它只能在PACS位中找到。我也可以成功地进入和退出透明会话。我唯一需要的是PACS位,502中没有记录