From 65ea6c17a0c1348aa9ef4e158102ddf173936882 Mon Sep 17 00:00:00 2001 From: Yuuta Liang Date: Thu, 23 Nov 2023 08:09:01 +0800 Subject: Add GUI Signed-off-by: Yuuta Liang --- src/main/model/asn1/ObjectIdentifier.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/main/model/asn1') diff --git a/src/main/model/asn1/ObjectIdentifier.java b/src/main/model/asn1/ObjectIdentifier.java index f6e850a..64ade8e 100644 --- a/src/main/model/asn1/ObjectIdentifier.java +++ b/src/main/model/asn1/ObjectIdentifier.java @@ -104,6 +104,22 @@ public class ObjectIdentifier extends ASN1Object { this.ints = nums.toArray(new Integer[0]); } + /** + * EFFECTS: Get OID from a known part, case insensitive. Currently known: C CN OU O L DC. + * Throws {@link ParseException} if the name is unsupported. + */ + public static Integer[] getKnown(String name) throws ParseException { + switch (name.toUpperCase()) { + case "C": return OID_C; + case "CN": return OID_CN; + case "OU": return OID_OU; + case "O": return OID_O; + case "L": return OID_L; + case "DC": return OID_DC; + default: throw new ParseException("Unsupported DN part: " + name); + } + } + /** * EFFECTS: Parse input OID bytes. * REQUIRES: raw.length >= 1 -- cgit v1.2.3