[gmime: 8/23] GMimeCertificate: expose identity validity



commit 383870f8ae43118fff1db630cedef0da7b7a20e4
Author: Daniel Kahn Gillmor <dkg fifthhorseman net>
Date:   Mon Oct 16 01:39:59 2017 -0400

    GMimeCertificate: expose identity validity
    
    The GMimeCertificate currently doesn't expose any indication of
    whether the user should believe the identity assertions contained in
    the certificate.  This changeset provides a mechanism for exposing
    that information.
    
    A subsequent revision will actually set that value so that it is
    visible to the user of the GMime library.
    
    Note that this is an API change and an ABI extension, but it's one
    that has no effect on anyone who uses GMime in the standard way (with
    constructors, destructors, and accessor functions, rather than static
    allocation of GMime objects on the stack or direct manipulation of the
    underlying struct).
    
    This API extension is comparable to the addition of
    retrieve_session_key to the GMimeGpgContext last year (in the
    transition from 2.6.20 to 2.6.21) and the addition of user_id to
    GMimeCertificate (in this series), so hopefully it's not considered a
    breaking change.

 docs/reference/gmime-sections.txt |    2 ++
 gmime/gmime-certificate.c         |   36 ++++++++++++++++++++++++++++++++++++
 gmime/gmime-certificate.h         |    5 +++++
 3 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gmime-sections.txt b/docs/reference/gmime-sections.txt
index 52191ab..29c5ae0 100644
--- a/docs/reference/gmime-sections.txt
+++ b/docs/reference/gmime-sections.txt
@@ -1410,6 +1410,8 @@ g_mime_certificate_get_name
 g_mime_certificate_set_name
 g_mime_certificate_get_user_id
 g_mime_certificate_set_user_id
+g_mime_certificate_get_id_validity
+g_mime_certificate_set_id_validity
 <SUBSECTION>
 GMimeCertificateList
 g_mime_certificate_list_new
diff --git a/gmime/gmime-certificate.c b/gmime/gmime-certificate.c
index a2edb6b..32913b2 100644
--- a/gmime/gmime-certificate.c
+++ b/gmime/gmime-certificate.c
@@ -95,6 +95,7 @@ g_mime_certificate_init (GMimeCertificate *cert, GMimeCertificateClass *klass)
        cert->email = NULL;
        cert->name = NULL;
        cert->user_id = NULL;
+       cert->id_validity = GMIME_VALIDITY_UNKNOWN;
 }
 
 static void
@@ -488,6 +489,41 @@ g_mime_certificate_get_user_id (GMimeCertificate *cert)
 
 
 /**
+ * g_mime_certificate_set_id_validity:
+ * @cert: a #GMimeCertificate
+ * @validity: a #GMimeValidity representing the validity of the certificate's identity information.
+ *
+ * Set the validity associated with the certificate's name, email, and user_id.
+ **/
+void
+g_mime_certificate_set_id_validity (GMimeCertificate *cert, GMimeValidity validity)
+{
+       g_return_if_fail (GMIME_IS_CERTIFICATE (cert));
+       
+       cert->id_validity = validity;
+}
+
+
+/**
+ * g_mime_certificate_get_id_validity:
+ * @cert: a #GMimeCertificate
+ *
+ * Get the validity of the certificate's identity information.  This
+ * validity applies to the name, email, and user_id fields associated
+ * with the certificate.
+ *
+ * Returns: the identity validity of the certificate.
+ **/
+GMimeValidity
+g_mime_certificate_get_id_validity (GMimeCertificate *cert)
+{
+       g_return_val_if_fail (GMIME_IS_CERTIFICATE (cert), GMIME_VALIDITY_UNKNOWN);
+       
+       return cert->id_validity;
+}
+
+
+/**
  * g_mime_certificate_set_created:
  * @cert: a #GMimeCertificate
  * @created: creation date
diff --git a/gmime/gmime-certificate.h b/gmime/gmime-certificate.h
index 266f1e1..ed26785 100644
--- a/gmime/gmime-certificate.h
+++ b/gmime/gmime-certificate.h
@@ -196,6 +196,7 @@ typedef enum {
  * @email: The email address of the person or entity.
  * @name: The name of the person or entity.
  * @user_id: The full User ID of the certificate.
+ * @id_validity: the validity of the email address, name, and User ID.
  *
  * An object containing useful information about a certificate.
  **/
@@ -214,6 +215,7 @@ struct _GMimeCertificate {
        char *email;
        char *name;
        char *user_id;
+       GMimeValidity id_validity;
 };
 
 struct _GMimeCertificateClass {
@@ -256,6 +258,9 @@ const char *g_mime_certificate_get_name (GMimeCertificate *cert);
 void g_mime_certificate_set_user_id (GMimeCertificate *cert, const char *user_id);
 const char *g_mime_certificate_get_user_id (GMimeCertificate *cert);
 
+void g_mime_certificate_set_id_validity (GMimeCertificate *cert, GMimeValidity validity);
+GMimeValidity g_mime_certificate_get_id_validity (GMimeCertificate *cert);
+
 void g_mime_certificate_set_created (GMimeCertificate *cert, time_t created);
 time_t g_mime_certificate_get_created (GMimeCertificate *cert);
 


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