From f27a600db14d745cb7f13f8dc839863078b7f1c7 Mon Sep 17 00:00:00 2001 From: CGantert345 <57003061+CGantert345@users.noreply.github.com> Date: Tue, 18 Jun 2024 15:37:32 +0200 Subject: - bug fix on travel date in train link in version 1.3 - bug fix on travel date in train link in version 1.3 - replaced out-dated java functions - switched all tests to non-deprecated functions --- src/main/java/org/uic/barcode/Decoder.java | 55 ++++++++++-------------------- 1 file changed, 18 insertions(+), 37 deletions(-) (limited to 'src/main/java/org/uic/barcode/Decoder.java') diff --git a/src/main/java/org/uic/barcode/Decoder.java b/src/main/java/org/uic/barcode/Decoder.java index d9f20ff..1e0a02d 100644 --- a/src/main/java/org/uic/barcode/Decoder.java +++ b/src/main/java/org/uic/barcode/Decoder.java @@ -56,7 +56,17 @@ public class Decoder { /** The data. */ byte[] data = null; + private Provider defaultProvider = null; + + public Provider getDefaultProvider() { + return defaultProvider; + } + + public void setDefaultProvider(Provider defaultProvider) { + this.defaultProvider = defaultProvider; + } + /** * Instantiates a new decoder. * @@ -67,6 +77,11 @@ public class Decoder { */ public Decoder (byte[] data) throws IOException, EncodingFormatException, DataFormatException { this.data = data; + + if (defaultProvider == null) { + defaultProvider = SecurityUtils.getDefaultProvider(); + } + decode(data); } @@ -86,22 +101,7 @@ public class Decoder { * @deprecated */ public int validateLevel1(PublicKey key) throws InvalidKeyException, NoSuchAlgorithmException, SignatureException, IllegalArgumentException, UnsupportedOperationException, IOException, EncodingFormatException { - if (dynamicFrame != null) { - return dynamicFrame.validateLevel1(key) ; - } else if (staticFrame != null) { - if (staticFrame.verifyByAlgorithmOid(key,null)) { - return Constants.LEVEL1_VALIDATION_OK; - } else { - return Constants.LEVEL1_VALIDATION_FRAUD; - } - } else if (ssbFrame!= null) { - if (ssbFrame.verifyByAlgorithmOid(key,null, null)) { - return Constants.LEVEL1_VALIDATION_OK; - } else { - return Constants.LEVEL1_VALIDATION_FRAUD; - } - } - return Constants.LEVEL1_VALIDATION_NO_SIGNATURE; + return validateLevel1(key,null, defaultProvider); } /** @@ -120,22 +120,7 @@ public class Decoder { * @deprecated */ public int validateLevel1(PublicKey key, String signingAlg) throws InvalidKeyException, NoSuchAlgorithmException, SignatureException, IllegalArgumentException, UnsupportedOperationException, IOException, EncodingFormatException { - if (dynamicFrame != null ) { - return dynamicFrame.validateLevel1(key, signingAlg) ; - } else if (staticFrame != null) { - if (staticFrame.verifyByAlgorithmOid(key,signingAlg)) { - return Constants.LEVEL1_VALIDATION_OK; - } else { - return Constants.LEVEL1_VALIDATION_FRAUD; - } - } else if (ssbFrame!= null) { - if (ssbFrame.verifyByAlgorithmOid(key,signingAlg, null)) { - return Constants.LEVEL1_VALIDATION_OK; - } else { - return Constants.LEVEL1_VALIDATION_FRAUD; - } - } - return Constants.LEVEL1_VALIDATION_NO_SIGNATURE; + return validateLevel1(key, signingAlg, defaultProvider); } /** @@ -184,11 +169,7 @@ public class Decoder { * @deprecated */ public int validateLevel2() throws EncodingFormatException { - if (!isStaticHeader(data) && dynamicFrame != null) { - return dynamicFrame.validateLevel2() ; - } else { - return Constants.LEVEL2_VALIDATION_NO_SIGNATURE; - } + return validateLevel2(defaultProvider); } /* -- cgit v1.2.3