简体   繁体   中英

javax.smartcardio transmit to NFC USB reader without card

Is it possible to send APDU to the NFC reader (for example ACR1222L) using javax.smartcardio without actual card "connected" ? As per my API investigation, you can send APDU only using CardChannel which you get from Card and that you get from connect on CardTerminal. However, if you try to connect when no card in NFC reader, you get CardException. On some readers, peripherals are controlled using standard APDUs. This way it seems you cannot control any peripheral of the ACR1222 prior card is presented. Or am I missing something in javax.smartcardio ?

I will partially answer it for myself as per my investigation. Card class has method transmitControlCommand. Do not know, how APDUs are translated to "controlCode" and "command" byte array, though. You can obtain Card object from CardTerminal using connect method with "direct" as protocol even if there is no card connected. For some reason, "direct" works on Windows JVM 1.6 but not on Mac and reportedly not on Linux JVMs.

Another observation indicates, controlCode should be 3500 for ESCAPE command. According documentation for ACR 1222 L escape command is usefull for controlling peripherals of the reader even if there is no card attached. Command byte sequence is then "plain-old" APDU. This is up to theory proven to function using Android USB library provided by ACS. Odd thing is, standard PCSC drivers do not like 3500 (0xDAC) command. Mac's PCSC driver from ACS does not even like connect("direct"). So for now java applet to control ACR1222L is not going to happen. :(

Ok guys, we are almost there. This is the message for the future generation :-) Method transmitControlCommand requires controlCode related to the "feature" you want to access. According ACS specifications, my feature to control ACS peripherals is ESCAPE with code 3500 (decimal). However control code is compound of:

FILE_DEVICE_SMARTCARD = 0x310000 COMMAND = 3500 * 4

eg resulting IOCTL_SMARTCARD_ESCAPE_COMMAND controlCode = 0x310000 + 3500 * 4

Now, your ACS 122x terminal will accept the command. Note, each terminal may have different COMMAND to control peripherals.

Credits: Adrian Stabiszewski (https://github.com/grundid/nfctools)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM