diff options
author | CGantert345 <57003061+CGantert345@users.noreply.github.com> | 2024-06-18 15:37:32 +0200 |
---|---|---|
committer | CGantert345 <57003061+CGantert345@users.noreply.github.com> | 2024-06-18 15:37:32 +0200 |
commit | f27a600db14d745cb7f13f8dc839863078b7f1c7 (patch) | |
tree | 188418280d46e1e8b4abd7f36269c475140e7c34 /src/main/java/org/uic/barcode/Decoder.java | |
parent | fix test for dynamic content in years with feb29. (diff) | |
download | UIC-barcode-f27a600db14d745cb7f13f8dc839863078b7f1c7.tar UIC-barcode-f27a600db14d745cb7f13f8dc839863078b7f1c7.tar.gz UIC-barcode-f27a600db14d745cb7f13f8dc839863078b7f1c7.tar.bz2 UIC-barcode-f27a600db14d745cb7f13f8dc839863078b7f1c7.tar.lz UIC-barcode-f27a600db14d745cb7f13f8dc839863078b7f1c7.tar.xz UIC-barcode-f27a600db14d745cb7f13f8dc839863078b7f1c7.tar.zst UIC-barcode-f27a600db14d745cb7f13f8dc839863078b7f1c7.zip |
Diffstat (limited to '')
-rw-r--r-- | src/main/java/org/uic/barcode/Decoder.java | 55 |
1 files changed, 18 insertions, 37 deletions
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);
}
/*
|