Skip to content
This repository was archived by the owner on Jun 10, 2025. It is now read-only.

Commit 585a469

Browse files
feat: add the secure session "pre-open" variant (#53)
1 parent 823ef4b commit 585a469

File tree

5 files changed

+70
-41
lines changed

5 files changed

+70
-41
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Added
9+
- `CalypsoCardSelection.prepareReadBinary` method.
10+
- `CalypsoCardSelection.prepareReadCounter` method.
11+
- `CalypsoCardSelection.preparePreOpenSecureSession` method (pre-open secure session variant).
12+
### Upgraded
13+
- "Calypsonet Terminal Reader API" to version `1.2.0`
814

915
## [1.6.0] - 2023-02-17
1016
### Added

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ repositories {
2727
maven(url = "https://s01.oss.sonatype.org/content/repositories/snapshots")
2828
}
2929
dependencies {
30-
implementation("org.calypsonet.terminal:calypsonet-terminal-reader-java-api:1.1.0")
30+
implementation("org.calypsonet.terminal:calypsonet-terminal-reader-java-api:1.2.0")
3131
testImplementation("junit:junit:4.13.2")
3232
testImplementation("org.assertj:assertj-core:3.15.0")
3333
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
group = org.calypsonet.terminal
22
title = Calypsonet Terminal Calypso API
33
description = API defining the needed interfaces to manage Calypso cards
4-
version = 1.6.1
4+
version = 1.7.0
55

66
javaSourceLevel = 1.6
77
javaTargetLevel = 1.6

src/main/java/org/calypsonet/terminal/calypso/CalypsoApiProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class CalypsoApiProperties {
2323
*
2424
* @since 1.0.0
2525
*/
26-
public static final String VERSION = "1.6";
26+
public static final String VERSION = "1.7";
2727

2828
/** Private constructor */
2929
private CalypsoApiProperties() {}

src/main/java/org/calypsonet/terminal/calypso/card/CalypsoCardSelection.java

Lines changed: 61 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import org.calypsonet.terminal.calypso.GetDataTag;
1515
import org.calypsonet.terminal.calypso.SelectFileControl;
16+
import org.calypsonet.terminal.calypso.WriteAccessLevel;
1617
import org.calypsonet.terminal.reader.selection.spi.CardSelection;
1718

1819
/**
@@ -226,13 +227,13 @@ public interface CalypsoCardSelection extends CardSelection {
226227
CalypsoCardSelection prepareReadRecordFile(byte sfi, int recordNumber);
227228

228229
/**
229-
* Adds a command APDU to read a single record from the indicated EF.
230+
* Adds an APDU command to read a single record from the indicated Linear or Cyclic EF.
230231
*
231232
* <p>Once this command is processed, the result is available in {@link CalypsoCard} if the
232-
* requested file and record exist in the file structure of the card (best effort behavior).
233+
* requested file and record exist in the file structure of the card (best-effort mode).
233234
*
234-
* <p>Caution: the resulting APDU command must be compliant with PRIME revision 3 cards.
235-
* Therefore, the command may be rejected by some earlier revision cards.
235+
* <p>Caution: the resulting APDU command is compliant with PRIME revision 3 cards. Therefore, the
236+
* command may be rejected by some earlier revision cards.
236237
*
237238
* @param sfi The SFI of the EF to read
238239
* @param recordNumber The record number to read.
@@ -242,40 +243,62 @@ public interface CalypsoCardSelection extends CardSelection {
242243
*/
243244
CalypsoCardSelection prepareReadRecord(byte sfi, int recordNumber);
244245

245-
// /**
246-
// * Adds an APDU command to attempt a secure session pre-opening. For cards that support this
247-
// * feature, this optimizes exchanges with the card in the case of deterministic secure
248-
// sessions
249-
// * that can be executed in a single step.
250-
// *
251-
// * <p>The use of this method or one of the following methods is a prerequisite for the use of
252-
// the
253-
// * {@link CardTransactionManager#processPreOpenedSecureSession()} method:
254-
// *
255-
// * <ul>
256-
// * <li>{@link #preparePreOpenSecureSession(WriteAccessLevel, byte, int)}
257-
// * <li>{@link CardTransactionManager#preparePreOpenSecureSession(WriteAccessLevel)}
258-
// * <li>{@link CardTransactionManager#preparePreOpenSecureSession(WriteAccessLevel, byte,
259-
// int)}
260-
// * </ul>
261-
// *
262-
// * It is not advised to use it in other cases.
263-
// *
264-
// * <p>The secure session opening which will be done by {@link
265-
// * CardTransactionManager#processPreOpenedSecureSession()} will use the same parameters (same
266-
// * {@link WriteAccessLevel}, no record reading).
267-
// *
268-
// * @param writeAccessLevel The write access level.
269-
// * @return The object instance.
270-
// * @throws IllegalArgumentException If writeAccessLevel is null.
271-
// * @throws IllegalStateException If "Pre-Open" command is already prepared.
272-
// * @see #preparePreOpenSecureSession(WriteAccessLevel, byte, int)
273-
// * @see CardTransactionManager#preparePreOpenSecureSession(WriteAccessLevel)
274-
// * @see CardTransactionManager#preparePreOpenSecureSession(WriteAccessLevel, byte, int)
275-
// * @see CardTransactionManager#processPreOpenedSecureSession()
276-
// * @since 1.6.0
277-
// */
278-
// CalypsoCardSelection preparePreOpenSecureSession(WriteAccessLevel writeAccessLevel);
246+
/**
247+
* Adds one or multiple APDU commands to read all or part of the indicated Binary EF.
248+
*
249+
* <p>Once this command is processed, the result is available in {@link CalypsoCard} if the
250+
* requested file exist in the file structure of the card and if the offset and number of bytes to
251+
* read are valid (best-effort mode).
252+
*
253+
* <p>Caution: the resulting APDU command is compliant with PRIME revision 3 cards. Therefore, the
254+
* command may be rejected by some earlier revision cards.
255+
*
256+
* @param sfi The SFI of the EF.
257+
* @param offset The offset (0 indicates the first byte).
258+
* @param nbBytesToRead The number of bytes to read.
259+
* @return The current instance.
260+
* @throws IllegalArgumentException If one of the provided argument is out of range.
261+
* @since 1.7.0
262+
*/
263+
CalypsoCardSelection prepareReadBinary(byte sfi, int offset, int nbBytesToRead);
264+
265+
/**
266+
* Adds an APDU command to read a part of a record of the indicated EF, which should be a counter
267+
* file.
268+
*
269+
* <p>The record will be read up to the counter location indicated in parameter.<br>
270+
* Thus, all previous counters will also be read.
271+
*
272+
* <p>Once this command is processed, the result is available in {@link CalypsoCard} if the
273+
* requested file and the counter number exist in the file structure of the card (best-effort
274+
* mode).
275+
*
276+
* <p>Caution: the resulting APDU command is compliant with PRIME revision 3 cards. Therefore, the
277+
* command may be rejected by some earlier revision cards.
278+
*
279+
* @param sfi The SFI of the EF.
280+
* @param nbCountersToRead The number of counters to read.
281+
* @return The current instance.
282+
* @throws IllegalArgumentException If one of the provided argument is out of range.
283+
* @since 1.7.0
284+
*/
285+
CalypsoCardSelection prepareReadCounter(byte sfi, int nbCountersToRead);
286+
287+
/**
288+
* Adds an APDU command to attempt a secure session pre-opening. For cards that support this
289+
* feature, this optimizes future exchanges with the card in the case of secure sessions intended
290+
* to be executed in a single step.
291+
*
292+
* <p>Caution: the resulting APDU command is compliant with PRIME revision 3 cards supporting the
293+
* extended mode. Therefore, the command may be rejected by some earlier revision cards.
294+
*
295+
* @param writeAccessLevel The write access level.
296+
* @return The object instance.
297+
* @throws IllegalArgumentException If writeAccessLevel is null.
298+
* @throws IllegalStateException If "Pre-Open" command is already prepared.
299+
* @since 1.7.0
300+
*/
301+
CalypsoCardSelection preparePreOpenSecureSession(WriteAccessLevel writeAccessLevel);
279302

280303
/**
281304
* Navigation options through the different applications contained in the card according to the

0 commit comments

Comments
 (0)