gnome-keyring r1571 - in trunk: . egg egg/tests gcr



Author: nnielsen
Date: Sat Feb 14 00:23:07 2009
New Revision: 1571
URL: http://svn.gnome.org/viewvc/gnome-keyring?rev=1571&view=rev

Log:
Pull out OID information functionality into it's own file.

Added:
   trunk/egg/egg-oid.c
   trunk/egg/egg-oid.h
   trunk/egg/tests/unit-test-oid.c
Modified:
   trunk/ChangeLog
   trunk/egg/Makefile.am
   trunk/egg/egg-asn1.c
   trunk/egg/egg-asn1.h
   trunk/egg/tests/Makefile.am
   trunk/egg/tests/unit-test-asn1.c
   trunk/gcr/gcr-certificate-details-widget.c

Modified: trunk/egg/Makefile.am
==============================================================================
--- trunk/egg/Makefile.am	(original)
+++ trunk/egg/Makefile.am	Sat Feb 14 00:23:07 2009
@@ -23,6 +23,7 @@
 	egg-buffer.c egg-buffer.h \
 	egg-hex.c egg-hex.h \
 	egg-libgcrypt.c egg-libgcrypt.h \
+	egg-oid.c egg-oid.h \
 	egg-openssl.c egg-openssl.h \
 	egg-unix-credentials.c egg-unix-credentials.h \
 	egg-secure-memory.c egg-secure-memory.h \

Modified: trunk/egg/egg-asn1.c
==============================================================================
--- trunk/egg/egg-asn1.c	(original)
+++ trunk/egg/egg-asn1.c	Sat Feb 14 00:23:07 2009
@@ -24,6 +24,7 @@
 #include "config.h"
 
 #include "egg-asn1.h"
+#include "egg-oid.h"
 
 #include <libtasn1.h>
 
@@ -782,76 +783,6 @@
  * Reading DN's
  */
 
-typedef struct _PrintableOid {
-	GQuark oid;
-	const gchar *oidstr;
-	const gchar *attr;
-	const gchar *description;
-	gboolean is_choice;
-} PrintableOid;
-
-static PrintableOid printable_oids[] = {
-	{ 0, "0.9.2342.19200300.100.1.25", "DC", N_("Domain Component"), FALSE },
-	{ 0, "0.9.2342.19200300.100.1.1", "UID", N_("User ID"), TRUE },
-
-	{ 0, "1.2.840.113549.1.9.1", "EMAIL", N_("Email"), FALSE },
-	{ 0, "1.2.840.113549.1.9.7", NULL, NULL, TRUE },
-	{ 0, "1.2.840.113549.1.9.20", NULL, NULL, FALSE },
-	
-	{ 0, "1.3.6.1.5.5.7.9.1", "dateOfBirth", N_("Date of Birth"), FALSE },
-	{ 0, "1.3.6.1.5.5.7.9.2", "placeOfBirth", N_("Place of Birth"), FALSE },
-	{ 0, "1.3.6.1.5.5.7.9.3", "gender", N_("Gender"), FALSE },
-        { 0, "1.3.6.1.5.5.7.9.4", "countryOfCitizenship", N_("Country of Citizenship"), FALSE },
-        { 0, "1.3.6.1.5.5.7.9.5", "countryOfResidence", N_("Country of Residence"), FALSE },
-
-	{ 0, "2.5.4.3", "CN", N_("Common Name"), TRUE },
-	{ 0, "2.5.4.4", "surName", N_("Surname"), TRUE },
-	{ 0, "2.5.4.5", "serialNumber", N_("Serial Number"), FALSE },
-	{ 0, "2.5.4.6", "C", N_("Country"), FALSE, },
-	{ 0, "2.5.4.7", "L", N_("Locality"), TRUE },
-	{ 0, "2.5.4.8", "ST", N_("State"), TRUE },
-	{ 0, "2.5.4.9", "STREET", N_("Street"), TRUE },
-	{ 0, "2.5.4.10", "O", N_("Organization"), TRUE },
-	{ 0, "2.5.4.11", "OU", N_("Organizational Unit"), TRUE },
-	{ 0, "2.5.4.12", "T", N_("Title"), TRUE },
-	{ 0, "2.5.4.20", "telephoneNumber", N_("Telephone Number"), FALSE },
-	{ 0, "2.5.4.42", "givenName", N_("Given Name"), TRUE },
-	{ 0, "2.5.4.43", "initials", N_("Initials"), TRUE },
-	{ 0, "2.5.4.44", "generationQualifier", N_("Generation Qualifier"), TRUE },
-	{ 0, "2.5.4.46", "dnQualifier", N_("DN Qualifier"), FALSE },
-	{ 0, "2.5.4.65", "pseudonym", N_("Pseudonym"), TRUE },
-
-	{ 0, NULL, NULL, NULL, FALSE }
-};
-
-static void
-init_printable_oids (void)
-{
-	static volatile gsize inited_oids = 0;
-	int i;
-	
-	if (g_once_init_enter (&inited_oids)) {
-		for (i = 0; printable_oids[i].oidstr != NULL; ++i)
-			printable_oids[i].oid = g_quark_from_static_string (printable_oids[i].oidstr);
-		g_once_init_leave (&inited_oids, 1);
-	}
-}
-
-static PrintableOid*
-dn_find_printable (GQuark oid)
-{
-	int i;
-	
-	g_return_val_if_fail (oid != 0, NULL);
-	
-	for (i = 0; printable_oids[i].oidstr != NULL; ++i) {
-		if (printable_oids[i].oid == oid)
-			return &printable_oids[i];
-	}
-	
-	return NULL;
-}
-
 static const char HEXC[] = "0123456789ABCDEF";
 
 static gchar*
