summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/uic/barcode/Decoder.java
diff options
context:
space:
mode:
authorCGantert345 <57003061+CGantert345@users.noreply.github.com>2024-06-18 15:42:51 +0200
committerGitHub <noreply@github.com>2024-06-18 15:42:51 +0200
commit6b9254296a5b3b323c2e103db40865c01ffad005 (patch)
treea02e7adfe7c44ab01feaf94cd26689f9e09bfc62 /src/main/java/org/uic/barcode/Decoder.java
parentMerge pull request #81 from UnionInternationalCheminsdeFer/fix_test_for_year_with_feb29 (diff)
parentCreate MAVticketTest.java (diff)
downloadUIC-barcode-1.4.6.tar
UIC-barcode-1.4.6.tar.gz
UIC-barcode-1.4.6.tar.bz2
UIC-barcode-1.4.6.tar.lz
UIC-barcode-1.4.6.tar.xz
UIC-barcode-1.4.6.tar.zst
UIC-barcode-1.4.6.zip
Diffstat (limited to 'src/main/java/org/uic/barcode/Decoder.java')
-rw-r--r--src/main/java/org/uic/barcode/Decoder.java55
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);
}
/*