summaryrefslogtreecommitdiffstats
path: root/comm/third_party/asn1js/src/ObjectIdentifier.ts
diff options
context:
space:
mode:
Diffstat (limited to 'comm/third_party/asn1js/src/ObjectIdentifier.ts')
-rw-r--r--comm/third_party/asn1js/src/ObjectIdentifier.ts53
1 files changed, 53 insertions, 0 deletions
diff --git a/comm/third_party/asn1js/src/ObjectIdentifier.ts b/comm/third_party/asn1js/src/ObjectIdentifier.ts
new file mode 100644
index 0000000000..7608a3cf7d
--- /dev/null
+++ b/comm/third_party/asn1js/src/ObjectIdentifier.ts
@@ -0,0 +1,53 @@
+import { BaseBlock, BaseBlockJson, BaseBlockParams } from "./BaseBlock";
+import { LocalObjectIdentifierValueBlockParams, LocalObjectIdentifierValueBlock, LocalObjectIdentifierValueBlockJson } from "./internals/LocalObjectIdentifierValueBlock";
+import { typeStore } from "./TypeStore";
+
+export interface ObjectIdentifierParams extends BaseBlockParams, LocalObjectIdentifierValueBlockParams { }
+export interface ObjectIdentifierJson extends BaseBlockJson<LocalObjectIdentifierValueBlockJson> {
+ value: string;
+}
+
+export class ObjectIdentifier extends BaseBlock<LocalObjectIdentifierValueBlock, LocalObjectIdentifierValueBlockJson> {
+
+ static {
+ typeStore.ObjectIdentifier = this;
+ }
+
+ public static override NAME = "OBJECT IDENTIFIER";
+
+ /**
+ * Gets string representation of Object Identifier
+ * @since 3.0.0
+ */
+ public getValue(): string {
+ return this.valueBlock.toString();
+ }
+
+ /**
+ * Sets Object Identifier value from string
+ * @param value String value
+ * @since 3.0.0
+ */
+ public setValue(value: string): void {
+ this.valueBlock.fromString(value);
+ }
+
+ constructor(parameters: ObjectIdentifierParams = {}) {
+ super(parameters, LocalObjectIdentifierValueBlock);
+
+ this.idBlock.tagClass = 1; // UNIVERSAL
+ this.idBlock.tagNumber = 6; // OBJECT IDENTIFIER
+ }
+
+ protected override onAsciiEncoding(): string {
+ return `${(this.constructor as typeof ObjectIdentifier).NAME} : ${this.valueBlock.toString() || "empty"}`;
+ }
+
+ public override toJSON(): ObjectIdentifierJson {
+ return {
+ ...super.toJSON(),
+ value: this.getValue(),
+ };
+ }
+
+}