diff options
Diffstat (limited to '')
5 files changed, 84 insertions, 85 deletions
diff --git a/src/main/java/org/uic/barcode/Decoder.java b/src/main/java/org/uic/barcode/Decoder.java index 637bbf6..0878d8d 100644 --- a/src/main/java/org/uic/barcode/Decoder.java +++ b/src/main/java/org/uic/barcode/Decoder.java @@ -82,6 +82,7 @@ public class Decoder { * @throws UnsupportedOperationException the unsupported operation exception
* @throws IOException Signals that an I/O exception has occurred.
* @throws EncodingFormatException the encoding format exception
+ * @deprecated
*/
public int validateLevel1(PublicKey key) throws InvalidKeyException, NoSuchAlgorithmException, SignatureException, IllegalArgumentException, UnsupportedOperationException, IOException, EncodingFormatException {
if (dynamicFrame != null) {
@@ -115,6 +116,7 @@ public class Decoder { * @throws UnsupportedOperationException the unsupported operation exception
* @throws IOException Signals that an I/O exception has occurred.
* @throws EncodingFormatException the encoding format exception
+ * @deprecated
*/
public int validateLevel1(PublicKey key, String signingAlg) throws InvalidKeyException, NoSuchAlgorithmException, SignatureException, IllegalArgumentException, UnsupportedOperationException, IOException, EncodingFormatException {
if (dynamicFrame != null ) {
@@ -177,6 +179,7 @@ public class Decoder { *
* @return the return code indicating errors
* @throws EncodingFormatException
+ * @deprecated
*/
public int validateLevel2() throws EncodingFormatException {
if (!isStaticHeader(data) && dynamicFrame != null) {
diff --git a/src/main/java/org/uic/barcode/Encoder.java b/src/main/java/org/uic/barcode/Encoder.java index f8dae02..3eb2faf 100644 --- a/src/main/java/org/uic/barcode/Encoder.java +++ b/src/main/java/org/uic/barcode/Encoder.java @@ -234,6 +234,7 @@ public class Encoder { *
* @param key the key
* @throws Exception the exception
+ * @deprecated
*/
public void signLevel2(PrivateKey key) throws Exception {
if (dynamicFrame != null) {
@@ -367,6 +368,7 @@ public class Encoder { * @param signingAlg the signing algorithm (OID)
* @param keyId the key id
* @throws Exception the exception
+ * @deprecated
*/
public void signLevel1(String securityProvider,PrivateKey key,String signingAlg, String keyId) throws Exception {
if (dynamicFrame != null) {
diff --git a/src/main/java/org/uic/barcode/dynamicFrame/api/DynamicFrameCoder.java b/src/main/java/org/uic/barcode/dynamicFrame/api/DynamicFrameCoder.java index 53efb3e..091cd4c 100644 --- a/src/main/java/org/uic/barcode/dynamicFrame/api/DynamicFrameCoder.java +++ b/src/main/java/org/uic/barcode/dynamicFrame/api/DynamicFrameCoder.java @@ -49,10 +49,10 @@ public class DynamicFrameCoder { if (frame.getFormat() != null && frame.getFormat().equals(Constants.DYNAMIC_BARCODE_FORMAT_VERSION_1)) {
return frame;
- }
- } catch(Exception e1) {
+ }
+ } catch (Throwable e) {
frame = null;
- // failed, try next
+ // failed, try next
}
frame = new SimpleDynamicFrame();
@@ -62,7 +62,7 @@ public class DynamicFrameCoder { if (frame.getFormat() != null && frame.getFormat().equals(Constants.DYNAMIC_BARCODE_FORMAT_VERSION_2)) {
return frame;
}
- } catch(Exception e1) {
+ } catch(Throwable e) {
throw new EncodingFormatException("Dynamic Header Version not supported");
// failed
}
diff --git a/src/test/java/org/uic/barcode/ticketTestDB/EurailPassTest2.java b/src/test/java/org/uic/barcode/ticketTestDB/EurailPassTest2.java deleted file mode 100644 index d1db192..0000000 --- a/src/test/java/org/uic/barcode/ticketTestDB/EurailPassTest2.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.uic.barcode.ticketTestDB; - - -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.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 EurailPassTest2 { - - TimeZone defaulttimeZone = null; - - String ticketBase64 = "I1VUMDE5OTAxVFQwMDEwLAIUNSMMrRGIB8fL3UcWDUxGq2yI5YICFEtBKOXG+1" - + "iZAAHvKzvpQNsmkR4CAAAAADAzNzd4nFVSTWvDMAz9KzoHmkl2HKdHL3FpIHWK63T0VAYrbDB2" - + "2MZ+/yT3MyYJSJbee3rKdFx71yEhGr1cIsH9OGWXK7sgpQlJoUL+VuQDwHRMgztwU91gbBPf6I" - + "ZvuZ1fPrWfousHTnMKK0lVwW28kFxrmljC7qMoipw4J6lpx8128BsfkosH2LrdDimDNNJj23EK" - + "KTLzDYconH7fT9+fr19vPygqCbXU6rbfc1RzbLIAmQ6VgPEwMougw+Kp7xYhosqI+cIUD+dPaV" - + "RUcXktKMZ105CYQV1xzd4NfccZBlbCrLSmEqkULbCAe4D6Tq47lzyMK3juY1qjzuwCx+qpLAp+" - + "xEf2jvCcL7AmnEVXUUqf7YYxeLg4dLauNuaxo6ZZZG8RoZ0x2RmTnaHYGYoVFVhnkG0cu6lNsm" - + "jSxD3ayh7sGIYDZJfgpU9rlrj3EVzossjtGBPvgCpjL+bIChQ++nExkMythiqeeQS4rol/iOYiBJe3H/cfqY6d6Q=="; - - - - String ticketHex = "23555430323131383130303330314713bb51986a0c947ce7b06aeb53ef44b96c7cbab606cf" - + "ee61d19d56c352ffc1ace883e82b4edaada9fa715eb7d501fec6df3bc8bd8fc570f3cc37" - + "887f75482630323139789c0b8d77f3718d3030363032322e52625467bced17c0cb69aad3" - + "b0d1b05aa92435b72027b124352cb5a838333f4fc94ac9c8d8c852cf5ccf50494729bfb4" - + "a4a0b424a4b22015281ee0e2a654eb202adc2030e7d2b57b370ebd7ac6b7eed08d17174e" - + "3d99d17b412043f800038b4cc6fd33394fde78acd5ddb8746bebc5a5bd6ba75e68e68b68" - + "d4bc3a77eace090d0a5b1a6fee3db9996fe2d5994be74e3dd3180892bfc4662278f38398" - + "3a7f8a4f8e9e4f57ce3acd736b97b8bbb8b9b8b680043a755a801c35360848810876f9ac" - + "3b0951a5e2bf800100bac05beb"; - - /** - * 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); - - byte[] content = TestUtils.hexStringToByteArray(ticketHex); - - // try to decode - Decoder decoder = new Decoder(content); - TicketLayout layout = decoder.getLayout(); - IUicRailTicket ticket = decoder.getUicTicket(); - - Assert.assertNotNull(layout); - //Assert.assertNotNull(ticket); - - } - - -}
\ No newline at end of file diff --git a/src/test/java/org/uic/barcode/ticketTests/TIticketTest.java b/src/test/java/org/uic/barcode/ticketTests/TIticketTest.java new file mode 100644 index 0000000..b205e16 --- /dev/null +++ b/src/test/java/org/uic/barcode/ticketTests/TIticketTest.java @@ -0,0 +1,75 @@ +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)); + + + } + + +}
\ No newline at end of file |