1
votes

After consulting a lot of threads on stackoverflow, I still have not found a working "example" for reading/writing MiFare Ultralight or Classic NFC cards using a ACS ACR122 Usb smart card reader in a Java Application... Sure, I tried to consult the documentation of NXP or ACS but still did not manage to "simply" read/write a block of data.

There are a lot of Android-specific libraries out there, but not any plain old J2SE libraries that simplify MiFare communication (using the javax.smartcardio and APDU commands...)

Can anyone give me some real good and usefull pointers:

  • using APDU command for MiFare Ultralight & classic
  • (help me develop) a J2SE library that removes the complexity of all HEX commands that are sent to/from card
  • examples to be used on these cards (Ultralight / Classic) ...

Any help is greatly appriciated.

Development is done with:

  • ACS acr122U NFC reader
  • Linux platform using PC/SC lite libraries
  • MiFare Ultralight and Classic 1K/4K 7UID cards
  • Java SDK 1.6+ and higher
  • Android 4.4.x phone with NFC (e.g. Huwawei ...)
1

1 Answers

1
votes

I wrote a small Java (1.7+) program to dump (and write to) MiFare Classic 1K tags using an ACS ACR122U. It is available on GitHub. Under the hood it uses a plain old J2SE library called NFCTools.

NFCTools helps you communicate with NFC cards by managing all the hexadecimal/APDU stuff. It comes with numerous examples. However I don't know if the main developer still wants to maintain it. For instance he marked a lot of Mifare classes as deprecated in order to refactor Mifare support, but it's still a work-in-progress for 2 years now. From the mailing list:

I first wrote the support for mifare classic cards and it seemed as using those classes to describe the memory area was a good idea. However when I wanted to add support for the ultralight tags the above classes would not work. With the ultralight tags I decided to use a new approach and create a org.nfctools.mf.ul.MemoryLayout class. I think this is the way to go, so I marked the MfCard classes as deprecated.

In spite of this intermediate state it supports a lot of readers and tag formats. The examples are pretty useful. Then if you have some specific requirements I advise you to contribute to this project or fork it.