From fede7c5983f6a3966c7b22e8b6f57a90ba5026ed Mon Sep 17 00:00:00 2001 From: =?utf8?q?Felix=20D=C3=B6rre?= Date: Sat, 16 Aug 2014 00:13:01 +0200 Subject: [PATCH 1/1] Extract EKU-OIDs to class constants. --- .../pages/account/CertificateIssueForm.java | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/src/org/cacert/gigi/pages/account/CertificateIssueForm.java b/src/org/cacert/gigi/pages/account/CertificateIssueForm.java index 936ced84..2bca9d58 100644 --- a/src/org/cacert/gigi/pages/account/CertificateIssueForm.java +++ b/src/org/cacert/gigi/pages/account/CertificateIssueForm.java @@ -42,6 +42,7 @@ import sun.security.pkcs10.PKCS10Attribute; import sun.security.pkcs10.PKCS10Attributes; import sun.security.util.DerInputStream; import sun.security.util.DerValue; +import sun.security.util.ObjectIdentifier; import sun.security.x509.AVA; import sun.security.x509.AlgorithmId; import sun.security.x509.CertificateExtensions; @@ -69,6 +70,30 @@ public class CertificateIssueForm extends Form { private final static Template tIni = new Template(CertificateAdd.class.getResource("RequestCertificate.templ")); + public static final ObjectIdentifier OID_KEY_USAGE_SSL_SERVER = ObjectIdentifier.newInternal(new int[] { + 1, 3, 6, 1, 5, 5, 7, 3, 1 + }); + + public static final ObjectIdentifier OID_KEY_USAGE_SSL_CLIENT = ObjectIdentifier.newInternal(new int[] { + 1, 3, 6, 1, 5, 5, 7, 3, 2 + }); + + public static final ObjectIdentifier OID_KEY_USAGE_CODESIGN = ObjectIdentifier.newInternal(new int[] { + 1, 3, 6, 1, 5, 5, 7, 3, 3 + }); + + public static final ObjectIdentifier OID_KEY_USAGE_EMAIL_PROTECTION = ObjectIdentifier.newInternal(new int[] { + 1, 3, 6, 1, 5, 5, 7, 3, 4 + }); + + public static final ObjectIdentifier OID_KEY_USAGE_TIMESTAMP = ObjectIdentifier.newInternal(new int[] { + 1, 3, 6, 1, 5, 5, 7, 3, 8 + }); + + public static final ObjectIdentifier OID_KEY_USAGE_OCSP = ObjectIdentifier.newInternal(new int[] { + 1, 3, 6, 1, 5, 5, 7, 3, 9 + }); + User u; private CSRType csrType; @@ -151,17 +176,17 @@ public class CertificateIssueForm extends Form { } else if (c instanceof ExtendedKeyUsageExtension) { ExtendedKeyUsageExtension ekue = (ExtendedKeyUsageExtension) c; for (String s : ekue.getExtendedKeyUsage()) { - if (s.equals("1.3.6.1.5.5.7.3.1")) { + if (s.equals(OID_KEY_USAGE_SSL_SERVER.toString())) { // server - } else if (s.equals("1.3.6.1.5.5.7.3.2")) { + } else if (s.equals(OID_KEY_USAGE_SSL_CLIENT.toString())) { // client - } else if (s.equals("1.3.6.1.5.5.7.3.3")) { + } else if (s.equals(OID_KEY_USAGE_CODESIGN.toString())) { // code sign - } else if (s.equals("1.3.6.1.5.5.7.3.4")) { + } else if (s.equals(OID_KEY_USAGE_EMAIL_PROTECTION.toString())) { // emailProtection - } else if (s.equals("1.3.6.1.5.5.7.3.8")) { + } else if (s.equals(OID_KEY_USAGE_TIMESTAMP.toString())) { // timestamp - } else if (s.equals("1.3.6.1.5.5.7.3.9")) { + } else if (s.equals(OID_KEY_USAGE_OCSP.toString())) { // OCSP } } -- 2.39.2