diff options
Diffstat (limited to 'src/test/java/org/uic/barcode')
36 files changed, 269 insertions, 199 deletions
diff --git a/src/test/java/org/uic/barcode/asn1/test/BinaryStringTest.java b/src/test/java/org/uic/barcode/asn1/test/BinaryStringTest.java index bb06eae..6129db3 100644 --- a/src/test/java/org/uic/barcode/asn1/test/BinaryStringTest.java +++ b/src/test/java/org/uic/barcode/asn1/test/BinaryStringTest.java @@ -41,7 +41,7 @@ public class BinaryStringTest { 0b0000_0001,
};
String bs3 = AsnUtils.toBooleanString(mask);
- byte[] bytes2 = AsnUtils.fromBooleanString(bs3);
+ //byte[] bytes2 = AsnUtils.fromBooleanString(bs3);
byte[] mask2 = new byte[] {
@@ -51,7 +51,7 @@ public class BinaryStringTest { 0b0001_0000,
};
String bs4 = AsnUtils.toBooleanString(mask2);
- byte[] bytes3 = AsnUtils.fromBooleanString(bs4);
+ //byte[] bytes3 = AsnUtils.fromBooleanString(bs4);
assert(bs4.equals(ms2));
diff --git a/src/test/java/org/uic/barcode/asn1/test/TestSequenceOfLong.java b/src/test/java/org/uic/barcode/asn1/test/TestSequenceOfLong.java index 61af5fa..821bf2b 100644 --- a/src/test/java/org/uic/barcode/asn1/test/TestSequenceOfLong.java +++ b/src/test/java/org/uic/barcode/asn1/test/TestSequenceOfLong.java @@ -13,7 +13,7 @@ public class TestSequenceOfLong extends Asn1SequenceOf<Long> { public TestSequenceOfLong(List<Long> numbers) {
super();
for (Long number: numbers){
- this.add(new Long(number));
+ this.add(Long.valueOf(number));
}
}
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeBooleanTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeBooleanTest.java index dea2716..de39e5c 100644 --- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeBooleanTest.java +++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeBooleanTest.java @@ -43,7 +43,7 @@ public class UperEncodeBooleanTest { } @Test public void testTrue() throws IllegalArgumentException, IllegalAccessException { - TestRecord record = new TestRecord(new Boolean(true)); + TestRecord record = new TestRecord(Boolean.valueOf(true)); byte[] encoded = UperEncoder.encode(record); String hex = UperEncoder.hexStringFromBytes(encoded); UperEncoder.logger.log(Level.FINEST,String.format("data hex: %s", hex)); @@ -51,7 +51,7 @@ public class UperEncodeBooleanTest { } @Test public void testFalse() throws IllegalArgumentException, IllegalAccessException { - TestRecord record = new TestRecord(new Boolean(false)); + TestRecord record = new TestRecord(Boolean.valueOf(false)); byte[] encoded = UperEncoder.encode(record); String hex = UperEncoder.hexStringFromBytes(encoded); UperEncoder.logger.log(Level.FINEST,String.format("data hex: %s", hex)); @@ -59,7 +59,7 @@ public class UperEncodeBooleanTest { } @Test public void testDecodeTrue() throws IllegalArgumentException, IllegalAccessException { - TestRecord record = new TestRecord(new Boolean(true)); + TestRecord record = new TestRecord(Boolean.valueOf(true)); byte[] encoded = UperEncoder.encode(record); String hex = UperEncoder.hexStringFromBytes(encoded); UperEncoder.logger.log(Level.FINEST,String.format("data hex: %s", hex)); @@ -70,7 +70,7 @@ public class UperEncodeBooleanTest { } @Test public void testDecodeFalse() throws IllegalArgumentException, IllegalAccessException { - TestRecord record = new TestRecord(new Boolean(false)); + TestRecord record = new TestRecord(Boolean.valueOf(false)); byte[] encoded = UperEncoder.encode(record); String hex = UperEncoder.hexStringFromBytes(encoded); UperEncoder.logger.log(Level.FINEST,String.format("data hex: %s", hex)); diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerConstrainedTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerConstrainedTest.java index 2f46046..bde99fe 100644 --- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerConstrainedTest.java +++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerConstrainedTest.java @@ -42,7 +42,7 @@ public class UperEncodeIntegerConstrainedTest { public TestRecord() { - this(new Long(63L)); + this(Long.valueOf(63L)); } public TestRecord(Long num) { diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerSmallTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerSmallTest.java index 39bfb32..d6600fe 100644 --- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerSmallTest.java +++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerSmallTest.java @@ -33,7 +33,7 @@ public class UperEncodeIntegerSmallTest { public Integer value2; public TestRecord() { - this(new Long(12345678909999899L)); + this(Long.valueOf(12345678909999899L)); } public TestRecord(Long num) { diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerTest.java index 412689b..3e10fc7 100644 --- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerTest.java +++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerTest.java @@ -30,7 +30,7 @@ public class UperEncodeIntegerTest { Asn1BigInteger value; public TestRecord() { - this(new Long(12345678909999899L)); + this(Long.valueOf(12345678909999899L)); } public TestRecord(Long num) { diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeRestrictedIntegerTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeRestrictedIntegerTest.java index f806c88..3f0f08a 100644 --- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeRestrictedIntegerTest.java +++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeRestrictedIntegerTest.java @@ -31,7 +31,7 @@ TestRecord ::= [APPLICATION 0] IMPLICIT SEQUENCE { Long value; public TestRecord() { - this(new Long(33005)); + this(Long.valueOf(33005)); } public TestRecord(Long num) { diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfIntegerTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfIntegerTest.java index 3213b1e..ea0d955 100644 --- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfIntegerTest.java +++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfIntegerTest.java @@ -46,8 +46,8 @@ TestRecord ::= [APPLICATION 0] IMPLICIT SEQUENCE { @Test public void test() throws IllegalArgumentException, IllegalAccessException { ArrayList<Long> nums = new ArrayList<Long>(); - nums.add(new Long(12345678909999899L)); - nums.add(new Long(12345678909999899L)); + nums.add(Long.valueOf(12345678909999899L)); + nums.add(Long.valueOf(12345678909999899L)); TestRecord record = new TestRecord(nums); byte[] encoded = UperEncoder.encode(record); String hex = UperEncoder.hexStringFromBytes(encoded); @@ -59,8 +59,8 @@ TestRecord ::= [APPLICATION 0] IMPLICIT SEQUENCE { @Test public void testDecode() throws IllegalArgumentException, IllegalAccessException { ArrayList<Long> nums = new ArrayList<Long>(); - nums.add(new Long(12345678909999899L)); - nums.add(new Long(12345678909999899L)); + nums.add(Long.valueOf(12345678909999899L)); + nums.add(Long.valueOf(12345678909999899L)); TestRecord record = new TestRecord(nums); byte[] encoded = UperEncoder.encode(record); String hex = UperEncoder.hexStringFromBytes(encoded); diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfRestrictedIntegerTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfRestrictedIntegerTest.java index 33e9b9f..fffffd4 100644 --- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfRestrictedIntegerTest.java +++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfRestrictedIntegerTest.java @@ -49,8 +49,8 @@ TestRecord ::= [APPLICATION 0] IMPLICIT SEQUENCE { TestRecord record = new TestRecord(); - record.addNumber(new Long(9500001L)); - record.addNumber(new Long(9699999L)); + record.addNumber(Long.valueOf(9500001L)); + record.addNumber(Long.valueOf(9699999L)); byte[] encoded = UperEncoder.encode(record); @@ -63,8 +63,8 @@ TestRecord ::= [APPLICATION 0] IMPLICIT SEQUENCE { TestRecord record = new TestRecord(); - record.addNumber(new Long(9500001L)); - record.addNumber(new Long(9699999L)); + record.addNumber(Long.valueOf(9500001L)); + record.addNumber(Long.valueOf(9699999L)); byte[] encoded = UperEncoder.encode(record); diff --git a/src/test/java/org/uic/barcode/test/DynamicContentCoderTest.java b/src/test/java/org/uic/barcode/test/DynamicContentCoderTest.java index 07147bf..1fb8bb9 100644 --- a/src/test/java/org/uic/barcode/test/DynamicContentCoderTest.java +++ b/src/test/java/org/uic/barcode/test/DynamicContentCoderTest.java @@ -2,9 +2,6 @@ package org.uic.barcode.test; import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.TimeZone;
-
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureCompressedCurveTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureCompressedCurveTest.java index 3a3f7d2..344f55f 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureCompressedCurveTest.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureCompressedCurveTest.java @@ -87,7 +87,7 @@ public class DynamicFrameDoubleSignatureCompressedCurveTest { try {
enc.setLevel1Algs(signatureAlgorithmOID, keyPairAlgorithmOID);
enc.setLevel2Algs(signatureAlgorithmOID, keyPairAlgorithmOID,keyPairLevel2.getPublic(), ECKeyEncoder.ENCODING_X962_COMPRESSED);
- enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1", provider);
} catch (Exception e) {
assert(false);
}
@@ -98,7 +98,7 @@ public class DynamicFrameDoubleSignatureCompressedCurveTest { IData level2Data = Level2TestDataFactory.getLevel2SimpleTestData();
try {
enc.setLevel2Data(level2Data);
- enc.signLevel2(keyPairLevel2.getPrivate());
+ enc.signLevel2(keyPairLevel2.getPrivate(),provider);
} catch (Exception e) {
assert(false);
}
@@ -127,7 +127,7 @@ public class DynamicFrameDoubleSignatureCompressedCurveTest { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(), null);
+ signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(), null, provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
@@ -136,7 +136,7 @@ public class DynamicFrameDoubleSignatureCompressedCurveTest { signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel2();
+ signatureCheck = dec.validateLevel2(provider);
} catch (Exception e) {
assert(false);
}
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureCurve2Test.java b/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureCurve2Test.java index f118026..2f2a185 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureCurve2Test.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureCurve2Test.java @@ -86,7 +86,7 @@ public class DynamicFrameDoubleSignatureCurve2Test { try {
enc.setLevel1Algs(signatureAlgorithmOID, keyPairAlgorithmOID);
enc.setLevel2Algs(signatureAlgorithmOID, keyPairAlgorithmOID,keyPairLevel2.getPublic());
- enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1", provider);
} catch (Exception e) {
assert(false);
}
@@ -97,7 +97,7 @@ public class DynamicFrameDoubleSignatureCurve2Test { IData level2Data = Level2TestDataFactory.getLevel2SimpleTestData();
try {
enc.setLevel2Data(level2Data);
- enc.signLevel2(keyPairLevel2.getPrivate());
+ enc.signLevel2(keyPairLevel2.getPrivate(),provider);
} catch (Exception e) {
assert(false);
}
@@ -126,7 +126,7 @@ public class DynamicFrameDoubleSignatureCurve2Test { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(), null);
+ signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(), null, provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
@@ -135,7 +135,7 @@ public class DynamicFrameDoubleSignatureCurve2Test { signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel2();
+ signatureCheck = dec.validateLevel2(provider);
} catch (Exception e) {
assert(false);
}
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentApiTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentApiTest.java index da701bd..5906f8c 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentApiTest.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentApiTest.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -44,6 +45,8 @@ public class DynamicFrameDynamicContentApiTest { public byte[] passIdHash = "PassId".getBytes();
public byte[] phoneIdHash = "myPhone".getBytes();
+ public Provider provider = null;
+
public IUicRailTicket testFCBticket = null;
@@ -58,7 +61,8 @@ public class DynamicFrameDynamicContentApiTest { testFCBticket = SimpleUICTestTicket.getUicTestTicket();
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPairLevel1 = generateECKeys(keyPairAlgorithmOID, elipticCurve);
@@ -91,14 +95,14 @@ public class DynamicFrameDynamicContentApiTest { enc.setLevel2Algs(signatureAlgorithmOID, keyPairAlgorithmOID, keyPairLevel2.getPublic());
try {
- enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
try {
enc.setDynamicData(DynamicTestContent.createDynamicTestContent());
- enc.signLevel2(keyPairLevel2.getPrivate());
+ enc.signLevel2(keyPairLevel2.getPrivate(),provider);
} catch (Exception e) {
assert(false);
@@ -135,14 +139,14 @@ public class DynamicFrameDynamicContentApiTest { enc.setLevel2Algs(signatureAlgorithmOID, keyPairAlgorithmOID, keyPairLevel2.getPublic());
try {
- enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
try {
enc.setDynamicData(DynamicTestContent.createDynamicTestContent());
- enc.signLevel2(keyPairLevel2.getPrivate());
+ enc.signLevel2(keyPairLevel2.getPrivate(),provider);
} catch (Exception e) {
assert(false);
}
@@ -171,7 +175,7 @@ public class DynamicFrameDynamicContentApiTest { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null);
+ signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
@@ -183,7 +187,7 @@ public class DynamicFrameDynamicContentApiTest { int level2check = 0;
try {
- level2check = dec.validateLevel2();
+ level2check = dec.validateLevel2(provider);
} catch (Exception e) {
assert(false);
}
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentTest.java index b91cd0c..a7ea2ea 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentTest.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentTest.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -48,9 +49,13 @@ public class DynamicFrameDynamicContentTest { ZonedDateTime originalTimeStamp = ZonedDateTime.now(ZoneId.of("UTC"));
+ public Provider provider = null;
+
public IUicRailTicket testFCBticket = null;
+
+
@Before public void initialize() {
LoggerFactory.setActivateConsoleLog(true);
@@ -61,7 +66,8 @@ public class DynamicFrameDynamicContentTest { testFCBticket = SimpleUICTestTicket.getUicTestTicket();
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPairLevel1 = generateECKeys(keyPairAlgorithmOID, elipticCurve);
@@ -94,7 +100,7 @@ public class DynamicFrameDynamicContentTest { enc.setLevel2Algs(signatureAlgorithmOID, keyPairAlgorithmOID, keyPairLevel2.getPublic());
try {
- enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1", provider);
} catch (Exception e) {
assert(false);
}
@@ -115,7 +121,7 @@ public class DynamicFrameDynamicContentTest { dcd.setGeoCoordinate(geo);
enc.setDynamicContentDataUIC1(dcd);
- enc.signLevel2(keyPairLevel2.getPrivate());
+ enc.signLevel2(keyPairLevel2.getPrivate(),provider);
} catch (Exception e) {
assert(false);
}
@@ -151,7 +157,7 @@ public class DynamicFrameDynamicContentTest { enc.setLevel2Algs(signatureAlgorithmOID, keyPairAlgorithmOID, keyPairLevel2.getPublic());
try {
- enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -173,7 +179,7 @@ public class DynamicFrameDynamicContentTest { dcd.setTimeStamp(ts);
enc.setDynamicContentDataUIC1(dcd);
- enc.signLevel2(keyPairLevel2.getPrivate());
+ enc.signLevel2(keyPairLevel2.getPrivate(),provider);
} catch (Exception e) {
assert(false);
}
@@ -202,7 +208,7 @@ public class DynamicFrameDynamicContentTest { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null);
+ signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
@@ -214,7 +220,7 @@ public class DynamicFrameDynamicContentTest { int level2check = 0;
try {
- level2check = dec.validateLevel2();
+ level2check = dec.validateLevel2(provider);
} catch (Exception e) {
assert(false);
}
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion1Test.java b/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion1Test.java index dafeb49..b71487e 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion1Test.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion1Test.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -36,6 +37,8 @@ public class DynamicFrameFcbVersion1Test { public IUicRailTicket testFCBticket = null;
+ public Provider provider = null;
+
@Before public void initialize() {
@@ -47,7 +50,8 @@ public class DynamicFrameFcbVersion1Test { testFCBticket = SimpleUICTestTicket.getUicTestTicket();
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateECKeys(Constants.KG_EC, elipticCurve);
@@ -76,7 +80,7 @@ public class DynamicFrameFcbVersion1Test { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -109,7 +113,7 @@ public class DynamicFrameFcbVersion1Test { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -138,7 +142,7 @@ public class DynamicFrameFcbVersion1Test { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),null);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),null,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion3Test.java b/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion3Test.java index 7f03658..08b6df8 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion3Test.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion3Test.java @@ -1,12 +1,11 @@ package org.uic.barcode.test;
import java.io.IOException;
-import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -36,6 +35,8 @@ public class DynamicFrameFcbVersion3Test { public IUicRailTicket testFCBticket = null;
+ public Provider provider = null;
+
@Before public void initialize() {
@@ -47,7 +48,8 @@ public class DynamicFrameFcbVersion3Test { testFCBticket = SimpleUICTestTicket.getUicTestTicket();
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateECKeys(Constants.KG_EC, elipticCurve);
@@ -76,7 +78,7 @@ public class DynamicFrameFcbVersion3Test { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -109,7 +111,7 @@ public class DynamicFrameFcbVersion3Test { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -138,7 +140,7 @@ public class DynamicFrameFcbVersion3Test { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic());
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),null,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameSimpleTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameSimpleTest.java index 931324d..ff552cb 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameSimpleTest.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameSimpleTest.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -35,6 +36,8 @@ public class DynamicFrameSimpleTest { public IUicRailTicket testFCBticket = null;
+ public Provider provider = null;
+
@Before public void initialize() {
@@ -46,7 +49,8 @@ public class DynamicFrameSimpleTest { testFCBticket = SimpleUICTestTicket.getUicTestTicket();
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateECKeys(Constants.KG_EC, elipticCurve);
@@ -75,7 +79,7 @@ public class DynamicFrameSimpleTest { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -109,7 +113,7 @@ public class DynamicFrameSimpleTest { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -138,7 +142,7 @@ public class DynamicFrameSimpleTest { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),null);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),null,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameV2FcbVersion3Test.java b/src/test/java/org/uic/barcode/test/DynamicFrameV2FcbVersion3Test.java index ab4c39e..f9afaef 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameV2FcbVersion3Test.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameV2FcbVersion3Test.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -36,6 +37,8 @@ public class DynamicFrameV2FcbVersion3Test { public IUicRailTicket testFCBticket = null;
+ public Provider provider = null;
+
@Before public void initialize() {
@@ -47,7 +50,8 @@ public class DynamicFrameV2FcbVersion3Test { testFCBticket = SimpleUICTestTicket.getUicTestTicket();
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateECKeys(Constants.KG_EC, elipticCurve);
@@ -76,7 +80,7 @@ public class DynamicFrameV2FcbVersion3Test { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -109,7 +113,7 @@ public class DynamicFrameV2FcbVersion3Test { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -138,7 +142,7 @@ public class DynamicFrameV2FcbVersion3Test { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),null);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),null,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsert2Test.java b/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsert2Test.java index 5b5a8ae..bae03f9 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsert2Test.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsert2Test.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -46,6 +47,8 @@ public class DynamicFrameV2SignatureInsert2Test { public IUicRailTicket testFCBticket = null;
+ public Provider provider = null;
+
ZonedDateTime originalTimeStamp = ZonedDateTime.now(ZoneId.of("UTC"));
@Before public void initialize() {
@@ -58,7 +61,8 @@ public class DynamicFrameV2SignatureInsert2Test { testFCBticket = SimpleUICTestTicket.getUicTestTicket();
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPairLevel1 = generateECKeys(keyPairAlgorithmOID, elipticCurve);
@@ -97,7 +101,7 @@ public class DynamicFrameV2SignatureInsert2Test { //sign level 1 data
try {
- enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -139,7 +143,7 @@ public class DynamicFrameV2SignatureInsert2Test { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null);
+ signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
@@ -169,7 +173,7 @@ public class DynamicFrameV2SignatureInsert2Test { //-----------
// sign level 2
try {
- enc.signLevel2(keyPairLevel2.getPrivate());
+ enc.signLevel2(keyPairLevel2.getPrivate(),provider);
} catch (Exception e) {
assert(false);
}
@@ -204,7 +208,7 @@ public class DynamicFrameV2SignatureInsert2Test { signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null);
+ signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
@@ -215,7 +219,7 @@ public class DynamicFrameV2SignatureInsert2Test { signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel2();
+ signatureCheck = dec.validateLevel2(provider);
} catch (Exception e) {
assert(false);
}
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsertTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsertTest.java index 68be52e..f539bfa 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsertTest.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsertTest.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -46,6 +47,8 @@ public class DynamicFrameV2SignatureInsertTest { public IUicRailTicket testFCBticket = null;
+ public Provider provider = null;
+
ZonedDateTime originalTimeStamp = ZonedDateTime.now(ZoneId.of("UTC"));
@Before public void initialize() {
@@ -58,7 +61,8 @@ public class DynamicFrameV2SignatureInsertTest { testFCBticket = SimpleUICTestTicket.getUicTestTicket();
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPairLevel1 = generateECKeys(keyPairAlgorithmOID, elipticCurve);
@@ -97,7 +101,7 @@ public class DynamicFrameV2SignatureInsertTest { //sign level 1 data
try {
- enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -139,7 +143,7 @@ public class DynamicFrameV2SignatureInsertTest { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null);
+ signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
@@ -188,7 +192,7 @@ public class DynamicFrameV2SignatureInsertTest { //-----------
// sign level 2
try {
- enc.signLevel2(keyPairLevel2.getPrivate());
+ enc.signLevel2(keyPairLevel2.getPrivate(),provider);
} catch (Exception e) {
assert(false);
}
@@ -223,7 +227,7 @@ public class DynamicFrameV2SignatureInsertTest { signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null);
+ signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
@@ -234,7 +238,7 @@ public class DynamicFrameV2SignatureInsertTest { signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel2();
+ signatureCheck = dec.validateLevel2(provider);
} catch (Exception e) {
assert(false);
}
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameV2ValidityDateTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameV2ValidityDateTest.java index a198b97..56272d3 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameV2ValidityDateTest.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameV2ValidityDateTest.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -40,6 +41,8 @@ public class DynamicFrameV2ValidityDateTest { public IUicRailTicket testFCBticket = null;
+ public Provider provider = null;
+
@Before public void initialize() {
@@ -51,7 +54,8 @@ public class DynamicFrameV2ValidityDateTest { testFCBticket = SimpleUICTestTicket.getUicTestTicket();
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateECKeys(Constants.KG_EC, elipticCurve);
@@ -93,7 +97,7 @@ public class DynamicFrameV2ValidityDateTest { enc.getDynamicFrame().getLevel2Data().getLevel1Data().setValidityDuration(100L);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -139,7 +143,7 @@ public class DynamicFrameV2ValidityDateTest { enc.getDynamicFrame().getLevel2Data().getLevel1Data().setValidityDuration(100L);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -168,7 +172,7 @@ public class DynamicFrameV2ValidityDateTest { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),null);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),null,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestGroup.java b/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestGroup.java index f6ec58b..b0f1589 100644 --- a/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestGroup.java +++ b/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestGroup.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -40,6 +41,8 @@ public class SsbFrameBarcodeTestGroup { public SsbFrame ssbFrame = null;
+ public Provider provider = null;
+
/**
* Initialize.
*
@@ -55,7 +58,8 @@ public class SsbFrameBarcodeTestGroup { algorithmOID = Constants.DSA_SHA224;
keySize = 1024;
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateDSAKeys(keySize);
@@ -90,7 +94,7 @@ public class SsbFrameBarcodeTestGroup { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -129,7 +133,7 @@ public class SsbFrameBarcodeTestGroup { assert(enc != null);
try {
- enc.signLevel1("4711", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("4711", keyPair.getPrivate(), algorithmOID, "1", provider);
} catch (Exception e) {
assert(false);
}
@@ -158,7 +162,7 @@ public class SsbFrameBarcodeTestGroup { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestNonUic.java b/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestNonUic.java index 2a28d80..201e417 100644 --- a/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestNonUic.java +++ b/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestNonUic.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -38,6 +39,8 @@ public class SsbFrameBarcodeTestNonUic { public SsbFrame ssbFrame = null;
+
+ public Provider provider = null;
/**
@@ -55,7 +58,8 @@ public class SsbFrameBarcodeTestNonUic { algorithmOID = Constants.DSA_SHA224;
keySize = 1024;
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateDSAKeys(keySize);
@@ -90,7 +94,7 @@ public class SsbFrameBarcodeTestNonUic { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -129,7 +133,7 @@ public class SsbFrameBarcodeTestNonUic { assert(enc != null);
try {
- enc.signLevel1("4711", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("4711", keyPair.getPrivate(), algorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -158,7 +162,7 @@ public class SsbFrameBarcodeTestNonUic { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestNrt.java b/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestNrt.java index 2000ee1..f0e7d79 100644 --- a/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestNrt.java +++ b/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestNrt.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -38,6 +39,8 @@ public class SsbFrameBarcodeTestNrt { public SsbFrame ssbFrame = null;
+
+ public Provider provider = null;
/**
@@ -55,7 +58,8 @@ public class SsbFrameBarcodeTestNrt { algorithmOID = Constants.DSA_SHA224;
keySize = 1024;
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateDSAKeys(keySize);
@@ -90,7 +94,7 @@ public class SsbFrameBarcodeTestNrt { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -129,7 +133,7 @@ public class SsbFrameBarcodeTestNrt { assert(enc != null);
try {
- enc.signLevel1("4711", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("4711", keyPair.getPrivate(), algorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -158,7 +162,7 @@ public class SsbFrameBarcodeTestNrt { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestPass.java b/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestPass.java index dd2101a..ff78d01 100644 --- a/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestPass.java +++ b/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestPass.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -38,6 +39,8 @@ public class SsbFrameBarcodeTestPass { public SsbFrame ssbFrame = null;
+
+ public Provider provider = null;
/**
@@ -55,7 +58,8 @@ public class SsbFrameBarcodeTestPass { algorithmOID = Constants.DSA_SHA224;
keySize = 1024;
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateDSAKeys(keySize);
@@ -90,7 +94,7 @@ public class SsbFrameBarcodeTestPass { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -129,7 +133,7 @@ public class SsbFrameBarcodeTestPass { assert(enc != null);
try {
- enc.signLevel1("4711", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("4711", keyPair.getPrivate(), algorithmOID, "1", provider);
} catch (Exception e) {
assert(false);
}
@@ -158,7 +162,7 @@ public class SsbFrameBarcodeTestPass { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestReservation.java b/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestReservation.java index 5f9e11e..e81bcb4 100644 --- a/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestReservation.java +++ b/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestReservation.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -39,6 +40,8 @@ public class SsbFrameBarcodeTestReservation { public SsbFrame ssbFrame = null;
+ public Provider provider = null;
+
/**
* Initialize.
@@ -55,7 +58,8 @@ public class SsbFrameBarcodeTestReservation { algorithmOID = Constants.DSA_SHA224;
keySize = 1024;
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateDSAKeys(keySize);
@@ -90,7 +94,7 @@ public class SsbFrameBarcodeTestReservation { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -129,7 +133,7 @@ public class SsbFrameBarcodeTestReservation { assert(enc != null);
try {
- enc.signLevel1("4711", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("4711", keyPair.getPrivate(), algorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -158,7 +162,7 @@ public class SsbFrameBarcodeTestReservation { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTest.java b/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTest.java index 0aafc3b..2162b71 100644 --- a/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTest.java +++ b/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTest.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -43,6 +44,8 @@ public class StaticFrameBarcodeTest { public TicketLayout testLayout = null;
+ public Provider provider = null;
+
/**
* Initialize.
@@ -61,7 +64,8 @@ public class StaticFrameBarcodeTest { testFCBticket = SimpleUICTestTicket.getUicTestTicket();
testLayout = SimpleTestTicketLayout.getSimpleTestTicketLayout();
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateDSAKeys(keySize);
@@ -96,7 +100,7 @@ public class StaticFrameBarcodeTest { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -136,7 +140,7 @@ public class StaticFrameBarcodeTest { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1", provider);
} catch (Exception e) {
assert(false);
}
@@ -165,7 +169,7 @@ public class StaticFrameBarcodeTest { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID, provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTestFCB2.java b/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTestFCB2.java index 0a0c245..ab6c2b4 100644 --- a/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTestFCB2.java +++ b/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTestFCB2.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -43,6 +44,8 @@ public class StaticFrameBarcodeTestFCB2 { public TicketLayout testLayout = null;
+ public Provider provider = null;
+
/**
* Initialize.
@@ -61,7 +64,8 @@ public class StaticFrameBarcodeTestFCB2 { testFCBticket = SimpleUICTestTicket.getUicTestTicket();
testLayout = SimpleTestTicketLayout.getSimpleTestTicketLayout();
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateDSAKeys(keySize);
@@ -96,7 +100,7 @@ public class StaticFrameBarcodeTestFCB2 { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -136,7 +140,7 @@ public class StaticFrameBarcodeTestFCB2 { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1", provider);
} catch (Exception e) {
assert(false);
}
@@ -165,7 +169,7 @@ public class StaticFrameBarcodeTestFCB2 { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/TimeStampTest.java b/src/test/java/org/uic/barcode/test/TimeStampTest.java index 8c07b06..c2c1d19 100644 --- a/src/test/java/org/uic/barcode/test/TimeStampTest.java +++ b/src/test/java/org/uic/barcode/test/TimeStampTest.java @@ -65,8 +65,8 @@ public class TimeStampTest { //implementation not available on older android versions:
ZonedDateTime now = ZonedDateTime.now(ZoneId.of("UTC"));
- long day = new Long(now.get(ChronoField.DAY_OF_YEAR));
- long secondOfDay = new Long(now.get(ChronoField.SECOND_OF_DAY));
+ long day = Long.valueOf(now.get(ChronoField.DAY_OF_YEAR));
+ long secondOfDay = Long.valueOf(now.get(ChronoField.SECOND_OF_DAY));
//alternative implementation
Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/SecurityProviderTestV1.java b/src/test/java/org/uic/barcode/ticket/api/test/SecurityProviderTestV1.java index 240907c..d0fc191 100644 --- a/src/test/java/org/uic/barcode/ticket/api/test/SecurityProviderTestV1.java +++ b/src/test/java/org/uic/barcode/ticket/api/test/SecurityProviderTestV1.java @@ -1,6 +1,5 @@ package org.uic.barcode.ticket.api.test;
-import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
@@ -8,11 +7,10 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
import java.util.zip.DataFormatException;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
@@ -46,6 +44,8 @@ public class SecurityProviderTestV1 { public TicketLayout testLayout = null;
+ public Provider provider = null;
+
/**
* Initialize.
@@ -66,8 +66,8 @@ public class SecurityProviderTestV1 { testFCBticket.getIssuerDetails().setSecurityProvider("1080");
testFCBticket.getIssuerDetails().setIssuer("4711");
-
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateDSAKeys(keySize);
@@ -105,7 +105,7 @@ public class SecurityProviderTestV1 { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -134,7 +134,7 @@ public class SecurityProviderTestV1 { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/ticketTestDB/BahnCardTest.java b/src/test/java/org/uic/barcode/ticketTestDB/BahnCardTest.java index 8a0dd8d..f89e7e7 100644 --- a/src/test/java/org/uic/barcode/ticketTestDB/BahnCardTest.java +++ b/src/test/java/org/uic/barcode/ticketTestDB/BahnCardTest.java @@ -61,7 +61,7 @@ public class BahnCardTest { assert(card.getCardTypeDescr().equals("My BahnCard 50 (2. Klasse)")); assert(card.getClassCode().equals(ITravelClassType.second)); assert(card.getExtension() != null); - assert(card.getIncludedServices().contains(new Integer(1))); + assert(card.getIncludedServices().contains(Integer.valueOf(1))); Assert.assertNotNull(card.getCustomer() != null); diff --git a/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java b/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java index 2898b59..90e33c1 100644 --- a/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java +++ b/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java @@ -98,7 +98,7 @@ public class DecodeSparpreisTicketDBTest { Assert.assertNotNull(tl); assert(tl.getTrain().equals("ICE973")); String departureDate = tl.getDepartureDateTime().toString(); - assert(departureDate.equals("Fri Nov 06 11:58:00 CET 2020")); + assert(departureDate.equals("Thu Nov 05 11:58:00 CET 2020")); Assert.assertNull(layout); Assert.assertNotNull(decoder); } diff --git a/src/test/java/org/uic/barcode/ticketTestDB/EncodeSparpreisTicketDBTest.java b/src/test/java/org/uic/barcode/ticketTestDB/EncodeSparpreisTicketDBTest.java index 2cb6d69..cddcd60 100644 --- a/src/test/java/org/uic/barcode/ticketTestDB/EncodeSparpreisTicketDBTest.java +++ b/src/test/java/org/uic/barcode/ticketTestDB/EncodeSparpreisTicketDBTest.java @@ -5,6 +5,7 @@ import java.security.InvalidAlgorithmParameterException; import java.security.KeyPair;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.Security;
import java.util.TimeZone;
import java.util.zip.DataFormatException;
@@ -39,6 +40,8 @@ public class EncodeSparpreisTicketDBTest { public IUicRailTicket ticket = null;
TimeZone defaulttimeZone = null;
+
+ public Provider provider = null;
/**
* Prepare tickets.
@@ -57,7 +60,8 @@ public class EncodeSparpreisTicketDBTest { algorithmOID = Constants.DSA_SHA1;
keySize = 1024;
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = TestUtils.generateDSAKeys(keySize);
@@ -88,7 +92,7 @@ public class EncodeSparpreisTicketDBTest { 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");
+ encoder.signLevel1(securityProvider, keyPair.getPrivate(), algorithmOID, "1", null);
byte[] encoded = encoder.encode();
diff --git a/src/test/java/org/uic/barcode/ticketTestDB/EurailPassTest.java b/src/test/java/org/uic/barcode/ticketTestDB/EurailPassTest.java index b75f248..cc317b8 100644 --- a/src/test/java/org/uic/barcode/ticketTestDB/EurailPassTest.java +++ b/src/test/java/org/uic/barcode/ticketTestDB/EurailPassTest.java @@ -1,7 +1,6 @@ package org.uic.barcode.ticketTestDB; -import java.util.Base64; import java.util.TimeZone; import org.junit.After; @@ -12,7 +11,6 @@ import org.uic.barcode.Decoder; import org.uic.barcode.logger.LoggerFactory; import org.uic.barcode.staticFrame.ticketLayoutBarcode.TicketLayout; import org.uic.barcode.test.utils.TestUtils; -import org.uic.barcode.ticket.api.spec.IUicRailTicket; public class EurailPassTest { @@ -70,7 +68,7 @@ public class EurailPassTest { // try to decode Decoder decoder = new Decoder(content); TicketLayout layout = decoder.getLayout(); - IUicRailTicket ticket = decoder.getUicTicket(); + //IUicRailTicket ticket = decoder.getUicTicket(); Assert.assertNotNull(layout); //Assert.assertNotNull(ticket); diff --git a/src/test/java/org/uic/barcode/ticketTestDB/SignatureValidationDBTicketTest.java b/src/test/java/org/uic/barcode/ticketTestDB/SignatureValidationDBTicketTest.java index e8922d2..d4b262f 100644 --- a/src/test/java/org/uic/barcode/ticketTestDB/SignatureValidationDBTicketTest.java +++ b/src/test/java/org/uic/barcode/ticketTestDB/SignatureValidationDBTicketTest.java @@ -2,6 +2,7 @@ package org.uic.barcode.ticketTestDB; import java.io.ByteArrayInputStream;
import java.security.NoSuchAlgorithmException;
+import java.security.Provider;
import java.security.PublicKey;
import java.security.Security;
import java.security.cert.CertificateException;
@@ -23,6 +24,8 @@ import org.uic.barcode.logger.LoggerFactory; public class SignatureValidationDBTicketTest {
TimeZone defaulttimeZone = null;
+
+ Provider provider= null;
/**
* Prepare tickets.
@@ -30,8 +33,9 @@ public class SignatureValidationDBTicketTest { @Before public void prepare() {
LoggerFactory.setActivateConsoleLog(true);
-
- Security.addProvider(new BouncyCastleProvider());
+
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
defaulttimeZone = TimeZone.getDefault();
//decode in local CET time zone
@@ -63,7 +67,7 @@ public class SignatureValidationDBTicketTest { String algorithmOID = Constants.DSA_SHA256;
- int result = decoder.validateLevel1(getPublicKey2(), algorithmOID);
+ int result = decoder.validateLevel1(getPublicKey2(), algorithmOID,provider);
assert(result == 0);
diff --git a/src/test/java/org/uic/barcode/ticketTests/TIticketTest.java b/src/test/java/org/uic/barcode/ticketTests/TIticketTest.java index b205e16..a428995 100644 --- a/src/test/java/org/uic/barcode/ticketTests/TIticketTest.java +++ b/src/test/java/org/uic/barcode/ticketTests/TIticketTest.java @@ -1,75 +1,78 @@ -package org.uic.barcode.ticketTests; - - -import java.util.Base64; -import java.util.TimeZone; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.uic.barcode.Decoder; -import org.uic.barcode.dynamicFrame.Constants; -import org.uic.barcode.dynamicFrame.api.IDynamicFrame; -import org.uic.barcode.logger.LoggerFactory; -import org.uic.barcode.staticFrame.ticketLayoutBarcode.TicketLayout; -import org.uic.barcode.ticket.api.spec.IUicRailTicket; - -public class TIticketTest { - - TimeZone defaulttimeZone = null; - - String ticketBase64 = "AVVlV4hJ4ABQCCRocJknuREASeB6KmwhTRgwYMGrRg4coAqB4AROT01FB0NP" - + "R05PTUVPAEAEEgFYWAAAFAO5r+0lA5zvA32uCITK5NwUtOrK5NLG0ECQxJ3AidwAAAQVQyRn" - + "HoGAg4SwQyQAsoGCAYCEFUMkZx6CAYEtmCyYCYMDlUMkZx6BAIMEFUMkZx6BgIOBoQACIdM/" - + "3NC/C94syIud9wO7mYNByejQ4l/ik6HEhi7t3XV7vuPZQox/T2r6zccEDw3Ri48MO0LAjOH6" - + "sdzYk9CRfgMaOYIoEQM8jg15cDXzeO2ixAMSKKNvwfo2Fa5brPyMkyd0o0EpmBEIBRkK7smz" - + "ZoF34ztlSrOxWZs5itVsgL3PIlWZ/yhVOgpo"; - - - - - /** - * Prepare tickets. - */ - @Before public void prepare() { - - LoggerFactory.setActivateConsoleLog(true); - - defaulttimeZone = TimeZone.getDefault(); - //decode in local CET time zone - TimeZone.setDefault(TimeZone.getTimeZone("CET")); - } - - - /** - * clean up - */ - @After public void resetTimeZone() { - TimeZone.setDefault(defaulttimeZone); - } - - @Test - public void testDecoder() throws Exception { - - - byte[] content = Base64.getDecoder().decode(ticketBase64); - - // try to decode - Decoder decoder = new Decoder(content); - TicketLayout layout = decoder.getLayout(); - IUicRailTicket ticket = decoder.getUicTicket(); - IDynamicFrame frame = decoder.getDynamicFrame(); - - Assert.assertNotNull(frame); - Assert.assertNotNull(frame.getLevel2Data()); - Assert.assertNotNull(frame.getLevel2Data().getLevel1Data()); - - Assert.assertNotNull(frame.getLevel2Data().getLevel1Signature()); - assert(frame.getFormat().equals(Constants.DYNAMIC_BARCODE_FORMAT_VERSION_2)); - - - } - - +package org.uic.barcode.ticketTests;
+
+
+import java.util.Base64;
+import java.util.TimeZone;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.uic.barcode.Decoder;
+import org.uic.barcode.dynamicFrame.Constants;
+import org.uic.barcode.dynamicFrame.api.IDynamicFrame;
+import org.uic.barcode.logger.LoggerFactory;
+import org.uic.barcode.staticFrame.ticketLayoutBarcode.TicketLayout;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+
+public class TIticketTest {
+
+ TimeZone defaulttimeZone = null;
+
+ String ticketBase64 = "AVVlV4hJ4ABQCCRocJknuREASeB6KmwhTRgwYMGrRg4coAqB4AROT01FB0NP"
+ + "R05PTUVPAEAEEgFYWAAAFAO5r+0lA5zvA32uCITK5NwUtOrK5NLG0ECQxJ3AidwAAAQVQyRn"
+ + "HoGAg4SwQyQAsoGCAYCEFUMkZx6CAYEtmCyYCYMDlUMkZx6BAIMEFUMkZx6BgIOBoQACIdM/"
+ + "3NC/C94syIud9wO7mYNByejQ4l/ik6HEhi7t3XV7vuPZQox/T2r6zccEDw3Ri48MO0LAjOH6"
+ + "sdzYk9CRfgMaOYIoEQM8jg15cDXzeO2ixAMSKKNvwfo2Fa5brPyMkyd0o0EpmBEIBRkK7smz"
+ + "ZoF34ztlSrOxWZs5itVsgL3PIlWZ/yhVOgpo";
+
+
+
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ LoggerFactory.setActivateConsoleLog(true);
+
+ defaulttimeZone = TimeZone.getDefault();
+ //decode in local CET time zone
+ TimeZone.setDefault(TimeZone.getTimeZone("CET"));
+ }
+
+
+ /**
+ * clean up
+ */
+ @After public void resetTimeZone() {
+ TimeZone.setDefault(defaulttimeZone);
+ }
+
+ @Test
+ public void testDecoder() throws Exception {
+
+
+ byte[] content = Base64.getDecoder().decode(ticketBase64);
+
+ // try to decode
+ Decoder decoder = new Decoder(content);
+ TicketLayout layout = decoder.getLayout();
+ IUicRailTicket ticket = decoder.getUicTicket();
+ IDynamicFrame frame = decoder.getDynamicFrame();
+
+ Assert.assertNotNull(frame);
+ Assert.assertNotNull(frame.getLevel2Data());
+ Assert.assertNotNull(frame.getLevel2Data().getLevel1Data());
+
+ Assert.assertNotNull(ticket);
+ Assert.assertNull(layout);
+
+ Assert.assertNotNull(frame.getLevel2Data().getLevel1Signature());
+ assert(frame.getFormat().equals(Constants.DYNAMIC_BARCODE_FORMAT_VERSION_2));
+
+
+ }
+
+
}
\ No newline at end of file |