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

Commit 135e2de

Browse files
feat: add SAM event counters and ceilings management (#49)
1 parent c4cc756 commit 135e2de

File tree

8 files changed

+242
-76
lines changed

8 files changed

+242
-76
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ 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+
- `prepareWriteEventCeiling`, `prepareWriteEventCeilings` methods to `SamTransactionManager` API (issue [#25])
10+
- `prepareReadEventCeiling`, `prepareReadEventCeilings` methods to `SamTransactionManager` and `getEventCeiling`, `getEventCeilings` methods to `CalypsoSam` API (issue [#26])
11+
- `prepareReadEventCounter`, `prepareReadEventCounters` methods to `SamTransactionManager` and `getEventCounter`, `getEventCounters` methods to `CalypsoSam` API (issue [#27])
812

913
## [1.3.0] - 2022-10-04
1014
### Added
@@ -110,6 +114,9 @@ This is the initial release.
110114
[#38]: https://github.com/calypsonet/calypsonet-terminal-calypso-java-api/issues/38
111115
[#29]: https://github.com/calypsonet/calypsonet-terminal-calypso-java-api/issues/29
112116
[#28]: https://github.com/calypsonet/calypsonet-terminal-calypso-java-api/issues/28
117+
[#27]: https://github.com/calypsonet/calypsonet-terminal-calypso-java-api/issues/27
118+
[#26]: https://github.com/calypsonet/calypsonet-terminal-calypso-java-api/issues/26
119+
[#25]: https://github.com/calypsonet/calypsonet-terminal-calypso-java-api/issues/25
113120
[#24]: https://github.com/calypsonet/calypsonet-terminal-calypso-java-api/issues/24
114121
[#23]: https://github.com/calypsonet/calypsonet-terminal-calypso-java-api/issues/23
115122
[#22]: https://github.com/calypsonet/calypsonet-terminal-calypso-java-api/issues/22

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.3.1
4+
version = 1.4.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.3";
26+
public static final String VERSION = "1.4";
2727

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public interface FileData {
5656
/**
5757
* Gets a reference to all known records content.
5858
*
59-
* @return a not null map eventually empty if there's no content.
59+
* @return a not null map possibly empty if there's no content.
6060
* @since 1.0.0
6161
*/
6262
SortedMap<Integer, byte[]> getAllRecordsContent();

src/main/java/org/calypsonet/terminal/calypso/sam/CalypsoSam.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
************************************************************************************** */
1212
package org.calypsonet.terminal.calypso.sam;
1313

14+
import java.util.SortedMap;
1415
import org.calypsonet.terminal.reader.selection.spi.SmartCard;
1516

1617
/**
@@ -141,4 +142,40 @@ enum ProductType {
141142
*/
142143
UNKNOWN
143144
}
145+
146+
/**
147+
* Returns the value of an event counter.
148+
*
149+
* @param eventCounterNumber The number of the event counter (in range [0..26]).
150+
* @return null if the event counter value is not set.
151+
* @since 1.4.0
152+
*/
153+
Integer getEventCounter(int eventCounterNumber);
154+
155+
/**
156+
* Returns the value of known event counters in a sorted map where {@code key} is the counter
157+
* number and {@code value} is the counter value.
158+
*
159+
* @return a not null map.
160+
* @since 1.4.0
161+
*/
162+
SortedMap<Integer, Integer> getEventCounters();
163+
164+
/**
165+
* Returns the value of an event ceiling.
166+
*
167+
* @param eventCeilingNumber The number of the event ceiling (in range [0..26]).
168+
* @return null if the event ceiling value is not set.
169+
* @since 1.4.0
170+
*/
171+
Integer getEventCeiling(int eventCeilingNumber);
172+
173+
/**
174+
* Returns the value of known event ceilings in a sorted map where {@code key} is the ceiling
175+
* number and {@code value} is the ceiling value.
176+
*
177+
* @return a not null map.
178+
* @since 1.4.0
179+
*/
180+
SortedMap<Integer, Integer> getEventCeilings();
144181
}

src/main/java/org/calypsonet/terminal/calypso/transaction/SamTransactionManager.java

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
************************************************************************************** */
1212
package org.calypsonet.terminal.calypso.transaction;
1313

14+
import java.util.List;
1415
import org.calypsonet.terminal.calypso.sam.CalypsoSam;
1516
import org.calypsonet.terminal.reader.CardReader;
1617

@@ -55,4 +56,89 @@ public interface SamTransactionManager
5556
* @since 1.2.0
5657
*/
5758
CalypsoSam getCalypsoSam();
59+
60+
/**
61+
* Schedules the execution of a <b>Read Event Counter</b> command to read a single event counter.
62+
*
63+
* <p>Once this command is processed, the result is available in {@link CalypsoSam}.
64+
*
65+
* @param eventCounterNumber The number of the event counter to read (in range [0..26]).
66+
* @return The current instance.
67+
* @throws IllegalArgumentException If the provided argument is out of range.
68+
* @since 1.4.0
69+
*/
70+
SamTransactionManager prepareReadEventCounter(int eventCounterNumber);
71+
72+
/**
73+
* Schedules the execution of a <b>Read Event Counter</b> command to read one or more consecutive
74+
* event counters.
75+
*
76+
* <p>Once this command is processed, the result is available in {@link CalypsoSam}.
77+
*
78+
* @param fromEventCounterNumber The number of the first event counter to read (in range [0..26]).
79+
* @param toEventCounterNumber The number of the last event counter to read (in range [0..26]).
80+
* @return The current instance.
81+
* @throws IllegalArgumentException If one of the provided argument is out of range.
82+
* @since 1.4.0
83+
*/
84+
SamTransactionManager prepareReadEventCounters(
85+
int fromEventCounterNumber, int toEventCounterNumber);
86+
87+
/**
88+
* Schedules the execution of a <b>Read Ceilings</b> command to read a single event ceiling.
89+
*
90+
* <p>Once this command is processed, the result is available in {@link CalypsoSam}.
91+
*
92+
* @param eventCeilingNumber The number of the event ceiling to read (in range [0..26]).
93+
* @return The current instance.
94+
* @throws IllegalArgumentException If the provided argument is out of range.
95+
* @since 1.4.0
96+
*/
97+
SamTransactionManager prepareReadEventCeiling(int eventCeilingNumber);
98+
99+
/**
100+
* Schedules the execution of a <b>Read Ceilings</b> command to read one or more consecutive event
101+
* ceilings.
102+
*
103+
* <p>Once this command is processed, the result is available in {@link CalypsoSam}.
104+
*
105+
* @param fromEventCeilingNumber The number of the first event ceiling to read (in range [0..26]).
106+
* @param toEventCeilingNumber The number of the last event ceiling to read (in range [0..26]).
107+
* @return The current instance.
108+
* @throws IllegalArgumentException If one of the provided argument is out of range.
109+
* @since 1.4.0
110+
*/
111+
SamTransactionManager prepareReadEventCeilings(
112+
int fromEventCeilingNumber, int toEventCeilingNumber);
113+
114+
/**
115+
* Schedules the execution of a <b>Write Ceilings</b> command to write a single event ceiling.
116+
*
117+
* <p>Once this command is processed, the ceiling value available in {@link CalypsoSam} is
118+
* updated.
119+
*
120+
* @param eventCeilingNumber The number of the event ceiling to write.
121+
* @param newValue The desired value for the event ceiling (defined as a positive int {@code <=}
122+
* 16777215 [FFFFFFh]).
123+
* @return The current instance.
124+
* @throws IllegalArgumentException If the provided argument is out of range.
125+
* @since 1.4.0
126+
*/
127+
SamTransactionManager prepareWriteEventCeiling(int eventCeilingNumber, int newValue);
128+
129+
/**
130+
* Schedules the execution of a <b>Write Ceilings</b> command to write multiple event ceilings.
131+
*
132+
* <p>Once this command is processed, the ceiling values available in {@link CalypsoSam} are
133+
* updated.
134+
*
135+
* @param fromEventCeilingNumber The number of the first event ceiling to write.
136+
* @param newValues A list of event ceilings values to be written from the indicated position
137+
* (each event ceiling value is defined as a positive int {@code <=} 16777215 [FFFFFFh]).
138+
* @return The current instance.
139+
* @throws IllegalArgumentException If one of the provided argument is out of range.
140+
* @since 1.4.0
141+
*/
142+
SamTransactionManager prepareWriteEventCeilings(
143+
int fromEventCeilingNumber, List<Integer> newValues);
58144
}

src/main/uml/api_class_diagram.puml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@startuml
22
title
3-
Calypsonet - calypsonet-terminal-calypso-java-api - 1.3.+ (2022-10-04)
3+
Calypsonet - calypsonet-terminal-calypso-java-api - 1.4.+ (2022-10-10)
44
end title
55

66
' == THEME ==
@@ -261,6 +261,11 @@ package "org.calypsonet.terminal.calypso" as api {
261261
+byte getSoftwareIssuer ()
262262
+byte getSoftwareVersion ()
263263
+byte getSoftwareRevision ()
264+
265+
+Integer getEventCounter (int eventCounterNumber)
266+
+SortedMap<Integer, Integer> getEventCounters ()
267+
+Integer getEventCeiling (int eventCeilingNumber)
268+
+SortedMap<Integer, Integer> getEventCeilings ()
264269
}
265270
+enum "ProductType" as SamProductType {
266271
SAM_C1
@@ -416,6 +421,13 @@ package "org.calypsonet.terminal.calypso" as api {
416421
+interface SamTransactionManager extends CommonTransactionManager {
417422
+<back:yellow>CardReader</back> getSamReader ()
418423
+CalypsoSam getCalypsoSam ()
424+
425+
+SamTransactionManager prepareReadEventCounter (int eventCounterNumber)
426+
+SamTransactionManager prepareReadEventCounters (int fromEventCounterNumber, int toEventCounterNumber)
427+
+SamTransactionManager prepareReadEventCeiling (int eventCeilingNumber)
428+
+SamTransactionManager prepareReadEventCeilings (int fromEventCeilingNumber, int toEventCeilingNumber)
429+
+SamTransactionManager prepareWriteEventCeiling (int eventCeilingNumber, int newValue)
430+
+SamTransactionManager prepareWriteEventCeilings (int fromEventCeilingNumber, List<Integer> newValues)
419431
}
420432
+interface SamSecuritySetting extends CommonSecuritySetting {
421433
}

0 commit comments

Comments
 (0)