[gcr] gcr: Add gcr_certificate_get_xxx_name()
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcr] gcr: Add gcr_certificate_get_xxx_name()
- Date: Tue, 29 Nov 2011 11:39:13 +0000 (UTC)
commit 09d2d7d14b0fcadaabad6155ab635f890c957bd9
Author: Stef Walter <stefw collabora co uk>
Date: Tue Nov 29 12:38:39 2011 +0100
gcr: Add gcr_certificate_get_xxx_name()
* To get a decent name for a certificate, using the CN, OU, and O
docs/reference/gcr/gcr-sections.txt | 2 +
gcr/gcr-base.symbols | 2 +
gcr/gcr-certificate.c | 58 ++++++++++++++++++++++++++++++++--
gcr/gcr-certificate.h | 4 ++
4 files changed, 62 insertions(+), 4 deletions(-)
---
diff --git a/docs/reference/gcr/gcr-sections.txt b/docs/reference/gcr/gcr-sections.txt
index 7503337..c545321 100644
--- a/docs/reference/gcr/gcr-sections.txt
+++ b/docs/reference/gcr/gcr-sections.txt
@@ -55,11 +55,13 @@ GcrCertificateIface
gcr_certificate_get_der_data
gcr_certificate_get_issuer_cn
gcr_certificate_get_issuer_dn
+gcr_certificate_get_issuer_name
gcr_certificate_get_issuer_part
gcr_certificate_get_issuer_raw
gcr_certificate_is_issuer
gcr_certificate_get_subject_cn
gcr_certificate_get_subject_dn
+gcr_certificate_get_subject_name
gcr_certificate_get_subject_part
gcr_certificate_get_subject_raw
gcr_certificate_get_issued_date
diff --git a/gcr/gcr-base.symbols b/gcr/gcr-base.symbols
index 2d2f1b8..f030a2c 100644
--- a/gcr/gcr-base.symbols
+++ b/gcr/gcr-base.symbols
@@ -25,6 +25,7 @@ gcr_certificate_get_icon
gcr_certificate_get_issued_date
gcr_certificate_get_issuer_cn
gcr_certificate_get_issuer_dn
+gcr_certificate_get_issuer_name
gcr_certificate_get_issuer_part
gcr_certificate_get_issuer_raw
gcr_certificate_get_key_size
@@ -32,6 +33,7 @@ gcr_certificate_get_serial_number
gcr_certificate_get_serial_number_hex
gcr_certificate_get_subject_cn
gcr_certificate_get_subject_dn
+gcr_certificate_get_subject_name
gcr_certificate_get_subject_part
gcr_certificate_get_subject_raw
gcr_certificate_get_type
diff --git a/gcr/gcr-certificate.c b/gcr/gcr-certificate.c
index d0ab5a6..e2f37c1 100644
--- a/gcr/gcr-certificate.c
+++ b/gcr/gcr-certificate.c
@@ -205,7 +205,7 @@ calculate_markup (GcrCertificate *self)
gchar *markup;
g_object_get (self, "label", &label, NULL);
- issuer = gcr_certificate_get_issuer_cn (self);
+ issuer = gcr_certificate_get_issuer_name (self);
if (issuer)
markup = g_markup_printf_escaped ("%s\n<small>Issued by: %s</small>", label, issuer);
@@ -377,6 +377,31 @@ gcr_certificate_get_der_data (GcrCertificate *self,
}
/**
+ * gcr_certificate_get_issuer_name:
+ * @self: a #GcrCertificate
+ *
+ * Get a name to represent the issuer of this certificate.
+ *
+ * This will try to lookup the common name, orianizational unit,
+ * organization in that order.
+ *
+ * Returns: the allocated issuer name, or NULL if no issuer name
+ */
+gchar *
+gcr_certificate_get_issuer_name (GcrCertificate *self)
+{
+ gchar *name;
+
+ name = gcr_certificate_get_issuer_part (self, "cn");
+ if (name == NULL)
+ name = gcr_certificate_get_issuer_part (self, "ou");
+ if (name == NULL)
+ name = gcr_certificate_get_issuer_part (self, "o");
+
+ return name;
+}
+
+/**
* gcr_certificate_get_issuer_cn:
* @self: a #GcrCertificate
*
@@ -549,6 +574,31 @@ gcr_certificate_get_subject_cn (GcrCertificate *self)
}
/**
+ * gcr_certificate_get_subject_name:
+ * @self: a #GcrCertificate
+ *
+ * Get a name to represent the subject of this certificate.
+ *
+ * This will try to lookup the common name, orianizational unit,
+ * organization in that order.
+ *
+ * Returns: the allocated subject name, or NULL if no subject name
+ */
+gchar *
+gcr_certificate_get_subject_name (GcrCertificate *self)
+{
+ gchar *name;
+
+ name = gcr_certificate_get_subject_part (self, "cn");
+ if (name == NULL)
+ name = gcr_certificate_get_subject_part (self, "ou");
+ if (name == NULL)
+ name = gcr_certificate_get_subject_part (self, "o");
+
+ return name;
+}
+
+/**
* gcr_certificate_get_subject_part:
* @self: a #GcrCertificate
* @part: a DN type string or OID.
@@ -1026,10 +1076,10 @@ gcr_certificate_mixin_get_property (GObject *obj, guint prop_id,
switch (prop_id) {
case PROP_LABEL:
- g_value_take_string (value, gcr_certificate_get_subject_cn (cert));
+ g_value_take_string (value, gcr_certificate_get_subject_name (cert));
break;
case PROP_SUBJECT:
- g_value_take_string (value, gcr_certificate_get_subject_cn (cert));
+ g_value_take_string (value, gcr_certificate_get_subject_name (cert));
break;
case PROP_ICON:
g_value_set_object (value, gcr_certificate_get_icon (cert));
@@ -1041,7 +1091,7 @@ gcr_certificate_mixin_get_property (GObject *obj, guint prop_id,
g_value_take_string (value, calculate_markup (cert));
break;
case PROP_ISSUER:
- g_value_take_string (value, gcr_certificate_get_issuer_cn (cert));
+ g_value_take_string (value, gcr_certificate_get_issuer_name (cert));
break;
case PROP_EXPIRY:
g_value_take_boxed (value, gcr_certificate_get_expiry_date (cert));
diff --git a/gcr/gcr-certificate.h b/gcr/gcr-certificate.h
index 62ae08a..6846cbf 100644
--- a/gcr/gcr-certificate.h
+++ b/gcr/gcr-certificate.h
@@ -70,6 +70,8 @@ const GcrColumn* gcr_certificate_get_columns (void);
gint gcr_certificate_compare (GcrComparable *first,
GcrComparable *other);
+gchar * gcr_certificate_get_issuer_name (GcrCertificate *self);
+
gchar* gcr_certificate_get_issuer_cn (GcrCertificate *self);
gchar* gcr_certificate_get_issuer_dn (GcrCertificate *self);
@@ -83,6 +85,8 @@ guchar * gcr_certificate_get_issuer_raw (GcrCertificate *self
gboolean gcr_certificate_is_issuer (GcrCertificate *self,
GcrCertificate *issuer);
+gchar * gcr_certificate_get_subject_name (GcrCertificate *self);
+
gchar* gcr_certificate_get_subject_cn (GcrCertificate *self);
gchar* gcr_certificate_get_subject_dn (GcrCertificate *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]