summaryrefslogtreecommitdiffstats
path: root/base/util
diff options
context:
space:
mode:
authorFraser Tweedale <ftweedal@redhat.com>2017-02-01 16:17:51 +1000
committerFraser Tweedale <ftweedal@redhat.com>2017-02-08 12:24:00 +1000
commit225dd099efa7e2f752c3f50157aaec71a9834873 (patch)
treeb4abbd817d0aa9a7d07f05c74b710091e07b59ec /base/util
parentf371114134ee3b6a83b747eecf46e001080b1e9c (diff)
downloadpki-225dd099efa7e2f752c3f50157aaec71a9834873.tar.gz
pki-225dd099efa7e2f752c3f50157aaec71a9834873.tar.xz
pki-225dd099efa7e2f752c3f50157aaec71a9834873.zip
GeneralName: add method to get at inner value
The 'GeneralNameInterface' interface represents a single X.509 General Name value. Various types are supported. The 'GeneralName' class (which also implements 'GeneralNameInterface') is a singleton container for another 'GeneralNameInterface' value. To implement a profile component that copies CN to a SAN dNSName, we need to examine existing General Names in the SAN extension (if present), to avoid duplicate values. We can iterate 'GeneralNames', but if the value is of type 'GeneralName' we need a way to "unwrap" the value, down to the innermost value which will be of a specific General Name type. Add the 'unwrap' method to 'GeneralName'. Part of: https://fedorahosted.org/pki/ticket/1710
Diffstat (limited to 'base/util')
-rw-r--r--base/util/src/netscape/security/x509/GeneralName.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/base/util/src/netscape/security/x509/GeneralName.java b/base/util/src/netscape/security/x509/GeneralName.java
index a90ac7bf2..55b5bfcf3 100644
--- a/base/util/src/netscape/security/x509/GeneralName.java
+++ b/base/util/src/netscape/security/x509/GeneralName.java
@@ -196,4 +196,19 @@ public class GeneralName implements GeneralNameInterface {
constructedForm, (byte) nameType), tmp);
}
}
+
+ /**
+ * Unwrap this GeneralName until we reach something that is not
+ * a GeneralName.
+ */
+ public GeneralNameInterface unwrap() {
+ if (this == name)
+ return null; // can't happen, but just in case...
+
+ if (name instanceof GeneralName)
+ return ((GeneralName) name).unwrap();
+ else
+ return name;
+ }
+
}