summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCGantert345 <57003061+CGantert345@users.noreply.github.com>2021-05-12 14:00:22 +0200
committerCGantert345 <57003061+CGantert345@users.noreply.github.com>2021-05-12 14:00:22 +0200
commit9c27db0284c86583c135282e637f5e4dcb220c89 (patch)
tree597775f5246e830877d59ff275d7b757d6646dc8
parentupdate (diff)
downloadUIC-barcode-9c27db0284c86583c135282e637f5e4dcb220c89.tar
UIC-barcode-9c27db0284c86583c135282e637f5e4dcb220c89.tar.gz
UIC-barcode-9c27db0284c86583c135282e637f5e4dcb220c89.tar.bz2
UIC-barcode-9c27db0284c86583c135282e637f5e4dcb220c89.tar.lz
UIC-barcode-9c27db0284c86583c135282e637f5e4dcb220c89.tar.xz
UIC-barcode-9c27db0284c86583c135282e637f5e4dcb220c89.tar.zst
UIC-barcode-9c27db0284c86583c135282e637f5e4dcb220c89.zip
-rw-r--r--misc/dynamicContentDFCB1.asn90
-rw-r--r--misc/dynamicContentFDCv1.0.asn115
-rw-r--r--src/main/java/org/uic/barcode/Encoder.java6
-rw-r--r--src/main/java/org/uic/barcode/dynamicContent/dfcb1/UicDynamicContentData1.java268
-rw-r--r--src/main/java/org/uic/barcode/dynamicContent/fdc1/ExtensionData.java (renamed from src/main/java/org/uic/barcode/dynamicContent/dfcb1/ExtensionData.java)2
-rw-r--r--src/main/java/org/uic/barcode/dynamicContent/fdc1/GeoCoordinateSystemType.java (renamed from src/main/java/org/uic/barcode/dynamicContent/dfcb1/GeoCoordinateSystemType.java)2
-rw-r--r--src/main/java/org/uic/barcode/dynamicContent/fdc1/GeoCoordinateType.java (renamed from src/main/java/org/uic/barcode/dynamicContent/dfcb1/GeoCoordinateType.java)2
-rw-r--r--src/main/java/org/uic/barcode/dynamicContent/fdc1/GeoUnitType.java (renamed from src/main/java/org/uic/barcode/dynamicContent/dfcb1/GeoUnitType.java)2
-rw-r--r--src/main/java/org/uic/barcode/dynamicContent/fdc1/HemisphereLatitudeType.java (renamed from src/main/java/org/uic/barcode/dynamicContent/dfcb1/HemisphereLatitudeType.java)2
-rw-r--r--src/main/java/org/uic/barcode/dynamicContent/fdc1/HemisphereLongitudeType.java (renamed from src/main/java/org/uic/barcode/dynamicContent/dfcb1/HemisphereLongitudeType.java)2
-rw-r--r--src/main/java/org/uic/barcode/dynamicContent/fdc1/SequenceOfExtension.java11
-rw-r--r--src/main/java/org/uic/barcode/dynamicContent/fdc1/TimeStamp.java144
-rw-r--r--src/main/java/org/uic/barcode/dynamicContent/fdc1/UicDynamicContentDataFDC1.java205
-rw-r--r--src/main/java/org/uic/barcode/dynamicFrame/DynamicFrame.java10
-rw-r--r--src/main/java/org/uic/barcode/staticFrame/UHEADDataRecord.java2
15 files changed, 490 insertions, 373 deletions
diff --git a/misc/dynamicContentDFCB1.asn b/misc/dynamicContentDFCB1.asn
deleted file mode 100644
index 7ca6d41..0000000
--- a/misc/dynamicContentDFCB1.asn
+++ /dev/null
@@ -1,90 +0,0 @@
--- ##########################################################################################
--- #
--- # FCB Dynamic Content for UicBarcodeHeader.level2SignedData.level2Data.data
--- # (identified as "FDC1" in UicBarcodeHeader.level2SignedData.level2Data.dataFormat)
--- #
--- # Draft version 0.1
--- #
--- ##########################################################################################
- UicDynamicContentData ::= SEQUENCE {
-
- -- Moment of generation of the dynamic content, expressed in UTC :
- -- * dynamicContentDay is the number of days from issuing date
- -- (UicRailTicketData.issuingDetail.issuingYear and issuingDay)
- -- The range 0..1070 allows a validity equal to that of the validFrom (700) plus
- -- validUntil (370) elements of the different transport documents of UicRailTicketData.
- -- * dynamicContentTime is the number of seconds of the day
- -- (from 0 = 0:00:00 to 86399 = 23:59:59)
- -- These two elements shall be either both present, either both absent
- dynamicContentDay INTEGER (0..1070) DEFAULT 0,
- dynamicContentTime INTEGER (0..86399) OPTIONAL,
-
- -- Coordinates of the place where the dynamic content has been generated
- -- (same GeoCoordinateType type as in UicRailTicketData)
- dynamicContentGeoCoordinate GeoCoordinateType OPTIONAL,
-
- -- Response from the mobile to any data received from the terminal.
- -- The data received from the terminal may be a random number, or any other information.
- -- The response may be the data itself, a hashing of this data, or any other response.
- -- This response may be completed with other information: IMEI, mobile phone number...
- -- The type used is ExtensionData, as it is fully adapted.
- -- extensionId shall be set to:
- -- * "=" if the data included in extensionData is exactly the one that was transmitted by the terminal,
- -- * any other value (chosen by the issuer) in other cases.
- dynamicContentResponseToChallenge ExtensionData OPTIONAL,
-
- -- proprietary data defined bilaterally
- dynamicContentExtension ExtensionData OPTIONAL,
-
- -- challenge string asked by the TCO
- challengeString IA5String OPTIONAL,
-
- -- phoneIdHash hashed phone id to be made available via 90918-4 ticket control data
- phoneIdHash OCTETSTRING OPTIONAL,
-
- -- e-passport-id hash to be read by the phone at control and to be made available via 90918-4 ticket control data
- phoneIdHash OCTETSTRING OPTIONAL,
- ...
- }
-
- -- ##########################################################################################
- -- # Generic type for geo coordinates
- -- ##########################################################################################
- GeoCoordinateType ::= SEQUENCE {
- geoUnit GeoUnitType DEFAULT milliDegree,
- coordinateSystem GeoCoordinateSystemType DEFAULT wgs84,
- hemisphereLongitude HemisphereLongitudeType DEFAULT north, -- separate hemishpere flag reduces the data size
- hemisphereLatitude HemisphereLatitudeType DEFAULT east, -- separate hemishpere flag reduces the data size
- longitude INTEGER,
- latitude INTEGER,
- accuracy GeoUnitType OPTIONAL
- }
-
- GeoCoordinateSystemType ::= ENUMERATED {
- wgs84 (0), -- WGS 84 standard system
- grs80 (1) -- (outdated) GRS 80 coordinate system
- }
-
- GeoUnitType ::= ENUMERATED {
- microDegree (0), -- approx. 11 cm on earth surface
- tenthmilliDegree (1), -- 1 / 10000 degree is approx. 11 meter on earth surface
- milliDegree (2), -- approx 110 meter on earth surface
- centiDegree (3),
- deciDegree (4)
- }
-
- HemisphereLongitudeType ::= ENUMERATED {
- north (0),
- south (1)
- }
-
- HemisphereLatitudeType ::= ENUMERATED {
- east (0),
- west (1)
- }
-
- -- ###########################################################################################
- ExtensionData ::= SEQUENCE {
- extensionId IA5String,
- extensionData OCTET STRING
- } \ No newline at end of file
diff --git a/misc/dynamicContentFDCv1.0.asn b/misc/dynamicContentFDCv1.0.asn
new file mode 100644
index 0000000..693980f
--- /dev/null
+++ b/misc/dynamicContentFDCv1.0.asn
@@ -0,0 +1,115 @@
+-- ##########################################################################################
+-- #
+-- # FCB Dynamic Content - Version 1.0 - Draft #3 (2021-05-12)
+-- #
+-- # This file is available on the UIC FCB User Group GitHub:
+-- # <GitHub-link-to-be-added-here>
+-- # Please check this link to see if a more recent version of this file is available.
+-- #
+-- # The type UicDynamicContentData defined below is at least intended to generate a data
+-- # that, once valued and encoded as PER unaligned [UPER],
+-- # is to be stored in UicBarcodeHeader.level2SignedData.level2Data.data,
+-- # and identified as "FDC1" in UicBarcodeHeader.level2SignedData.level2Data.dataFormat.
+-- #
+-- ##########################################################################################
+ UicDynamicContentData ::= SEQUENCE {
+
+ -- Identification of the mobile application that generated the barcode
+ -- and filled in the data of its dynamic part.
+ --
+ -- The possible values are defined by the security provider
+ -- (the security provider being UicBarcodeHeader.level2SignedData.level1Data.securityProviderNum/IA5)
+ dynamicContentMobileAppId IA5String OPTIONAL,
+
+ -- Moment of generation of the dynamic content, expressed in UTC
+ dynamicContentTimeStamp TimeStampData OPTIONAL,
+
+ -- Coordinates of the place where the dynamic content has been generated
+ -- (same GeoCoordinateType type as in UicRailTicketData)
+ dynamicContentGeoCoordinate GeoCoordinateType OPTIONAL,
+
+ -- Response from the mobile to any data received from the terminal.
+ -- The data received from the terminal may be a random number, or any other information.
+ -- The response may be the received data itself, possibly completed with other information
+ -- (e.g. IMEI, mobile phone number, user identifier assigned by the phone-app...),
+ -- the whole being returned as is, or hashed, or modified in some way.
+ --
+ -- The type used is a SEQUENCE OF ExtensionData
+ -- (the same ExtensionData type as in UicRailTicketData, as it is fully adapted),
+ -- in which extensionId identifies the content of extensionData.
+ --
+ -- Two types of value are possible for extensionId:
+ -- * predefined standardized values
+ -- (e.g. "=" if extensionData is exactly the data received from the terminal)
+ -- The list of predefined values is available on the UIC FCB User Group GitHub.
+ -- * "_" followed by any other value, defined by the security provider, in other cases.
+ -- (the security provider being UicBarcodeHeader.level2SignedData.level1Data.securityProviderNum/IA5)
+ dynamicContentResponseToChallenge SEQUENCE OF ExtensionData OPTIONAL,
+
+ -- Proprietary data defined bilaterally
+ -- (same ExtensionData type as in UicRailTicketData).
+ -- extensionId identifies the content of extensionData,
+ -- it shall be set to "_" + RICS + addon chosen by the issuer identified by its RICS code
+ dynamicContentExtension ExtensionData OPTIONAL,
+
+ ...
+ }
+
+ -- ##########################################################################################
+ -- # Generic type for timestamp, with a precision to the second.
+ -- #
+ -- # Day is the number of the day in the year (1 = January 1st, 2 = January 2nd...)
+ -- #
+ -- # Time is the number of seconds of the day (from 0 = 0:00:00 to 86399 = 23:59:59)
+ -- ##########################################################################################
+ TimeStampData ::= SEQUENCE {
+ day INTEGER (1..366),
+ time INTEGER (0..86399)
+ }
+
+ -- ##########################################################################################
+ -- # Generic type for geo coordinates.
+ -- ##########################################################################################
+ GeoCoordinateType ::= SEQUENCE {
+ geoUnit GeoUnitType DEFAULT milliDegree,
+ coordinateSystem GeoCoordinateSystemType DEFAULT wgs84,
+ hemisphereLongitude HemisphereLongitudeType DEFAULT north, -- separate hemisphere flag reduces the data size
+ hemisphereLatitude HemisphereLatitudeType DEFAULT east, -- separate hemisphere flag reduces the data size
+ longitude INTEGER,
+ latitude INTEGER,
+ accuracy GeoUnitType OPTIONAL
+ }
+
+ GeoCoordinateSystemType ::= ENUMERATED {
+ wgs84 (0), -- WGS 84 standard system
+ grs80 (1) -- (outdated) GRS 80 coordinate system
+ }
+
+ GeoUnitType ::= ENUMERATED {
+ microDegree (0), -- approx. 11 cm on earth surface
+ tenthmilliDegree (1), -- 1 / 10000 degree is approx. 11 meter on earth surface
+ milliDegree (2), -- approx 110 meter on earth surface
+ centiDegree (3),
+ deciDegree (4)
+ }
+
+ HemisphereLongitudeType ::= ENUMERATED {
+ north (0),
+ south (1)
+ }
+
+ HemisphereLatitudeType ::= ENUMERATED {
+ east (0),
+ west (1)
+ }
+
+ -- ###########################################################################################
+ -- # Generic extension element.
+ -- #
+ -- # extensionId identifies the content of extensionData.
+ -- ###########################################################################################
+ ExtensionData ::= SEQUENCE {
+ extensionId IA5String,
+ extensionData OCTET STRING
+ }
+ \ No newline at end of file
diff --git a/src/main/java/org/uic/barcode/Encoder.java b/src/main/java/org/uic/barcode/Encoder.java
index 29ce63d..d971214 100644
--- a/src/main/java/org/uic/barcode/Encoder.java
+++ b/src/main/java/org/uic/barcode/Encoder.java
@@ -5,7 +5,7 @@ import java.security.PrivateKey;
import java.security.PublicKey;
import org.uic.barcode.asn1.datatypesimpl.OctetString;
-import org.uic.barcode.dynamicContent.dfcb1.UicDynamicContentData1;
+import org.uic.barcode.dynamicContent.fdc1.UicDynamicContentDataFDC1;
import org.uic.barcode.dynamicFrame.Constants;
import org.uic.barcode.dynamicFrame.DataType;
import org.uic.barcode.dynamicFrame.DynamicFrame;
@@ -166,7 +166,7 @@ public class Encoder {
}
}
- public void setDynamicContentDataUIC1(UicDynamicContentData1 dcd) {
+ public void setDynamicContentDataUIC1(UicDynamicContentDataFDC1 dcd) {
if (dynamicFrame != null) {
if (dynamicFrame.getLevel2SignedData() == null) {
dynamicFrame.setLevel2SignedData(new Level2DataType());
@@ -182,7 +182,7 @@ public class Encoder {
return null;
}
- public UicDynamicContentData1 getDynamicContentDataUIC1() {
+ public UicDynamicContentDataFDC1 getDynamicContentDataUIC1() {
if (dynamicFrame != null && dynamicFrame.getLevel2SignedData() != null) {
return dynamicFrame.getDynamicDataFDC1();
}
diff --git a/src/main/java/org/uic/barcode/dynamicContent/dfcb1/UicDynamicContentData1.java b/src/main/java/org/uic/barcode/dynamicContent/dfcb1/UicDynamicContentData1.java
deleted file mode 100644
index 034057a..0000000
--- a/src/main/java/org/uic/barcode/dynamicContent/dfcb1/UicDynamicContentData1.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- *
- */
-package org.uic.barcode.dynamicContent.dfcb1;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.TimeZone;
-
-import org.uic.barcode.asn1.datatypes.Asn1Default;
-import org.uic.barcode.asn1.datatypes.Asn1Optional;
-import org.uic.barcode.asn1.datatypes.CharacterRestriction;
-import org.uic.barcode.asn1.datatypes.FieldOrder;
-import org.uic.barcode.asn1.datatypes.HasExtensionMarker;
-import org.uic.barcode.asn1.datatypes.IntRange;
-import org.uic.barcode.asn1.datatypes.RestrictedString;
-import org.uic.barcode.asn1.datatypes.Sequence;
-import org.uic.barcode.asn1.datatypesimpl.OctetString;
-import org.uic.barcode.asn1.uper.UperEncoder;
-import org.uic.barcode.dynamicFrame.DataType;
-
-
-/**
- * The Class UicDynamicContentData.
- *
- * The dynamic content for FDC1
- *
- */
-
-
-@Sequence
-@HasExtensionMarker
-public class UicDynamicContentData1 {
-
- //-- Moment of generation of the dynamic content, expressed in UTC :
- //-- * dynamicContentDay is the number of days from issuing date
- //-- (UicRailTicketData.issuingDetail.issuingYear and issuingDay)
- // -- The range 0..1070 allows a validity equal to that of the validFrom (700) plus
- // -- validUntil (370) elements of the different transport documents of UicRailTicketData.
- //-- * dynamicContentTime is the number of seconds of the day
- //-- (from 0 = 0:00:00 to 86399 = 23:59:59)
- //-- These two elements shall be either both present, either both absent
- /** The day. */
- //dynamicContentDay INTEGER (0..1070) DEFAULT 0,
- @FieldOrder(order = 0)
- @Asn1Default(value="0")
- @IntRange(minValue=0, maxValue=1070)
- public Long day;
-
- /** The second of day. */
- // dynamicContentTime INTEGER (0..86399) OPTIONAL,
- @FieldOrder(order = 1)
- @IntRange(minValue=0, maxValue=86399)
- public Long secondOfDay;
-
- //-- Coordinates of the place where the dynamic content has been generated
- // -- (same GeoCoordinateType type as in UicRailTicketData)
- /** The geo coordinate. */
- //dynamicContentGeoCoordinate GeoCoordinateType OPTIONAL,
- @FieldOrder(order = 2)
- @Asn1Optional public GeoCoordinateType geoCoordinate;
- //-- Response from the mobile to any data received from the terminal.
- //-- The data received from the terminal may be a random number, or any other information.
- //-- The response may be the data itself, a hashing of this data, or any other response.
- // -- This response may be completed with other information: IMEI, mobile phone number...
- //-- The type used is ExtensionData, as it is fully adapted.
- // -- extensionId shall be set to:
- // -- * "=" if the data included in extensionData is exactly the one that was transmitted by the terminal,
- // -- * any other value (chosen by the issuer) in other cases.
- /** The challenge response. */
- //dynamicContentResponseToChallenge ExtensionData OPTIONAL,
- @FieldOrder(order = 3)
- @Asn1Optional public ExtensionData challengeResponse;
-
- /** The extension. */
- //-- proprietary data defined bilaterally
- @FieldOrder(order = 4)
- @Asn1Optional public ExtensionData extension;
- //dynamicContentExtension ExtensionData OPTIONAL,
-
- // challenge string asked by the TCO
- @FieldOrder(order = 5)
- @RestrictedString(CharacterRestriction.IA5String)
- @Asn1Optional public String challengeString;
-
- // hashed phone id
- @FieldOrder(order = 6)
- public OctetString phoneIdHash;
-
- // hashed e-passport-id
- @FieldOrder(order = 7)
- public OctetString passHash;
-
- //...
-
- /**
- * Gets the day.
- *
- * @return the day
- */
- public Long getDay() {
- return day;
- }
-
- /**
- * Sets the day.
- *
- * @param day the new day
- */
- public void setDay(Long day) {
- this.day = day;
- }
-
- /**
- * Gets the time.
- *
- * @return the time
- */
- public Long getTime() {
- return secondOfDay;
- }
-
- /**
- * Sets the time.
- *
- * @param time the new time
- */
- public void setTime(Long time) {
- this.secondOfDay = time;
- }
-
- /**
- * Gets the geo coordinate.
- *
- * @return the geo coordinate
- */
- public GeoCoordinateType getGeoCoordinate() {
- return geoCoordinate;
- }
-
- /**
- * Sets the geo coordinate.
- *
- * @param geoCoordinate the new geo coordinate
- */
- public void setGeoCoordinate(GeoCoordinateType geoCoordinate) {
- this.geoCoordinate = geoCoordinate;
- }
-
- /**
- * Gets the challenge response.
- *
- * @return the challenge response
- */
- public ExtensionData getChallengeResponse() {
- return challengeResponse;
- }
-
- /**
- * Sets the challenge response.
- *
- * @param challengeResponse the new challenge response
- */
- public void setChallengeResponse(ExtensionData challengeResponse) {
- this.challengeResponse = challengeResponse;
- }
-
- /**
- * Gets the extension.
- *
- * @return the extension
- */
- public ExtensionData getExtension() {
- return extension;
- }
-
- /**
- * Sets the extension.
- *
- * @param extension the new extension
- */
- public void setExtension(ExtensionData extension) {
- this.extension = extension;
- }
-
- /**
- * Gets the time.
- *
- * @param issuingDate the issuing date in UTC
- * @return the date and time of content creation in UTC
- */
- public Date getTime(Date issuingDate) {
-
- Calendar cal = Calendar.getInstance();
- cal.setTime(issuingDate);
- cal.setTimeZone(TimeZone.getTimeZone("UTC"));
- cal.set(Calendar.SECOND,0);
- cal.set(Calendar.HOUR,0);
- cal.set(Calendar.MINUTE,0);
- cal.add(Calendar.DATE, day.intValue());
- cal.add(Calendar.SECOND, secondOfDay.intValue());
-
- return cal.getTime();
- }
-
- /**
- * Sets the date time.
- *
- * @param dateUTC the current date and time in UTC
- * @param issuingDateUTC the issuing date and time in UTC
- */
- public void setDateTime(Date dateUTC, Date issuingDateUTC) {
-
- Calendar cal1 = Calendar.getInstance();
- cal1.setTime(issuingDateUTC);
-
- Calendar cal2 = Calendar.getInstance();
- cal2.setTime(dateUTC);
-
- int days1 = cal1.get(Calendar.DATE);
- int days2 = cal2.get(Calendar.DATE);
-
- day = new Long (days2 - days1);
-
- secondOfDay = (long) cal2.get(Calendar.SECOND);
- secondOfDay = secondOfDay + 60 * (long) cal2.get(Calendar.MINUTE);
- secondOfDay = secondOfDay + 60 * 60 * (long) cal2.get(Calendar.HOUR_OF_DAY);
-
- }
-
- public static String getFormat() {
- return "FDC1";
- }
-
- public DataType getDataType() {
- DataType data = new DataType();
- data.setFormat(UicDynamicContentData1.getFormat());
- data.setByteData(UperEncoder.encode(this));
- return data;
- }
-
- public String getChallengeString() {
- return challengeString;
- }
-
- public void setChallengeString(String challengeString) {
- this.challengeString = challengeString;
- }
-
- public OctetString getPhoneIdHash() {
- return phoneIdHash;
- }
-
- public void setPhoneIdHash(OctetString phoneIdHash) {
- this.phoneIdHash = phoneIdHash;
- }
-
- public OctetString getPassHash() {
- return passHash;
- }
-
- public void setPassHash(OctetString passHash) {
- this.passHash = passHash;
- }
-
-
-
-}
diff --git a/src/main/java/org/uic/barcode/dynamicContent/dfcb1/ExtensionData.java b/src/main/java/org/uic/barcode/dynamicContent/fdc1/ExtensionData.java
index c00da89..52b76d1 100644
--- a/src/main/java/org/uic/barcode/dynamicContent/dfcb1/ExtensionData.java
+++ b/src/main/java/org/uic/barcode/dynamicContent/fdc1/ExtensionData.java
@@ -17,7 +17,7 @@
* along with openASN.1. If not, see <http://www.gnu.org/licenses/>.
*
*/
-package org.uic.barcode.dynamicContent.dfcb1;
+package org.uic.barcode.dynamicContent.fdc1;
import org.uic.barcode.asn1.datatypes.CharacterRestriction;
import org.uic.barcode.asn1.datatypes.FieldOrder;
diff --git a/src/main/java/org/uic/barcode/dynamicContent/dfcb1/GeoCoordinateSystemType.java b/src/main/java/org/uic/barcode/dynamicContent/fdc1/GeoCoordinateSystemType.java
index e535c7f..b25ad1a 100644
--- a/src/main/java/org/uic/barcode/dynamicContent/dfcb1/GeoCoordinateSystemType.java
+++ b/src/main/java/org/uic/barcode/dynamicContent/fdc1/GeoCoordinateSystemType.java
@@ -17,7 +17,7 @@
* along with openASN.1. If not, see <http://www.gnu.org/licenses/>.
*
*/
-package org.uic.barcode.dynamicContent.dfcb1;
+package org.uic.barcode.dynamicContent.fdc1;
// TODO: Auto-generated Javadoc
diff --git a/src/main/java/org/uic/barcode/dynamicContent/dfcb1/GeoCoordinateType.java b/src/main/java/org/uic/barcode/dynamicContent/fdc1/GeoCoordinateType.java
index e1a5e9b..1f1cfc5 100644
--- a/src/main/java/org/uic/barcode/dynamicContent/dfcb1/GeoCoordinateType.java
+++ b/src/main/java/org/uic/barcode/dynamicContent/fdc1/GeoCoordinateType.java
@@ -17,7 +17,7 @@
* along with openASN.1. If not, see <http://www.gnu.org/licenses/>.
*
*/
-package org.uic.barcode.dynamicContent.dfcb1;
+package org.uic.barcode.dynamicContent.fdc1;
import org.uic.barcode.asn1.datatypes.Asn1BigInteger;
import org.uic.barcode.asn1.datatypes.Asn1Default;
diff --git a/src/main/java/org/uic/barcode/dynamicContent/dfcb1/GeoUnitType.java b/src/main/java/org/uic/barcode/dynamicContent/fdc1/GeoUnitType.java
index 222f68d..4eaa8c9 100644
--- a/src/main/java/org/uic/barcode/dynamicContent/dfcb1/GeoUnitType.java
+++ b/src/main/java/org/uic/barcode/dynamicContent/fdc1/GeoUnitType.java
@@ -17,7 +17,7 @@
* along with openASN.1. If not, see <http://www.gnu.org/licenses/>.
*
*/
-package org.uic.barcode.dynamicContent.dfcb1;
+package org.uic.barcode.dynamicContent.fdc1;
// TODO: Auto-generated Javadoc
/**
diff --git a/src/main/java/org/uic/barcode/dynamicContent/dfcb1/HemisphereLatitudeType.java b/src/main/java/org/uic/barcode/dynamicContent/fdc1/HemisphereLatitudeType.java
index e76d120..5157b0e 100644
--- a/src/main/java/org/uic/barcode/dynamicContent/dfcb1/HemisphereLatitudeType.java
+++ b/src/main/java/org/uic/barcode/dynamicContent/fdc1/HemisphereLatitudeType.java
@@ -17,7 +17,7 @@
* along with openASN.1. If not, see <http://www.gnu.org/licenses/>.
*
*/
-package org.uic.barcode.dynamicContent.dfcb1;
+package org.uic.barcode.dynamicContent.fdc1;
// TODO: Auto-generated Javadoc
/**
diff --git a/src/main/java/org/uic/barcode/dynamicContent/dfcb1/HemisphereLongitudeType.java b/src/main/java/org/uic/barcode/dynamicContent/fdc1/HemisphereLongitudeType.java
index 3eeed52..c0e33e6 100644
--- a/src/main/java/org/uic/barcode/dynamicContent/dfcb1/HemisphereLongitudeType.java
+++ b/src/main/java/org/uic/barcode/dynamicContent/fdc1/HemisphereLongitudeType.java
@@ -17,7 +17,7 @@
* along with openASN.1. If not, see <http://www.gnu.org/licenses/>.
*
*/
-package org.uic.barcode.dynamicContent.dfcb1;
+package org.uic.barcode.dynamicContent.fdc1;
// TODO: Auto-generated Javadoc
/**
diff --git a/src/main/java/org/uic/barcode/dynamicContent/fdc1/SequenceOfExtension.java b/src/main/java/org/uic/barcode/dynamicContent/fdc1/SequenceOfExtension.java
new file mode 100644
index 0000000..38833df
--- /dev/null
+++ b/src/main/java/org/uic/barcode/dynamicContent/fdc1/SequenceOfExtension.java
@@ -0,0 +1,11 @@
+package org.uic.barcode.dynamicContent.fdc1;
+
+import java.util.Collection;
+
+import org.uic.barcode.asn1.datatypes.Asn1SequenceOf;
+import org.uic.barcode.ticket.api.asn.omv2.TravelerType;
+
+public class SequenceOfExtension extends Asn1SequenceOf<ExtensionData> {
+ public SequenceOfExtension() { super(); }
+ public SequenceOfExtension(Collection<ExtensionData> coll) { super(coll); }
+}
diff --git a/src/main/java/org/uic/barcode/dynamicContent/fdc1/TimeStamp.java b/src/main/java/org/uic/barcode/dynamicContent/fdc1/TimeStamp.java
new file mode 100644
index 0000000..32cce65
--- /dev/null
+++ b/src/main/java/org/uic/barcode/dynamicContent/fdc1/TimeStamp.java
@@ -0,0 +1,144 @@
+package org.uic.barcode.dynamicContent.fdc1;
+
+import java.time.Instant;
+import java.time.temporal.ChronoField;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.TimeZone;
+
+import org.uic.barcode.asn1.datatypes.FieldOrder;
+import org.uic.barcode.asn1.datatypes.IntRange;
+import org.uic.barcode.asn1.datatypes.Sequence;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class TimeStamp.
+ */
+@Sequence
+public class TimeStamp {
+
+
+ /*
+ -- Moment of generation of the dynamic content, expressed in UTC :
+ -- * dynamicContentDay is the number of days from issuing date
+ -- (UicRailTicketData.issuingDetail.issuingYear and issuingDay)
+ -- The range 0..1070 allows a validity equal to that of the validFrom (700) plus
+ -- validUntil (370) elements of the different transport documents of UicRailTicketData.
+ -- * dynamicContentTime is the number of seconds of the day
+ -- (from 0 = 0:00:00 to 86399 = 23:59:59)
+ -- These two elements shall be either both present, either both absent
+ dynamicContentDay INTEGER (0..366),
+ *
+ */
+ @FieldOrder(order = 0)
+ @IntRange(minValue=1, maxValue=366)
+ public Long day;
+
+ /** The second of day. */
+ // dynamicContentTime INTEGER (0..86399) OPTIONAL,
+ @FieldOrder(order = 1)
+ @IntRange(minValue=0, maxValue=86399)
+ public Long secondOfDay;
+
+
+
+ /**
+ * Instantiates a new time stamp and sets the time-stamp to now.
+ */
+ public TimeStamp() {
+ Instant now = Instant.now();
+ day = new Long(now.get(ChronoField.DAY_OF_YEAR));
+ secondOfDay = new Long(now.get(ChronoField.SECOND_OF_DAY));
+ }
+
+ /**
+ * Sets the the time-stamp to now.
+ */
+ public void setNow() {
+ Instant now = Instant.now();
+ day = new Long(now.get(ChronoField.DAY_OF_YEAR));
+ secondOfDay = new Long(now.get(ChronoField.SECOND_OF_DAY));
+ }
+
+ /**
+ * Gets the day.
+ *
+ * @return the day
+ */
+ public Long getDay() {
+ return day;
+ }
+
+ /**
+ * Sets the day.
+ *
+ * @param day the new day
+ */
+ public void setDay(Long day) {
+ this.day = day;
+ }
+
+ /**
+ * Gets the time.
+ *
+ * @return the time
+ */
+ public Long getTime() {
+ return secondOfDay;
+ }
+
+ /**
+ * Sets the time.
+ *
+ * @param time the new time
+ */
+ public void setTime(Long time) {
+ this.secondOfDay = time;
+ }
+
+ /**
+ * Gets the time.
+ *
+ * @return the date and time of content creation in UTC
+ */
+ public Date getTimeAsDate() {
+
+ Calendar cal = Calendar.getInstance();
+ int dayOfYear = cal.get(Calendar.DAY_OF_YEAR);
+
+ if (dayOfYear - day.intValue() > 250) {
+ cal.add(Calendar.YEAR, 1);
+ }
+ if (day.intValue() - dayOfYear > 250) {
+ cal.add(Calendar.YEAR, -1);
+ }
+
+ cal.setTimeZone(TimeZone.getTimeZone("UTC"));
+ cal.set(Calendar.SECOND,0);
+ cal.set(Calendar.HOUR,0);
+ cal.set(Calendar.MINUTE,0);
+ cal.set(Calendar.DAY_OF_YEAR, day.intValue());
+ cal.add(Calendar.SECOND, secondOfDay.intValue());
+
+ return cal.getTime();
+ }
+
+ /**
+ * Sets the date time.
+ *
+ * @param dateUTC the current date and time in UTC
+ */
+ public void setDateTime(Date dateUTC) {
+
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(dateUTC);
+
+ day = Long.valueOf(cal.get(Calendar.DAY_OF_YEAR));
+
+ secondOfDay = (long) cal.get(Calendar.SECOND);
+ secondOfDay = secondOfDay + 60 * (long) cal.get(Calendar.MINUTE);
+ secondOfDay = secondOfDay + 60 * 60 * (long) cal.get(Calendar.HOUR_OF_DAY);
+
+ }
+
+}
diff --git a/src/main/java/org/uic/barcode/dynamicContent/fdc1/UicDynamicContentDataFDC1.java b/src/main/java/org/uic/barcode/dynamicContent/fdc1/UicDynamicContentDataFDC1.java
new file mode 100644
index 0000000..ce6d1b3
--- /dev/null
+++ b/src/main/java/org/uic/barcode/dynamicContent/fdc1/UicDynamicContentDataFDC1.java
@@ -0,0 +1,205 @@
+/*
+ *
+ */
+package org.uic.barcode.dynamicContent.fdc1;
+
+import java.io.UnsupportedEncodingException;
+import org.uic.barcode.asn1.datatypes.Asn1Optional;
+import org.uic.barcode.asn1.datatypes.CharacterRestriction;
+import org.uic.barcode.asn1.datatypes.FieldOrder;
+import org.uic.barcode.asn1.datatypes.HasExtensionMarker;
+import org.uic.barcode.asn1.datatypes.RestrictedString;
+import org.uic.barcode.asn1.datatypes.Sequence;
+import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.dynamicContent.DynamicContent;
+import org.uic.barcode.dynamicFrame.DataType;
+
+
+/**
+ * The Class UicDynamicContentData.
+ *
+ * The dynamic content for FDC1
+ *
+ */
+
+
+
+
+@Sequence
+@HasExtensionMarker
+public class UicDynamicContentDataFDC1 {
+
+
+
+ /*
+ -- The possible values are defined by the security provider
+ -- (the security provider being UicBarcodeHeader.level2SignedData.level1Data.securityProviderNum/IA5)
+ dynamicContentMobileAppId IA5String OPTIONAL,
+ */
+ //timestamp when the bar code was created
+ @FieldOrder(order = 0)
+ @RestrictedString(CharacterRestriction.IA5String)
+ @Asn1Optional public String appId;
+
+ //timestamp when the bar code was created
+ @FieldOrder(order = 1)
+ @Asn1Optional public TimeStamp timeStamp;
+
+
+ //-- Coordinates of the place where the dynamic content has been generated
+ // -- (same GeoCoordinateType type as in UicRailTicketData)
+ /** The geo coordinate. */
+ //dynamicContentGeoCoordinate GeoCoordinateType OPTIONAL,
+ @FieldOrder(order = 2)
+ @Asn1Optional public GeoCoordinateType geoCoordinate;
+ //-- Response from the mobile to any data received from the terminal.
+ //-- The data received from the terminal may be a random number, or any other information.
+ //-- The response may be the data itself, a hashing of this data, or any other response.
+ // -- This response may be completed with other information: IMEI, mobile phone number...
+ //-- The type used is ExtensionData, as it is fully adapted.
+ // -- extensionId shall be set to:
+ // -- * "=" if the data included in extensionData is exactly the one that was transmitted by the terminal,
+ // -- * any other value (chosen by the issuer) in other cases.
+ /** The challenge response. */
+
+ @FieldOrder(order = 3)
+ @Asn1Optional public SequenceOfExtension extensions;
+
+
+
+ //...
+
+
+
+ /**
+ * Gets the geo coordinate.
+ *
+ * @return the geo coordinate
+ */
+ public GeoCoordinateType getGeoCoordinate() {
+ return geoCoordinate;
+ }
+
+ /**
+ * Sets the geo coordinate.
+ *
+ * @param geoCoordinate the new geo coordinate
+ */
+ public void setGeoCoordinate(GeoCoordinateType geoCoordinate) {
+ this.geoCoordinate = geoCoordinate;
+ }
+
+ public static String getFormat() {
+ return "FDC1";
+ }
+
+ public DataType getDataType() {
+ DataType data = new DataType();
+ data.setFormat(getFormat());
+ data.setByteData(UperEncoder.encode(this));
+ return data;
+ }
+
+ public String getChallengeString() {
+ if (this.extensions != null) {
+ for (ExtensionData ed : extensions) {
+ if (ed.getExtensionId().equals("=")) {
+ byte[] c = ed.getExtensionData();
+ try {
+ return new String(c,"UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ return null;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public void setChallengeString(String challengeString) {
+ if (extensions == null) {
+ extensions = new SequenceOfExtension();
+ };
+ ExtensionData ed = new ExtensionData();
+ ed.setExtensionId("=");
+ try {
+ ed.setExtensionData(challengeString.getBytes("UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ return;
+ }
+ extensions.add(ed);
+ }
+
+ public byte[] getPhoneIdHash() {
+ if (this.extensions != null) {
+ for (ExtensionData ed : extensions) {
+ if (ed.getExtensionId().equals("phone")) {
+ return ed.getExtensionData();
+ }
+ }
+ }
+ return null;
+ }
+
+ public void setPhoneIdHash(byte[] phoneIdHash) {
+ if (extensions == null) {
+ extensions = new SequenceOfExtension();
+ };
+ ExtensionData ed = new ExtensionData();
+ ed.setExtensionId("phone");
+ ed.setExtensionData(phoneIdHash);
+ extensions.add(ed);
+ }
+
+ public byte[] getPassIdHash() {
+ if (this.extensions != null) {
+ for (ExtensionData ed : extensions) {
+ if (ed.getExtensionId().equals("pass")) {
+ return ed.getExtensionData();
+ }
+ }
+ }
+ return null;
+ }
+
+ public void setPassIdHash(byte[] phoneIdHash) {
+ if (extensions == null) {
+ extensions = new SequenceOfExtension();
+ };
+ ExtensionData ed = new ExtensionData();
+ ed.setExtensionId("pass");
+ ed.setExtensionData(phoneIdHash);
+ extensions.add(ed);
+ }
+
+ public TimeStamp getTimeStamp() {
+ return timeStamp;
+ }
+
+ public void setTimeStamp(TimeStamp timeStamp) {
+ this.timeStamp = timeStamp;
+ }
+
+ public SequenceOfExtension getExtensions() {
+ return extensions;
+ }
+
+ public void setExtensions(SequenceOfExtension extensions) {
+ this.extensions = extensions;
+ }
+
+ public byte[] encode() {
+ return UperEncoder.encode(this);
+ }
+
+ public String getAppId() {
+ return appId;
+ }
+
+ public void setAppId(String appId) {
+ this.appId = appId;
+ }
+
+
+
+}
diff --git a/src/main/java/org/uic/barcode/dynamicFrame/DynamicFrame.java b/src/main/java/org/uic/barcode/dynamicFrame/DynamicFrame.java
index 886cb79..375e2c6 100644
--- a/src/main/java/org/uic/barcode/dynamicFrame/DynamicFrame.java
+++ b/src/main/java/org/uic/barcode/dynamicFrame/DynamicFrame.java
@@ -18,7 +18,7 @@ import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.OctetString;
import org.uic.barcode.asn1.uper.UperEncoder;
-import org.uic.barcode.dynamicContent.dfcb1.UicDynamicContentData1;
+import org.uic.barcode.dynamicContent.fdc1.UicDynamicContentDataFDC1;
import org.uic.barcode.utils.AlgorithmNameResolver;
@@ -263,19 +263,19 @@ public class DynamicFrame extends Object{
}
- public void addLevel2DynamicData(UicDynamicContentData1 dynamicData) {
+ public void addLevel2DynamicData(UicDynamicContentDataFDC1 dynamicData) {
this.getLevel2SignedData().setLevel2Data( dynamicData.getDataType());
}
- public UicDynamicContentData1 getDynamicDataFDC1() {
+ public UicDynamicContentDataFDC1 getDynamicDataFDC1() {
if (this.getLevel2SignedData() == null ||
this.getLevel2SignedData().getLevel2Data() == null){
return null;
}
- if ( UicDynamicContentData1.getFormat().equals(this.getLevel2SignedData().getLevel2Data().getFormat())) {
- return UperEncoder.decode(this.getLevel2SignedData().getLevel2Data().getByteData(), UicDynamicContentData1.class);
+ if ( UicDynamicContentDataFDC1.getFormat().equals(this.getLevel2SignedData().getLevel2Data().getFormat())) {
+ return UperEncoder.decode(this.getLevel2SignedData().getLevel2Data().getByteData(), UicDynamicContentDataFDC1.class);
}
return null;
diff --git a/src/main/java/org/uic/barcode/staticFrame/UHEADDataRecord.java b/src/main/java/org/uic/barcode/staticFrame/UHEADDataRecord.java
index 855c9d5..492656a 100644
--- a/src/main/java/org/uic/barcode/staticFrame/UHEADDataRecord.java
+++ b/src/main/java/org/uic/barcode/staticFrame/UHEADDataRecord.java
@@ -180,7 +180,7 @@ public class UHEADDataRecord extends DataRecord{
}
// date format "DDMMYYYYHHMM"
- SimpleDateFormat formatter = new SimpleDateFormat("ddMMyyyyhhmm");
+ SimpleDateFormat formatter = new SimpleDateFormat("ddMMyyyyHHmm");
try {
issuingDate = formatter.parse(issuingDateString);
} catch (ParseException e) {