NFC Part 6

This is the final part of a six-part series on porting BlackBerry Java applications that use NFC to BlackBerry 10. So far we’ve looked at Tag Reading, Tag Writing, Peer to Peer mode, the reading of contactless cards and virtual target emulation. In this post, we’ll review the porting of code that implements card emulation using a secure element.

Here’s where we are in the series as a whole:

  1. Reading NFC Tags
  2. Writing NFC Tags
  3. Peer to Peer Mode
  4. Reading NFC Contactless Cards
  5. NFC Virtual Tag and Card Emulation
  6. NFC Card Emulation

Issues for Java Developers:

  1. Switch the required ISO14 protocol routing to a selected secure element (UICC vs embedded SE): BlackBerry devices that support NFC may have a choice of up to two secure elements available: one in the UICC (SIM card), and one embedded in the Blackberry device itself (the “embedded SE”). Applications can switch specific ISO14 protocols (A, B or B prime) to a specific secure element using the SecureElementManager and SecureElement APIs.
  1. Connect to an applet and exchange ISO7816-4 APDUs with it: Java developers use the JSR177 API to open logical connections to applets and to exchange APDUs.
  1. Receive notification of “card transaction events”: The BlackBerry 7 Java developer implements the TransactionListener interface and registers with the system by calling SecureElement.addTransactionListener. They must indicate the AID(s) of the applet(s) whose transactions their app is responsible for monitoring in this call.

The BlackBerry 10 Native approach:

1. Switch the required ISO14 protocol routing to a selected secure element (UICC vs embedded SE)

At the time of writing, only secure elements in a UICC/SIM are available from a BlackBerry 10 application. As such there is no need for protocol switching and the issue is moot.

2. Connect to an applet and exchange ISO7816-4 APDUs with it

Developers must use BPS (BlackBerry Platform Services) APIs to connect to and interact with applets in a secure element. The following example illustrates the key steps:

3. Receive notification of “card transaction events”

Developers include a special entry in their application’s bar-descriptor.xml file to register for transaction events from a specified applet. The invocation framework is used to dispatch such events to applications when they arise. Applications use the InvokeManager class to receive and decode transaction details.

BlackBerry 10 and BlackBerry 7 differ in that transaction events can include “supplementary parameters” as defined in ETSI TS 102 622. This data will be included in any data delivered by the invocation framework and be in Base64 encoding.

An example bar-descriptor.xml entry follows. Note the syntax for specifying the AID.

Code showing how to receive transaction notifications from the invocation framework appears next. Note that the MIME type that transaction notifications have is “application/vnd.bb.nfc_transaction” and the payload is in JSON format with binary data in Base64 encoding.

So there you have it: a complete BlackBerry Java NFC porting guide in 6 posts. We hope this was useful for you!

Resources

Knowledge Base Articles:

Sample Code:

Contacts:

image

Read original article: 

Porting BlackBerry Java NFC Applications to BlackBerry 10 Part 6: Card Emulation with a SIM-based Secure Element