[gnome-online-accounts/wip/rishi/port-to-g-declare] kerberos-identity: Make it a final class
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts/wip/rishi/port-to-g-declare] kerberos-identity: Make it a final class
- Date: Fri, 6 Dec 2019 19:30:33 +0000 (UTC)
commit fee993f12ad9e37fef733adf6371eebcef34917e
Author: Debarshi Ray <debarshir gnome org>
Date: Fri Dec 6 20:25:18 2019 +0100
kerberos-identity: Make it a final class
https://gitlab.gnome.org/GNOME/gnome-online-accounts/merge_requests/40
src/goaidentity/goakerberosidentity.c | 411 +++++++++++++---------------------
src/goaidentity/goakerberosidentity.h | 14 --
2 files changed, 154 insertions(+), 271 deletions(-)
---
diff --git a/src/goaidentity/goakerberosidentity.c b/src/goaidentity/goakerberosidentity.c
index 9b8c8098..61db67c3 100644
--- a/src/goaidentity/goakerberosidentity.c
+++ b/src/goaidentity/goakerberosidentity.c
@@ -39,8 +39,10 @@ typedef enum
VERIFICATION_LEVEL_SIGNED_IN
} VerificationLevel;
-struct _GoaKerberosIdentityPrivate
+struct _GoaKerberosIdentity
{
+ GObject parent;
+
krb5_context kerberos_context;
krb5_ccache credentials_cache;
@@ -64,6 +66,11 @@ struct _GoaKerberosIdentityPrivate
guint is_signed_in_idle_id;
};
+struct _GoaKerberosIdentityClass
+{
+ GObjectClass parent_class;
+};
+
enum
{
EXPIRING,
@@ -103,7 +110,6 @@ G_LOCK_DEFINE_STATIC (identity_lock);
G_DEFINE_TYPE_WITH_CODE (GoaKerberosIdentity,
goa_kerberos_identity,
G_TYPE_OBJECT,
- G_ADD_PRIVATE (GoaKerberosIdentity)
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
initable_interface_init)
G_IMPLEMENT_INTERFACE (GOA_TYPE_IDENTITY,
@@ -112,13 +118,10 @@ static void
goa_kerberos_identity_dispose (GObject *object)
{
GoaKerberosIdentity *self = GOA_KERBEROS_IDENTITY (object);
- GoaKerberosIdentityPrivate *priv;
-
- priv = goa_kerberos_identity_get_instance_private (self);
G_LOCK (identity_lock);
clear_alarms (self);
- g_clear_pointer (&priv->preauth_identity_source, g_free);
+ g_clear_pointer (&self->preauth_identity_source, g_free);
G_UNLOCK (identity_lock);
G_OBJECT_CLASS (goa_kerberos_identity_parent_class)->dispose (object);
@@ -129,14 +132,11 @@ static void
goa_kerberos_identity_finalize (GObject *object)
{
GoaKerberosIdentity *self = GOA_KERBEROS_IDENTITY (object);
- GoaKerberosIdentityPrivate *priv;
-
- priv = goa_kerberos_identity_get_instance_private (self);
- g_free (priv->identifier);
+ g_free (self->identifier);
- if (priv->credentials_cache != NULL)
- krb5_cc_close (priv->kerberos_context, priv->credentials_cache);
+ if (self->credentials_cache != NULL)
+ krb5_cc_close (self->kerberos_context, self->credentials_cache);
G_OBJECT_CLASS (goa_kerberos_identity_parent_class)->finalize (object);
}
@@ -148,15 +148,12 @@ goa_kerberos_identity_get_property (GObject *object,
GParamSpec *param_spec)
{
GoaKerberosIdentity *self = GOA_KERBEROS_IDENTITY (object);
- GoaKerberosIdentityPrivate *priv;
-
- priv = goa_kerberos_identity_get_instance_private (self);
switch (property_id)
{
case PROP_IDENTIFIER:
G_LOCK (identity_lock);
- g_value_set_string (value, priv->identifier);
+ g_value_set_string (value, self->identifier);
G_UNLOCK (identity_lock);
break;
case PROP_IS_SIGNED_IN:
@@ -165,17 +162,17 @@ goa_kerberos_identity_get_property (GObject *object,
break;
case PROP_START_TIMESTAMP:
G_LOCK (identity_lock);
- g_value_set_int64 (value, (gint64) priv->start_time);
+ g_value_set_int64 (value, (gint64) self->start_time);
G_UNLOCK (identity_lock);
break;
case PROP_RENEWAL_TIMESTAMP:
G_LOCK (identity_lock);
- g_value_set_int64 (value, (gint64) priv->renewal_time);
+ g_value_set_int64 (value, (gint64) self->renewal_time);
G_UNLOCK (identity_lock);
break;
case PROP_EXPIRATION_TIMESTAMP:
G_LOCK (identity_lock);
- g_value_set_int64 (value, (gint64) priv->expiration_time);
+ g_value_set_int64 (value, (gint64) self->expiration_time);
G_UNLOCK (identity_lock);
break;
default:
@@ -259,18 +256,15 @@ static char *
get_identifier (GoaKerberosIdentity *self,
GError **error)
{
- GoaKerberosIdentityPrivate *priv;
krb5_principal principal;
krb5_error_code error_code;
char *unparsed_name;
char *identifier = NULL;
- priv = goa_kerberos_identity_get_instance_private (self);
-
- if (priv->credentials_cache == NULL)
+ if (self->credentials_cache == NULL)
return NULL;
- error_code = krb5_cc_get_principal (priv->kerberos_context, priv->credentials_cache, &principal);
+ error_code = krb5_cc_get_principal (self->kerberos_context, self->credentials_cache, &principal);
if (error_code != 0)
{
if (error_code == KRB5_CC_END)
@@ -292,23 +286,23 @@ get_identifier (GoaKerberosIdentity *self,
return NULL;
}
- error_code = krb5_unparse_name_flags (priv->kerberos_context, principal, 0, &unparsed_name);
+ error_code = krb5_unparse_name_flags (self->kerberos_context, principal, 0, &unparsed_name);
if (error_code != 0)
{
const char *error_message;
- error_message = krb5_get_error_message (priv->kerberos_context, error_code);
+ error_message = krb5_get_error_message (self->kerberos_context, error_code);
g_debug ("GoaKerberosIdentity: Error parsing principal identity name: %s",
error_message);
- krb5_free_error_message (priv->kerberos_context, error_message);
+ krb5_free_error_message (self->kerberos_context, error_message);
goto out;
}
identifier = g_strdup (unparsed_name);
- krb5_free_unparsed_name (priv->kerberos_context, unparsed_name);
+ krb5_free_unparsed_name (self->kerberos_context, unparsed_name);
out:
- krb5_free_principal (priv->kerberos_context, principal);
+ krb5_free_principal (self->kerberos_context, principal);
return identifier;
}
@@ -325,14 +319,11 @@ set_and_prefix_error_from_krb5_error_code (GoaKerberosIdentity *self,
const char *format,
...)
{
- GoaKerberosIdentityPrivate *priv;
const char *error_message;
char *literal_prefix;
va_list args;
- priv = goa_kerberos_identity_get_instance_private (self);
-
- error_message = krb5_get_error_message (priv->kerberos_context, error_code);
+ error_message = krb5_get_error_message (self->kerberos_context, error_code);
g_set_error_literal (error, GOA_IDENTITY_ERROR, code, error_message);
va_start (args, format);
@@ -342,49 +333,46 @@ set_and_prefix_error_from_krb5_error_code (GoaKerberosIdentity *self,
g_prefix_error (error, "%s", literal_prefix);
g_free (literal_prefix);
- krb5_free_error_message (priv->kerberos_context, error_message);
+ krb5_free_error_message (self->kerberos_context, error_message);
}
char *
goa_kerberos_identity_get_principal_name (GoaKerberosIdentity *self)
{
- GoaKerberosIdentityPrivate *priv;
krb5_principal principal;
krb5_error_code error_code;
char *unparsed_name;
char *principal_name;
int flags;
- priv = goa_kerberos_identity_get_instance_private (self);
-
- if (priv->identifier == NULL)
+ if (self->identifier == NULL)
return NULL;
- error_code = krb5_parse_name (priv->kerberos_context, priv->identifier, &principal);
+ error_code = krb5_parse_name (self->kerberos_context, self->identifier, &principal);
if (error_code != 0)
{
const char *error_message;
- error_message = krb5_get_error_message (priv->kerberos_context, error_code);
- g_debug ("GoaKerberosIdentity: Error parsing identity %s into kerberos principal: %s",
priv->identifier, error_message);
- krb5_free_error_message (priv->kerberos_context, error_message);
+ error_message = krb5_get_error_message (self->kerberos_context, error_code);
+ g_debug ("GoaKerberosIdentity: Error parsing identity %s into kerberos principal: %s",
self->identifier, error_message);
+ krb5_free_error_message (self->kerberos_context, error_message);
return NULL;
}
flags = KRB5_PRINCIPAL_UNPARSE_DISPLAY;
- error_code = krb5_unparse_name_flags (priv->kerberos_context, principal, flags, &unparsed_name);
+ error_code = krb5_unparse_name_flags (self->kerberos_context, principal, flags, &unparsed_name);
if (error_code != 0)
{
const char *error_message;
- error_message = krb5_get_error_message (priv->kerberos_context, error_code);
+ error_message = krb5_get_error_message (self->kerberos_context, error_code);
g_debug ("GoaKerberosIdentity: Error parsing principal identity name: %s",
error_message);
- krb5_free_error_message (priv->kerberos_context, error_message);
+ krb5_free_error_message (self->kerberos_context, error_message);
return NULL;
}
principal_name = g_strdup (unparsed_name);
- krb5_free_unparsed_name (priv->kerberos_context, unparsed_name);
+ krb5_free_unparsed_name (self->kerberos_context, unparsed_name);
return principal_name;
}
@@ -392,30 +380,27 @@ goa_kerberos_identity_get_principal_name (GoaKerberosIdentity *self)
char *
goa_kerberos_identity_get_realm_name (GoaKerberosIdentity *self)
{
- GoaKerberosIdentityPrivate *priv;
krb5_principal principal;
krb5_error_code error_code;
krb5_data *realm;
char *realm_name;
- priv = goa_kerberos_identity_get_instance_private (self);
-
- if (priv->identifier == NULL)
+ if (self->identifier == NULL)
return NULL;
- error_code = krb5_parse_name (priv->kerberos_context, priv->identifier, &principal);
+ error_code = krb5_parse_name (self->kerberos_context, self->identifier, &principal);
if (error_code != 0)
{
const char *error_message;
- error_message = krb5_get_error_message (priv->kerberos_context, error_code);
- g_debug ("GoaKerberosIdentity: Error parsing identity %s into kerberos principal: %s",
priv->identifier, error_message);
- krb5_free_error_message (priv->kerberos_context, error_message);
+ error_message = krb5_get_error_message (self->kerberos_context, error_code);
+ g_debug ("GoaKerberosIdentity: Error parsing identity %s into kerberos principal: %s",
self->identifier, error_message);
+ krb5_free_error_message (self->kerberos_context, error_message);
return NULL;
}
- realm = krb5_princ_realm (priv->kerberos_context, principal);
+ realm = krb5_princ_realm (self->kerberos_context, principal);
realm_name = g_strndup (realm->data, realm->length);
- krb5_free_principal (priv->kerberos_context, principal);
+ krb5_free_principal (self->kerberos_context, principal);
return realm_name;
}
@@ -423,42 +408,32 @@ goa_kerberos_identity_get_realm_name (GoaKerberosIdentity *self)
char *
goa_kerberos_identity_get_preauthentication_source (GoaKerberosIdentity *self)
{
- GoaKerberosIdentityPrivate *priv;
-
- priv = goa_kerberos_identity_get_instance_private (self);
- return g_strdup (priv->preauth_identity_source);
+ return g_strdup (self->preauth_identity_source);
}
static const char *
goa_kerberos_identity_get_identifier (GoaIdentity *identity)
{
GoaKerberosIdentity *self = GOA_KERBEROS_IDENTITY (identity);
- GoaKerberosIdentityPrivate *priv;
-
- priv = goa_kerberos_identity_get_instance_private (self);
- return priv->identifier;
+ return self->identifier;
}
static gboolean
credentials_validate_existence (GoaKerberosIdentity *self,
krb5_principal principal, krb5_creds * credentials)
{
- GoaKerberosIdentityPrivate *priv;
-
- priv = goa_kerberos_identity_get_instance_private (self);
-
/* Checks if default principal associated with the cache has a valid
* ticket granting ticket in the passed in credentials
*/
- if (krb5_is_config_principal (priv->kerberos_context, credentials->server))
+ if (krb5_is_config_principal (self->kerberos_context, credentials->server))
return FALSE;
/* looking for the krbtgt / REALM pair, so it should be exactly 2 items */
- if (krb5_princ_size (priv->kerberos_context, credentials->server) != 2)
+ if (krb5_princ_size (self->kerberos_context, credentials->server) != 2)
return FALSE;
- if (!krb5_realm_compare (priv->kerberos_context, credentials->server, principal))
+ if (!krb5_realm_compare (self->kerberos_context, credentials->server, principal))
{
/* credentials are from some other realm */
return FALSE;
@@ -487,14 +462,11 @@ snoop_preauth_identity_from_credentials (GoaKerberosIdentity *self,
krb5_creds *credentials,
char **identity_source)
{
- GoaKerberosIdentityPrivate *priv;
GRegex *regex;
GMatchInfo *match_info = NULL;
gboolean identity_source_exposed = FALSE;
- priv = goa_kerberos_identity_get_instance_private (self);
-
- if (!krb5_is_config_principal (priv->kerberos_context, credentials->server))
+ if (!krb5_is_config_principal (self->kerberos_context, credentials->server))
return FALSE;
regex = g_regex_new ("\"X509_user_identity\":\"(?P<identity_source>[^\"]*)\"",
@@ -526,20 +498,17 @@ snoop_preauth_identity_from_credentials (GoaKerberosIdentity *self,
static krb5_timestamp
get_current_time (GoaKerberosIdentity *self)
{
- GoaKerberosIdentityPrivate *priv;
krb5_timestamp current_time;
krb5_error_code error_code;
- priv = goa_kerberos_identity_get_instance_private (self);
-
- error_code = krb5_timeofday (priv->kerberos_context, ¤t_time);
+ error_code = krb5_timeofday (self->kerberos_context, ¤t_time);
if (error_code != 0)
{
const char *error_message;
- error_message = krb5_get_error_message (priv->kerberos_context, error_code);
+ error_message = krb5_get_error_message (self->kerberos_context, error_code);
g_debug ("GoaKerberosIdentity: Error getting current time: %s", error_message);
- krb5_free_error_message (priv->kerberos_context, error_message);
+ krb5_free_error_message (self->kerberos_context, error_message);
return 0;
}
@@ -598,14 +567,10 @@ static gboolean
set_start_time (GoaKerberosIdentity *self,
krb5_timestamp start_time)
{
- GoaKerberosIdentityPrivate *priv;
-
- priv = goa_kerberos_identity_get_instance_private (self);
-
- if (priv->start_time != start_time)
+ if (self->start_time != start_time)
{
- priv->start_time = start_time;
- queue_notify (self, &priv->start_time_idle_id, "start-timestamp");
+ self->start_time = start_time;
+ queue_notify (self, &self->start_time_idle_id, "start-timestamp");
return TRUE;
}
return FALSE;
@@ -615,14 +580,10 @@ static gboolean
set_renewal_time (GoaKerberosIdentity *self,
krb5_timestamp renewal_time)
{
- GoaKerberosIdentityPrivate *priv;
-
- priv = goa_kerberos_identity_get_instance_private (self);
-
- if (priv->renewal_time != renewal_time)
+ if (self->renewal_time != renewal_time)
{
- priv->renewal_time = renewal_time;
- queue_notify (self, &priv->renewal_time_idle_id, "renewal-timestamp");
+ self->renewal_time = renewal_time;
+ queue_notify (self, &self->renewal_time_idle_id, "renewal-timestamp");
return TRUE;
}
return FALSE;
@@ -632,14 +593,10 @@ static gboolean
set_expiration_time (GoaKerberosIdentity *self,
krb5_timestamp expiration_time)
{
- GoaKerberosIdentityPrivate *priv;
-
- priv = goa_kerberos_identity_get_instance_private (self);
-
- if (priv->expiration_time != expiration_time)
+ if (self->expiration_time != expiration_time)
{
- priv->expiration_time = expiration_time;
- queue_notify (self, &priv->expiration_time_idle_id, "expiration-timestamp");
+ self->expiration_time = expiration_time;
+ queue_notify (self, &self->expiration_time_idle_id, "expiration-timestamp");
return TRUE;
}
return FALSE;
@@ -653,13 +610,10 @@ examine_credentials (GoaKerberosIdentity *self,
krb5_timestamp *expiration_time,
gboolean *are_expired)
{
- GoaKerberosIdentityPrivate *priv;
krb5_timestamp credentials_start_time;
krb5_timestamp credentials_end_time;
krb5_timestamp current_time;
- priv = goa_kerberos_identity_get_instance_private (self);
-
G_LOCK (identity_lock);
if (credentials->times.starttime != 0)
@@ -671,11 +625,11 @@ examine_credentials (GoaKerberosIdentity *self,
credentials_end_time = credentials->times.endtime;
- if (priv->start_time == 0)
+ if (self->start_time == 0)
*start_time = credentials_start_time;
else
- *start_time = MIN (priv->start_time, credentials_start_time);
- *expiration_time = MAX (credentials->times.endtime, priv->expiration_time);
+ *start_time = MIN (self->start_time, credentials_start_time);
+ *expiration_time = MAX (credentials->times.endtime, self->expiration_time);
G_UNLOCK (identity_lock);
current_time = get_current_time (self);
@@ -692,7 +646,6 @@ verify_identity (GoaKerberosIdentity *self,
char **preauth_identity_source,
GError **error)
{
- GoaKerberosIdentityPrivate *priv;
krb5_principal principal = NULL;
krb5_cc_cursor cursor;
krb5_creds credentials;
@@ -702,12 +655,10 @@ verify_identity (GoaKerberosIdentity *self,
krb5_timestamp expiration_time = 0;
VerificationLevel verification_level = VERIFICATION_LEVEL_UNVERIFIED;
- priv = goa_kerberos_identity_get_instance_private (self);
-
- if (priv->credentials_cache == NULL)
+ if (self->credentials_cache == NULL)
goto out;
- error_code = krb5_cc_get_principal (priv->kerberos_context, priv->credentials_cache, &principal);
+ error_code = krb5_cc_get_principal (self->kerberos_context, self->credentials_cache, &principal);
if (error_code != 0)
{
if (error_code == KRB5_CC_END || error_code == KRB5_FCC_NOFILE)
@@ -722,7 +673,7 @@ verify_identity (GoaKerberosIdentity *self,
goto out;
}
- error_code = krb5_cc_start_seq_get (priv->kerberos_context, priv->credentials_cache, &cursor);
+ error_code = krb5_cc_start_seq_get (self->kerberos_context, self->credentials_cache, &cursor);
if (error_code != 0)
{
set_and_prefix_error_from_krb5_error_code (self,
@@ -737,7 +688,7 @@ verify_identity (GoaKerberosIdentity *self,
verification_level = VERIFICATION_LEVEL_UNVERIFIED;
- error_code = krb5_cc_next_cred (priv->kerberos_context, priv->credentials_cache, &cursor, &credentials);
+ error_code = krb5_cc_next_cred (self->kerberos_context, self->credentials_cache, &cursor, &credentials);
while (error_code == 0)
{
if (credentials_validate_existence (self, principal, &credentials))
@@ -760,8 +711,8 @@ verify_identity (GoaKerberosIdentity *self,
snoop_preauth_identity_from_credentials (self, &credentials, preauth_identity_source);
}
- krb5_free_cred_contents (priv->kerberos_context, &credentials);
- error_code = krb5_cc_next_cred (priv->kerberos_context, priv->credentials_cache, &cursor,
&credentials);
+ krb5_free_cred_contents (self->kerberos_context, &credentials);
+ error_code = krb5_cc_next_cred (self->kerberos_context, self->credentials_cache, &cursor,
&credentials);
}
if (error_code != KRB5_CC_END)
@@ -777,7 +728,7 @@ verify_identity (GoaKerberosIdentity *self,
}
end_sequence:
- error_code = krb5_cc_end_seq_get (priv->kerberos_context, priv->credentials_cache, &cursor);
+ error_code = krb5_cc_end_seq_get (self->kerberos_context, self->credentials_cache, &cursor);
if (error_code != 0)
{
verification_level = VERIFICATION_LEVEL_ERROR;
@@ -799,7 +750,7 @@ out:
G_UNLOCK (identity_lock);
if (principal != NULL)
- krb5_free_principal (priv->kerberos_context, principal);
+ krb5_free_principal (self->kerberos_context, principal);
return verification_level;
}
@@ -807,13 +758,10 @@ static gboolean
goa_kerberos_identity_is_signed_in (GoaIdentity *identity)
{
GoaKerberosIdentity *self = GOA_KERBEROS_IDENTITY (identity);
- GoaKerberosIdentityPrivate *priv;
gboolean is_signed_in = FALSE;
- priv = goa_kerberos_identity_get_instance_private (self);
-
G_LOCK (identity_lock);
- if (priv->cached_verification_level == VERIFICATION_LEVEL_SIGNED_IN)
+ if (self->cached_verification_level == VERIFICATION_LEVEL_SIGNED_IN)
is_signed_in = TRUE;
G_UNLOCK (identity_lock);
@@ -864,14 +812,10 @@ static void
on_renewal_alarm_fired (GoaAlarm *alarm,
GoaKerberosIdentity *self)
{
- GoaKerberosIdentityPrivate *priv;
-
g_return_if_fail (GOA_IS_ALARM (alarm));
g_return_if_fail (GOA_IS_KERBEROS_IDENTITY (self));
- priv = goa_kerberos_identity_get_instance_private (self);
-
- if (priv->cached_verification_level == VERIFICATION_LEVEL_SIGNED_IN)
+ if (self->cached_verification_level == VERIFICATION_LEVEL_SIGNED_IN)
{
g_debug ("GoaKerberosIdentity: renewal alarm fired for signed-in identity");
g_signal_emit (G_OBJECT (self), signals[NEEDS_RENEWAL], 0);
@@ -892,14 +836,10 @@ static void
on_expiring_alarm_fired (GoaAlarm *alarm,
GoaKerberosIdentity *self)
{
- GoaKerberosIdentityPrivate *priv;
-
g_return_if_fail (GOA_IS_ALARM (alarm));
g_return_if_fail (GOA_IS_KERBEROS_IDENTITY (self));
- priv = goa_kerberos_identity_get_instance_private (self);
-
- if (priv->cached_verification_level == VERIFICATION_LEVEL_SIGNED_IN)
+ if (self->cached_verification_level == VERIFICATION_LEVEL_SIGNED_IN)
{
g_debug ("GoaKerberosIdentity: expiring alarm fired for signed-in identity");
g_signal_emit (G_OBJECT (self), signals[EXPIRING], 0);
@@ -946,64 +886,53 @@ reset_alarm (GoaKerberosIdentity *self,
static void
disconnect_alarm_signals (GoaKerberosIdentity *self)
{
- GoaKerberosIdentityPrivate *priv;
-
- priv = goa_kerberos_identity_get_instance_private (self);
-
- if (priv->renewal_alarm)
+ if (self->renewal_alarm)
{
- g_signal_handlers_disconnect_by_func (G_OBJECT (priv->renewal_alarm), G_CALLBACK
(on_renewal_alarm_fired), self);
- g_signal_handlers_disconnect_by_func (G_OBJECT (priv->renewal_alarm), G_CALLBACK
(on_renewal_alarm_rearmed), self);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (self->renewal_alarm), G_CALLBACK
(on_renewal_alarm_fired), self);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (self->renewal_alarm), G_CALLBACK
(on_renewal_alarm_rearmed), self);
}
- if (priv->expiring_alarm)
+ if (self->expiring_alarm)
{
- g_signal_handlers_disconnect_by_func (G_OBJECT (priv->expiring_alarm), G_CALLBACK
(on_expiring_alarm_fired), self);
- g_signal_handlers_disconnect_by_func (G_OBJECT (priv->expiring_alarm), G_CALLBACK
(on_expiring_alarm_rearmed), self);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (self->expiring_alarm), G_CALLBACK
(on_expiring_alarm_fired), self);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (self->expiring_alarm), G_CALLBACK
(on_expiring_alarm_rearmed), self);
}
- if (priv->expiration_alarm)
+ if (self->expiration_alarm)
{
- g_signal_handlers_disconnect_by_func (G_OBJECT (priv->expiration_alarm), G_CALLBACK
(on_expiration_alarm_rearmed), self);
- g_signal_handlers_disconnect_by_func (G_OBJECT (priv->expiration_alarm), G_CALLBACK
(on_expiration_alarm_fired), self);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (self->expiration_alarm), G_CALLBACK
(on_expiration_alarm_rearmed), self);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (self->expiration_alarm), G_CALLBACK
(on_expiration_alarm_fired), self);
}
}
static void
connect_alarm_signals (GoaKerberosIdentity *self)
{
- GoaKerberosIdentityPrivate *priv;
-
- priv = goa_kerberos_identity_get_instance_private (self);
-
- if (priv->renewal_alarm)
+ if (self->renewal_alarm)
{
- g_signal_connect (G_OBJECT (priv->renewal_alarm), "fired", G_CALLBACK (on_renewal_alarm_fired), self);
- g_signal_connect (G_OBJECT (priv->renewal_alarm), "rearmed", G_CALLBACK (on_renewal_alarm_rearmed),
self);
+ g_signal_connect (G_OBJECT (self->renewal_alarm), "fired", G_CALLBACK (on_renewal_alarm_fired), self);
+ g_signal_connect (G_OBJECT (self->renewal_alarm), "rearmed", G_CALLBACK (on_renewal_alarm_rearmed),
self);
}
- g_signal_connect (G_OBJECT (priv->expiring_alarm), "fired", G_CALLBACK (on_expiring_alarm_fired), self);
- g_signal_connect (G_OBJECT (priv->expiring_alarm), "rearmed", G_CALLBACK (on_expiring_alarm_rearmed),
self);
- g_signal_connect (G_OBJECT (priv->expiration_alarm), "fired", G_CALLBACK (on_expiration_alarm_fired),
self);
- g_signal_connect (G_OBJECT (priv->expiration_alarm), "rearmed", G_CALLBACK (on_expiration_alarm_rearmed),
self);
+ g_signal_connect (G_OBJECT (self->expiring_alarm), "fired", G_CALLBACK (on_expiring_alarm_fired), self);
+ g_signal_connect (G_OBJECT (self->expiring_alarm), "rearmed", G_CALLBACK (on_expiring_alarm_rearmed),
self);
+ g_signal_connect (G_OBJECT (self->expiration_alarm), "fired", G_CALLBACK (on_expiration_alarm_fired),
self);
+ g_signal_connect (G_OBJECT (self->expiration_alarm), "rearmed", G_CALLBACK (on_expiration_alarm_rearmed),
self);
}
static void
reset_alarms (GoaKerberosIdentity *self)
{
- GoaKerberosIdentityPrivate *priv;
GDateTime *start_time = NULL;
GDateTime *expiration_time = NULL;
GDateTime *expiring_time = NULL;
GDateTime *latest_possible_renewal_time = NULL;
GDateTime *renewal_time = NULL;
- priv = goa_kerberos_identity_get_instance_private (self);
-
G_LOCK (identity_lock);
- start_time = g_date_time_new_from_unix_local (priv->start_time);
- if (priv->renewal_time != 0)
- latest_possible_renewal_time = g_date_time_new_from_unix_local (priv->renewal_time);
- expiration_time = g_date_time_new_from_unix_local (priv->expiration_time);
+ start_time = g_date_time_new_from_unix_local (self->start_time);
+ if (self->renewal_time != 0)
+ latest_possible_renewal_time = g_date_time_new_from_unix_local (self->renewal_time);
+ expiration_time = g_date_time_new_from_unix_local (self->expiration_time);
G_UNLOCK (identity_lock);
/* Let the user reauthenticate 10 min before expiration */
@@ -1024,10 +953,10 @@ reset_alarms (GoaKerberosIdentity *self)
disconnect_alarm_signals (self);
if (renewal_time != NULL)
- reset_alarm (self, &priv->renewal_alarm, renewal_time);
+ reset_alarm (self, &self->renewal_alarm, renewal_time);
- reset_alarm (self, &priv->expiring_alarm, expiring_time);
- reset_alarm (self, &priv->expiration_alarm, expiration_time);
+ reset_alarm (self, &self->expiring_alarm, expiring_time);
+ reset_alarm (self, &self->expiration_alarm, expiration_time);
g_clear_pointer (&expiring_time, g_date_time_unref);
g_clear_pointer (&renewal_time, g_date_time_unref);
@@ -1041,14 +970,10 @@ reset_alarms (GoaKerberosIdentity *self)
static void
clear_alarms (GoaKerberosIdentity *self)
{
- GoaKerberosIdentityPrivate *priv;
-
- priv = goa_kerberos_identity_get_instance_private (self);
-
disconnect_alarm_signals (self);
- clear_alarm_and_unref_on_idle (self, &priv->renewal_alarm);
- clear_alarm_and_unref_on_idle (self, &priv->expiring_alarm);
- clear_alarm_and_unref_on_idle (self, &priv->expiration_alarm);
+ clear_alarm_and_unref_on_idle (self, &self->renewal_alarm);
+ clear_alarm_and_unref_on_idle (self, &self->expiring_alarm);
+ clear_alarm_and_unref_on_idle (self, &self->expiration_alarm);
}
static gboolean
@@ -1057,32 +982,29 @@ goa_kerberos_identity_initable_init (GInitable *initable,
GError **error)
{
GoaKerberosIdentity *self = GOA_KERBEROS_IDENTITY (initable);
- GoaKerberosIdentityPrivate *priv;
GError *verification_error;
- priv = goa_kerberos_identity_get_instance_private (self);
-
if (g_cancellable_set_error_if_cancelled (cancellable, error))
return FALSE;
- if (priv->identifier == NULL)
+ if (self->identifier == NULL)
{
- priv->identifier = get_identifier (self, error);
+ self->identifier = get_identifier (self, error);
- if (priv->identifier != NULL)
- queue_notify (self, &priv->identifier_idle_id, "identifier");
+ if (self->identifier != NULL)
+ queue_notify (self, &self->identifier_idle_id, "identifier");
}
verification_error = NULL;
- priv->cached_verification_level = verify_identity (self, &priv->preauth_identity_source,
&verification_error);
+ self->cached_verification_level = verify_identity (self, &self->preauth_identity_source,
&verification_error);
- switch (priv->cached_verification_level)
+ switch (self->cached_verification_level)
{
case VERIFICATION_LEVEL_EXISTS:
case VERIFICATION_LEVEL_SIGNED_IN:
reset_alarms (self);
- queue_notify (self, &priv->is_signed_in_idle_id, "is-signed-in");
+ queue_notify (self, &self->is_signed_in_idle_id, "is-signed-in");
return TRUE;
case VERIFICATION_LEVEL_UNVERIFIED:
@@ -1160,19 +1082,16 @@ static gboolean
create_credential_cache (GoaKerberosIdentity *self,
GError **error)
{
- GoaKerberosIdentityPrivate *priv;
krb5_ccache default_cache;
const char *cache_type;
krb5_error_code error_code;
- priv = goa_kerberos_identity_get_instance_private (self);
-
- error_code = krb5_cc_default (priv->kerberos_context, &default_cache);
+ error_code = krb5_cc_default (self->kerberos_context, &default_cache);
if (error_code == 0)
{
- cache_type = krb5_cc_get_type (priv->kerberos_context, default_cache);
- error_code = krb5_cc_new_unique (priv->kerberos_context, cache_type, NULL, &priv->credentials_cache);
+ cache_type = krb5_cc_get_type (self->kerberos_context, default_cache);
+ error_code = krb5_cc_new_unique (self->kerberos_context, cache_type, NULL, &self->credentials_cache);
}
if (error_code != 0)
@@ -1195,21 +1114,18 @@ goa_kerberos_identity_update_credentials (GoaKerberosIdentity *self,
krb5_creds *new_credentials,
GError **error)
{
- GoaKerberosIdentityPrivate *priv;
krb5_error_code error_code;
- priv = goa_kerberos_identity_get_instance_private (self);
-
- if (priv->credentials_cache == NULL)
+ if (self->credentials_cache == NULL)
{
if (!create_credential_cache (self, error))
{
- krb5_free_cred_contents (priv->kerberos_context, new_credentials);
+ krb5_free_cred_contents (self->kerberos_context, new_credentials);
goto out;
}
}
- error_code = krb5_cc_initialize (priv->kerberos_context, priv->credentials_cache, principal);
+ error_code = krb5_cc_initialize (self->kerberos_context, self->credentials_cache, principal);
if (error_code != 0)
{
set_and_prefix_error_from_krb5_error_code (self,
@@ -1218,11 +1134,11 @@ goa_kerberos_identity_update_credentials (GoaKerberosIdentity *self,
error_code,
_("Could not initialize credentials cache: "));
- krb5_free_cred_contents (priv->kerberos_context, new_credentials);
+ krb5_free_cred_contents (self->kerberos_context, new_credentials);
goto out;
}
- error_code = krb5_cc_store_cred (priv->kerberos_context, priv->credentials_cache, new_credentials);
+ error_code = krb5_cc_store_cred (self->kerberos_context, self->credentials_cache, new_credentials);
if (error_code != 0)
{
set_and_prefix_error_from_krb5_error_code (self,
@@ -1231,10 +1147,10 @@ goa_kerberos_identity_update_credentials (GoaKerberosIdentity *self,
error_code,
_("Could not store new credentials in credentials cache:
"));
- krb5_free_cred_contents (priv->kerberos_context, new_credentials);
+ krb5_free_cred_contents (self->kerberos_context, new_credentials);
goto out;
}
- krb5_free_cred_contents (priv->kerberos_context, new_credentials);
+ krb5_free_cred_contents (self->kerberos_context, new_credentials);
return TRUE;
out:
@@ -1285,7 +1201,6 @@ goa_kerberos_identity_sign_in (GoaKerberosIdentity *self,
GCancellable *cancellable,
GError **error)
{
- GoaKerberosIdentityPrivate *priv;
SignInOperation *operation;
krb5_principal principal;
krb5_error_code error_code;
@@ -1295,12 +1210,10 @@ goa_kerberos_identity_sign_in (GoaKerberosIdentity *self,
char *service_name;
gboolean signed_in;
- priv = goa_kerberos_identity_get_instance_private (self);
-
if (g_cancellable_set_error_if_cancelled (cancellable, error))
return FALSE;
- error_code = krb5_get_init_creds_opt_alloc (priv->kerberos_context, &options);
+ error_code = krb5_get_init_creds_opt_alloc (self->kerberos_context, &options);
if (error_code != 0)
{
set_and_prefix_error_from_krb5_error_code (self,
@@ -1322,13 +1235,13 @@ goa_kerberos_identity_sign_in (GoaKerberosIdentity *self,
destroy_notify,
cancellable);
- if (g_strcmp0 (priv->identifier, principal_name) != 0)
+ if (g_strcmp0 (self->identifier, principal_name) != 0)
{
- g_free (priv->identifier);
- priv->identifier = g_strdup (principal_name);
+ g_free (self->identifier);
+ self->identifier = g_strdup (principal_name);
}
- error_code = krb5_parse_name (priv->kerberos_context, principal_name, &principal);
+ error_code = krb5_parse_name (self->kerberos_context, principal_name, &principal);
if (error_code != 0)
{
set_and_prefix_error_from_krb5_error_code (self,
@@ -1352,7 +1265,7 @@ goa_kerberos_identity_sign_in (GoaKerberosIdentity *self,
krb5_get_init_creds_opt_set_renew_life (options, G_MAXINT);
if (preauth_source != NULL)
- krb5_get_init_creds_opt_set_pa (priv->kerberos_context, options, "X509_user_identity", preauth_source);
+ krb5_get_init_creds_opt_set_pa (self->kerberos_context, options, "X509_user_identity", preauth_source);
/* Poke glibc in case the network changed
*/
@@ -1360,7 +1273,7 @@ goa_kerberos_identity_sign_in (GoaKerberosIdentity *self,
start_time = 0;
service_name = NULL;
- error_code = krb5_get_init_creds_password (priv->kerberos_context,
+ error_code = krb5_get_init_creds_password (self->kerberos_context,
&new_credentials,
principal,
(char *)
@@ -1381,7 +1294,7 @@ goa_kerberos_identity_sign_in (GoaKerberosIdentity *self,
destroy_notify (inquiry_data);
sign_in_operation_free (operation);
- krb5_free_principal (priv->kerberos_context, principal);
+ krb5_free_principal (self->kerberos_context, principal);
goto done;
}
@@ -1397,7 +1310,7 @@ goa_kerberos_identity_sign_in (GoaKerberosIdentity *self,
destroy_notify (inquiry_data);
sign_in_operation_free (operation);
- krb5_free_principal (priv->kerberos_context, principal);
+ krb5_free_principal (self->kerberos_context, principal);
goto done;
}
@@ -1410,10 +1323,10 @@ goa_kerberos_identity_sign_in (GoaKerberosIdentity *self,
&new_credentials,
error))
{
- krb5_free_principal (priv->kerberos_context, principal);
+ krb5_free_principal (self->kerberos_context, principal);
goto done;
}
- krb5_free_principal (priv->kerberos_context, principal);
+ krb5_free_principal (self->kerberos_context, principal);
g_debug ("GoaKerberosIdentity: identity signed in");
signed_in = TRUE;
@@ -1425,17 +1338,14 @@ done:
static void
update_identifier (GoaKerberosIdentity *self, GoaKerberosIdentity *new_identity)
{
- GoaKerberosIdentityPrivate *priv;
char *new_identifier;
- priv = goa_kerberos_identity_get_instance_private (self);
-
new_identifier = get_identifier (self, NULL);
- if (g_strcmp0 (priv->identifier, new_identifier) != 0 && new_identifier != NULL)
+ if (g_strcmp0 (self->identifier, new_identifier) != 0 && new_identifier != NULL)
{
- g_free (priv->identifier);
- priv->identifier = new_identifier;
- queue_notify (self, &priv->identifier_idle_id, "identifier");
+ g_free (self->identifier);
+ self->identifier = new_identifier;
+ queue_notify (self, &self->identifier_idle_id, "identifier");
}
else
{
@@ -1447,28 +1357,23 @@ void
goa_kerberos_identity_update (GoaKerberosIdentity *self,
GoaKerberosIdentity *new_identity)
{
- GoaKerberosIdentityPrivate *priv;
- GoaKerberosIdentityPrivate *new_identity_priv;
VerificationLevel old_verification_level, new_verification_level;
gboolean time_changed = FALSE;
char *preauth_identity_source = NULL;
- priv = goa_kerberos_identity_get_instance_private (self);
- new_identity_priv = goa_kerberos_identity_get_instance_private (new_identity);
-
- if (priv->credentials_cache != NULL)
- krb5_cc_close (priv->kerberos_context, priv->credentials_cache);
+ if (self->credentials_cache != NULL)
+ krb5_cc_close (self->kerberos_context, self->credentials_cache);
- krb5_cc_dup (new_identity_priv->kerberos_context, new_identity_priv->credentials_cache,
&priv->credentials_cache);
+ krb5_cc_dup (new_identity->kerberos_context, new_identity->credentials_cache, &self->credentials_cache);
G_LOCK (identity_lock);
update_identifier (self, new_identity);
- time_changed |= set_start_time (self, new_identity_priv->start_time);
- time_changed |= set_renewal_time (self, new_identity_priv->renewal_time);
- time_changed |= set_expiration_time (self, new_identity_priv->expiration_time);
- old_verification_level = priv->cached_verification_level;
- new_verification_level = new_identity_priv->cached_verification_level;
+ time_changed |= set_start_time (self, new_identity->start_time);
+ time_changed |= set_renewal_time (self, new_identity->renewal_time);
+ time_changed |= set_expiration_time (self, new_identity->expiration_time);
+ old_verification_level = self->cached_verification_level;
+ new_verification_level = new_identity->cached_verification_level;
G_UNLOCK (identity_lock);
if (time_changed)
@@ -1480,8 +1385,8 @@ goa_kerberos_identity_update (GoaKerberosIdentity *self,
}
G_LOCK (identity_lock);
- g_free (priv->preauth_identity_source);
- priv->preauth_identity_source = preauth_identity_source;
+ g_free (self->preauth_identity_source);
+ self->preauth_identity_source = preauth_identity_source;
G_UNLOCK (identity_lock);
if (new_verification_level != old_verification_level)
@@ -1490,7 +1395,7 @@ goa_kerberos_identity_update (GoaKerberosIdentity *self,
new_verification_level == VERIFICATION_LEVEL_EXISTS)
{
G_LOCK (identity_lock);
- priv->cached_verification_level = new_verification_level;
+ self->cached_verification_level = new_verification_level;
G_UNLOCK (identity_lock);
g_signal_emit (G_OBJECT (self), signals[EXPIRED], 0);
@@ -1499,7 +1404,7 @@ goa_kerberos_identity_update (GoaKerberosIdentity *self,
new_verification_level == VERIFICATION_LEVEL_SIGNED_IN)
{
G_LOCK (identity_lock);
- priv->cached_verification_level = new_verification_level;
+ self->cached_verification_level = new_verification_level;
G_UNLOCK (identity_lock);
g_signal_emit (G_OBJECT (self), signals[UNEXPIRED], 0);
@@ -1507,26 +1412,23 @@ goa_kerberos_identity_update (GoaKerberosIdentity *self,
else
{
G_LOCK (identity_lock);
- priv->cached_verification_level = new_verification_level;
+ self->cached_verification_level = new_verification_level;
G_UNLOCK (identity_lock);
}
- queue_notify (self, &priv->is_signed_in_idle_id, "is-signed-in");
+ queue_notify (self, &self->is_signed_in_idle_id, "is-signed-in");
}
}
gboolean
goa_kerberos_identity_renew (GoaKerberosIdentity *self, GError **error)
{
- GoaKerberosIdentityPrivate *priv;
krb5_error_code error_code = 0;
krb5_principal principal;
krb5_creds new_credentials;
gboolean renewed = FALSE;
char *name = NULL;
- priv = goa_kerberos_identity_get_instance_private (self);
-
- if (priv->credentials_cache == NULL)
+ if (self->credentials_cache == NULL)
{
g_set_error (error,
GOA_IDENTITY_ERROR,
@@ -1535,7 +1437,7 @@ goa_kerberos_identity_renew (GoaKerberosIdentity *self, GError **error)
goto out;
}
- error_code = krb5_cc_get_principal (priv->kerberos_context, priv->credentials_cache, &principal);
+ error_code = krb5_cc_get_principal (self->kerberos_context, self->credentials_cache, &principal);
if (error_code != 0)
{
set_and_prefix_error_from_krb5_error_code (self,
@@ -1547,7 +1449,7 @@ goa_kerberos_identity_renew (GoaKerberosIdentity *self, GError **error)
name = goa_kerberos_identity_get_principal_name (self);
- error_code = krb5_get_renewed_creds (priv->kerberos_context, &new_credentials, principal,
priv->credentials_cache, NULL);
+ error_code = krb5_get_renewed_creds (self->kerberos_context, &new_credentials, principal,
self->credentials_cache, NULL);
if (error_code != 0)
{
set_and_prefix_error_from_krb5_error_code (self,
@@ -1571,7 +1473,7 @@ goa_kerberos_identity_renew (GoaKerberosIdentity *self, GError **error)
renewed = TRUE;
free_principal:
- krb5_free_principal (priv->kerberos_context, principal);
+ krb5_free_principal (self->kerberos_context, principal);
out:
g_free (name);
@@ -1582,15 +1484,12 @@ out:
gboolean
goa_kerberos_identity_erase (GoaKerberosIdentity *self, GError **error)
{
- GoaKerberosIdentityPrivate *priv;
krb5_error_code error_code = 0;
- priv = goa_kerberos_identity_get_instance_private (self);
-
- if (priv->credentials_cache != NULL)
+ if (self->credentials_cache != NULL)
{
- error_code = krb5_cc_destroy (priv->kerberos_context, priv->credentials_cache);
- priv->credentials_cache = NULL;
+ error_code = krb5_cc_destroy (self->kerberos_context, self->credentials_cache);
+ self->credentials_cache = NULL;
}
if (error_code != 0)
@@ -1609,13 +1508,11 @@ GoaIdentity *
goa_kerberos_identity_new (krb5_context context, krb5_ccache cache, GError **error)
{
GoaKerberosIdentity *self;
- GoaKerberosIdentityPrivate *priv;
self = GOA_KERBEROS_IDENTITY (g_object_new (GOA_TYPE_KERBEROS_IDENTITY, NULL));
- priv = goa_kerberos_identity_get_instance_private (self);
- krb5_cc_dup (context, cache, &priv->credentials_cache);
- priv->kerberos_context = context;
+ krb5_cc_dup (context, cache, &self->credentials_cache);
+ self->kerberos_context = context;
error = NULL;
if (!g_initable_init (G_INITABLE (self), NULL, error))
diff --git a/src/goaidentity/goakerberosidentity.h b/src/goaidentity/goakerberosidentity.h
index e9898b50..a7b685ed 100644
--- a/src/goaidentity/goakerberosidentity.h
+++ b/src/goaidentity/goakerberosidentity.h
@@ -28,13 +28,9 @@
G_BEGIN_DECLS
#define GOA_TYPE_KERBEROS_IDENTITY (goa_kerberos_identity_get_type ())
#define GOA_KERBEROS_IDENTITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GOA_TYPE_KERBEROS_IDENTITY, GoaKerberosIdentity))
-#define GOA_KERBEROS_IDENTITY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GOA_TYPE_KERBEROS_IDENTITY, GoaKerberosIdentityClass))
#define GOA_IS_KERBEROS_IDENTITY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GOA_TYPE_KERBEROS_IDENTITY))
-#define GOA_IS_KERBEROS_IDENTITY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GOA_TYPE_KERBEROS_IDENTITY))
-#define GOA_KERBEROS_IDENTITY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GOA_TYPE_KERBEROS_IDENTITY,
GoaKerberosIdentityClass))
typedef struct _GoaKerberosIdentity GoaKerberosIdentity;
typedef struct _GoaKerberosIdentityClass GoaKerberosIdentityClass;
-typedef struct _GoaKerberosIdentityPrivate GoaKerberosIdentityPrivate;
typedef enum _GoaKerberosIdentityDescriptionLevel
GoaKerberosIdentityDescriptionLevel;
@@ -45,16 +41,6 @@ enum _GoaKerberosIdentityDescriptionLevel
GOA_KERBEROS_IDENTITY_DESCRIPTION_USERNAME_ROLE_AND_REALM
};
-struct _GoaKerberosIdentity
-{
- GObject parent;
-};
-
-struct _GoaKerberosIdentityClass
-{
- GObjectClass parent_class;
-};
-
GType goa_kerberos_identity_get_type (void);
GoaIdentity *goa_kerberos_identity_new (krb5_context kerberos_context,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]