Link and Contact
Website |
Support |
Copyright © Calypso Networks Association, https://calypsonet.org.
This specification is licensed under the Creative Commons Attribution-NoDerivatives 4.0 International (CC BY-ND 4.0).
You are free to share — copy and redistribute this document in any medium or format for any purpose, even commercially — under the following terms:
-
Attribution — You MUST give appropriate credit to the Calypso Networks Association, provide a link to the license, and indicate if changes were made. You MAY do so in any reasonable manner, but not in any way that suggests the Calypso Networks Association endorses you or your use.
-
NoDerivatives — If you remix, transform, or build upon this document, you MAY NOT distribute the modified material.
No additional restrictions — You MAY NOT apply legal terms or technological measures that legally restrict others from doing anything the license permits.
Implementation grant — The NoDerivatives condition above applies to this specification document only — its text, tables and diagrams. It does not restrict the use of the technical information the document contains. The Calypso Networks Association hereby grants everyone an irrevocable, worldwide, royalty-free permission to use the information contained in this specification to design, develop, and distribute software implementations of this API, in any programming language, under the license of their choice.
The full license text is available at https://creativecommons.org/licenses/by-nd/4.0/.
1. Abstract
This document is the official technical specification of the Terminal Reader API standardised by the Calypso Networks Association (CNA). It defines, in a language-agnostic way (using a notation inspired by the Kotlin language), the interfaces, classes, enumerations, errors, structural relationships and behavioural requirements that any conforming implementation of the Terminal Reader API MUST satisfy.
The Terminal Reader API is part of the broader CNA Terminal API family and acts as the contract through which terminal applications discover card readers, observe card events, select cards and exchange data with them.
Document Status
Reference |
261028-SP-CNATerminalAPI-Reader |
|---|---|
Short name |
CNA-TR-API |
Version |
3.0.0 |
Revision date |
2026-10-28 |
Editor |
Calypso Networks Association |
Source repository |
https://github.com/calypsonet/calypsonet-terminal-reader-api-spec |
Reference license |
Creative Commons Attribution-NoDerivatives 4.0 International (CC BY-ND 4.0) |
| The present document specifies the 3.0.0 of the Terminal Reader API. It defines a single, coherent baseline against which conforming implementations are evaluated; the Since column indicates the version in which each member was introduced. |
Revision List
|
This section lists the high-level changes per version. The complete, fine-grained
changelog is maintained in the |
| Version / Date | Modifications |
|---|---|
v3.0.0 |
Initial edition of this document. |
2. Introduction
2.1. Purpose
The Terminal Reader API defines a standardised set of contracts allowing terminal applications to interact with card readers and the cards presented to them, independently of:
-
the underlying reader hardware (contact, contactless, virtual, etc.),
-
the card technology family (ISO/IEC 7816-4, ISO/IEC 14443, proprietary),
-
the implementation technology of the application (programming language, runtime).
Conforming implementations of this specification MUST allow extension modules (e.g. card-specific APIs such as the
Calypso Card API) to plug in transparently through the Service Provider Interface (SPI) mechanism defined in
reader.selection.spi and reader.transaction.spi.
2.2. Scope
This specification covers:
-
the discovery and basic interrogation of card readers,
-
the observation of reader events related to card presence and selection,
-
the configuration of card detection (RF technologies, detection mode, ECP frame),
-
the description and orchestration of card selection scenarios, including multi-channel scenarios,
-
the abstraction of the physical and logical communication channels established with cards,
-
the contract surface required by card extension modules to interoperate with reader implementations,
-
the management of single-channel and multi-channel card transactions.
The following topics are out of scope:
-
the wire-level protocols used between reader and card (e.g. APDU framing, ISO/IEC 14443 anti-collision),
-
the cryptographic operations performed by or on behalf of the card,
-
the lifecycle and packaging of reader drivers,
-
the user interface presented by the terminal application.
2.3. Conformance
A software product conforms to this specification if and only if:
-
it implements every interface and class defined in Chapter 5 with the operations and semantics prescribed in this document,
-
it raises errors exclusively of the types defined in Section 5.6 for the situations described,
-
it preserves the structural relationships described in Chapter 4.
Throughout this specification, the key words MUST, MUST NOT, SHOULD, SHOULD NOT, RECOMMENDED, MAY and OPTIONAL are to be interpreted as described in RFC 2119 and RFC 8174 when, and only when, they appear in all capitals.
In conformance with RFC 2119, SHALL is equivalent to MUST; this specification uses MUST exclusively in order to avoid ambiguity.
2.4. Document Conventions
2.4.1. Naming
Type names follow UpperCamelCase; operation, parameter and enumeration-member names follow lowerCamelCase
except for enumeration values which use UPPER_SNAKE_CASE. Names defined by this specification are reproduced
as-is in the UML class diagram (Section 4.6).
2.4.2. Data types
The following type names, whose notation is inspired by the Kotlin language, are used in operation signatures and are mapped, in each binding, to the closest equivalent native type. Implementations MUST preserve the semantic intent rather than the syntactic form.
| Type | Description | Typical bindings |
|---|---|---|
|
Sequence of characters, UTF-8 encoded by default. |
|
|
Two-state truth value. |
|
|
Signed 32-bit integer. |
|
|
Signed 64-bit integer. |
|
|
Ordered sequence of octets. |
|
|
Ordered collection of |
|
|
Unordered collection of unique |
|
|
Associative array binding keys of type |
|
|
Value of any type, root of the type hierarchy. |
|
|
Nullable value: either a |
|
|
Absence of value, the alternative held by a nullable type. |
|
|
Own type of the receiver: a fluent operation returns the instance it was called on. |
|
|
Indicates that an operation returns no value. |
|
2.4.3. Type tables
Each interface, class, enumeration and error defined in this document is described by a table of the form:
Name |
The type’s normalized name. |
|---|---|
Kind |
The category of the type (interface, class, enumeration, error, etc.). |
Namespace |
The namespace in which the type is defined. |
Extends |
The type extended by this type, when applicable. |
Implements |
The interface implemented by this type, when applicable. |
Since |
The version of the API in which the type was introduced. |
Purpose |
A normative description of the type’s responsibility. |
See also |
Cross-references to related operations or types, each a hyperlink to the corresponding table. Present only when applicable. |
The Purpose row states, in one or two sentences, the responsibility of the type and the way an instance is obtained. It is meant to be scanned, not read: any content that requires structure or depth — rules, lists, notes, value tables or examples — is placed as prose below the table.
2.4.4. Operation tables
Each operation defined in this document is described by a table of the form:
Signature |
The operation’s signature. |
|---|---|
Since |
The version of the API in which the operation was introduced. |
Description |
A normative description of the operation’s behaviour. |
Parameters |
A description of each input parameter. |
Returns |
A description of the returned value, if any. |
Pre-conditions |
The conditions the caller MUST satisfy before invoking the operation, each prefixed by its nature. |
Errors |
A list of error conditions a correct caller must handle, each mapped to a specific error type. |
See also |
Cross-references to related operations or types, each a hyperlink to the corresponding table. Present only when applicable. |
2.4.5. Operation contracts
To avoid repetition, the following rules apply to every operation table in Chapter 5 and are therefore not restated for each operation:
-
Pre-conditions. The Pre-conditions row states what the caller MUST guarantee before invoking the operation. Violating one is a contract error, never listed in the Errors row, which describes only the outcomes a correct caller must handle. Each entry is prefixed by its nature, which determines the error raised when the condition is not met:
-
Argument — an illegal argument error. Applies to any invalid argument, including values bounded by a card or SAM protocol.
-
Range — an index out of bounds error. Applies when the argument designates a position within a collection or memory image exposed by the API.
-
State — an illegal state error.
-
Capability — an unsupported operation error.
-
-
Non-
nullresults. Unless the return type is marked nullable (T?) or the Returns row states otherwise, an operation returns a non-nullvalue. -
Collections. Unless the return type is marked nullable (
T?), an operation whose return type is a collection (e.g.List,Set,Map) returns an empty collection rather thannull. -
Fluent composition. Builder-style operations return the current instance so that calls can be chained.
2.4.6. Concurrency
Unless explicitly stated otherwise, the stateful types defined by this specification are not thread-safe. A given instance MUST be accessed from a single thread at a time; concurrent use of the same instance without external synchronisation results in undefined behaviour. Distinct instances MAY be used concurrently.
2.5. References and Resources
2.5.1. Calypso References
References to CNA Terminal APIs designate the indicated major version; any later release within the same major is backward-compatible per that API’s evolution policy.
| Reference | Document |
|---|---|
CNA Terminal API — Reader Definitions (SP-CNATerminalAPI-ReaderDefinitions), version 1.0, Calypso Networks Association. Provides the |
2.5.2. Normative References
| Reference | Document |
|---|---|
Key words for use in RFCs to Indicate Requirement Levels, S. Bradner, March 1997. |
|
Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words, B. Leiba, May 2017. |
|
Identification cards — Contactless integrated circuit cards — Proximity cards. |
2.5.3. External Resources
| Resource | Link |
|---|---|
Calypso Networks Association |
|
Terminal APIs website |
|
Terminal APIs documentation |
3. Glossary and Acronyms
3.1. Glossary
| Term | Definition |
|---|---|
Card |
Any physical or virtual smart card that can be presented to a reader for selection and dialog. |
Card Reader |
Hardware or software component capable of detecting cards and exchanging data with them. |
Card Selection |
Sequence of operations used to identify, filter and prepare a card for application-level dialog. |
Logical Channel |
Software-level communication path established with a card after a successful selection. |
Basic Channel |
The default logical channel (channel |
Multi-Channel |
Capability of an ISO/IEC 7816-4 card to host several active logical channels in parallel. |
Physical Channel |
Hardware-level communication path between the reader and the card. |
Observable Reader |
Reader implementation able to notify a registered event handler asynchronously of card-related events. |
Power-on Data |
Data returned by the reader at the moment a card is detected (e.g. ATR, virtual ATR, anti-collision data). |
Card Application |
Application Dedicated File (DF) selected on a card, identified by its AID, as defined in ISO/IEC 7816-4. |
AID |
Application IDentifier as defined in ISO/IEC 7816-4 (5 to 16 bytes). |
APDU |
Application Protocol Data Unit, the message format used between the terminal and the card, as defined in ISO/IEC 7816-3. |
ECP |
Enhanced Contactless Polling, an extended polling mechanism enabling fast card detection in mobile transit deployments. |
RF Technology |
Radio-frequency communication technology used by a contactless reader to detect a card, as defined in ISO/IEC 14443. |
Card Type |
Identified product or transport-protocol family of a detected card. |
SPI |
Service Provider Interface — a set of interfaces designed to be implemented by an extension module. |
3.2. Acronyms
| Abbreviation | Expansion |
|---|---|
AID |
Application IDentifier |
APDU |
Application Protocol Data Unit |
ATR |
Answer To Reset |
CNA |
Calypso Networks Association |
DF |
Dedicated File |
ECP |
Enhanced Contactless Polling |
FCI |
File Control Information |
FCP |
File Control Parameters |
FMD |
File Management Data |
ISO |
International Organization for Standardization |
RF |
Radio Frequency |
RFC |
Request For Comments |
SPI |
Service Provider Interface |
UML |
Unified Modelling Language |
4. Architectural Overview
4.1. Functional positioning
The Terminal Reader API sits between the terminal application and the reader drivers, exposing a stable contract on each side:
4.2. Logical namespaces
| Namespace | Role | Summary |
|---|---|---|
|
Public API |
Entry points of the API and the abstractions used to manipulate readers and the events they produce; exposes
|
|
SPI |
Contracts implemented by the application (as opposed to the reader implementation) when readers are observed. |
|
Public API |
Orchestration of card selection scenarios: the hierarchy of card selection managers (one per selection mode), the family of selectors, the channel and notification policies and the structures exposing selection results. |
|
SPI |
Contracts implemented by card extensions to plug into the selection machinery. |
|
SPI |
Common contract shared by all card transaction managers exposed by card extensions; its three interfaces form a hierarchy letting each extension anchor its transaction manager at the capability level matching its card model (non-ISO, optionally multi-channel, intrinsically multi-channel). |
4.3. Multi-channel design
The Terminal Reader API explicitly supports ISO/IEC 7816-4 cards that host several active logical channels in parallel.
The design follows a three-tier hierarchy in the reader.transaction.spi namespace:
-
CardTransactionManager— root contract common to every transaction manager, regardless of channel model. -
IsoCardTransactionManager— intermediate contract for ISO/IEC 7816-4 cards for which multi-channel is an optional capability of the underlying card. It exposes the cast operationasMultichannelCardTransactionManagerthat returns aMultichannelCardTransactionManagerwhen the card supports it. -
MultichannelCardTransactionManager— contract for cards that are intrinsically multi-channel by design. Consumer APIs whose target cards are always multi-channel SHOULD make their transaction manager extend this contract directly.
4.4. Card selection modes
A card selection scenario — prepared through one of the card selection managers described in
CardSelectionManager, whose type determines the selection mode — can be operated in
two ways, chosen according to the reader capability and the use case.
| This section is informative. It gives an end-to-end view of the two modes; the normative behaviour of each operation is defined in the sections of the card selection managers. |
- Synchronous (explicit)
-
The card is already present on a
CardReader. The application runs the scenario itself with theprocessCardSelectionScenariooperation of its manager and obtains the corresponding result immediately (SingleCardSelectionResult,SequentialCardSelectionResultorMultichannelCardSelectionResult). The same entity manages both the selection and the subsequent card processing. - Asynchronous (scheduled / event-driven)
-
On an
ObservableCardReader, the scenario is registered ahead of time withscheduleCardSelectionScenario— available on the single-channel managersSingleCardSelectionManagerandSequentialCardSelectionManageronly — and executed automatically by the reader upon card insertion. The outcome is delivered as aCardReaderEventto theCardReaderEventHandler— its type (CARD_MATCHEDorCARD_INSERTED) depending on theCardPresenceNotificationPolicy— and decoded with theparseScheduledCardSelectionsResponseoperation of the same manager. Here the reader drives the selection while the event handler performs the card processing.
The runtime execution of the asynchronous mode — the reader states and transitions — is detailed in Reader observation lifecycle.
4.5. Reader observation lifecycle
An ObservableCardReader tracks card insertion and removal through an internal state
machine. The diagram below gives the integrator a complete view of that lifecycle: how
startCardDetection /
stopCardDetection and
endCardProcessing move the reader between states, when a
CardReaderEvent is produced, and how the DetectionMode and
CardPresenceNotificationPolicy settings steer the flow.
| This section is informative. The state and trigger names shown are internal to the implementation and are not part of the normative API surface; they are provided only to explain the observed runtime behavior. |
The diagram uses the following notation:
Triggers — events that drive the transitions:
-
Application triggers (blue transitions in the diagram):
-
CARD_DETECTION_START_REQUESTED— the application calledstartCardDetection. -
CARD_DETECTION_STOP_REQUESTED— the application calledstopCardDetection(factorized on the composite-state boundary). -
CARD_PROCESSING_ENDED— the application calledendCardProcessing.
-
-
Hardware triggers (red transitions in the diagram):
-
CARD_INSERTED— the monitoring job detected a card. -
CARD_REMOVED— the monitoring job detected card removal.
-
Reader capabilities:
-
[MONITORING_DURING_PROCESSING]— the reader can detect card removal while processing is running, AND card processing is executed in a dedicated thread.
Card eligibility:
-
[CARD_PROCESSABLE]— the inserted card matched at least one case of the card selection scenario, OR the notification policy covers every detected card regardless of selection (CardPresenceNotificationPolicy == ALWAYS). -
[CARD_NON_PROCESSABLE]— the inserted card matched no case of the card selection scenario, AND the notification policy is restricted to matched cards (CardPresenceNotificationPolicy == MATCHED_ONLY).
Detection mode — the active DetectionMode, evaluated when a card-processing cycle ends:
-
[REPEATING]— detection resumes after each card-processing cycle, ready for the next card. -
[SINGLE_SHOT]— detection stops after the first card-processing cycle; a new call tostartCardDetectionis required to detect further cards.
Actions — effect executed on a transition:
-
/ facade.operation()— a public API call (event production or event-handler notification). -
/ driver.operation()— a low-level hardware call (hardware notification). -
/ start job— a monitoring job submitted to the background executor.
4.6. UML class diagram
The following UML class diagram provides a visual representation of the types and relationships defined by this specification:
5. API Specification
5.1. Constants
5.1.1. Reader API Properties
Name |
|
|---|---|
Kind |
Constants |
Namespace |
|
Since |
1.0 |
Purpose |
Exposes the immutable properties of the Terminal Reader API. |
| Name | Type | Since | Description |
|---|---|---|---|
|
|
1.0 |
String representation of the version of the API implemented by the conforming binding.
The value is a dotted decimal of the form |
5.2. Data
5.2.1. Basic Card Selector
Name |
|
|---|---|
Kind |
Data |
Namespace |
|
Implements |
|
Since |
2.0 |
Purpose |
Basic, technology-agnostic card selector, built directly by the application. |
BasicCardSelector carries no ISO/IEC 7816-4-specific filter; it exists to express their absence at the
type level. Every filter is optional and MAY be combined with the others. When no filter is set, any card
that responds when presented to the reader is considered selected; when one or more filters are set, the card
is rejected as soon as one of them does not match.
| Name | Type | Default | Since | Description |
|---|---|---|---|---|
|
|
|
3.0 |
Restricts the selection to cards whose detected type matches this value. The value |
|
|
|
2.0 |
Restricts the selection to cards whose power-on data, as provided by the reader, matches this regular
expression. |
5.2.2. Card Detection Settings
Name |
|
|---|---|
Kind |
Data |
Namespace |
|
Since |
3.0 |
Purpose |
Carries the configuration of a card detection cycle, built directly by the application. |
| Name | Type | Default | Since | Description |
|---|---|---|---|---|
|
|
3.0 |
Governs the reader behaviour once a card-processing cycle has terminated. With |
|
|
|
|
3.0 |
The set of RF technologies the reader activates during polling. Not relevant for contact readers, where it is accepted without effect. MUST NOT be empty. |
|
|
|
3.0 |
The ECP (Enhanced Contactless Polling) frame to emit at polling startup, treated by this specification
as opaque binary data constructed by the application in accordance with the relevant ECP specification
and transmitted as-is to the reader. Relevant only on readers supporting ECP; on the others the frame is
silently ignored and a |
5.2.3. Card Reader Event
Name |
|
|---|---|
Kind |
Data |
Namespace |
|
Since |
1.0 |
Purpose |
Data container describing a change of state observed by a |
A CardReaderEvent carries the origin of the event (the reader name), the event type and, when available,
the card selection response. The circumstances under which each event type is emitted are described in
Reader observation lifecycle.
| Name | Type | Default | Since | Description |
|---|---|---|---|---|
|
|
— |
1.0 |
Name of the reader that generated the event. Non-empty. |
|
— |
1.0 |
Type of the event. |
|
|
— |
1.0 |
Response of the selection scenario scheduled on the reader. It is |
5.2.4. ISO Card Selector
Name |
|
|---|---|
Kind |
Data |
Namespace |
|
Implements |
|
Since |
2.0 |
Purpose |
ISO/IEC 7816-4 card selector, built directly by the application. |
IsoCardSelector adds the ISO/IEC 7816-4-specific filters to those common to every selector. They are all
optional and MAY be combined. When no filter is set, any card that responds when presented to the reader is
considered selected; when one or more filters are set, the card is rejected as soon as one of them does not
match.
| Name | Type | Default | Since | Description |
|---|---|---|---|---|
|
|
|
3.0 |
Restricts the selection to cards whose detected type matches this value. The value |
|
|
|
2.0 |
Restricts the selection to cards whose power-on data, as provided by the reader, matches this regular
expression. |
|
|
|
2.0 |
Selects a card application DF by its name: the DF is selected only if its name starts with this AID, as
defined by ISO/IEC 7816-4 section 4.2. The value is used as a parameter of the Select Application ISO
card command and MUST contain 5 to 16 bytes. |
|
|
2.0 |
File occurrence mode (see ISO/IEC 7816-4). |
|
|
|
2.0 |
File control mode (see ISO/IEC 7816-4). |
5.2.5. Multichannel Card Selection Result
Name |
|
|---|---|
Kind |
Data |
Namespace |
|
Since |
3.0 |
Purpose |
Result of a selection scenario executed by a |
Each successful selection case has been placed on its own logical channel. All the smart cards exposed by the result
are active in parallel; the one placed on the basic channel, if any, is identified through
IsoSmartCard.isBasicChannel.
| Name | Type | Default | Since | Description |
|---|---|---|---|---|
|
|
— |
3.0 |
Type of the detected card, as defined by the |
|
|
— |
3.0 |
All |
5.2.6. Sequential Card Selection Result
Name |
|
|---|---|
Kind |
Data |
Namespace |
|
Since |
3.0 |
Purpose |
Result of a selection scenario executed by a |
Every selection case of the scenario has been tried. The result exposes the smart cards of all the successful
selection cases, indexed by their selectionCaseId. Since the card is operated on a single channel, only the smart card
of the last successful selection case, in execution order, remains active; the others are deactivated but still
expose the data collected during their selection (see the SmartCard lifecycle).
activeSelectionCaseId is null if and only if smartCards is empty.
| Name | Type | Default | Since | Description |
|---|---|---|---|---|
|
|
— |
3.0 |
Type of the detected card, as defined by the |
|
|
— |
3.0 |
All |
|
|
— |
3.0 |
Identifier of the last successful selection case in execution order, whose smart card is the only one remaining
active, or |
5.2.7. Single Card Selection Result
Name |
|
|---|---|
Kind |
Data |
Namespace |
|
Since |
3.0 |
Purpose |
Result of a selection scenario executed by a |
The execution stops at the first successful selection case, so the result exposes at most one smart card,
identified by the selectionCaseId supplied to prepareSelectionCase. selectionCaseId and smartCard are either both
null, when no selection case succeeded, or both non-null.
| Name | Type | Default | Since | Description |
|---|---|---|---|---|
|
|
— |
3.0 |
Type of the detected card, as defined by the |
|
|
— |
3.0 |
Identifier of the successful selection case, or |
|
— |
3.0 |
The active |
5.3. API Interfaces
5.3.1. Card Reader
Name |
|
|---|---|
Kind |
Interface |
Namespace |
|
Since |
1.0 |
Purpose |
Represents a card reader capable of driving the underlying hardware to manage card detection. |
Get Name
Signature |
|
|---|---|
Since |
1.0 |
Description |
Returns the name of the reader. |
Returns |
A non-empty |
Pre-conditions |
None. |
Errors |
None. |
Is Card Present
Signature |
|
|---|---|
Since |
1.0 |
Description |
Indicates whether a card is currently detected by the reader. What counts as present depends on the reader’s
communication mode (see |
Returns |
|
Pre-conditions |
None. |
Errors |
|
Is Contactless
Signature |
|
|---|---|
Since |
1.0 |
Description |
Indicates whether the card communication mode is contactless. |
Returns |
|
Pre-conditions |
None. |
Errors |
None. |
5.3.2. Card Reader Provider
Name |
|
|---|---|
Kind |
Interface |
Namespace |
|
Since |
3.0 |
Purpose |
Standardised discovery and access surface for the card readers available in the execution environment. |
The CardReaderProvider is obtained from the ReaderApiFactory. It offers an
implementation-agnostic view over the readers currently registered in the environment. Reader lifecycle (registration and un-registration) is handled by the runtime environment; the provider is a
read-only view reflecting the readers active at the moment of each call.
Find Reader
Signature |
|
|---|---|
Since |
3.0 |
Description |
Returns the first reader whose name matches the supplied regular expression. This lookup is convenient when reader names embed variable elements (serial numbers, USB port index, etc.) that the application cannot hard-code. |
Parameters |
|
Returns |
A |
Pre-conditions |
Argument — every parameter is non- |
Errors |
None. |
Get Reader
Signature |
|
|---|---|
Since |
3.0 |
Description |
Returns the reader whose name exactly matches the supplied string. |
Parameters |
|
Returns |
A |
Pre-conditions |
Argument — every parameter is non- |
Errors |
None. |
Get Reader Names
Signature |
|
|---|---|
Since |
3.0 |
Description |
Returns the names of all readers currently registered in the execution environment. |
Returns |
A |
Pre-conditions |
None. |
Errors |
None. |
Get Readers
Signature |
|
|---|---|
Since |
3.0 |
Description |
Returns all readers currently registered in the execution environment. |
Returns |
A |
Pre-conditions |
None. |
Errors |
None. |
5.3.3. Card Selection Manager
Name |
|
|---|---|
Kind |
Interface |
Namespace |
|
Since |
1.0 |
Purpose |
Common contract of the card selection managers: preparation of the card selection scenario and export/import of the scenario and of its processed result. An instance is obtained through one of the specialised managers created by the |
A card selection scenario is composed of one or more selection cases, each identified by an application-chosen
identifier and backed by a CardSelectionExtension. A selection case targets a
specific card and MAY define additional commands to be executed after the successful selection. Selection cases are
executed in the order in which they were prepared, regardless of their identifiers. When a selection case fails, the
manager tries the next selection case defined in the scenario, until no further selection case is available.
All the selection cases of a scenario target the same card presented to the reader. What a scenario
discriminates is, in practice, the applications hosted by that card — for example the Calypso applications of a
multi-application card. The qualifiers single, sequential and multichannel in the names of the managers
therefore describe how the scenario is executed and how many selections are retained, never a number of cards. The
term card is kept throughout the API because a selection case also targets cards that host no application, such
as storage cards, where the selection targets the card itself.
The selection mode is not a parameter of the execution: it is carried by the type of the manager, each specialised manager being obtained from its own factory operation and producing its own result type.
| Manager | Behaviour | Execution | Result |
|---|---|---|---|
Single-channel. Stops at the first successful selection case. |
Explicit or scheduled |
||
Single-channel. Processes every selection case regardless of intermediate successes. |
Explicit or scheduled |
||
ISO/IEC 7816-4 multi-channel cards. Places each successful selection case on its own logical channel, according to
a |
Explicit |
This interface carries the operations common to the three modes. The operations whose result depends on the mode — execution, scheduling, parsing of a scheduled response and import of a processed scenario — are defined by each specialised manager. See Card selection modes for an end-to-end view of the synchronous and asynchronous flows.
A scenario is considered prepared once at least one selection case has been appended via prepareSelectionCase or
imported via importCardSelectionScenario. A prepared scenario MAY be executed multiple times; each execution
operates on the scenario as it stood at the time of the call.
Export Card Selection Scenario
Signature |
|
|---|---|
Since |
1.1 |
Description |
Exports the content of the current prepared selection scenario, including the identifiers of its selection cases, as a |
Returns |
A non-empty |
Pre-conditions |
None. |
Errors |
None. |
See also |
Export Processed Card Selection Scenario
Signature |
|
|---|---|
Since |
1.3 |
Description |
Exports the content of the previously processed selection scenario as a Caution: if the local environment does not have all the card extensions involved in the scenario, the selection result produced locally will not contain any active selection. In that case, the processed scenario MUST be exported so that it can be re-imported and interpreted on a manager which has the relevant card extensions. |
Returns |
A non-empty |
Pre-conditions |
State — the scenario has been processed successfully, via |
Errors |
None. |
See also |
|
Import Card Selection Scenario
Signature |
|
|---|---|
Since |
1.1 |
Description |
Replaces the current scenario with a previously exported scenario, including the identifiers of its selection cases. The selection cases prepared or imported before the call are discarded. |
Parameters |
|
Returns |
The current instance ( |
Pre-conditions |
Argument — every parameter is non- |
Errors |
None. |
See also |
Prepare Selection Case
Signature |
|
|---|---|
Since |
2.0 |
Description |
Appends a selection case, identified by |
Parameters |
|
Returns |
The current instance ( |
Pre-conditions |
Argument — every parameter is non- |
Errors |
None. |
5.3.4. Card Selector
Name |
|
|---|---|
Kind |
Sealed interface |
Namespace |
|
Since |
2.0 |
Purpose |
Common supertype of the card selectors. Carries no member; it exists to let an operation accept any selector. |
Its permitted implementations are BasicCardSelector and
IsoCardSelector, which carry the filters restricting the selection process.
5.3.5. Multichannel Card Selection Manager
Name |
|
|---|---|
Kind |
Interface |
Namespace |
|
Extends |
|
Since |
3.0 |
Purpose |
Card selection manager executing every selection case of the scenario, keeping each matching application of an ISO/IEC 7816-4 multi-channel card active simultaneously, each on its own logical channel. Out of scope for storage cards. An instance is obtained via |
Each successful selection case is placed on its own logical channel of the ISO/IEC 7816-4 card, the use of the
basic channel being governed by the ChannelSelectionPolicy passed at execution
time. All the smart cards of the resulting
MultichannelCardSelectionResult remain active in parallel. Only the
explicit execution is available: scheduled selection is not supported in multi-channel mode.
Import Processed Card Selection Scenario
Signature |
|
|---|---|
Since |
3.0 |
Description |
Imports a previously exported processed selection scenario and returns the corresponding result. |
Parameters |
|
Returns |
|
Pre-conditions |
Argument — every parameter is non- |
Errors |
|
See also |
Process Card Selection Scenario
Signature |
|
|---|---|
Since |
3.0 |
Description |
Explicitly executes the previously prepared selection scenario in multi-channel mode against the provided reader, placing each successful selection case on its own logical channel according to the requested channel policy, and returns the result. If the presented card is not a multi-channel ISO/IEC 7816-4 card, an |
Parameters |
|
Returns |
|
Pre-conditions |
Argument — every parameter is non- |
Errors |
|
5.3.6. Observable Card Reader
Name |
|
|---|---|
Kind |
Interface |
Namespace |
|
Extends |
|
Since |
1.0 |
Purpose |
A |
The observation contract is co-located with the start of detection: a single call to startCardDetection provides
both the CardDetectionSettings that govern the polling behaviour and the
CardReaderEventHandler that receives the resulting events.
The reader’s complete insertion/processing/removal lifecycle — including when each observation event is produced — is described in Reader observation lifecycle.
Clear Scheduled Card Selection Scenario
Signature |
|
|---|---|
Since |
3.0 |
Description |
Removes the card selection scenario scheduled on this reader, if any. From the next card insertion onwards, no
scenario is executed and the This operation is idempotent: calling it when no scenario is scheduled has no effect. |
Pre-conditions |
None. |
Errors |
None. |
See also |
|
End Card Processing
Signature |
|
|---|---|
Since |
3.0 |
Description |
Notifies the reader that the business processing of the current card has been completed. Upon receiving this notification, the reader:
In addition, the reader releases the references to the This operation is idempotent: calling it twice on the same card processing cycle has no effect after the
first call. It is RECOMMENDED to call |
Pre-conditions |
None. |
Errors |
None. |
Start Card Detection
Signature |
|
|---|---|
Since |
3.0 |
Description |
Activates card detection. Once activated, the application is notified of card events through the registered
Parameters carried by |
Parameters |
|
Pre-conditions |
Argument — every parameter is non- |
Errors |
None. |
Stop Card Detection
Signature |
|
|---|---|
Since |
1.0 |
Description |
Stops card detection. After this operation has returned, the registered event handler does not receive card events until detection is restarted. |
Pre-conditions |
None. |
Errors |
None. |
5.3.7. Reader API Factory
Name |
|
|---|---|
Kind |
Interface |
Namespace |
|
Since |
2.0 |
Purpose |
Factory used by the application to obtain instances of the public types provided by the API. |
The ReaderApiFactory is the single entry point through which the application instantiates the public types of
the API. It is provided as a single instance. Its create operations each return a fresh, fully initialised
object, whereas getCardReaderProvider gives access to the CardReaderProvider of the execution environment.
Create Multichannel Card Selection Manager
Signature |
|
|---|---|
Since |
3.0 |
Description |
Creates a |
Returns |
|
Pre-conditions |
None. |
Errors |
None. |
Create Sequential Card Selection Manager
Signature |
|
|---|---|
Since |
3.0 |
Description |
Creates a |
Returns |
|
Pre-conditions |
None. |
Errors |
None. |
Create Single Card Selection Manager
Signature |
|
|---|---|
Since |
3.0 |
Description |
Creates a |
Returns |
|
Pre-conditions |
None. |
Errors |
None. |
Get Card Reader Provider
Signature |
|
|---|---|
Since |
3.0 |
Description |
Returns the |
Returns |
|
Pre-conditions |
None. |
Errors |
None. |
5.3.8. Scheduled Card Selections Response
Name |
|
|---|---|
Kind |
Marker interface |
Namespace |
|
Since |
1.0 |
Purpose |
Carrier for the response of the execution of a scheduled selection scenario, provided by a |
This interface declares no operation. It conveys the card responses to one or more of the scenario’s selection
cases (selection step itself plus any subsequent commands). Its content MUST be interpreted through the
parseScheduledCardSelectionsResponse operation of the manager that scheduled the scenario
(SingleCardSelectionManager or
SequentialCardSelectionManager).
5.3.9. Sequential Card Selection Manager
Name |
|
|---|---|
Kind |
Interface |
Namespace |
|
Extends |
|
Since |
3.0 |
Purpose |
Card selection manager executing every selection case of the scenario, selecting in turn each matching application of the card; only the last selected application remains active. Intended for cards hosting several applications, and therefore not applicable to storage cards. An instance is obtained via |
Every selection case is tried, in the order in which they were prepared, whatever the outcome of the previous ones.
Since the card is operated on a single channel, each successful selection deactivates the smart card produced by
the previous one: in the resulting SequentialCardSelectionResult, only the
smart card of the last successful selection case remains active. To keep several selections active in parallel on
a multi-channel ISO/IEC 7816-4 card, the MultichannelCardSelectionManager
MUST be used instead. The scenario can be executed explicitly, on a card already present, or scheduled on an
ObservableCardReader.
Import Processed Card Selection Scenario
Signature |
|
|---|---|
Since |
3.0 |
Description |
Imports a previously exported processed selection scenario and returns the corresponding result. |
Parameters |
|
Returns |
|
Pre-conditions |
Argument — every parameter is non- |
Errors |
|
See also |
Parse Scheduled Card Selections Response
Signature |
|
|---|---|
Since |
3.0 |
Description |
Analyses the responses provided by a |
Parameters |
|
Returns |
|
Pre-conditions |
Argument — every parameter is non- |
Errors |
|
Process Card Selection Scenario
Signature |
|
|---|---|
Since |
3.0 |
Description |
Explicitly executes the previously prepared selection scenario against the provided reader, processing every selection case regardless of intermediate successes, and returns the result. |
Parameters |
|
Returns |
|
Pre-conditions |
Argument — every parameter is non- |
Errors |
|
Schedule Card Selection Scenario
Signature |
|
|---|---|
Since |
3.0 |
Description |
Schedules the execution of the prepared selection scenario as soon as a card is presented to the supplied
observable reader. Events are pushed to the registered event handler according to the requested notification
policy. The result of the execution MUST be parsed via
|
Parameters |
|
Pre-conditions |
Argument — every parameter is non- |
Errors |
None. |
5.3.10. Single Card Selection Manager
Name |
|
|---|---|
Kind |
Interface |
Namespace |
|
Extends |
|
Since |
3.0 |
Purpose |
Card selection manager executing the scenario up to the first matching selection case: the first matching card application — for example the Calypso application of a Calypso card — or the card itself when it hosts no application, as a storage card. An instance is obtained via |
The selection cases are tried in the order in which they were prepared; the execution stops as soon as one of them
succeeds. The resulting SingleCardSelectionResult therefore exposes at
most one smart card. The scenario can be executed explicitly, on a card already present, or scheduled on an
ObservableCardReader.
Import Processed Card Selection Scenario
Signature |
|
|---|---|
Since |
3.0 |
Description |
Imports a previously exported processed selection scenario and returns the corresponding result. |
Parameters |
|
Returns |
|
Pre-conditions |
Argument — every parameter is non- |
Errors |
|
See also |
Parse Scheduled Card Selections Response
Signature |
|
|---|---|
Since |
3.0 |
Description |
Analyses the responses provided by a |
Parameters |
|
Returns |
|
Pre-conditions |
Argument — every parameter is non- |
Errors |
|
Process Card Selection Scenario
Signature |
|
|---|---|
Since |
3.0 |
Description |
Explicitly executes the previously prepared selection scenario against the provided reader, stopping at the first successful selection case, and returns the result. |
Parameters |
|
Returns |
|
Pre-conditions |
Argument — every parameter is non- |
Errors |
|
Schedule Card Selection Scenario
Signature |
|
|---|---|
Since |
3.0 |
Description |
Schedules the execution of the prepared selection scenario as soon as a card is presented to the supplied
observable reader. Events are pushed to the registered event handler according to the requested notification
policy. The result of the execution MUST be parsed via
|
Parameters |
|
Pre-conditions |
Argument — every parameter is non- |
Errors |
None. |
5.4. SPI Interfaces
5.4.1. Card Reader Event Handler
Name |
|
|---|---|
Kind |
Interface (SPI) |
Namespace |
|
Since |
3.0 |
Purpose |
Interface that the application MUST implement to receive reader events and observation errors from an |
This SPI unifies the reception of nominal events (onReaderEvent) and of fatal observation errors
(onReaderError) into a single contract, which the application implements once and registers at the call to
startCardDetection.
On Reader Error
Signature |
|
|---|---|
Since |
3.0 |
Description |
Called when a fatal error occurs on the observed reader. After the operation returns, the observation process is considered stopped. |
Parameters |
|
Pre-conditions |
Argument — every parameter is non- |
Errors |
None. |
On Reader Event
Signature |
|
|---|---|
Since |
3.0 |
Description |
Called when a reader event occurs. Dispatch is sequential and synchronous unless a different policy is explicitly documented. |
Parameters |
|
Pre-conditions |
Argument — every parameter is non- |
Errors |
None. Any error raised by the handler is routed to |
5.4.2. Card Selection Extension
Name |
|
|---|---|
Kind |
Marker interface (SPI) |
Namespace |
|
Since |
2.0 |
Purpose |
Provided by card extensions to enrich a selection case with additional commands and to interpret the response in order to build the corresponding |
This interface declares no operation at the API level; the contract between the selection manager and the extension is defined by the card extension specification consuming this SPI.
5.4.3. Card Transaction Manager
Name |
|
|---|---|
Kind |
Interface (SPI) |
Namespace |
|
Since |
2.1 |
Purpose |
Root contract common to every card transaction manager exposed by a card extension. Defines the single operation |
To exchange data with a card, the application first prepares the commands to transmit (via the operations of
the consuming card extension) and then processes them. The preparation step allows commands to be grouped to
minimise network exchanges, which is especially valuable in distributed architectures. The
SmartCard registered with the manager is updated after each data exchange with the card.
Process Commands
Signature |
|
|---|---|
Since |
3.0 |
Description |
Processes all previously prepared commands. All APDUs corresponding to the prepared commands are sent to the card, their responses retrieved and used
to update the |
Pre-conditions |
None. |
Errors |
|
5.4.4. ISO Card Transaction Manager
Name |
|
|---|---|
Kind |
Interface (SPI) |
Namespace |
|
Extends |
|
Since |
3.0 |
Purpose |
Intermediate contract for ISO/IEC 7816-4 cards. Exposes the on-demand cast to multi-channel. |
As Multichannel Card Transaction Manager
Signature |
|
|---|---|
Since |
3.0 |
Description |
Returns a view of this manager as a The conversion itself never fails. If the underlying ISO/IEC 7816-4 card does not support multi-channel
operation, an |
Returns |
|
Pre-conditions |
None. |
Errors |
None. |
5.4.5. ISO Smart Card
Name |
|
|---|---|
Kind |
Interface (SPI) |
Namespace |
|
Extends |
|
Since |
2.0 |
Purpose |
ISO/IEC 7816-4 smart card whose communication has been established after a successful selection. |
In addition to the inherited power-on data, an IsoSmartCard exposes the response to the Select Application
command. Both the power-on data and the Select Application response are optional, but at least one of them is
always present.
Get Select Application Response
Signature |
|
|---|---|
Since |
1.0 |
Description |
Returns the data received from the card in response to the Select Application command, including the status word. |
Returns |
The non-empty response bytes, or |
Pre-conditions |
None. |
Errors |
None. |
Is Basic Channel
Signature |
|
|---|---|
Since |
3.0 |
Description |
Indicates whether this smart card is attached to the basic channel (channel |
Returns |
|
Pre-conditions |
None. |
Errors |
None. |
5.4.6. Multichannel Card Transaction Manager
Name |
|
|---|---|
Kind |
Interface (SPI) |
Namespace |
|
Extends |
|
Since |
3.0 |
Purpose |
Multi-channel contract. Exposes the operations to close a logical channel explicitly. |
This contract MAY be obtained either:
-
through
IsoCardTransactionManager.asMultichannelCardTransactionManager, for ISO/IEC 7816-4 cards on which multi-channel is an optional capability; -
directly as the declared supertype of the transaction manager of a card extension targeting intrinsically multi-channel cards.
Close Channel
Signature |
|
|---|---|
Since |
3.0 |
Description |
Closes the underlying logical channel without processing any pending command. This operation is idempotent: calling it on an already-closed channel has no effect. |
Pre-conditions |
None. |
Errors |
|
Process Commands And Close Channel
Signature |
|
|---|---|
Since |
3.0 |
Description |
Processes all previously prepared commands and, upon success, closes the underlying logical channel. If any command fails, the channel is left open, as with |
Pre-conditions |
None. |
Errors |
|
5.4.7. Smart Card
Name |
|
|---|---|
Kind |
Interface (SPI) |
Namespace |
|
Since |
1.0 |
Purpose |
Basic smart card whose communication has been established after a successful selection. The instance is ready to receive APDUs. |
Card extensions implement (and may extend) this interface to expose the data they collected during the selection.
Get Power On Data
Signature |
|
|---|---|
Since |
1.0 |
Description |
Returns the card’s power-on data, as collected by the reader at the moment the card was inserted.
Because this data varies from one reader to another, it is exposed here as a |
Returns |
The non-empty power-on data, or |
Pre-conditions |
None. |
Errors |
None. |
Is Active
Signature |
|
|---|---|
Since |
3.0 |
Description |
Returns whether this smart card is currently active on its logical channel. A smart card is considered active between its creation (as the result of a successful selection case) and the
occurrence of any of the following events, at which point the reader deactivates it (
Until then, the reader holds the references to the |
Returns |
|
Pre-conditions |
None. |
Errors |
None. |
5.5. Enumerations
5.5.1. Card Presence Notification Policy
Name |
|
|---|---|
Kind |
Enumeration |
Namespace |
|
Since |
3.0 |
Purpose |
Options applied when a card is detected, used to decide which cards trigger event-handler notifications. |
In the reader observation lifecycle, this policy determines whether a detected card is treated as processable — see Reader observation lifecycle.
| Value | Since | Description |
|---|---|---|
|
3.0 |
All cards presented to the reader are notified, regardless of the result of the selection. |
|
3.0 |
Only cards that have been successfully selected are notified. The others are ignored. |
5.5.2. Card Reader Event Type
Name |
|
|---|---|
Kind |
Enumeration |
Namespace |
|
Since |
1.0 |
Purpose |
Possible card reader events. |
| Value | Since | Description |
|---|---|---|
|
1.0 |
A card has been inserted, with or without a specific selection. |
|
1.0 |
A card has been inserted that matches the selection criteria. |
|
1.0 |
The card has been removed from the reader. |
|
3.0 |
The reader has been unregistered and is no longer usable. |
5.5.3. Channel Selection Policy
Name |
|
|---|---|
Kind |
Enumeration |
Namespace |
|
Since |
3.0 |
Purpose |
Policy governing the use of the basic channel in a multi-channel selection scenario. |
| Value | Since | Description |
|---|---|---|
|
3.0 |
The basic channel (channel |
|
3.0 |
Selection cases are placed only on additional logical channels; the basic channel is not used. |
5.5.4. Detection Mode
Name |
|
|---|---|
Kind |
Enumeration |
Namespace |
|
Since |
3.0 |
Purpose |
Defines the behaviour to apply after a card processing cycle has terminated. |
In the reader observation lifecycle, this setting is the guard that decides whether detection resumes after a card-processing cycle — see Reader observation lifecycle.
| Value | Since | Description |
|---|---|---|
|
3.0 |
The reader continues waiting for the next card insertion. |
|
3.0 |
The reader stops detection after the current card-processing cycle; a new call to |
5.5.5. File Control Information
Name |
|
|---|---|
Kind |
Enumeration |
Namespace |
|
Since |
2.0 |
Purpose |
Types of templates returned in response to the Select Application command, according to ISO/IEC 7816-4. |
| Value | Since | Description |
|---|---|---|
|
2.0 |
File Control Information. |
|
2.0 |
File Control Parameters. |
|
2.0 |
File Management Data. |
|
2.0 |
No response expected. |
5.5.6. File Occurrence
Name |
|
|---|---|
Kind |
Enumeration |
Namespace |
|
Since |
2.0 |
Purpose |
Navigation options through the applications contained on the card according to ISO/IEC 7816-4. |
| Value | Since | Description |
|---|---|---|
|
2.0 |
First occurrence. |
|
2.0 |
Last occurrence. |
|
2.0 |
Next occurrence. |
|
2.0 |
Previous occurrence. |
5.6. Errors
Every error defined below carries two properties: message (String), which describes the condition, and
cause (Any?), the underlying error that triggered it, null when there is none. They are not
restated for each error.
5.6.1. Card Communication
Name |
|
|---|---|
Kind |
Error |
Namespace |
|
Since |
1.0 |
Purpose |
Indicates that the communication with the card has failed, typically because the card was removed from the reader before the exchange could complete. |
5.6.2. Invalid Card Response
Name |
|
|---|---|
Kind |
Error |
Namespace |
|
Since |
2.1 |
Purpose |
Indicates that a response received from the card was invalid — typically when the returned status word does not match any of those expected — either during a selection process or during the processing of a transaction. This error is also raised when an ISO/IEC 7816-4 card does not support a requested multi-channel operation. |
5.6.3. Reader Communication
Name |
|
|---|---|
Kind |
Error |
Namespace |
|
Since |
1.0 |
Purpose |
Indicates that the communication with the reader has failed. The most likely cause is a physical disconnection of the reader, but other technical problems MAY also be at the origin of the failure. |