summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCGantert345 <57003061+CGantert345@users.noreply.github.com>2021-04-23 13:41:58 +0200
committerCGantert345 <57003061+CGantert345@users.noreply.github.com>2021-04-23 13:41:58 +0200
commitc45fc85b78f3d8701346a231f07b7ffa984ca4ed (patch)
tree1485df9ae1746a12409b0c17bb32d1f810875774 /src
parentincluded open ticket test (diff)
downloadUIC-barcode-c45fc85b78f3d8701346a231f07b7ffa984ca4ed.tar
UIC-barcode-c45fc85b78f3d8701346a231f07b7ffa984ca4ed.tar.gz
UIC-barcode-c45fc85b78f3d8701346a231f07b7ffa984ca4ed.tar.bz2
UIC-barcode-c45fc85b78f3d8701346a231f07b7ffa984ca4ed.tar.lz
UIC-barcode-c45fc85b78f3d8701346a231f07b7ffa984ca4ed.tar.xz
UIC-barcode-c45fc85b78f3d8701346a231f07b7ffa984ca4ed.tar.zst
UIC-barcode-c45fc85b78f3d8701346a231f07b7ffa984ca4ed.zip
Diffstat (limited to '')
-rw-r--r--misc/headerSpec.asn (renamed from src/resources/headerSpec.asn)0
-rw-r--r--misc/uicBarcodeFCBv2.0.1.asn (renamed from src/resources/uicBarcodeFCBv2.0.1.asn)2
-rw-r--r--misc/uicBarcodeFCBv2.0.2.asn (renamed from src/resources/uicBarcodeFCBv2.0.2.asn)2
-rw-r--r--misc/uicBarcodeFCBv2.0.asn (renamed from src/resources/uicBarcodeFCBv2.0.asn)2
-rw-r--r--misc/uicBarcodeV1finalDelayConfirmation1.3.1.asn (renamed from src/resources/uicBarcodeV1finalDelayConfirmation1.3.1.asn)2
-rw-r--r--misc/uicBarcodeV1finalDelayConfirmation1.3.asn (renamed from src/resources/uicBarcodeV1finalDelayConfirmation1.3.asn)2
-rw-r--r--src/main/java/org/uic/barcode/Encoder.java18
-rw-r--r--src/main/java/org/uic/barcode/dynamicContent/dfcb1/ExtensionData.java59
-rw-r--r--src/main/java/org/uic/barcode/dynamicContent/dfcb1/GeoCoordinateSystemType.java57
-rw-r--r--src/main/java/org/uic/barcode/dynamicContent/dfcb1/GeoCoordinateType.java144
-rw-r--r--src/main/java/org/uic/barcode/dynamicContent/dfcb1/GeoUnitType.java65
-rw-r--r--src/main/java/org/uic/barcode/dynamicContent/dfcb1/HemisphereLatitudeType.java56
-rw-r--r--src/main/java/org/uic/barcode/dynamicContent/dfcb1/HemisphereLongitudeType.java55
-rw-r--r--src/main/java/org/uic/barcode/dynamicContent/dfcb1/UicDynamicContentData1.java268
-rw-r--r--src/main/java/org/uic/barcode/dynamicFrame/Constants.java2
-rw-r--r--src/main/java/org/uic/barcode/dynamicFrame/DynamicFrame.java19
-rw-r--r--src/main/java/org/uic/barcode/dynamicFrame/Level1DataType.java4
-rw-r--r--src/main/java/org/uic/barcode/staticFrame/StaticFrame.java9
-rw-r--r--src/main/java/org/uic/barcode/utils/AlgorithmNameResolver.java2
-rw-r--r--src/test/java/org/uic/barcode/test/utils/TestUtils.java35
-rw-r--r--src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java1
-rw-r--r--src/test/java/org/uic/barcode/ticketTestDB/EncodeSparpreisTicketDBTest.java121
-rw-r--r--src/test/java/org/uic/barcode/ticketTestDB/SignatureValidationDBTicketTest.java2
23 files changed, 915 insertions, 12 deletions
diff --git a/src/resources/headerSpec.asn b/misc/headerSpec.asn
index 08d84f6..08d84f6 100644
--- a/src/resources/headerSpec.asn
+++ b/misc/headerSpec.asn
diff --git a/src/resources/uicBarcodeFCBv2.0.1.asn b/misc/uicBarcodeFCBv2.0.1.asn
index 010c49c..16c376b 100644
--- a/src/resources/uicBarcodeFCBv2.0.1.asn
+++ b/misc/uicBarcodeFCBv2.0.1.asn
@@ -1998,7 +1998,7 @@ ASN-Module DEFINITIONS AUTOMATIC TAGS ::= BEGIN
GeoUnitType ::= ENUMERATED {
microDegree (0), -- approx. 11 cm on earth surface
- tenthmilliDegree (1), -- 1 / 100000 degree is approx. 1.1 meter 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)
diff --git a/src/resources/uicBarcodeFCBv2.0.2.asn b/misc/uicBarcodeFCBv2.0.2.asn
index 5ac906d..d7067ca 100644
--- a/src/resources/uicBarcodeFCBv2.0.2.asn
+++ b/misc/uicBarcodeFCBv2.0.2.asn
@@ -2069,7 +2069,7 @@ ASN-Module DEFINITIONS AUTOMATIC TAGS ::= BEGIN
GeoUnitType ::= ENUMERATED {
microDegree (0), -- approx. 11 cm on earth surface
- tenthmilliDegree (1), -- 1 / 100000 degree is approx. 1.1 meter 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)
diff --git a/src/resources/uicBarcodeFCBv2.0.asn b/misc/uicBarcodeFCBv2.0.asn
index 2c2eda7..924a415 100644
--- a/src/resources/uicBarcodeFCBv2.0.asn
+++ b/misc/uicBarcodeFCBv2.0.asn
@@ -1996,7 +1996,7 @@ ASN-Module DEFINITIONS AUTOMATIC TAGS ::= BEGIN
GeoUnitType ::= ENUMERATED {
microDegree (0), -- approx. 11 cm on earth surface
- tenthmilliDegree (1), -- 1 / 100000 degree is approx. 1.1 meter 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)
diff --git a/src/resources/uicBarcodeV1finalDelayConfirmation1.3.1.asn b/misc/uicBarcodeV1finalDelayConfirmation1.3.1.asn
index 3c589eb..0181738 100644
--- a/src/resources/uicBarcodeV1finalDelayConfirmation1.3.1.asn
+++ b/misc/uicBarcodeV1finalDelayConfirmation1.3.1.asn
@@ -1977,7 +1977,7 @@ ASN-Module DEFINITIONS AUTOMATIC TAGS ::= BEGIN
GeoUnitType ::= ENUMERATED {
microDegree (0), -- approx. 11 cm on earth surface
- tenthmilliDegree (1), -- 1 / 100000 degree is approx. 1.1 meter 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)
diff --git a/src/resources/uicBarcodeV1finalDelayConfirmation1.3.asn b/misc/uicBarcodeV1finalDelayConfirmation1.3.asn
index fb19462..6b79451 100644
--- a/src/resources/uicBarcodeV1finalDelayConfirmation1.3.asn
+++ b/misc/uicBarcodeV1finalDelayConfirmation1.3.asn
@@ -2003,7 +2003,7 @@ ASN-Module DEFINITIONS AUTOMATIC TAGS ::= BEGIN
GeoUnitType ::= ENUMERATED {
microDegree (0), -- approx. 11 cm on earth surface
- tenthmilliDegree (1), -- 1 / 100000 degree is approx. 1.1 meter 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)
diff --git a/src/main/java/org/uic/barcode/Encoder.java b/src/main/java/org/uic/barcode/Encoder.java
index aafe5cc..29ce63d 100644
--- a/src/main/java/org/uic/barcode/Encoder.java
+++ b/src/main/java/org/uic/barcode/Encoder.java
@@ -5,6 +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.dynamicFrame.Constants;
import org.uic.barcode.dynamicFrame.DataType;
import org.uic.barcode.dynamicFrame.DynamicFrame;
@@ -165,6 +166,15 @@ public class Encoder {
}
}
+ public void setDynamicContentDataUIC1(UicDynamicContentData1 dcd) {
+ if (dynamicFrame != null) {
+ if (dynamicFrame.getLevel2SignedData() == null) {
+ dynamicFrame.setLevel2SignedData(new Level2DataType());
+ }
+ dynamicFrame.getLevel2SignedData().setLevel2Data(dcd.getDataType());
+ }
+ }
+
public DataType getLevel2Data() {
if (dynamicFrame != null && dynamicFrame.getLevel2SignedData() != null) {
return dynamicFrame.getLevel2SignedData().getLevel2Data();
@@ -172,6 +182,14 @@ public class Encoder {
return null;
}
+ public UicDynamicContentData1 getDynamicContentDataUIC1() {
+ if (dynamicFrame != null && dynamicFrame.getLevel2SignedData() != null) {
+ return dynamicFrame.getDynamicDataFDC1();
+ }
+ return null;
+ }
+
+
/**
* Sign level 1 of a dynamic bar code or a static bar code.
*
diff --git a/src/main/java/org/uic/barcode/dynamicContent/dfcb1/ExtensionData.java b/src/main/java/org/uic/barcode/dynamicContent/dfcb1/ExtensionData.java
new file mode 100644
index 0000000..c00da89
--- /dev/null
+++ b/src/main/java/org/uic/barcode/dynamicContent/dfcb1/ExtensionData.java
@@ -0,0 +1,59 @@
+/*
+ * This file was generated by openASN.1 - an open source ASN.1 toolkit for java
+ *
+ * openASN.1 is Copyright (C) 2007 Clayton Hoss, Marc Weyland
+ *
+ * openASN.1 is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * openASN.1 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with openASN.1. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.uic.barcode.dynamicContent.dfcb1;
+
+import org.uic.barcode.asn1.datatypes.CharacterRestriction;
+import org.uic.barcode.asn1.datatypes.FieldOrder;
+import org.uic.barcode.asn1.datatypes.RestrictedString;
+import org.uic.barcode.asn1.datatypes.Sequence;
+import org.uic.barcode.asn1.datatypesimpl.OctetString;
+
+
+@Sequence
+public class ExtensionData extends Object {
+ public ExtensionData() {
+ }
+
+ @FieldOrder(order = 0)
+ @RestrictedString(CharacterRestriction.IA5String)
+ public String extensionId;
+
+ @FieldOrder(order = 1)
+ public OctetString extensionData;
+
+ public String getExtensionId() {
+ return this.extensionId;
+ }
+
+ public byte[] getExtensionData() {
+ return extensionData.toByteArray();
+ }
+
+ public void setExtensionId(String extensionId) {
+ this.extensionId = extensionId;
+ }
+
+ public void setExtensionData(byte[] extensionData) {
+ this.extensionData = new OctetString(extensionData);
+ }
+
+
+
+}
diff --git a/src/main/java/org/uic/barcode/dynamicContent/dfcb1/GeoCoordinateSystemType.java b/src/main/java/org/uic/barcode/dynamicContent/dfcb1/GeoCoordinateSystemType.java
new file mode 100644
index 0000000..e535c7f
--- /dev/null
+++ b/src/main/java/org/uic/barcode/dynamicContent/dfcb1/GeoCoordinateSystemType.java
@@ -0,0 +1,57 @@
+/*
+ * This file was generated by openASN.1 - an open source ASN.1 toolkit for java
+ *
+ * openASN.1 is Copyright (C) 2007 Clayton Hoss, Marc Weyland
+ *
+ * openASN.1 is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * openASN.1 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with openASN.1. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.uic.barcode.dynamicContent.dfcb1;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Enum GeoCoordinateSystemType.
+ */
+public enum GeoCoordinateSystemType {
+
+ /** The wgs 84. */
+ wgs84("wgs84"),
+
+ /** The grs 80. */
+ grs80("grs80");
+
+
+ /** The text. */
+ public String text;
+
+ /**
+ * Instantiates a new geo coordinate system type.
+ *
+ * @param text the text
+ */
+ GeoCoordinateSystemType(String text) {
+ this.text = text;
+ }
+
+ /**
+ * To string.
+ *
+ * @return the string
+ */
+ public String toString(){
+ return text;
+ }
+}
+
diff --git a/src/main/java/org/uic/barcode/dynamicContent/dfcb1/GeoCoordinateType.java b/src/main/java/org/uic/barcode/dynamicContent/dfcb1/GeoCoordinateType.java
new file mode 100644
index 0000000..e1a5e9b
--- /dev/null
+++ b/src/main/java/org/uic/barcode/dynamicContent/dfcb1/GeoCoordinateType.java
@@ -0,0 +1,144 @@
+/*
+ * This file was generated by openASN.1 - an open source ASN.1 toolkit for java
+ *
+ * openASN.1 is Copyright (C) 2007 Clayton Hoss, Marc Weyland
+ *
+ * openASN.1 is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * openASN.1 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with openASN.1. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.uic.barcode.dynamicContent.dfcb1;
+
+import org.uic.barcode.asn1.datatypes.Asn1BigInteger;
+import org.uic.barcode.asn1.datatypes.Asn1Default;
+import org.uic.barcode.asn1.datatypes.Asn1Optional;
+import org.uic.barcode.asn1.datatypes.FieldOrder;
+import org.uic.barcode.asn1.datatypes.Sequence;
+
+@Sequence
+public class GeoCoordinateType extends Object {
+ public GeoCoordinateType() {
+ }
+
+ @FieldOrder(order = 0)
+ @Asn1Default(value="milliDegree")
+ @Asn1Optional public GeoUnitType geoUnit;
+
+ @FieldOrder(order = 1)
+ @Asn1Default(value="wgs84")
+ @Asn1Optional public GeoCoordinateSystemType coordinateSystem;
+
+ @FieldOrder(order = 2)
+ @Asn1Default(value="north")
+ @Asn1Optional public HemisphereLongitudeType hemisphereLongitude;
+
+ @FieldOrder(order = 3)
+ @Asn1Default(value="east")
+ @Asn1Optional public HemisphereLatitudeType hemisphereLatitude;
+
+ @FieldOrder(order = 4)
+ public Asn1BigInteger longitude;
+
+ @FieldOrder(order = 5)
+ public Asn1BigInteger latitude;
+
+ @FieldOrder(order = 6)
+ @Asn1Optional public GeoUnitType accuracy;
+
+ public GeoUnitType getGeoUnit() {
+
+ if (geoUnit == null){
+ return GeoUnitType.milliDegree;
+ }
+ return this.geoUnit;
+ }
+
+ public GeoCoordinateSystemType getCoordinateSystem() {
+
+ if (coordinateSystem == null) {
+ return GeoCoordinateSystemType.wgs84;
+ }
+
+ return this.coordinateSystem;
+ }
+
+ public HemisphereLongitudeType getHemisphereLongitude() {
+
+ if (hemisphereLongitude == null){
+ return HemisphereLongitudeType.north;
+ }
+
+ return this.hemisphereLongitude;
+ }
+
+ public HemisphereLatitudeType getHemisphereLatitude() {
+
+ if (hemisphereLatitude == null) {
+ return HemisphereLatitudeType.east;
+ }
+
+ return this.hemisphereLatitude;
+ }
+
+ public Long getLongitude() {
+
+ return Asn1BigInteger.toLong(this.longitude);
+ }
+
+ public Long getLatitude() {
+
+ return Asn1BigInteger.toLong(this.latitude);
+ }
+
+ public GeoUnitType getAccuracy() {
+
+ return this.accuracy;
+ }
+
+ public void setGeoUnit(GeoUnitType geoUnit) {
+
+ this.geoUnit = geoUnit;
+ }
+
+ public void setCoordinateSystem(GeoCoordinateSystemType coordinateSystem) {
+
+ this.coordinateSystem = coordinateSystem;
+ }
+
+ public void setHemisphereLongitude(HemisphereLongitudeType hemisphereLongitude) {
+
+ this.hemisphereLongitude = hemisphereLongitude;
+ }
+
+ public void setHemisphereLatitude(HemisphereLatitudeType hemisphereLatitude) {
+
+ this.hemisphereLatitude = hemisphereLatitude;
+ }
+
+ public void setLongitude(Long longitude) {
+
+ this.longitude = Asn1BigInteger.toAsn1(longitude);
+ }
+
+ public void setLatitude(Long latitude) {
+
+ this.latitude = Asn1BigInteger.toAsn1(latitude);
+ }
+
+ public void setAccuracy(GeoUnitType accuracy) {
+
+ this.accuracy = accuracy;
+ }
+
+
+}
diff --git a/src/main/java/org/uic/barcode/dynamicContent/dfcb1/GeoUnitType.java b/src/main/java/org/uic/barcode/dynamicContent/dfcb1/GeoUnitType.java
new file mode 100644
index 0000000..222f68d
--- /dev/null
+++ b/src/main/java/org/uic/barcode/dynamicContent/dfcb1/GeoUnitType.java
@@ -0,0 +1,65 @@
+/*
+ * This file was generated by openASN.1 - an open source ASN.1 toolkit for java
+ *
+ * openASN.1 is Copyright (C) 2007 Clayton Hoss, Marc Weyland
+ *
+ * openASN.1 is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * openASN.1 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with openASN.1. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.uic.barcode.dynamicContent.dfcb1;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Enum GeoUnitType.
+ */
+public enum GeoUnitType {
+
+ /** The micro degree. */
+ microDegree("microDegree"),
+
+ /** The tenthmilli degree. */
+ tenthmilliDegree("tenthmilliDegree"),
+
+ /** The milli degree. */
+ milliDegree("milliDegree"),
+
+ /** The centi degree. */
+ centiDegree("centiDegree"),
+
+ /** The deci degree. */
+ deciDegree("deciDegree");
+
+
+ /** The text. */
+ public String text;
+
+ /**
+ * Instantiates a new geo unit type.
+ *
+ * @param text the text
+ */
+ GeoUnitType(String text) {
+ this.text = text;
+ }
+
+ /**
+ * To string.
+ *
+ * @return the string
+ */
+ public String toString(){
+ return text;
+ }
+}
+
diff --git a/src/main/java/org/uic/barcode/dynamicContent/dfcb1/HemisphereLatitudeType.java b/src/main/java/org/uic/barcode/dynamicContent/dfcb1/HemisphereLatitudeType.java
new file mode 100644
index 0000000..e76d120
--- /dev/null
+++ b/src/main/java/org/uic/barcode/dynamicContent/dfcb1/HemisphereLatitudeType.java
@@ -0,0 +1,56 @@
+/*
+ * This file was generated by openASN.1 - an open source ASN.1 toolkit for java
+ *
+ * openASN.1 is Copyright (C) 2007 Clayton Hoss, Marc Weyland
+ *
+ * openASN.1 is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * openASN.1 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with openASN.1. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.uic.barcode.dynamicContent.dfcb1;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Enum HemisphereLatitudeType.
+ */
+public enum HemisphereLatitudeType {
+
+ /** The east. */
+ east("east"),
+
+ /** The west. */
+ west("west");
+
+
+ /** The text. */
+ public String text;
+
+ /**
+ * Instantiates a new hemisphere latitude type.
+ *
+ * @param text the text
+ */
+ HemisphereLatitudeType(String text) {
+ this.text = text;
+ }
+
+ /**
+ * To string.
+ *
+ * @return the string
+ */
+ public String toString(){
+ return text;
+ }
+}
+
diff --git a/src/main/java/org/uic/barcode/dynamicContent/dfcb1/HemisphereLongitudeType.java b/src/main/java/org/uic/barcode/dynamicContent/dfcb1/HemisphereLongitudeType.java
new file mode 100644
index 0000000..3eeed52
--- /dev/null
+++ b/src/main/java/org/uic/barcode/dynamicContent/dfcb1/HemisphereLongitudeType.java
@@ -0,0 +1,55 @@
+/*
+ * This file was generated by openASN.1 - an open source ASN.1 toolkit for java
+ *
+ * openASN.1 is Copyright (C) 2007 Clayton Hoss, Marc Weyland
+ *
+ * openASN.1 is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * openASN.1 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with openASN.1. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.uic.barcode.dynamicContent.dfcb1;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Enum HemisphereLongitudeType.
+ */
+public enum HemisphereLongitudeType {
+
+ /** The north. */
+ north("north"),
+
+ /** The south. */
+ south("south");
+
+ /** The text. */
+ public String text;
+
+ /**
+ * Instantiates a new hemisphere longitude type.
+ *
+ * @param text the text
+ */
+ HemisphereLongitudeType(String text) {
+ this.text = text;
+ }
+
+ /**
+ * To string.
+ *
+ * @return the string
+ */
+ public String toString(){
+ return text;
+ }
+}
+
diff --git a/src/main/java/org/uic/barcode/dynamicContent/dfcb1/UicDynamicContentData1.java b/src/main/java/org/uic/barcode/dynamicContent/dfcb1/UicDynamicContentData1.java
new file mode 100644
index 0000000..034057a
--- /dev/null
+++ b/src/main/java/org/uic/barcode/dynamicContent/dfcb1/UicDynamicContentData1.java
@@ -0,0 +1,268 @@
+/*
+ *
+ */
+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/dynamicFrame/Constants.java b/src/main/java/org/uic/barcode/dynamicFrame/Constants.java
index 98b62aa..774475a 100644
--- a/src/main/java/org/uic/barcode/dynamicFrame/Constants.java
+++ b/src/main/java/org/uic/barcode/dynamicFrame/Constants.java
@@ -12,7 +12,7 @@ public class Constants {
public static String DSA_SHA1 = "1.2.840.10040.4.3";
public static String DSA_SHA224 = "2.16.840.1.101.3.4.3.1";
- public static String DSA_SHA248 = "2.16.840.1.101.3.4.3.2";
+ public static String DSA_SHA256 = "2.16.840.1.101.3.4.3.2";
public static String DATA_TYPE_FCB_VERSION_1 = "FCB1";
public static String DATA_TYPE_FCB_VERSION_2 = "FCB2";
diff --git a/src/main/java/org/uic/barcode/dynamicFrame/DynamicFrame.java b/src/main/java/org/uic/barcode/dynamicFrame/DynamicFrame.java
index 9605a0d..886cb79 100644
--- a/src/main/java/org/uic/barcode/dynamicFrame/DynamicFrame.java
+++ b/src/main/java/org/uic/barcode/dynamicFrame/DynamicFrame.java
@@ -18,6 +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.utils.AlgorithmNameResolver;
@@ -262,5 +263,23 @@ public class DynamicFrame extends Object{
}
+ public void addLevel2DynamicData(UicDynamicContentData1 dynamicData) {
+ this.getLevel2SignedData().setLevel2Data( dynamicData.getDataType());
+ }
+
+ public UicDynamicContentData1 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);
+ }
+ return null;
+
+ }
+
}
diff --git a/src/main/java/org/uic/barcode/dynamicFrame/Level1DataType.java b/src/main/java/org/uic/barcode/dynamicFrame/Level1DataType.java
index 1f4d476..aac0188 100644
--- a/src/main/java/org/uic/barcode/dynamicFrame/Level1DataType.java
+++ b/src/main/java/org/uic/barcode/dynamicFrame/Level1DataType.java
@@ -49,7 +49,7 @@ public class Level1DataType {
*
* e.g.:
* -- DSA SHA224 2.16.840.1.101.3.4.3.1
- * -- DSA SHA248 2.16.840.1.101.3.4.3.2
+ * -- DSA SHA256 2.16.840.1.101.3.4.3.2
* -- ECC 256 1.2.840.10045.3.1.7
*
*
@@ -69,7 +69,7 @@ public class Level1DataType {
*
* e.g.:
* -- DSA SHA224 2.16.840.1.101.3.4.3.1
- * -- DSA SHA248 2.16.840.1.101.3.4.3.2
+ * -- DSA SHA256 2.16.840.1.101.3.4.3.2
* -- ECC 256 1.2.840.10045.3.1.7
*
*
diff --git a/src/main/java/org/uic/barcode/staticFrame/StaticFrame.java b/src/main/java/org/uic/barcode/staticFrame/StaticFrame.java
index 639af69..2759bf0 100644
--- a/src/main/java/org/uic/barcode/staticFrame/StaticFrame.java
+++ b/src/main/java/org/uic/barcode/staticFrame/StaticFrame.java
@@ -655,7 +655,7 @@ public class StaticFrame {
* @throws NoSuchAlgorithmException the no such algorithm exception
* @throws SignatureException the signature exception
* @throws IllegalArgumentException the illegal argument exception
- * @throws UnsupportedOperationException the unsupported operatign exception
+ * @throws UnsupportedOperationException the unsupported operating exception
* @throws EncodingFormatException
* @throws IOException
*/
@@ -669,6 +669,9 @@ public class StaticFrame {
algo = service.getAlgorithm();
}
}
+ if (algo == null) {
+ throw new NoSuchAlgorithmException("No service for algorithm found: " + signingAlg);
+ }
Signature sig = Signature.getInstance(algo);
sig.initVerify(key);
sig.update(getDataForSignature());
@@ -697,8 +700,12 @@ public class StaticFrame {
Service service = prov.getService("Signature",signingAlg);
if (service != null) {
algo = service.getAlgorithm();
+ break;
}
}
+ if (algo == null) {
+ throw new NoSuchAlgorithmException("No service for algorthm found: " + signingAlg);
+ }
Signature sig = Signature.getInstance(algo);
sig.initSign(key);
signedData = getDataForSignature();
diff --git a/src/main/java/org/uic/barcode/utils/AlgorithmNameResolver.java b/src/main/java/org/uic/barcode/utils/AlgorithmNameResolver.java
index 300bf7d..e3918b0 100644
--- a/src/main/java/org/uic/barcode/utils/AlgorithmNameResolver.java
+++ b/src/main/java/org/uic/barcode/utils/AlgorithmNameResolver.java
@@ -50,7 +50,7 @@ public class AlgorithmNameResolver {
Service pservice = prov.getService(ptype, poid);
String palgo = pservice.getAlgorithm();
- if (ptype.equalsIgnoreCase(type) && poid.equals(oid)) {
+ if (poid != null && ptype.equalsIgnoreCase(type) && poid.equals(oid)) {
return palgo;
}
}
diff --git a/src/test/java/org/uic/barcode/test/utils/TestUtils.java b/src/test/java/org/uic/barcode/test/utils/TestUtils.java
index 7311ae4..20a21c4 100644
--- a/src/test/java/org/uic/barcode/test/utils/TestUtils.java
+++ b/src/test/java/org/uic/barcode/test/utils/TestUtils.java
@@ -1,9 +1,19 @@
package org.uic.barcode.test.utils;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.SecureRandom;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
+import org.bouncycastle.jce.ECNamedCurveTable;
+import org.bouncycastle.jce.spec.ECParameterSpec;
+import org.uic.barcode.utils.AlgorithmNameResolver;
+
public class TestUtils {
final protected static char[] hexArray = "0123456789ABCDEF".toCharArray();
@@ -35,4 +45,29 @@ public class TestUtils {
}
+ /**
+ * Generate DSA keys.
+ *
+ * @return the key pair
+ * @throws NoSuchAlgorithmException the no such algorithm exception
+ * @throws NoSuchProviderException the no such provider exception
+ * @throws InvalidAlgorithmParameterException the invalid algorithm parameter exception
+ */
+ public static KeyPair generateDSAKeys(int keySize) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException{
+ KeyPairGenerator g = KeyPairGenerator.getInstance("DSA", "BC");
+ g.initialize(keySize, new SecureRandom());
+ return g.generateKeyPair();
+ }
+
+ public static KeyPair generateECKeys(String keyAlgorithmOid, String curve) throws Exception{
+
+ String keyAlgorithmName = AlgorithmNameResolver.getName(AlgorithmNameResolver.TYPE_KEY_GENERATOR_ALG, keyAlgorithmOid, "BC");
+
+ keyAlgorithmName = "ECDSA";
+ ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec(curve);
+ KeyPairGenerator g = KeyPairGenerator.getInstance(keyAlgorithmName, "BC");
+ g.initialize(ecSpec, new SecureRandom());
+ return g.generateKeyPair();
+ }
+
}
diff --git a/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java b/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java
index 480ab39..9999cec 100644
--- a/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java
+++ b/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java
@@ -1,6 +1,5 @@
package org.uic.barcode.ticketTestDB;
-import static org.junit.jupiter.api.Assertions.assertAll;
import java.util.TimeZone;
diff --git a/src/test/java/org/uic/barcode/ticketTestDB/EncodeSparpreisTicketDBTest.java b/src/test/java/org/uic/barcode/ticketTestDB/EncodeSparpreisTicketDBTest.java
new file mode 100644
index 0000000..787abf5
--- /dev/null
+++ b/src/test/java/org/uic/barcode/ticketTestDB/EncodeSparpreisTicketDBTest.java
@@ -0,0 +1,121 @@
+package org.uic.barcode.ticketTestDB;
+
+import java.io.IOException;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.KeyPair;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Security;
+import java.util.TimeZone;
+import java.util.zip.DataFormatException;
+
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.uic.barcode.Decoder;
+import org.uic.barcode.Encoder;
+import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.dynamicFrame.Constants;
+import org.uic.barcode.staticFrame.StaticFrame;
+import org.uic.barcode.test.utils.TestUtils;
+import org.uic.barcode.ticket.EncodingFormatException;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+
+public class EncodeSparpreisTicketDBTest {
+
+ /** The algorithm OID. */
+ public String algorithmOID = Constants.DSA_SHA1;
+
+ public int keySize = 1024;
+
+ /** The key pair. */
+ public KeyPair keyPair = null;
+
+ public String securityProvider = null;
+
+ /** the test ticket **/
+ public IUicRailTicket ticket = null;
+
+ TimeZone defaulttimeZone = null;
+
+ /**
+ * Prepare tickets.
+ * @throws DataFormatException
+ * @throws EncodingFormatException
+ * @throws IOException
+ */
+ @Before public void prepare() throws IOException, EncodingFormatException, DataFormatException {
+ defaulttimeZone = TimeZone.getDefault();
+ //decode in local CET time zone
+ TimeZone.setDefault(TimeZone.getTimeZone("CET"));
+
+ algorithmOID = Constants.DSA_SHA1;
+ keySize = 1024;
+
+ Security.addProvider(new BouncyCastleProvider());
+
+ try {
+ keyPair = TestUtils.generateDSAKeys(keySize);
+ } catch (NoSuchAlgorithmException | NoSuchProviderException | InvalidAlgorithmParameterException e) {
+ e.printStackTrace();
+ }
+
+ assert(keyPair != null);
+
+ //get original ticket
+ byte[] content = UperEncoder.bytesFromHexString(getEncodingV2Hex());
+ // decode to get the ticket
+ Decoder decoder = new Decoder(content);
+ ticket = decoder.getUicTicket();
+ StaticFrame frame = decoder.getStaticFrame();
+ securityProvider = frame.getSecurityProvider();
+ }
+
+
+ /**
+ * clean up
+ */
+ @After public void resetTimeZone() {
+ TimeZone.setDefault(defaulttimeZone);
+ }
+
+ @Test
+ public void testDecoder() throws Exception {
+
+ Encoder encoder = new Encoder(ticket, null, Encoder.UIC_BARCODE_TYPE_CLASSIC, 1, 2);
+ encoder.signLevel1(securityProvider, keyPair.getPrivate(), algorithmOID, "1");
+
+ byte[] encoded = encoder.encode();
+
+ assert(encoded != null);
+
+ //TODO check ticket in detail
+
+ }
+
+ private static String getEncodingV2Hex() {
+
+ return "2355543032313038303030303032782e" +
+ "2fe184a1d85e89e9338b298ec61aeba2" +
+ "48ce722056ca940a967c8a1d39126e2c" +
+ "628c4fcea91ba35216a0a350f894de5e" +
+ "bd7b8909920fde947feede0e20c43031" +
+ "3939789c01bc0043ff555f464c455831" +
+ "333031383862b20086e10dc125ea2815" +
+ "110881051c844464d985668e23a00a80" +
+ "000e96c2e4e6e8cadc08aed2d8d90104" +
+ "44d7be0100221ce610ea559b64364c38" +
+ "a82361d1cb5e1e5d32a3d0979bd099c8" +
+ "426b0b7373432b4b6852932baba3634b" +
+ "733b2b715ab34b09d101e18981c181f1" +
+ "424221521291521292a17a3a920a1152" +
+ "5a095282314952b20a49529952826278" +
+ "083001a4c38ae5bb303ace7003800700" +
+ "14b00240400f53757065722053706172" +
+ "7072656973c41e4a03";
+ }
+
+
+
+} \ No newline at end of file
diff --git a/src/test/java/org/uic/barcode/ticketTestDB/SignatureValidationDBTicketTest.java b/src/test/java/org/uic/barcode/ticketTestDB/SignatureValidationDBTicketTest.java
index 44f9c4a..9249f4f 100644
--- a/src/test/java/org/uic/barcode/ticketTestDB/SignatureValidationDBTicketTest.java
+++ b/src/test/java/org/uic/barcode/ticketTestDB/SignatureValidationDBTicketTest.java
@@ -58,7 +58,7 @@ public class SignatureValidationDBTicketTest {
assert("00002".equals(keyVersion));
- String algorithmOID = Constants.DSA_SHA248;
+ String algorithmOID = Constants.DSA_SHA256;
int result = decoder.validateLevel1(getPublicKey2(), algorithmOID);