diff options
author | CGantert345 <57003061+CGantert345@users.noreply.github.com> | 2022-06-09 10:17:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-09 10:17:12 +0200 |
commit | addf44cccdc9fd6d9358e617a501ea26ca6af722 (patch) | |
tree | 81a7b7dbf07b4245cac6c190d4faa9b0cab07d1a /src/main/java/org/uic/barcode/Encoder.java | |
parent | Merge pull request #48 from UnionInternationalCheminsdeFer/1.3.3 (diff) | |
parent | Delete DecodeDB9EuroTicketTest.java (diff) | |
download | UIC-barcode-addf44cccdc9fd6d9358e617a501ea26ca6af722.tar UIC-barcode-addf44cccdc9fd6d9358e617a501ea26ca6af722.tar.gz UIC-barcode-addf44cccdc9fd6d9358e617a501ea26ca6af722.tar.bz2 UIC-barcode-addf44cccdc9fd6d9358e617a501ea26ca6af722.tar.lz UIC-barcode-addf44cccdc9fd6d9358e617a501ea26ca6af722.tar.xz UIC-barcode-addf44cccdc9fd6d9358e617a501ea26ca6af722.tar.zst UIC-barcode-addf44cccdc9fd6d9358e617a501ea26ca6af722.zip |
Diffstat (limited to 'src/main/java/org/uic/barcode/Encoder.java')
-rw-r--r-- | src/main/java/org/uic/barcode/Encoder.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/main/java/org/uic/barcode/Encoder.java b/src/main/java/org/uic/barcode/Encoder.java index 9afddce..b01ca14 100644 --- a/src/main/java/org/uic/barcode/Encoder.java +++ b/src/main/java/org/uic/barcode/Encoder.java @@ -27,6 +27,7 @@ import org.uic.barcode.staticFrame.ticketLayoutBarcode.TicketLayout; import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.UicRailTicketCoder;
import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.utils.ECKeyEncoder;
/**
@@ -278,6 +279,30 @@ public class Encoder { }
}
+ /**
+ * Sets the level 2 algorithm Is.
+ *
+ * @param level2SigningAlg the level 2 signing algorithm (OID)
+ * @param level2KeyAlg the level 2 key algorithm (OID)
+ * @param publicKey the public key of the level 2 signature
+ * @param publicKeyEncodingFormat "X509", for elliptic curve keys only: "X962_UNCOMPRESSED", "X962_COMPRESSED" constants defined in class ECKeyEncoder.
+ **/
+ public void setLevel2Algs(String level2SigningAlg, String level2KeyAlg, PublicKey publicKey, String publicKeyEncodingFormat) {
+ if (dynamicFrame != null) {
+ if (dynamicFrame.getLevel2Data() == null) {
+ dynamicFrame.setLevel2Data(new SimpleLevel2Data());
+ }
+ if (dynamicFrame.getLevel2Data().getLevel1Data() == null) {
+ dynamicFrame.getLevel2Data().setLevel1Data(new SimpleLevel1Data());
+ }
+ dynamicFrame.getLevel2Data().getLevel1Data().setLevel2SigningAlg(level2SigningAlg);
+ dynamicFrame.getLevel2Data().getLevel1Data().setLevel2KeyAlg(level2KeyAlg);
+ if (publicKey != null) {
+ dynamicFrame.getLevel2Data().getLevel1Data().setLevel2publicKey(ECKeyEncoder.getEncoded(publicKey, publicKeyEncodingFormat));
+ }
+ }
+ }
+
public void setDynamicData(IUicDynamicContent content) throws EncodingFormatException {
if (dynamicFrame != null) {
if (dynamicFrame.getLevel2Data() == null) {
|