diff options
author | CGantert345 <57003061+CGantert345@users.noreply.github.com> | 2022-02-01 12:45:04 +0100 |
---|---|---|
committer | CGantert345 <57003061+CGantert345@users.noreply.github.com> | 2022-02-01 12:45:04 +0100 |
commit | 2f72a6419dd1e20acf6e77a9276a6055892e732a (patch) | |
tree | 9d5563dd16e6e033058971eca18539102aa9d827 /src/main/java/org/uic/barcode/Decoder.java | |
parent | new dynamic header version (diff) | |
download | UIC-barcode-2f72a6419dd1e20acf6e77a9276a6055892e732a.tar UIC-barcode-2f72a6419dd1e20acf6e77a9276a6055892e732a.tar.gz UIC-barcode-2f72a6419dd1e20acf6e77a9276a6055892e732a.tar.bz2 UIC-barcode-2f72a6419dd1e20acf6e77a9276a6055892e732a.tar.lz UIC-barcode-2f72a6419dd1e20acf6e77a9276a6055892e732a.tar.xz UIC-barcode-2f72a6419dd1e20acf6e77a9276a6055892e732a.tar.zst UIC-barcode-2f72a6419dd1e20acf6e77a9276a6055892e732a.zip |
Diffstat (limited to 'src/main/java/org/uic/barcode/Decoder.java')
-rw-r--r-- | src/main/java/org/uic/barcode/Decoder.java | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/src/main/java/org/uic/barcode/Decoder.java b/src/main/java/org/uic/barcode/Decoder.java index 3d97e0a..9f5ea82 100644 --- a/src/main/java/org/uic/barcode/Decoder.java +++ b/src/main/java/org/uic/barcode/Decoder.java @@ -79,9 +79,35 @@ public class Decoder { * @throws IOException Signals that an I/O exception has occurred.
* @throws EncodingFormatException the encoding format exception
*/
+ public int validateLevel1(PublicKey key) throws InvalidKeyException, NoSuchAlgorithmException, SignatureException, IllegalArgumentException, UnsupportedOperationException, IOException, EncodingFormatException {
+ if (dynamicFrame != null) {
+ return dynamicFrame.validateLevel1(key) ;
+ } else {
+ if (staticFrame != null) {
+ return Constants.LEVEL1_VALIDATION_SIG_ALG_NOT_IMPLEMENTED;
+ } else {
+ return Constants.LEVEL1_VALIDATION_FRAUD;
+ }
+ }
+ }
+
+ /**
+ * Validate level 1.
+ *
+ * @param key the public key
+ * @param signingAlg the signing algorithm OID
+ * @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) throws InvalidKeyException, NoSuchAlgorithmException, SignatureException, IllegalArgumentException, UnsupportedOperationException, IOException, EncodingFormatException {
if (dynamicFrame != null) {
- return dynamicFrame.validateLevel1(key, data) ;
+ return dynamicFrame.validateLevel1(key, signingAlg) ;
} else {
if (staticFrame.verifyByAlgorithmOid(key,signingAlg)) {
return Constants.LEVEL1_VALIDATION_OK;
@@ -108,7 +134,7 @@ public class Decoder { */
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, data) ;
+ return dynamicFrame.validateLevel1(key, provider) ;
} else {
if (staticFrame.verifyByAlgorithmOid(key,signingAlg, provider)) {
return Constants.LEVEL1_VALIDATION_OK;
@@ -126,7 +152,7 @@ public class Decoder { */
public int validateLevel2() throws EncodingFormatException {
if (!isStaticHeader(data)) {
- return dynamicFrame.validateLevel2(null, data) ;
+ return dynamicFrame.validateLevel2() ;
} else {
return Constants.LEVEL2_VALIDATION_NO_SIGNATURE;
}
@@ -139,7 +165,7 @@ public class Decoder { */
public int validateLevel2(Provider prov) throws EncodingFormatException {
if (!isStaticHeader(data)) {
- return dynamicFrame.validateLevel2(prov,data) ;
+ return dynamicFrame.validateLevel2(prov) ;
} else {
return Constants.LEVEL2_VALIDATION_NO_SIGNATURE;
}
@@ -164,7 +190,6 @@ public class Decoder { ILevel1Data level1 = level2.getLevel1Data();
-
for (IData level1Content : level1.getData()) {
uicTicketCoder = new UicRailTicketCoder();
|