summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/uic/barcode/Decoder.java
diff options
context:
space:
mode:
authorCGantert345 <57003061+CGantert345@users.noreply.github.com>2021-06-29 16:26:36 +0200
committerGitHub <noreply@github.com>2021-06-29 16:26:36 +0200
commit27d114203f6edaf8aea75ee710bd87f32d79f003 (patch)
tree794e40b39e154adef8e471ab8774c8a68bd3e434 /src/main/java/org/uic/barcode/Decoder.java
parentDelete uicBarcodeFCBv2.0.asn (diff)
parent- test for FCB version 3 (diff)
downloadUIC-barcode-27d114203f6edaf8aea75ee710bd87f32d79f003.tar
UIC-barcode-27d114203f6edaf8aea75ee710bd87f32d79f003.tar.gz
UIC-barcode-27d114203f6edaf8aea75ee710bd87f32d79f003.tar.bz2
UIC-barcode-27d114203f6edaf8aea75ee710bd87f32d79f003.tar.lz
UIC-barcode-27d114203f6edaf8aea75ee710bd87f32d79f003.tar.xz
UIC-barcode-27d114203f6edaf8aea75ee710bd87f32d79f003.tar.zst
UIC-barcode-27d114203f6edaf8aea75ee710bd87f32d79f003.zip
Diffstat (limited to 'src/main/java/org/uic/barcode/Decoder.java')
-rw-r--r--src/main/java/org/uic/barcode/Decoder.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/main/java/org/uic/barcode/Decoder.java b/src/main/java/org/uic/barcode/Decoder.java
index fe53ed0..09ee839 100644
--- a/src/main/java/org/uic/barcode/Decoder.java
+++ b/src/main/java/org/uic/barcode/Decoder.java
@@ -3,6 +3,7 @@ package org.uic.barcode;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
+import java.security.Provider;
import java.security.PublicKey;
import java.security.SignatureException;
import java.util.zip.DataFormatException;
@@ -89,6 +90,34 @@ public class Decoder {
}
}
+
+ /**
+ * Validate level 1.
+ *
+ * @param key the public key
+ * @param signingAlg the signing algorithm OID
+ * @param security provider in case a dedicated provider must be used (otherwise null)
+ * @return the return code indicating errors
+ * @throws InvalidKeyException the invalid key exception
+ * @throws NoSuchAlgorithmException the no such algorithm exception
+ * @throws SignatureException the signature exception
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws UnsupportedOperationException the unsupported operation exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ * @throws EncodingFormatException the encoding format exception
+ */
+ public int validateLevel1(PublicKey key, String signingAlg, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, SignatureException, IllegalArgumentException, UnsupportedOperationException, IOException, EncodingFormatException {
+ if (!isStaticHeader(data)) {
+ return dynamicFrame.validateLevel1(key, provider) ;
+ } else {
+ if (staticFrame.verifyByAlgorithmOid(key,signingAlg, provider)) {
+ return Constants.LEVEL1_VALIDATION_OK;
+ } else {
+ return Constants.LEVEL1_VALIDATION_FRAUD;
+ }
+ }
+ }
+
/**
* Validate level 2.
*
@@ -101,6 +130,20 @@ public class Decoder {
return Constants.LEVEL2_VALIDATION_NO_SIGNATURE;
}
}
+
+ /*
+ * Validate level 2.
+ * @param prov - provider of the java security implementation in case a dedicated provider must be used
+ * @return the return code indicating errors
+ */
+ public int validateLevel2(Provider prov) {
+ if (!isStaticHeader(data)) {
+ return dynamicFrame.validateLevel2(prov) ;
+ } else {
+ return Constants.LEVEL2_VALIDATION_NO_SIGNATURE;
+ }
+ }
+
/**
* Decode.