@@ -870,20 +801,18 @@
 }
 
 static gchar* 
-dn_print_oid_value_parsed (PrintableOid *printable, const guchar *data, gsize len)
+dn_print_oid_value_parsed (GQuark oid, guint flags, const guchar *data, gsize len)
 {
 	const gchar *asn_name;
 	ASN1_TYPE asn1;
 	gchar *part;
 	gchar *value;
 	
-	g_assert (printable);
 	g_assert (data);
 	g_assert (len);
-	g_assert (printable->oid);
 	
 	asn_name = asn1_find_structure_from_oid (egg_asn1_get_pkix_asn1type (), 
-	                                         printable->oidstr);
+	                                         g_quark_to_string (oid));
 	g_return_val_if_fail (asn_name, NULL);
 	
 	part = g_strdup_printf ("PKIX1.%s", asn_name);
@@ -891,7 +820,7 @@
 	g_free (part);
 	
 	if (!asn1) {
-		g_message ("couldn't decode value for OID: %s", printable->oidstr);
+		g_message ("couldn't decode value for OID: %s", g_quark_to_string (oid));
 		return NULL;
 	}
 
@@ -901,7 +830,7 @@
 	 * If it's a choice element, then we have to read depending
 	 * on what's there.
 	 */
-	if (value && printable->is_choice) {
+	if (value && (flags & EGG_OID_IS_CHOICE)) {
 		if (strcmp ("printableString", value) == 0 ||
 		    strcmp ("ia5String", value) == 0 ||
 		    strcmp ("utf8String", value) == 0 ||
@@ -916,7 +845,7 @@
 	}
 
 	if (!value) {
-		g_message ("couldn't read value for OID: %s", printable->oidstr);
+		g_message ("couldn't read value for OID: %s", g_quark_to_string (oid));
 		return NULL;
 	}
 
@@ -933,15 +862,15 @@
 }
 
 static gchar*
-dn_print_oid_value (PrintableOid *printable, const guchar *data, gsize len)
+dn_print_oid_value (GQuark oid, guint flags, const guchar *data, gsize len)
 {
 	gchar *value;
 	
 	g_assert (data);
 	g_assert (len);
 	
-	if (printable) {
-		value = dn_print_oid_value_parsed (printable, data, len);
+	if (flags & EGG_OID_PRINTABLE) {
+		value = dn_print_oid_value_parsed (oid, flags, data, len);
 		if (value != NULL)
 			return value;
 	}
@@ -952,7 +881,8 @@
 static gchar* 
 dn_parse_rdn (ASN1_TYPE asn, const gchar *part)
 {
-	PrintableOid *printable;
+	const gchar *name;
+	guint flags;
 	GQuark oid;
 	gchar *path;
 	guchar *value;
@@ -974,12 +904,13 @@
 	value = egg_asn1_read_value (asn, path, &n_value, NULL);
 	g_free (path);
 
-	printable = dn_find_printable (oid);
+	flags = egg_oid_get_flags (oid);
+	name = egg_oid_get_name (oid);
 	
 	g_return_val_if_fail (value, NULL);
-	display = dn_print_oid_value (printable, value, n_value);
+	display = dn_print_oid_value (oid, flags, value, n_value);
 	
-	result = g_strconcat (printable && printable->attr ? printable->attr : g_quark_to_string (oid), 
+	result = g_strconcat ((flags & EGG_OID_PRINTABLE) ? name : g_quark_to_string (oid), 
 			      "=", display, NULL);
 	g_free (display);
 	
@@ -998,8 +929,6 @@
 	g_return_val_if_fail (asn, NULL);
 	g_return_val_if_fail (part, NULL);
 	
-	init_printable_oids ();
-	
 	result = g_string_sized_new (64);
 	
 	/* Each (possibly multi valued) RDN */
@@ -1035,8 +964,8 @@
 gchar*
 egg_asn1_read_dn_part (ASN1_TYPE asn, const gchar *part, const gchar *match)
 {
-	PrintableOid *printable = NULL;
 	gboolean done = FALSE;
+	const gchar *name;
 	guchar *value;
 	gsize n_value;
 	gchar *path;
@@ -1047,8 +976,6 @@
 	g_return_val_if_fail (part, NULL);
 	g_return_val_if_fail (match, NULL);
 	
-	init_printable_oids ();
-	
 	/* Each (possibly multi valued) RDN */
 	for (i = 1; !done; ++i) {
 		
@@ -1067,9 +994,8 @@
 			
 			/* Does it match either the OID or the displayable? */
 			if (g_ascii_strcasecmp (g_quark_to_string (oid), match) != 0) {
-				printable = dn_find_printable (oid);
-				if (!printable || !printable->attr || 
-				    !g_ascii_strcasecmp (printable->attr, match) == 0)
+				name = egg_oid_get_name (oid);
+				if (!g_ascii_strcasecmp (name, match) == 0)
 					continue;
 			}
 
@@ -1080,7 +1006,7 @@
 			g_free (path);
 			
 			g_return_val_if_fail (value, NULL);
-			return dn_print_oid_value (printable, value, n_value);
+			return dn_print_oid_value (oid, egg_oid_get_flags (oid), value, n_value);
 		}
 	}
 	
@@ -1100,8 +1026,6 @@
 	
 	g_return_val_if_fail (asn, FALSE);
 	
-	init_printable_oids ();
-	
 	/* Each (possibly multi valued) RDN */
 	for (i = 1; !done; ++i) {
 		
@@ -1142,42 +1066,11 @@
 	return i > 1;
 }
 
-const gchar*
-egg_asn1_dn_oid_attr (GQuark oid)
-{
-	PrintableOid *printable;
-	
-	g_return_val_if_fail (oid, NULL);
-	
-	printable = dn_find_printable (oid);
-	if (!printable)
-		return g_quark_to_string (oid);
-	
-	return printable->attr;	
-}
-
-const gchar*
-egg_asn1_dn_oid_desc (GQuark oid)
-{
-	PrintableOid *printable;
-	
-	g_return_val_if_fail (oid, NULL);
-	
-	printable = dn_find_printable (oid);
-	if (!printable)
-		return g_quark_to_string (oid);
-	
-	return gettext (printable->description);
-}
-
 gchar*
 egg_asn1_dn_print_value (GQuark oid, const guchar *value, gsize n_value)
 {
-	PrintableOid *printable;
-	
 	g_return_val_if_fail (oid, NULL);
 	g_return_val_if_fail (value || !n_value, NULL);
 	
-	printable = dn_find_printable (oid);
-	return dn_print_oid_value (printable, value, n_value);
+	return dn_print_oid_value (oid, egg_oid_get_flags (oid), value, n_value);
 }

Modified: trunk/egg/egg-asn1.h
==============================================================================
--- trunk/egg/egg-asn1.h	(original)
+++ trunk/egg/egg-asn1.h	Sat Feb 14 00:23:07 2009
@@ -86,10 +86,6 @@
 gboolean           egg_asn1_dn_parse                      (ASN1_TYPE asn, const gchar *part, 
                                                            EggAsn1DnCallback callback, gpointer user_data);
 
-const gchar*       egg_asn1_dn_oid_attr                   (GQuark oid);
-
-const gchar*       egg_asn1_dn_oid_desc                   (GQuark oid);
-
 gchar*             egg_asn1_dn_print_value                (GQuark oid, const guchar *value, gsize n_value);
 
 #endif /*EGG_ASN1_H_*/

Added: trunk/egg/egg-oid.c
==============================================================================
--- (empty file)
+++ trunk/egg/egg-oid.c	Sat Feb 14 00:23:07 2009
@@ -0,0 +1,164 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* egg-oid.c - OID helper routines
+
+   Copyright (C) 2007 Stefan Walter
+
+   The Gnome Keyring Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The Gnome Keyring Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the Gnome Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+
+   Author: Stef Walter <stef memberwebs com>
+*/
+
+#include "config.h"
+
+#include "egg-oid.h"
+
+#include <string.h>
+
+#include <glib/gi18n-lib.h>
+
+typedef struct _OidInfo {
+	GQuark oid;
+	const gchar *oidstr;
+	const gchar *attr;
+	const gchar *description;
+	guint flags;
+} OidInfo;
+
+static OidInfo oid_info[] = {
+	{ 0, "0.9.2342.19200300.100.1.25", "DC", N_("Domain Component"), 
+		EGG_OID_PRINTABLE },
+	{ 0, "0.9.2342.19200300.100.1.1", "UID", N_("User ID"), 
+		EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
+
+	{ 0, "1.2.840.113549.1.9.1", "EMAIL", N_("Email"), 
+		EGG_OID_PRINTABLE },
+	{ 0, "1.2.840.113549.1.9.7", NULL, NULL, 
+		EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
+		
+	{ 0, "1.2.840.113549.1.9.20", NULL, NULL, 
+		EGG_OID_PRINTABLE },
+	
+	{ 0, "1.3.6.1.5.5.7.9.1", "dateOfBirth", N_("Date of Birth"), 
+		EGG_OID_PRINTABLE },
+	{ 0, "1.3.6.1.5.5.7.9.2", "placeOfBirth", N_("Place of Birth"), 
+		EGG_OID_PRINTABLE },
+	{ 0, "1.3.6.1.5.5.7.9.3", "gender", N_("Gender"), 
+		EGG_OID_PRINTABLE },
+        { 0, "1.3.6.1.5.5.7.9.4", "countryOfCitizenship", N_("Country of Citizenship"), 
+		EGG_OID_PRINTABLE },
+        { 0, "1.3.6.1.5.5.7.9.5", "countryOfResidence", N_("Country of Residence"), 
+		EGG_OID_PRINTABLE },
+
+	{ 0, "2.5.4.3", "CN", N_("Common Name"), 
+		EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
+	{ 0, "2.5.4.4", "surName", N_("Surname"), 
+		EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
+	{ 0, "2.5.4.5", "serialNumber", N_("Serial Number"), 
+		EGG_OID_PRINTABLE },
+	{ 0, "2.5.4.6", "C", N_("Country"), 
+		EGG_OID_PRINTABLE, },
+	{ 0, "2.5.4.7", "L", N_("Locality"), 
+		EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
+	{ 0, "2.5.4.8", "ST", N_("State"), 
+		EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
+	{ 0, "2.5.4.9", "STREET", N_("Street"), 
+		EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
+	{ 0, "2.5.4.10", "O", N_("Organization"), 
+		EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
+	{ 0, "2.5.4.11", "OU", N_("Organizational Unit"), 
+		EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
+	{ 0, "2.5.4.12", "T", N_("Title"), 
+		EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
+	{ 0, "2.5.4.20", "telephoneNumber", N_("Telephone Number"), 
+		EGG_OID_PRINTABLE },
+	{ 0, "2.5.4.42", "givenName", N_("Given Name"), 
+		EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
+	{ 0, "2.5.4.43", "initials", N_("Initials"), 
+		EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
+	{ 0, "2.5.4.44", "generationQualifier", N_("Generation Qualifier"), 
+		EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
+	{ 0, "2.5.4.46", "dnQualifier", N_("DN Qualifier"), 
+		EGG_OID_PRINTABLE },
+	{ 0, "2.5.4.65", "pseudonym", N_("Pseudonym"), 
+		EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
+
+	{ 0, NULL, NULL, NULL, FALSE }
+};
+
+static OidInfo*
+find_oid_info (GQuark oid)
+{
+	static volatile gsize inited_oids = 0;
+	int i;
+	
+	g_return_val_if_fail (oid != 0, NULL);
+
+	/* Initialize first time around */
+	if (g_once_init_enter (&inited_oids)) {
+		for (i = 0; oid_info[i].oidstr != NULL; ++i)
+			oid_info[i].oid = g_quark_from_static_string (oid_info[i].oidstr);
+		g_once_init_leave (&inited_oids, 1);
+	}
+	
+	for (i = 0; oid_info[i].oidstr != NULL; ++i) {
+		if (oid_info[i].oid == oid)
+			return &oid_info[i];
+	}
+	
+	return NULL;
+}
+
+const gchar*
+egg_oid_get_name (GQuark oid)
+{
+	OidInfo *info;
+	
+	g_return_val_if_fail (oid, NULL);
+	
+	info = find_oid_info (oid);
+	if (info == NULL)
+		return g_quark_to_string (oid);
+	
+	return info->attr;	
+}
+
+const gchar*
+egg_oid_get_description (GQuark oid)
+{
+	OidInfo *info;
+	
+	g_return_val_if_fail (oid, NULL);
+	
+	info = find_oid_info (oid);
+	if (info == NULL)
+		return g_quark_to_string (oid);
+	
+	return gettext (info->description);
+}
+
+guint
+egg_oid_get_flags (GQuark oid)
+{
+	OidInfo *info;
+	
+	g_return_val_if_fail (oid, 0);
+	
+	info = find_oid_info (oid);
+	if (info == NULL)
+		return 0;
+	
+	return info->flags;	
+}

Added: trunk/egg/egg-oid.h
==============================================================================
--- (empty file)
+++ trunk/egg/egg-oid.h	Sat Feb 14 00:23:07 2009
@@ -0,0 +1,39 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* egg-oid.h - OID helper routines
+
+   Copyright (C) 2007 Stefan Walter
+
+   The Gnome Keyring Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The Gnome Keyring Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the Gnome Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+
+   Author: Stef Walter <stef memberwebs com>
+*/
+
+#ifndef EGGOID_H_
+#define EGGOID_H_
+
+#include <glib.h>
+enum {
+	EGG_OID_PRINTABLE = 0x01,
+	EGG_OID_IS_CHOICE = 0x02
+};
+
+const gchar*       egg_oid_get_name                   (GQuark oid);
+
+guint              egg_oid_get_flags                  (GQuark oid);
+
+const gchar*       egg_oid_get_description            (GQuark oid);
+
+#endif /* EGGOID_H_ */

Modified: trunk/egg/tests/Makefile.am
==============================================================================
--- trunk/egg/tests/Makefile.am	(original)
+++ trunk/egg/tests/Makefile.am	Sat Feb 14 00:23:07 2009
@@ -9,6 +9,7 @@
 UNIT_AUTO = \
 	unit-test-asn1.c \
 	unit-test-hex.c \
+	unit-test-oid.c \
 	unit-test-secmem.c \
 	unit-test-symkey.c \
 	unit-test-openssl.c \

Modified: trunk/egg/tests/unit-test-asn1.c
==============================================================================
--- trunk/egg/tests/unit-test-asn1.c	(original)
+++ trunk/egg/tests/unit-test-asn1.c	Sat Feb 14 00:23:07 2009
@@ -26,6 +26,7 @@
 #include "run-auto-test.h"
 
 #include "egg/egg-asn1.h"
+#include "egg/egg-oid.h"
 
 #include <glib.h>
 #include <gcrypt.h>
@@ -394,20 +395,6 @@
 	g_assert (dn == NULL);
 }
 
-DEFINE_TEST(dn_oid)
-{
-	GQuark oid;
-	
-	oid = g_quark_from_static_string ("0.9.2342.19200300.100.1.25");
-	g_assert_cmpstr (egg_asn1_dn_oid_attr (oid), ==, "DC");
-	g_assert_cmpstr (egg_asn1_dn_oid_desc (oid), ==, "Domain Component");
-	
-	/* Should return OID for invalid oids */
-	oid = g_quark_from_static_string ("1.1.1.1.1");
-	g_assert_cmpstr (egg_asn1_dn_oid_attr (oid), ==, "1.1.1.1.1");
-	g_assert_cmpstr (egg_asn1_dn_oid_desc (oid), ==, "1.1.1.1.1");	
-}
-
 DEFINE_TEST(dn_value)
 {
 	const guchar value[] = { 0x13, 0x1a, 0x54, 0x68, 0x61, 0x77, 0x74, 0x65, 0x20, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x20, 0x50, 0x72, 0x65, 0x6d, 0x69, 0x75, 0x6d, 0x20, 0x43, 0x41 };
@@ -447,7 +434,7 @@
 		g_string_append (dn, ", ");
 	}
 	
-	g_string_append (dn, egg_asn1_dn_oid_attr (oid));
+	g_string_append (dn, egg_oid_get_name (oid));
 	g_string_append_c (dn, '=');
 	
 	text = egg_asn1_dn_print_value (oid, value, n_value);

Added: trunk/egg/tests/unit-test-oid.c
==============================================================================
--- (empty file)
+++ trunk/egg/tests/unit-test-oid.c	Sat Feb 14 00:23:07 2009
@@ -0,0 +1,46 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* unit-test-oid.c: Test OID routines
+
+   Copyright (C) 2008 Stefan Walter
+
+   The Gnome Keyring Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The Gnome Keyring Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the Gnome Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+
+   Author: Stef Walter <stef memberwebs com>
+*/
+
+#include "config.h"
+
+#include "run-auto-test.h"
+
+#include "egg/egg-oid.h"
+
+#include <glib.h>
+
+DEFINE_TEST(oid_tests)
+{
+	GQuark oid;
+	
+	oid = g_quark_from_static_string ("0.9.2342.19200300.100.1.25");
+	g_assert_cmpstr (egg_oid_get_name (oid), ==, "DC");
+	g_assert_cmpstr (egg_oid_get_description (oid), ==, "Domain Component");
+	g_assert_cmpuint (egg_oid_get_flags (oid), ==, EGG_OID_PRINTABLE);
+	
+	/* Should return OID for invalid oids */
+	oid = g_quark_from_static_string ("1.1.1.1.1");
+	g_assert_cmpstr (egg_oid_get_name (oid), ==, "1.1.1.1.1");
+	g_assert_cmpstr (egg_oid_get_description (oid), ==, "1.1.1.1.1");	
+	g_assert_cmpuint (egg_oid_get_flags (oid), ==, 0);
+}

Modified: trunk/gcr/gcr-certificate-details-widget.c
==============================================================================
--- trunk/gcr/gcr-certificate-details-widget.c	(original)
+++ trunk/gcr/gcr-certificate-details-widget.c	Sat Feb 14 00:23:07 2009
@@ -23,6 +23,7 @@
 #include "gcr-certificate-details-widget.h"
 
 #include "egg/egg-asn1.h"
+#include "egg/egg-oid.h"
 #include "egg/egg-hex.h"
 
 #include <glib/gi18n-lib.h>
@@ -184,8 +185,8 @@
 	
 	g_return_if_fail (GCR_IS_CERTIFICATE_DETAILS_WIDGET (self));
 	
-	attr = egg_asn1_dn_oid_attr (oid);
-	desc = egg_asn1_dn_oid_desc (oid);
+	attr = egg_oid_get_name (oid);
+	desc = egg_oid_get_description (oid);
 	
 	/* Combine them into something sane */
 	if (attr && desc) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]