diff options
-rw-r--r-- | src/server-tls-manager.c | 26 | ||||
-rw-r--r-- | src/tls-certificate.c | 72 |
2 files changed, 37 insertions, 61 deletions
diff --git a/src/server-tls-manager.c b/src/server-tls-manager.c index 394870c30..a28191cac 100644 --- a/src/server-tls-manager.c +++ b/src/server-tls-manager.c @@ -171,20 +171,18 @@ tls_certificate_accepted_cb (GabbleTLSCertificate *certificate, static void tls_certificate_rejected_cb (GabbleTLSCertificate *certificate, - GabbleTLSCertificateRejectReason reason, - const gchar *dbus_error, - GHashTable *details, + GPtrArray *rejections, gpointer user_data) { GError *error = NULL; GabbleServerTLSManager *self = user_data; - DEBUG ("TLS certificate rejected with reason %u, dbus error %s " - "and details map %p.", reason, dbus_error, details); + DEBUG ("TLS certificate rejected with rejections %p, long %u.", + rejections, rejections->len); self->priv->tls_state_changed = TRUE; - g_set_error (&error, GABBLE_SERVER_TLS_ERROR, reason, - "TLS certificate rejected with reason %u", reason); + g_set_error (&error, GABBLE_SERVER_TLS_ERROR, 0, + "TLS certificate rejected"); g_simple_async_result_set_from_error (self->priv->async_result, error); g_simple_async_result_complete_in_idle (self->priv->async_result); @@ -394,16 +392,24 @@ gabble_server_tls_manager_get_rejection_details (GabbleServerTLSManager *self, TpConnectionStatusReason *reason) { GabbleTLSCertificate *certificate; + GPtrArray *rejections; + GValueArray *rejection; GabbleTLSCertificateRejectReason tls_reason; certificate = gabble_server_tls_channel_get_certificate (self->priv->channel); g_object_get (certificate, - "reject-reason", &tls_reason, - "reject-error", dbus_error, - "reject-details", details, + "rejections", &rejections, NULL); + rejection = g_ptr_array_index (rejections, 0); + + tls_reason = g_value_get_uint (g_value_array_get_nth (rejection, 0)); + *dbus_error = g_value_dup_string (g_value_array_get_nth (rejection, 1)); + *details = g_value_dup_boxed (g_value_array_get_nth (rejection, 2)); + *reason = cert_reject_reason_to_conn_reason (tls_reason); + + g_ptr_array_unref (rejections); } diff --git a/src/tls-certificate.c b/src/tls-certificate.c index 4bbb03cab..dcb8a6e58 100644 --- a/src/tls-certificate.c +++ b/src/tls-certificate.c @@ -49,10 +49,7 @@ struct _GabbleTLSCertificatePrivate { gchar *cert_type; GabbleTLSCertificateState cert_state; - gchar *reject_error; - GHashTable *reject_details; - GabbleTLSCertificateRejectReason reject_reason; - + GPtrArray *rejections; GPtrArray *cert_data; TpDBusDaemon *daemon; @@ -63,9 +60,7 @@ struct _GabbleTLSCertificatePrivate { enum { PROP_OBJECT_PATH = 1, PROP_STATE, - PROP_REJECT_ERROR, - PROP_REJECT_DETAILS, - PROP_REJECT_REASON, + PROP_REJECTIONS, PROP_CERTIFICATE_TYPE, PROP_CERTIFICATE_CHAIN_DATA, @@ -91,14 +86,8 @@ gabble_tls_certificate_get_property (GObject *object, case PROP_STATE: g_value_set_uint (value, self->priv->cert_state); break; - case PROP_REJECT_ERROR: - g_value_set_string (value, self->priv->reject_error); - break; - case PROP_REJECT_DETAILS: - g_value_set_boxed (value, self->priv->reject_details); - break; - case PROP_REJECT_REASON: - g_value_set_uint (value, self->priv->reject_reason); + case PROP_REJECTIONS: + g_value_set_boxed (value, self->priv->rejections); break; case PROP_CERTIFICATE_TYPE: g_value_set_string (value, self->priv->cert_type); @@ -145,8 +134,7 @@ gabble_tls_certificate_finalize (GObject *object) { GabbleTLSCertificate *self = GABBLE_TLS_CERTIFICATE (object); - g_free (self->priv->reject_error); - tp_clear_pointer (&self->priv->reject_details, g_hash_table_unref); + tp_clear_pointer (&self->priv->rejections, g_ptr_array_unref); g_free (self->priv->object_path); g_free (self->priv->cert_type); @@ -190,6 +178,7 @@ gabble_tls_certificate_init (GabbleTLSCertificate *self) { self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GABBLE_TYPE_TLS_CERTIFICATE, GabbleTLSCertificatePrivate); + self->priv->rejections = g_ptr_array_new (); } static void @@ -197,7 +186,7 @@ gabble_tls_certificate_class_init (GabbleTLSCertificateClass *klass) { static TpDBusPropertiesMixinPropImpl object_props[] = { { "State", "state", NULL }, - { "RejectReason", "reject-reason", NULL }, + { "Rejections", "rejections", NULL }, { "CertificateType", "certificate-type", NULL }, { "CertificateChainData", "certificate-chain-data", NULL }, { NULL } @@ -236,27 +225,12 @@ gabble_tls_certificate_class_init (GabbleTLSCertificateClass *klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); g_object_class_install_property (oclass, PROP_STATE, pspec); - pspec = g_param_spec_string ("reject-error", - "The reject error", - "A DBus error name containing the reject error for this certificate", - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (oclass, PROP_REJECT_ERROR, pspec); - - pspec = g_param_spec_boxed ("reject-details", - "The reject error details", - "Additional information about the rejection of the certificate", - TP_HASH_TYPE_STRING_VARIANT_MAP, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (oclass, PROP_REJECT_DETAILS, pspec); - - pspec = g_param_spec_uint ("reject-reason", - "The reject reason", - "The reason why this certificate was rejected.", - 0, NUM_GABBLE_TLS_CERTIFICATE_REJECT_REASONS - 1, - GABBLE_TLS_CERTIFICATE_REJECT_REASON_UNKNOWN, + pspec = g_param_spec_boxed ("rejections", + "The reject reasons", + "The reasons why this TLS certificate has been rejected", + GABBLE_ARRAY_TYPE_TLS_CERTIFICATE_REJECTION_LIST, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (oclass, PROP_REJECT_REASON, pspec); + g_object_class_install_property (oclass, PROP_REJECTIONS, pspec); pspec = g_param_spec_string ("certificate-type", "The certificate type", @@ -314,15 +288,13 @@ gabble_tls_certificate_accept (GabbleSvcAuthenticationTLSCertificate *cert, static void gabble_tls_certificate_reject (GabbleSvcAuthenticationTLSCertificate *cert, - guint reason, - const gchar *dbus_error, - GHashTable *details, + const GPtrArray *rejections, DBusGMethodInvocation *context) { GabbleTLSCertificate *self = GABBLE_TLS_CERTIFICATE (cert); - DEBUG ("Reject() called on the TLS certificate with reason %u, error %s, " - "details %p; current state %u", reason, dbus_error, details, + DEBUG ("Reject() called on the TLS certificate with rejections %p, " + "long %u; current state %u", rejections, rejections->len, self->priv->cert_state); if (self->priv->cert_state != GABBLE_TLS_CERTIFICATE_STATE_PENDING) @@ -338,17 +310,15 @@ gabble_tls_certificate_reject (GabbleSvcAuthenticationTLSCertificate *cert, return; } - self->priv->cert_state = GABBLE_TLS_CERTIFICATE_STATE_REJECTED; - self->priv->reject_reason = reason; - self->priv->reject_error = g_strdup (dbus_error); - self->priv->reject_details = g_hash_table_new_full (g_str_hash, g_str_equal, - g_free, (GDestroyNotify) tp_g_value_slice_free); + tp_clear_pointer (&self->priv->rejections, g_ptr_array_unref); - tp_g_hash_table_update (self->priv->reject_details, details, - (GBoxedCopyFunc) g_strdup, (GBoxedCopyFunc) tp_g_value_slice_dup); + self->priv->rejections = + g_boxed_copy (GABBLE_ARRAY_TYPE_TLS_CERTIFICATE_REJECTION_LIST, + rejections); + self->priv->cert_state = GABBLE_TLS_CERTIFICATE_STATE_REJECTED; gabble_svc_authentication_tls_certificate_emit_rejected ( - self, reason, dbus_error, details); + self, self->priv->rejections); gabble_svc_authentication_tls_certificate_return_from_reject (context); } |