From a7515e3c057ef00ade3ae093b179c2787f07803b Mon Sep 17 00:00:00 2001 From: CGantert345 <57003061+CGantert345@users.noreply.github.com> Date: Thu, 30 Apr 2020 14:39:47 +0200 Subject: Implementation of ObjectIdentifier and dynamic header --- src/org/uic/header/DataBlockType.java | 110 ++++++++++++++++ src/org/uic/header/DataType.java | 66 ++++++++++ src/org/uic/header/DynamicHeader.java | 204 +++++++++++++++++++++++++++++ src/org/uic/header/Extension.java | 72 ++++++++++ src/org/uic/header/SequenceOfDataType.java | 26 ++++ src/org/uic/header/SignedDataType.java | 58 ++++++++ 6 files changed, 536 insertions(+) create mode 100644 src/org/uic/header/DataBlockType.java create mode 100644 src/org/uic/header/DataType.java create mode 100644 src/org/uic/header/DynamicHeader.java create mode 100644 src/org/uic/header/Extension.java create mode 100644 src/org/uic/header/SequenceOfDataType.java create mode 100644 src/org/uic/header/SignedDataType.java (limited to 'src/org') diff --git a/src/org/uic/header/DataBlockType.java b/src/org/uic/header/DataBlockType.java new file mode 100644 index 0000000..ce4084f --- /dev/null +++ b/src/org/uic/header/DataBlockType.java @@ -0,0 +1,110 @@ +package org.uic.header; + +import net.gcdc.asn1.datatypes.Asn1Optional; +import net.gcdc.asn1.datatypes.CharacterRestriction; +import net.gcdc.asn1.datatypes.IntRange; +import net.gcdc.asn1.datatypes.RestrictedString; +import net.gcdc.asn1.datatypes.Sequence; + +/** + * The Class DataBlockType. + */ +@Sequence +public class DataBlockType { + + + /** The data. */ + public SequenceOfDataType data; + + /** + * The signing algorithm + * Object Identifier of the Algorithm + * Number notation: + * + * e.g.: + * -- DSA SHA224 2.16.840.1.101.3.4.3.1 + * -- DSA SHA248 2.16.840.1.101.3.4.3.2 + * -- ECC 1.2.840.10045.3.1.7 + * + * + */ + @RestrictedString(CharacterRestriction.ObjectIdentifier) + @Asn1Optional public String signingAlg; + + /** The key id. */ + @IntRange(minValue=1,maxValue=1024) + @Asn1Optional public Long keyId; + + /** + * Gets the data. + * + * @return the data + */ + public SequenceOfDataType getData() { + return data; + } + + /** + * Sets the data. + * + * @param data the new data + */ + public void setData(SequenceOfDataType data) { + this.data = data; + } + + /** + * Gets the signing algorithm + * + * Object Identifier of algorithm Algorithm + * Number notation: + * + * e.g.: + * -- DSA SHA224 2.16.840.1.101.3.4.3.1 + * -- DSA SHA248 2.16.840.1.101.3.4.3.2 + * -- ECC 1.2.840.10045.3.1.7 + * + * @return the signing alg + */ + public String getSigningAlg() { + return signingAlg; + } + + /** + * Sets the signing algorithm + * + * Object Identifier of the Algorithm + * Number notation: + * + * e.g.: + * -- DSA SHA224 2.16.840.1.101.3.4.3.1 + * -- DSA SHA248 2.16.840.1.101.3.4.3.2 + * -- ECC 1.2.840.10045.3.1.7 + * + * @param signingAlg the new signing algorithm + */ + public void setSigningAlg(String signingAlgorithm) { + this.signingAlg = signingAlgorithm; + } + + /** + * Gets the key id. + * + * @return the key id + */ + public Long getKeyId() { + return keyId; + } + + /** + * Sets the key id. + * + * @param keyId the new key id + */ + public void setKeyId(Long keyId) { + this.keyId = keyId; + } + + + +} diff --git a/src/org/uic/header/DataType.java b/src/org/uic/header/DataType.java new file mode 100644 index 0000000..8d453a3 --- /dev/null +++ b/src/org/uic/header/DataType.java @@ -0,0 +1,66 @@ +package org.uic.header; + +import net.gcdc.asn1.datatypes.Sequence; +import net.gcdc.asn1.datatypesimpl.OctetString; + +// TODO: Auto-generated Javadoc +/** + * The Class DataType. + */ +@Sequence +public class DataType { + + /* + * -- format: + -- FCB1 FCB version 1 + -- RICS company code + addon + */ + + /** The data format. + * + * -- FCB1 FCB version 1 + * -- FCB2 FCB version 2 + * -- RICS company code + ... + * */ + public String format; + + /** The data. */ + public OctetString data; + + /** + * Gets the data format. + * + * @return the data format + */ + public String getFormat() { + return format; + } + + /** + * Sets the data format. + * + * @param dataFormat the new data format + */ + public void setFormat(String format) { + this.format = format; + } + + /** + * Gets the data. + * + * @return the data + */ + public OctetString getData() { + return data; + } + + /** + * Sets the data. + * + * @param data the new data + */ + public void setData(OctetString data) { + this.data = data; + } + +} diff --git a/src/org/uic/header/DynamicHeader.java b/src/org/uic/header/DynamicHeader.java new file mode 100644 index 0000000..05e06eb --- /dev/null +++ b/src/org/uic/header/DynamicHeader.java @@ -0,0 +1,204 @@ +package org.uic.header; + +import net.gcdc.asn1.datatypes.Asn1Optional; +import net.gcdc.asn1.datatypes.CharacterRestriction; +import net.gcdc.asn1.datatypes.HasExtensionMarker; +import net.gcdc.asn1.datatypes.IntRange; +import net.gcdc.asn1.datatypes.RestrictedString; +import net.gcdc.asn1.datatypes.Sequence; +import net.gcdc.asn1.datatypesimpl.OctetString; + + +/** + * The DynamicHeader for bar codes + * + * Implementation of the Draft under discussion, not final + * + */ +@Sequence +@HasExtensionMarker +public class DynamicHeader { + + + /** The format. */ + @RestrictedString(CharacterRestriction.IA5String) + public String format; + + /** The vesion. */ + @IntRange(minValue=1,maxValue=16) + public Long version; + + + /** + * The security provider + * numeric codes 1 ...32000 + * + * */ + @IntRange(minValue=1,maxValue=32000) + @Asn1Optional public Long securityProviderNum; + + /** The security provider + * alphanumeric codes + */ + @RestrictedString(CharacterRestriction.IA5String) + @Asn1Optional public String securityProviderIA5; + + + /** The static data. */ + public SignedDataType staticData; + + /** The dynamic data. */ + @Asn1Optional public SignedDataType dynamicData; + + /** The dynamic public key. */ + @Asn1Optional public OctetString dynamicPublicKey; + + /** The extension. */ + @Asn1Optional public Extension extension; + + /** + * Gets the format. + * + * @return the format + */ + public String getFormat() { + return format; + } + + /** + * Sets the format. + * + * @param format the new format + */ + public void setFormat(String format) { + this.format = format; + } + + /** + * Gets the version. + * + * @return the version + */ + public Long getVersion() { + return version; + } + + /** + * Sets the version. + * + * @param vesion the new version + */ + public void setVersion(Long version) { + this.version = version; + } + + /** + * Gets the security provider num. + * + * @return the security provider num + */ + public Long getSecurityProviderNum() { + return securityProviderNum; + } + + /** + * Sets the security provider num. + * + * @param securityProviderNum the new security provider num + */ + public void setSecurityProviderNum(Long securityProviderNum) { + this.securityProviderNum = securityProviderNum; + } + + /** + * Gets the security provider IA 5. + * + * @return the security provider IA 5 + */ + public String getSecurityProviderIA5() { + return securityProviderIA5; + } + + /** + * Sets the security provider IA 5. + * + * @param securityProviderIA5 the new security provider IA 5 + */ + public void setSecurityProviderIA5(String securityProviderIA5) { + this.securityProviderIA5 = securityProviderIA5; + } + + /** + * Gets the static data. + * + * @return the static data + */ + public SignedDataType getStaticData() { + return staticData; + } + + /** + * Sets the static data. + * + * @param staticData the new static data + */ + public void setStaticData(SignedDataType staticData) { + this.staticData = staticData; + } + + /** + * Gets the dynamic data. + * + * @return the dynamic data + */ + public SignedDataType getDynamicData() { + return dynamicData; + } + + /** + * Sets the dynamic data. + * + * @param dynamicData the new dynamic data + */ + public void setDynamicData(SignedDataType dynamicData) { + this.dynamicData = dynamicData; + } + + /** + * Gets the dynamic public key. + * + * @return the dynamic public key + */ + public OctetString getDynamicPublicKey() { + return dynamicPublicKey; + } + + /** + * Sets the dynamic public key. + * + * @param dynamicPublicKey the new dynamic public key + */ + public void setDynamicPublicKey(OctetString dynamicPublicKey) { + this.dynamicPublicKey = dynamicPublicKey; + } + + /** + * Gets the extension. + * + * @return the extension + */ + public Extension getExtension() { + return extension; + } + + /** + * Sets the extension. + * + * @param extension the new extension + */ + public void setExtension(Extension extension) { + this.extension = extension; + } + + +} diff --git a/src/org/uic/header/Extension.java b/src/org/uic/header/Extension.java new file mode 100644 index 0000000..98f44d7 --- /dev/null +++ b/src/org/uic/header/Extension.java @@ -0,0 +1,72 @@ +package org.uic.header; + + +import net.gcdc.asn1.datatypes.CharacterRestriction; +import net.gcdc.asn1.datatypes.RestrictedString; +import net.gcdc.asn1.datatypes.Sequence; +import net.gcdc.asn1.datatypesimpl.OctetString; + + +// TODO: Auto-generated Javadoc +/** + * The Class Extension. + */ +@Sequence +public class Extension extends Object { + + /** + * Instantiates a new extension. + */ + public Extension() {} + + /** The extension id. */ + @RestrictedString(CharacterRestriction.IA5String) + public String extensionId; + + /** The extension data. */ + public OctetString extensionData; + + /** + * Gets the extension id. + * + * @return the extension id + */ + public String getExtensionId() { + + return this.extensionId; + } + + /** + * Gets the extension data. + * + * @return the extension data + */ + public byte[] getExtensionData() { + + return extensionData.toByteArray(); + } + + /** + * Sets the extension id. + * + * @param extensionId the new extension id + */ + public void setExtensionId(String extensionId) { + + this.extensionId = extensionId; + } + + /** + * Sets the extension data. + * + * @param extensionData the new extension data + */ + public void setExtensionData(byte[] extensionData) { + + this.extensionData = new OctetString(extensionData); + + } + + + +} diff --git a/src/org/uic/header/SequenceOfDataType.java b/src/org/uic/header/SequenceOfDataType.java new file mode 100644 index 0000000..c91b8fa --- /dev/null +++ b/src/org/uic/header/SequenceOfDataType.java @@ -0,0 +1,26 @@ +package org.uic.header; + + +import java.util.Collection; + +import net.gcdc.asn1.datatypes.Asn1SequenceOf; +// TODO: Auto-generated Javadoc + +/** + * The Class SequenceOfDataType. + */ +public class SequenceOfDataType extends Asn1SequenceOf{ + + /** + * Instantiates a new sequence of data type. + */ + public SequenceOfDataType() { super(); } + + /** + * Instantiates a new sequence of data type. + * + * @param coll the coll + */ + public SequenceOfDataType(Collection coll) { super(coll); } + +} diff --git a/src/org/uic/header/SignedDataType.java b/src/org/uic/header/SignedDataType.java new file mode 100644 index 0000000..1cbaa8e --- /dev/null +++ b/src/org/uic/header/SignedDataType.java @@ -0,0 +1,58 @@ +package org.uic.header; + +import net.gcdc.asn1.datatypes.Asn1Optional; +import net.gcdc.asn1.datatypes.Sequence; +import net.gcdc.asn1.datatypesimpl.OctetString; + +// TODO: Auto-generated Javadoc +/** + * The Class SignedDataType. + */ +@Sequence +public class SignedDataType { + + /** The data. */ + public DataBlockType data; + + /** The signature. */ + @Asn1Optional public OctetString signature; + + /** + * Gets the data. + * + * @return the data + */ + public DataBlockType getData() { + return data; + } + + /** + * Sets the data. + * + * @param data the new data + */ + public void setData(DataBlockType data) { + this.data = data; + } + + /** + * Gets the signature. + * + * @return the signature + */ + public OctetString getSignature() { + return signature; + } + + /** + * Sets the signature. + * + * @param signature the new signature + */ + public void setSignature(OctetString signature) { + this.signature = signature; + } + + + +} -- cgit v1.2.3