Keyple Plugin PCSC Java Lib - 2.2.3

This document is the specification of the API dedicated to the integration of the PC/SC plugin in a Keyple Application.

Specific extensions

The plugin and readers have specific extensions defined in the PcscPlugin and PcscReader interfaces

So far, only the reader has specificities compared to the standard Keyple API.

Identification of the type of reader

The PC/SC plugin allows an application to use both contact and contactless PC/SC readers.

The PC/SC standard does not provide a simple way to know the type of reader, it must be deduced from the name assigned by its manufacturer.

Two methods are proposed to allow the application to assign a type to a reader discovered by the plugin:

  • when building the plugin by providing PcscPluginFactoryBuilder with regular expression based filters to deduce the type of the reader from its name.
  • once the reader is enumerated by the plugin by calling the setContactless() method of the specific reader API.

It is mandatory to use either of these two methods.

Note: the identification of the reader by its name may also be necessary to assign it a precise functional role, but this is the responsibility of the application.

Observability

The PC/SC plugin implements the Keyple observation pattern at the plugin (reader connection and disconnection) and reader (card insertion and removal) level, in this case it is imperative to cast the Plugin and Reader objects as ObservablePlugin and ObservableReader and to implement the interfaces defined for this purpose in the Keyple Service SPI package.

However, the use of these observation features is optional; it is possible to operate in a static mode on both the plugin and the reader side.

Note: because of potential accesses to the same reader from different execution threads of the same application it is sometimes necessary to configure the access in "SHARED" mode using the method PcscReader.setSharingMode. This is especially true when performing card transactions using a SAM (Security Access Module), as the initial connection with the SAM and its use are not done in the same execution thread.

Card identification

It is sometimes necessary to identify the type of card detected by the reader even before sending it an APDU command. Here again PC/SC does not offer much facility and the only information available in a more or less standardized way is the ATR.

The PC/SC plugin It uses an extensible mechanism of regular expression based rules to determine a protocol type. A number of rules are defined by default for common card technology types, but it is possible to redefine or add rules using PcscPluginFactoryBuilder.

Points to consider when the application is running on Windows

The Windows operating system (7/8/10/11) starts a number of default services that may interfere with the proper functioning of applications using PC/SC card readers.
To avoid this, we recommend disabling the Smart Card Plug and Play Service as well as the Certification Propagation Service using the group policy editing tool gpedit.msc.
These parameters are accessible through this path: Computer Configuration\Administrative Templates\Windows Components\Smart Card.

The Smart Card Device Enumeration Service can also interfere when readers are connected/disconnected (used or not by the Keyple application).
We also recommend disabling this service via the built-in service management tool services.msc or via the following command line:

sc config "ScDeviceEnum" start= disabled
When using PcscReader.transmitControlCommand, it is also possible that access to the IOCTL CCID ESCAPE command is blocked by default.
In this case, follow the procedure described here by Microsoft.
Packages
Package
Description
Contains the APIs needed to manage PC/SC readers in a Keyple-based application.