...
 
Commits (28)
alberto.mardegan@nokia.com
jussi.laako@linux.intel.com
......@@ -33,4 +33,7 @@ git-changelog-hook: Makefile
DISTCLEANFILES = \
$(pkgconfig_DATA)
valgrind:
cd tests; make valgrind
.PHONY: git-changelog-hook
......@@ -11,11 +11,16 @@ AC_CONFIG_HEADERS([config.h])
AC_CONFIG_SRCDIR([libsignon-glib.pc.in])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([1.11 -Wall check-news nostdinc silent-rules subdir-objects])
AM_INIT_AUTOMAKE([1.11 check-news nostdinc silent-rules subdir-objects -Wno-portability])
AC_PROG_CC
AC_PROG_CC_STDC
AM_PROG_CC_C_O
AM_PROG_AR
AX_CHECK_GNU_MAKE
if test "x$ifGNUmake" = "x#" ; then
AC_MSG_ERROR("GNUmake is required")
fi
LT_PREREQ([2.2])
LT_INIT([disable-static])
......@@ -28,12 +33,38 @@ PKG_CHECK_MODULES(
[gio-2.0 >= 2.30
gio-unix-2.0
glib-2.0 >= 2.32
gobject-2.0
signond >= 8.40])
gobject-2.0])
AC_SUBST(DEPS_CFLAGS)
AC_SUBST(DEPS_LIBS)
# Build tests.
AC_ARG_ENABLE(dbus-type,
[ --enable-dbus-type=dbus-type specify daemon dbus type:
p2p(default): uses peer to peer dbus
session: uses session message bus
system: uses system message bus],
[enable_dbus_type=$enableval], [enable_dbus_type=p2p])
echo "----------------------"
echo " DBUS TYPE : '$enable_dbus_type'"
echo "-----------------------"
if test "x$enable_dbus_type" = "xp2p" ; then
AC_DEFINE(USE_P2P, [1], [Use peer to peer dbus])
AC_DEFINE(SIGNOND_BUS_ADDRESS, ["unix:path=%s/gsignond/bus-sock"], [signond daemon server socket address])
elif test "x$enable_dbus_type" = "xsession" ; then
AC_DEFINE(SIGNOND_BUS_TYPE, [G_BUS_TYPE_SESSION], [Use session bus])
# Build tests.
PKG_CHECK_MODULES(GTestDBus, glib-2.0 >= 2.34, [gtestdbus=yes], [gtestdbus=no])
if test "x$gtestdbus" = xyes; then
AC_DEFINE(HAVE_GTESTDBUS, [1], [Define if GTestDBus exists.])
else
AC_DEFINE(HAVE_GTESTDBUS, [0], [GTestDBus does not exist.])
fi
elif test "x$enable_dbus_type" = "xsystem" ; then
AC_DEFINE(SIGNOND_BUS_TYPE, [G_BUS_TYPE_SYSTEM], [Use system bus])
fi
AM_CONDITIONAL(HAVE_GTESTDBUS, [test x$gtestdbus = xyes])
CHECK_REQUIRED="check >= 0.9.4"
......
......@@ -33,9 +33,9 @@ BUILT_SOURCES = \
CLEANFILES = \
$(BUILT_SOURCES) \
sso-auth-service-gen-doc-com.google.code.AccountsSSO.SingleSignOn.AuthService.xml \
sso-auth-session-gen-doc-com.google.code.AccountsSSO.SingleSignOn.AuthSession.xml \
sso-identity-gen-doc-com.google.code.AccountsSSO.SingleSignOn.Identity.xml
sso-auth-service-gen-doc-com.google.code.AccountsSSO.gSingleSignOn.AuthService.xml \
sso-auth-session-gen-doc-com.google.code.AccountsSSO.gSingleSignOn.AuthSession.xml \
sso-identity-gen-doc-com.google.code.AccountsSSO.gSingleSignOn.Identity.xml
libsignon_glib_la_SOURCES = \
signon-auth-service.h \
......@@ -54,6 +54,8 @@ libsignon_glib_la_SOURCES = \
signon-utils.h \
signon-utils.c \
signon-types.h \
signon-security-context.h \
signon-security-context.c \
sso-auth-service.c \
sso-auth-service.h
......@@ -63,6 +65,7 @@ libsignon_glib_include_HEADERS = \
signon-auth-session.h \
signon-identity-info.h \
signon-identity.h \
signon-security-context.h \
signon-errors.h \
signon-enum-types.h \
signon-glib.h \
......@@ -76,27 +79,28 @@ libsignon_glib_headers_with_enums = \
signon-identity-info.h
# This should come from `pkg-config --variable=interfaces_dir dbus-1`
DBUS_INTERFACES_DIR = /usr/share/dbus-1/interfaces
# default is /usr/share/dbus-1/interfaces
DBUS_INTERFACES_DIR = interfaces
sso-auth-service-gen.h sso-auth-service-gen.c: $(DBUS_INTERFACES_DIR)/com.google.code.AccountsSSO.SingleSignOn.AuthService.xml
sso-auth-service-gen.h sso-auth-service-gen.c: $(DBUS_INTERFACES_DIR)/com.google.code.AccountsSSO.gSingleSignOn.AuthService.xml
$(AM_V_GEN)gdbus-codegen \
--generate-c-code sso-auth-service-gen \
--generate-docbook sso-auth-service-gen-doc \
--annotate "com.google.code.AccountsSSO.SingleSignOn.AuthService" org.gtk.GDBus.C.Name SsoAuthService \
--annotate "com.google.code.AccountsSSO.gSingleSignOn.AuthService" org.gtk.GDBus.C.Name SsoAuthService \
$<
sso-auth-session-gen.h sso-auth-session-gen.c: $(DBUS_INTERFACES_DIR)/com.google.code.AccountsSSO.SingleSignOn.AuthSession.xml
sso-auth-session-gen.h sso-auth-session-gen.c: $(DBUS_INTERFACES_DIR)/com.google.code.AccountsSSO.gSingleSignOn.AuthSession.xml
$(AM_V_GEN)gdbus-codegen \
--generate-c-code sso-auth-session-gen \
--generate-docbook sso-auth-session-gen-doc \
--annotate "com.google.code.AccountsSSO.SingleSignOn.AuthSession" org.gtk.GDBus.C.Name SsoAuthSession \
--annotate "com.google.code.AccountsSSO.gSingleSignOn.AuthSession" org.gtk.GDBus.C.Name SsoAuthSession \
$<
sso-identity-gen.h sso-identity-gen.c: $(DBUS_INTERFACES_DIR)/com.google.code.AccountsSSO.SingleSignOn.Identity.xml
sso-identity-gen.h sso-identity-gen.c: $(DBUS_INTERFACES_DIR)/com.google.code.AccountsSSO.gSingleSignOn.Identity.xml
$(AM_V_GEN)gdbus-codegen \
--generate-c-code sso-identity-gen \
--generate-docbook sso-identity-gen-doc \
--annotate "com.google.code.AccountsSSO.SingleSignOn.Identity" org.gtk.GDBus.C.Name SsoIdentity \
--annotate "com.google.code.AccountsSSO.gSingleSignOn.Identity" org.gtk.GDBus.C.Name SsoIdentity \
$<
signon-marshal.h: signon-marshal.list Makefile
......@@ -137,7 +141,7 @@ signon-enum-types.c: Makefile $(libsignon_glib_headers_with_enums)
signon-errors-enum.c: Makefile signon-errors.h
$(AM_V_GEN)( cd $(srcdir) && glib-mkenums \
--fhead "#include \"signon-enum-types.h\"\n#include \"signon-errors.h\"\n#include \"signoncommon.h\"\n#define g_intern_static_string(s) (s)\n" \
--fhead "#include \"signon-enum-types.h\"\n#include \"signon-errors.h\"\n#include \"signon-internals.h\"\n#define g_intern_static_string(s) (s)\n" \
--fprod "\n/* enumerations from \"@filename@\" */" \
--ftail "\n#define __SIGNON_ENUM_TYPES_C__\n" \
--vhead "GType\n@enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G@Type@Value values[] = {" \
......
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="com.google.code.AccountsSSO.gSingleSignOn.AuthService">
<method name="registerNewIdentity">
<arg name="applicationContext" type="s" direction="in"/>
<arg name="objectPath" type="o" direction="out"/>
</method>
<method name="getIdentity">
<arg name="id" type="u" direction="in"/>
<arg name="applicationContext" type="s" direction="in"/>
<arg name="objectPath" type="o" direction="out"/>
<arg name="identityData" type="a{sv}" direction="out"/>
</method>
<method name="queryMethods">
<arg name="authMethods" type="as" direction="out"/>
</method>
<method name="queryMechanisms">
<arg name="mechanisms" type="as" direction="out"/>
<arg name="method" type="s" direction="in"/>
</method>
<method name="queryIdentities">
<arg name="filter" type="a{sv}" direction="in"/>
<arg name="applicationContext" type="s" direction="in"/>
<arg name="identities" type="aa{sv}" direction="out"/>
</method>
<method name="clear">
<arg type="b" direction="out"/>
</method>
<method name="backupStarts">
<arg type="y" direction="out"/>
</method>
<method name="backupFinished">
<arg type="y" direction="out"/>
</method>
<method name="restoreStarts">
<arg type="y" direction="out"/>
</method>
<method name="restoreFinished">
<arg type="y" direction="out"/>
</method>
</interface>
</node>
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="com.google.code.AccountsSSO.gSingleSignOn.AuthSession">
<signal name="stateChanged">
<arg name="state" type="i" direction="out"/>
<arg name="message" type="s" direction="out"/>
</signal>
<signal name="unregistered">
</signal>
<method name="queryAvailableMechanisms">
<arg type="as" direction="out"/>
<arg name="wantedMechanisms" type="as" direction="in"/>
</method>
<method name="process">
<arg type="a{sv}" direction="out"/>
<arg name="sessionDataVa" type="a{sv}" direction="in"/>
<arg name="mechanism" type="s" direction="in"/>
</method>
<method name="cancel">
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</method>
</interface>
</node>
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="com.google.code.AccountsSSO.gSingleSignOn.Identity">
<signal name="unregistered">
</signal>
<signal name="infoUpdated">
<arg type="i" direction="out"/>
</signal>
<method name="requestCredentialsUpdate">
<arg type="u" direction="out"/>
<arg name="message" type="s" direction="in"/>
</method>
<method name="getInfo">
<arg name="identityInfo" type="a{sv}" direction="out"/>
</method>
<method name="getAuthSession">
<arg name="objectPath" type="o" direction="out"/>
<arg name="method" type="s" direction="in"/>
</method>
<method name="verifyUser">
<arg type="b" direction="out"/>
<arg name="params" type="a{sv}" direction="in"/>
</method>
<method name="verifySecret">
<arg type="b" direction="out"/>
<arg name="secret" type="s" direction="in"/>
</method>
<method name="remove">
</method>
<method name="signOut">
<arg type="b" direction="out"/>
</method>
<method name="store">
<arg type="u" direction="out"/>
<arg type="a{sv}" direction="in"/>
</method>
<method name="addReference">
<arg type="i" direction="out"/>
<arg name="reference" type="s" direction="in"/>
</method>
<method name="removeReference">
<arg type="i" direction="out"/>
<arg name="reference" type="s" direction="in"/>
</method>
</interface>
</node>
......@@ -61,6 +61,13 @@ typedef struct _MechanismCbData
gchar *method;
} MechanismCbData;
typedef struct _IdentityCbData
{
SignonAuthService *service;
SignonQueryIdentitiesCb cb;
gpointer userdata;
} IdentityCbData;
#define SIGNON_AUTH_SERVICE_PRIV(obj) (SIGNON_AUTH_SERVICE(obj)->priv)
static void
......@@ -86,6 +93,7 @@ signon_auth_service_dispose (GObject *object)
if (priv->cancellable)
{
g_cancellable_cancel (priv->cancellable);
g_object_unref (priv->cancellable);
priv->cancellable = NULL;
}
......@@ -144,9 +152,7 @@ auth_query_methods_cb (GObject *object, GAsyncResult *res,
(data->cb)
(data->service, value, error, data->userdata);
g_strfreev (value);
if (error)
g_error_free (error);
g_clear_error (&error);
g_slice_free (MethodCbData, data);
}
......@@ -166,7 +172,6 @@ auth_query_mechanisms_cb (GObject *object, GAsyncResult *res,
(data->cb)
(data->service, data->method, value, error, data->userdata);
g_strfreev (value);
if (error)
g_error_free (error);
g_free (data->method);
......@@ -260,3 +265,105 @@ signon_auth_service_query_mechanisms (SignonAuthService *auth_service,
auth_query_mechanisms_cb,
cb_data);
}
static void
auth_query_identities_cb (GObject *object, GAsyncResult *res,
gpointer user_data)
{
SsoAuthService *proxy = SSO_AUTH_SERVICE (object);
IdentityCbData *data = (IdentityCbData *) user_data;
GVariant *value = NULL;
GError *error = NULL;
GVariantIter iter;
GVariant *identity_var;
SignonIdentityList *identity_list = NULL;
g_return_if_fail (data != NULL);
sso_auth_service_call_query_identities_finish (proxy,
&value,
res,
&error);
if (value && !error)
{
g_variant_iter_init (&iter, value);
while (g_variant_iter_next (&iter, "@a{sv}", &identity_var))
{
identity_list =
g_list_append (identity_list,
signon_identity_info_new_from_variant (identity_var));
g_variant_unref (identity_var);
}
}
(data->cb)
(data->service, identity_list, error, data->userdata);
if (error)
g_error_free (error);
g_slice_free (IdentityCbData, data);
}
/**
* SignonQueryIdentitiesCb:
* @auth_service: the #SignonAuthService.
* @identities: (transfer full): #GList based list of #SignonIdentityInfo.
* @user_data: the user data that was passed when installing this callback.
*
* Callback to be passed to signon_auth_service_query_identities().
*/
/**
* signon_auth_service_query_identities:
* @auth_service: the #SignonAuthService.
* @filter: filter variant dictionary based on #GHashTable.
* @application_context: application security context, can be %NULL.
* @cb: (scope async): callback to be invoked.
* @user_data: user data.
*/
void
signon_auth_service_query_identities (SignonAuthService *auth_service,
SignonIdentityFilter *filter,
const gchar *application_context,
SignonQueryIdentitiesCb cb,
gpointer user_data)
{
SignonAuthServicePrivate *priv;
GVariantBuilder builder;
GHashTableIter iter;
const gchar *key;
GVariant *value;
GVariant *filter_var;
g_return_if_fail (SIGNON_IS_AUTH_SERVICE (auth_service));
g_return_if_fail (cb != NULL);
priv = SIGNON_AUTH_SERVICE_PRIV (auth_service);
IdentityCbData *cb_data;
cb_data = g_slice_new (IdentityCbData);
cb_data->service = auth_service;
cb_data->cb = cb;
cb_data->userdata = user_data;
g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
if (filter)
{
g_hash_table_iter_init (&iter, filter);
while (g_hash_table_iter_next (&iter,
(gpointer) &key,
(gpointer) &value))
g_variant_builder_add (&builder, "{sv}", key, value);
}
filter_var = g_variant_builder_end (&builder);
if (!application_context)
application_context = "";
sso_auth_service_call_query_identities (priv->proxy,
filter_var,
application_context,
priv->cancellable,
auth_query_identities_cb,
cb_data);
}
......@@ -74,15 +74,31 @@ typedef void (*SignonQueryMechanismCb) (SignonAuthService *auth_service,
const GError *error,
gpointer user_data);
typedef GList SignonIdentityList;
typedef GHashTable SignonIdentityFilter;
typedef void (*SignonQueryIdentitiesCb) (SignonAuthService *auth_service,
SignonIdentityList *identities,
const GError *error,
gpointer user_data);
SignonAuthService *signon_auth_service_new ();
void signon_auth_service_query_methods (SignonAuthService *auth_service,
SignonQueryMethodsCb cb,
gpointer user_data);
void signon_auth_service_query_mechanisms (SignonAuthService *auth_service,
const gchar *method,
SignonQueryMechanismCb cb,
gpointer user_data);
void signon_auth_service_query_identities (SignonAuthService *auth_service,
SignonIdentityFilter *filter,
const gchar *application_context,
SignonQueryIdentitiesCb cb,
gpointer user_data);
G_END_DECLS
#endif /* _SIGNON_AUTH_SERVICE_H_ */
This diff is collapsed.
......@@ -5,8 +5,10 @@
*
* Copyright (C) 2009-2010 Nokia Corporation.
* Copyright (C) 2012 Canonical Ltd.
* Copyright (C) 2012-2013 Intel Corporation.
*
* Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
* Contact: Jussi Laako <jussi.laako@linux.intel.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
......@@ -142,7 +144,7 @@ struct _SignonAuthSessionClass {
GType signon_auth_session_get_type (void) G_GNUC_CONST;
SignonAuthSession *signon_auth_session_new(gint id,
SignonAuthSession *signon_auth_session_new(GObject *parent,
const gchar *method_name,
GError **err);
......
......@@ -5,8 +5,10 @@
*
* Copyright (C) 2009-2010 Nokia Corporation.
* Copyright (C) 2012 Canonical Ltd.
* Copyright (C) 2012 Intel Corporation.
*
* Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
* Contact: Jussi Laako <jussi.laako@linux.intel.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
......@@ -26,7 +28,6 @@
#include "signon-errors.h"
#include "signon-enum-types.h"
#include "signon-internals.h"
#include "signoncommon.h"
#include <gio/gio.h>
/**
......@@ -44,7 +45,7 @@ GQuark signon_error_quark (void)
{
static volatile gsize quark = 0;
g_dbus_error_register_error_domain ("signon-errors",
g_dbus_error_register_error_domain ("gsignond",
&quark,
signon_error_entries,
G_N_ELEMENTS (signon_error_entries));
......
......@@ -5,8 +5,10 @@
*
* Copyright (C) 2009-2010 Nokia Corporation.
* Copyright (C) 2011-2012 Canonical Ltd.
* Copyright (C) 2012-2013 Intel Corporation.
*
* Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
* Contact: Jussi Laako <jussi.laako@linux.intel.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
......@@ -69,6 +71,14 @@ static void identity_methods_copy (gpointer key, gpointer value, gpointer user_d
(const gchar* const *)value);
}
/**
* signon_identity_info_set_methods:
* @info: the #SignonIdentityInfo.
* @methods: (transfer none) (element-type utf8 GStrv): methods.
*
* Set allowed methods.
* Mechanisms are method-specific functions.
*/
void signon_identity_info_set_methods (SignonIdentityInfo *info,
const GHashTable *methods)
{
......@@ -90,6 +100,8 @@ SignonIdentityInfo *
signon_identity_info_new_from_variant (GVariant *variant)
{
GVariant *method_map;
GVariant *owner;
GVariant *acl;
if (!variant)
return NULL;
......@@ -144,12 +156,27 @@ signon_identity_info_new_from_variant (GVariant *variant)
{
g_hash_table_insert (info->methods, method, mechanisms);
}
g_variant_unref (method_map);
}
g_variant_lookup (variant,
SIGNOND_IDENTITY_INFO_ACL,
"^as",
&info->access_control_list);
if (g_variant_lookup (variant,
SIGNOND_IDENTITY_INFO_OWNER,
"@(ss)",
&owner))
{
info->owner = signon_security_context_deconstruct_variant (owner);
g_variant_unref (owner);
}
if (g_variant_lookup (variant,
SIGNOND_IDENTITY_INFO_ACL,
"@a(ss)",
&acl))
{
info->access_control_list =
signon_security_context_list_deconstruct_variant (acl);
g_variant_unref (acl);
}
g_variant_lookup (variant,
SIGNOND_IDENTITY_INFO_TYPE,
......@@ -217,13 +244,20 @@ signon_identity_info_to_variant (const SignonIdentityInfo *self)
-1));
}
if (self->owner != NULL)
{
g_variant_builder_add (&builder, "{sv}",
SIGNOND_IDENTITY_INFO_OWNER,
signon_security_context_build_variant (
self->owner));
}
if (self->access_control_list != NULL)
{
g_variant_builder_add (&builder, "{sv}",
SIGNOND_IDENTITY_INFO_ACL,
g_variant_new_strv ((const gchar * const *)
self->access_control_list,
-1));
signon_security_context_list_build_variant (
self->access_control_list));
}
g_variant_builder_add (&builder, "{sv}",
......@@ -271,7 +305,8 @@ void signon_identity_info_free (SignonIdentityInfo *info)
g_hash_table_destroy (info->methods);
g_strfreev (info->realms);
g_strfreev (info->access_control_list);
signon_security_context_free (info->owner);
signon_security_context_list_free (info->access_control_list);
g_slice_free (SignonIdentityInfo, info);
}
......@@ -291,16 +326,23 @@ SignonIdentityInfo *signon_identity_info_copy (const SignonIdentityInfo *other)
identity_info_set_id (info, signon_identity_info_get_id (other));
signon_identity_info_set_username (info, signon_identity_info_get_username (other));
signon_identity_info_set_username (info,
signon_identity_info_get_username (other));
signon_identity_info_set_secret (info, identity_info_get_secret(other),
signon_identity_info_get_storing_secret (other));
signon_identity_info_get_storing_secret (other));
signon_identity_info_set_caption (info, signon_identity_info_get_caption(other));
signon_identity_info_set_caption (info,
signon_identity_info_get_caption(other));
signon_identity_info_set_methods (info, signon_identity_info_get_methods (other));
signon_identity_info_set_methods (info,
signon_identity_info_get_methods (other));
signon_identity_info_set_realms (info, signon_identity_info_get_realms (other));
signon_identity_info_set_realms (info,
signon_identity_info_get_realms (other));
signon_identity_info_set_owner (info,
signon_identity_info_get_owner (other));
signon_identity_info_set_access_control_list (info,
signon_identity_info_get_access_control_list (other));
......@@ -396,18 +438,32 @@ const gchar* const *signon_identity_info_get_realms (const SignonIdentityInfo *i
return (const gchar* const *)info->realms;
}
/**
* signon_identity_info_get_owner:
* @info: the #SignonIdentityInfo.
*
* Get owner security context of @info.
*
* Returns: (transfer none): a security context.
*/
const SignonSecurityContext *signon_identity_info_get_owner (const SignonIdentityInfo *info)
{
g_return_val_if_fail (info != NULL, NULL);
return info->owner;
}
/**
* signon_identity_info_get_access_control_list:
* @info: the #SignonIdentityInfo.
*
* Get an array of ACL statements of the identity.
*
* Returns: (transfer none): a %NULL terminated array of ACL statements.
* Returns: (transfer none): a list of ACL security contexts.
*/
const gchar* const *signon_identity_info_get_access_control_list (const SignonIdentityInfo *info)
const SignonSecurityContextList *signon_identity_info_get_access_control_list (const SignonIdentityInfo *info)
{
g_return_val_if_fail (info != NULL, NULL);
return (const gchar* const *)info->access_control_list;
return info->access_control_list;
}
/**
......@@ -482,9 +538,8 @@ void signon_identity_info_set_caption (SignonIdentityInfo *info, const gchar *ca
* @method: an authentication method.
* @mechanisms: a %NULL-termianted list of mechanisms.
*
* Adds a method to the list of allowed methods. If this method is not called
* even once, then all methods are allowed.
* Mechanisms are method-specific variants of authentication.
* Adds a method to the list of allowed methods.
* Mechanisms are method-specific functions.
*/
void signon_identity_info_set_method (SignonIdentityInfo *info, const gchar *method,
const gchar* const *mechanisms)
......@@ -532,22 +587,82 @@ void signon_identity_info_set_realms (SignonIdentityInfo *info,
info->realms = g_strdupv ((gchar **)realms);
}
/**
* signon_identity_info_set_owner:
* @info: the #SignonIdentityInfo.
* @owner: (transfer none) a security context of owner.
*
* Specify owner security context.
*/
void signon_identity_info_set_owner (SignonIdentityInfo *info,
const SignonSecurityContext *owner)
{
g_return_if_fail (info != NULL);
if (info->owner) signon_security_context_free (info->owner);
info->owner = signon_security_context_copy (owner);
}
/**
* signon_identity_info_set_owner_from_values:
* @info: the #SignonIdentityInfo.
* @system_context: owner's system context.
* @application_context: owner's application context.
*
* Specify owner security context.
*/
void signon_identity_info_set_owner_from_values (
SignonIdentityInfo *info,
const gchar *system_context,
const gchar *application_context)
{
g_return_if_fail (info != NULL &&
system_context != NULL &&
application_context != NULL);
if (info->owner) signon_security_context_free (info->owner);
info->owner = signon_security_context_new_from_values(system_context,
application_context);
}
/**
* signon_identity_info_set_access_control_list:
* @info: the #SignonIdentityInfo.
* @access_control_list: a %NULL-terminated list of ACL security domains.
* @access_control_list: (transfer none) a list of ACL security contexts.
*
* Specifies the ACL for this identity. The actual meaning of the ACL depends
* on the security framework used by signond.
* on the security framework used by signond. Ownership of the list is trans
*/
void signon_identity_info_set_access_control_list (SignonIdentityInfo *info,
const gchar* const *access_control_list)
const SignonSecurityContextList *access_control_list)
{
g_return_if_fail (info != NULL);
if (info->access_control_list) g_strfreev (info->access_control_list);
if (info->access_control_list)
signon_security_context_list_free (info->access_control_list);
info->access_control_list =
signon_security_context_list_copy (access_control_list);
}
/**
* signon_identity_info_access_control_list_append:
* @info: the #SignonIdentityInfo.
* @security_context: (transfer full) a security context to be appended.
*
* Appends a new #SignonSecurityContext item to the access control list.
*/
void signon_identity_info_access_control_list_append (
SignonIdentityInfo *info,
SignonSecurityContext *security_context)
{
g_return_if_fail (info != NULL);
g_return_if_fail (security_context != NULL);
info->access_control_list = g_strdupv ((gchar **)access_control_list);
info->access_control_list = g_list_append (info->access_control_list,
security_context);
}
/**
......
......@@ -5,8 +5,10 @@
*
* Copyright (C) 2009-2010 Nokia Corporation.
* Copyright (C) 2011 Canonical Ltd.
* Copyright (C) 2012-2013 Intel Corporation.
*
* Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
* Contact: Jussi Laako <jussi.laako@linux.intel.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
......@@ -28,6 +30,8 @@
#include <glib-object.h>
#include "signon-security-context.h"
G_BEGIN_DECLS
/**
......@@ -62,25 +66,44 @@ SignonIdentityInfo *signon_identity_info_copy (const SignonIdentityInfo *other);
gint signon_identity_info_get_id (const SignonIdentityInfo *info);
const gchar *signon_identity_info_get_username (const SignonIdentityInfo *info);
gboolean signon_identity_info_get_storing_secret (const SignonIdentityInfo *info);
gboolean signon_identity_info_get_storing_secret (
const SignonIdentityInfo *info);
const gchar *signon_identity_info_get_caption (const SignonIdentityInfo *info);
const GHashTable *signon_identity_info_get_methods (const SignonIdentityInfo *info);
const gchar* const *signon_identity_info_get_realms (const SignonIdentityInfo *info);
const gchar* const *signon_identity_info_get_access_control_list (const SignonIdentityInfo *info);
SignonIdentityType signon_identity_info_get_identity_type (const SignonIdentityInfo *info);
const GHashTable *signon_identity_info_get_methods (
const SignonIdentityInfo *info);
const gchar* const *signon_identity_info_get_realms (
const SignonIdentityInfo *info);
const SignonSecurityContext *signon_identity_info_get_owner (
const SignonIdentityInfo *info);
const SignonSecurityContextList *signon_identity_info_get_access_control_list (
const SignonIdentityInfo *info);
SignonIdentityType signon_identity_info_get_identity_type (
const SignonIdentityInfo *info);
void signon_identity_info_set_username (SignonIdentityInfo *info, const gchar *username);
void signon_identity_info_set_secret (SignonIdentityInfo *info,
const gchar *secret,
gboolean store_secret);
void signon_identity_info_set_caption (SignonIdentityInfo *info, const gchar *caption);
void signon_identity_info_set_method (SignonIdentityInfo *info, const gchar *method,
void signon_identity_info_set_caption (SignonIdentityInfo *info,
const gchar *caption);
void signon_identity_info_set_methods (SignonIdentityInfo *info,
const GHashTable *methods);
void signon_identity_info_set_method (SignonIdentityInfo *info,
const gchar *method,
const gchar* const *mechanisms);
void signon_identity_info_remove_method (SignonIdentityInfo *info, const gchar *method);
void signon_identity_info_remove_method (SignonIdentityInfo *info,
const gchar *method);
void signon_identity_info_set_realms (SignonIdentityInfo *info,
const gchar* const *realms);
void signon_identity_info_set_owner (SignonIdentityInfo *info,
const SignonSecurityContext *owner);
void signon_identity_info_set_owner_from_values (SignonIdentityInfo *info,
const gchar *system_context,
const gchar *application_context);
void signon_identity_info_set_access_control_list (SignonIdentityInfo *info,
const gchar* const *access_control_list);
const SignonSecurityContextList *access_control_list);
void signon_identity_info_access_control_list_append (SignonIdentityInfo *info,
SignonSecurityContext *security_context);
void signon_identity_info_set_identity_type (SignonIdentityInfo *info,
SignonIdentityType type);
......
This diff is collapsed.
......@@ -4,8 +4,10 @@
* This file is part of libsignon-glib
*
* Copyright (C) 2009-2010 Nokia Corporation.
* Copyright (C) 2012-2013 Intel Corporation.
*
* Contact: Alberto Mardegan <alberto.mardegan@nokia.com>
* Contact: Jussi Laako <jussi.laako@linux.intel.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
......@@ -102,8 +104,9 @@ typedef SignonIdentityVoidCb SignonIdentityReferenceRemovedCb;
GType signon_identity_get_type (void) G_GNUC_CONST;
SignonIdentity *signon_identity_new_from_db (guint32 id);
SignonIdentity *signon_identity_new ();
SignonIdentity *signon_identity_new_from_db (guint32 id,
const gchar *application_context);
SignonIdentity *signon_identity_new (const gchar *application_context);
const GError *signon_identity_get_last_error (SignonIdentity *identity);
......@@ -132,16 +135,17 @@ void signon_identity_store_credentials_with_info(SignonIdentity *self,
gpointer user_data);
void signon_identity_store_credentials_with_args(SignonIdentity *self,
const gchar *username,
const gchar *secret,
const gboolean store_secret,
const GHashTable *methods,
const gchar *caption,
const gchar* const *realms,
const gchar* const *access_control_list,
SignonIdentityType type,
SignonIdentityStoreCredentialsCb cb,
gpointer user_data);
const gchar *username,
const gchar *secret,
const gboolean store_secret,
const GHashTable *methods,
const gchar *caption,
const gchar* const *realms,
const SignonSecurityContext *owner,
const SignonSecurityContextList *access_control_list,
SignonIdentityType type,
SignonIdentityStoreCredentialsCb cb,
gpointer user_data);
/**
* SignonIdentityVerifyCb:
......@@ -158,9 +162,9 @@ typedef void (*SignonIdentityVerifyCb) (SignonIdentity *self,
gpointer user_data);
void signon_identity_verify_secret(SignonIdentity *self,
const gchar *secret,
SignonIdentityVerifyCb cb,
gpointer user_data);
const gchar *secret,
SignonIdentityVerifyCb cb,
gpointer user_data);
/**
* SignonIdentityInfoCb:
......@@ -177,26 +181,37 @@ typedef void (*SignonIdentityInfoCb) (SignonIdentity *self,
gpointer user_data);
void signon_identity_query_info(SignonIdentity *self,
SignonIdentityInfoCb cb,
gpointer user_data);
SignonIdentityInfoCb cb,
gpointer user_data);
void signon_identity_remove(SignonIdentity *self,
SignonIdentityRemovedCb cb,
gpointer user_data);
SignonIdentityRemovedCb cb,
gpointer user_data);
void signon_identity_signout(SignonIdentity *self,
SignonIdentitySignedOutCb cb,
gpointer user_data);
SignonIdentitySignedOutCb cb,
gpointer user_data);
void signon_identity_add_reference(SignonIdentity *self,
const gchar *reference,
SignonIdentityReferenceAddedCb cb,
gpointer user_data);
const gchar *reference,
SignonIdentityReferenceAddedCb cb,
gpointer user_data);
void signon_identity_remove_reference(SignonIdentity *self,
const gchar *reference,
SignonIdentityReferenceRemovedCb cb,
gpointer user_data);
const gchar *reference,
SignonIdentityReferenceRemovedCb cb,
gpointer user_data);
typedef void (*SignonIdentitySessionReadyCb) (SignonAuthSession *self,
GError *error,
GDBusConnection *connection,
const gchar *bus_name,
const gchar *object_path);
void signon_identity_get_auth_session(SignonIdentity *self,
SignonAuthSession *session,
const gchar *method,
SignonIdentitySessionReadyCb cb);
G_END_DECLS
......
......@@ -5,8 +5,10 @@
*
* Copyright (C) 2009-2010 Nokia Corporation.
* Copyright (C) 2012 Canonical Ltd.
* Copyright (C) 2012 Intel Corporation.
*
* Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
* Contact: Jussi Laako <jussi.laako@linux.intel.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
......@@ -26,6 +28,8 @@
#ifndef _SIGNONINTERNALS_H_
#define _SIGNONINTERNALS_H_
#include "signon-security-context.h"
#ifndef SIGNON_TRACE
#define SIGNON_TRACE
#endif
......@@ -36,13 +40,118 @@
#define DEBUG(...) do {} while (0)
#endif
#include <signoncommon.h>
/*
* Common DBUS definitions
* */
#define SIGNOND_SERVICE_PREFIX "com.google.code.AccountsSSO.gSingleSignOn"
#define SIGNOND_SERVICE SIGNOND_SERVICE_PREFIX
#define SIGNOND_DAEMON_OBJECTPATH "/com/google/code/AccountsSSO/gSingleSignOn"
#define SIGNOND_DAEMON_INTERFACE SIGNOND_SERVICE_PREFIX ".AuthService"
#define SIGNOND_IDENTITY_INTERFACE SIGNOND_SERVICE_PREFIX ".Identity"
#define SIGNOND_AUTH_SESSION_INTERFACE SIGNOND_SERVICE_PREFIX ".AuthSession"
#define SIGNOND_ERR_PREFIX SIGNOND_SERVICE_PREFIX ".Error."
/*
* Common server/client identity info strings
* */
#define SIGNOND_IDENTITY_INFO_ID "Id"
#define SIGNOND_IDENTITY_INFO_USERNAME "UserName"
#define SIGNOND_IDENTITY_INFO_SECRET "Secret"
#define SIGNOND_IDENTITY_INFO_STORESECRET "StoreSecret"
#define SIGNOND_IDENTITY_INFO_CAPTION "Caption"
#define SIGNOND_IDENTITY_INFO_REALMS "Realms"
#define SIGNOND_IDENTITY_INFO_AUTHMETHODS "AuthMethods"
#define SIGNOND_IDENTITY_INFO_OWNER "Owner"
#define SIGNOND_IDENTITY_INFO_ACL "ACL"
#define SIGNOND_IDENTITY_INFO_TYPE "Type"
#define SIGNOND_IDENTITY_INFO_REFCOUNT "RefCount"
#define SIGNOND_IDENTITY_INFO_VALIDATED "Validated"
#define SIGNOND_IDENTITY_INFO_USERNAME_IS_SECRET "UserNameSecret"
/*
* Common server/client sides error names and messages
* */
#define SIGNOND_UNKNOWN_ERR_NAME SIGNOND_ERR_PREFIX "Unknown"
#define SIGNOND_INTERNAL_SERVER_ERR_NAME SIGNOND_ERR_PREFIX "InternalServer"
#define SIGNOND_INTERNAL_COMMUNICATION_ERR_NAME \
SIGNOND_ERR_PREFIX "InternalCommunication"
#define SIGNOND_PERMISSION_DENIED_ERR_NAME \
SIGNOND_ERR_PREFIX "PermissionDenied"
#define SIGNOND_METHOD_OR_MECHANISM_NOT_ALLOWED_ERR_NAME \
SIGNOND_ERR_PREFIX "MethodOrMechanismNotAllowed"
#define SIGNOND_ENCRYPTION_FAILED_ERR_NAME \
SIGNOND_ERR_PREFIX "EncryptionFailed"
#define SIGNOND_METHOD_NOT_KNOWN_ERR_NAME SIGNOND_ERR_PREFIX "MethodNotKnown"
#define SIGNOND_SERVICE_NOT_AVAILABLE_ERR_NAME \
SIGNOND_ERR_PREFIX "ServiceNotAvailable"
#define SIGNOND_INVALID_QUERY_ERR_NAME SIGNOND_ERR_PREFIX "InvalidQuery"
#define SIGNOND_METHOD_NOT_AVAILABLE_ERR_NAME \
SIGNOND_ERR_PREFIX "MethodNotAvailable"
#define SIGNOND_IDENTITY_NOT_FOUND_ERR_NAME \
SIGNOND_ERR_PREFIX "IdentityNotFound"
#define SIGNOND_STORE_FAILED_ERR_NAME SIGNOND_ERR_PREFIX "StoreFailed"
#define SIGNOND_REMOVE_FAILED_ERR_NAME SIGNOND_ERR_PREFIX "RemoveFailed"
#define SIGNOND_SIGNOUT_FAILED_ERR_NAME SIGNOND_ERR_PREFIX "SignOutFailed"
#define SIGNOND_IDENTITY_OPERATION_CANCELED_ERR_NAME \
SIGNOND_ERR_PREFIX "IdentityOperationCanceled"
#define SIGNOND_CREDENTIALS_NOT_AVAILABLE_ERR_NAME \
SIGNOND_ERR_PREFIX "CredentialsNotAvailable"
#define SIGNOND_REFERENCE_NOT_FOUND_ERR_NAME \
SIGNOND_ERR_PREFIX "ReferenceNotFound"
#define SIGNOND_MECHANISM_NOT_AVAILABLE_ERR_NAME \
SIGNOND_ERR_PREFIX "MechanismNotAvailable"
#define SIGNOND_MISSING_DATA_ERR_NAME SIGNOND_ERR_PREFIX "MissingData"
#define SIGNOND_INVALID_CREDENTIALS_ERR_NAME \
SIGNOND_ERR_PREFIX "InvalidCredentials"
#define SIGNOND_NOT_AUTHORIZED_ERR_NAME SIGNOND_ERR_PREFIX "NotAuthorized"
#define SIGNOND_WRONG_STATE_ERR_NAME SIGNOND_ERR_PREFIX "WrongState"
#define SIGNOND_OPERATION_NOT_SUPPORTED_ERR_NAME \
SIGNOND_ERR_PREFIX "OperationNotSupported"
#define SIGNOND_NO_CONNECTION_ERR_NAME SIGNOND_ERR_PREFIX "NoConnection"
#define SIGNOND_NETWORK_ERR_NAME SIGNOND_ERR_PREFIX "Network"
#define SIGNOND_SSL_ERR_NAME SIGNOND_ERR_PREFIX "Ssl"
#define SIGNOND_RUNTIME_ERR_NAME SIGNOND_ERR_PREFIX "Runtime"
#define SIGNOND_SESSION_CANCELED_ERR_NAME SIGNOND_ERR_PREFIX "SessionCanceled"
#define SIGNOND_TIMED_OUT_ERR_NAME SIGNOND_ERR_PREFIX "TimedOut"
#define SIGNOND_USER_INTERACTION_ERR_NAME SIGNOND_ERR_PREFIX "UserInteraction"
#define SIGNOND_OPERATION_FAILED_ERR_NAME SIGNOND_ERR_PREFIX "OperationFailed"
#define SIGNOND_TOS_NOT_ACCEPTED_ERR_NAME SIGNOND_ERR_PREFIX "TOSNotAccepted"
#define SIGNOND_FORGOT_PASSWORD_ERR_NAME SIGNOND_ERR_PREFIX "ForgotPassword"
#define SIGNOND_INCORRECT_DATE_ERR_NAME SIGNOND_ERR_PREFIX "IncorrectDate"
#define SIGNOND_USER_ERROR_ERR_NAME SIGNOND_ERR_PREFIX "User"
#include "signon-identity.h"
#include "signon-auth-session.h"
#include "signon-identity-info.h"
G_BEGIN_DECLS
enum SignonAuthSessionState {
SIGNON_AUTH_SESSION_STATE_NOT_STARTED = 0, /**< No message. */
SIGNON_AUTH_SESSION_STATE_RESOLVING_HOST, /**< Resolving remote server
host name. */
SIGNON_AUTH_SESSION_STATE_CONNECTING, /**< Connecting to remote
server. */
SIGNON_AUTH_SESSION_STATE_SENDING_DATA, /**< Sending data to remote
server. */
SIGNON_AUTH_SESSION_STATE_WAITING_REPLY, /**< Waiting reply from remote
server. */
SIGNON_AUTH_SESSION_STATE_USER_PENDING, /**< Waiting response from
user. */
SIGNON_AUTH_SESSION_STATE_UI_REFRESHING, /**< Refreshing ui request. */
SIGNON_AUTH_SESSION_STATE_PROCESS_PENDING, /**< Waiting another process
to start. */
SIGNON_AUTH_SESSION_STATE_STARTED, /**< Authentication session is
started. */
SIGNON_AUTH_SESSION_STATE_PROCESS_CANCELING, /**< Canceling.current
process. */
SIGNON_AUTH_SESSION_STATE_PROCESS_DONE, /**< Authentication
completed. */
SIGNON_AUTH_SESSION_STATE_CUSTOM, /**< Custom message. */
SIGNON_AUTH_SESSION_STATE_LAST
};
struct _SignonIdentityInfo
{
gint id;
......@@ -52,7 +161,8 @@ struct _SignonIdentityInfo
gboolean store_secret;
GHashTable *methods;
gchar **realms;
gchar **access_control_list;
SignonSecurityContext *owner;
SignonSecurityContextList *access_control_list;
gint type;
};
......@@ -64,14 +174,6 @@ G_GNUC_INTERNAL
GVariant *
signon_identity_info_to_variant (const SignonIdentityInfo *self);
G_GNUC_INTERNAL
void signon_identity_info_set_methods (SignonIdentityInfo *self,
const GHashTable *methods);
G_GNUC_INTERNAL
void signon_auth_session_set_id(SignonAuthSession* self,
gint32 id);
G_END_DECLS
#endif
......
/* vi: set et sw=4 ts=4 cino=t0,(0: */
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of libsignon-glib
*
* Copyright (C) 2012-2013 Intel Corporation.
*
* Contact: Jussi Laako <jussi.laako@linux.intel.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#include "signon-security-context.h"
static void
_security_context_free (gpointer ptr)
{
SignonSecurityContext *ctx = (SignonSecurityContext *) ptr;
signon_security_context_free (ctx);
}
/**
* signon_security_context_new:
*
* Allocates a new security context item.
*
* Returns: (transfer full) allocated #SignonSecurityContext.
*/
SignonSecurityContext *
signon_security_context_new ()
{
SignonSecurityContext *ctx;
ctx = g_slice_new0 (SignonSecurityContext);
ctx->sys_ctx = g_strdup ("");
ctx->app_ctx = g_strdup ("");
return ctx;
}
/**
* signon_security_context_new_from_vaues:
* @system_context: system security context (such as SMACK/MSSF label/token).
* @application_context: application security context (such as a script name).
*
* Allocates and initializes a new security context item.
*
* Returns: (transfer full) allocated #SignonSecurityContext.
*/
SignonSecurityContext *
signon_security_context_new_from_values (const gchar *system_context,
const gchar *application_context)
{
SignonSecurityContext *ctx;
g_return_val_if_fail (system_context != NULL, NULL);
ctx = g_slice_new0 (SignonSecurityContext);
ctx->sys_ctx = g_strdup (system_context);
if (application_context)
ctx->app_ctx = g_strdup (application_context);
else
ctx->app_ctx = g_strdup ("");
return ctx;
}
/**
* signon_security_context_copy:
* @src_ctx: source security context to copy.
*
* Copy a security context item.
*
* Returns: (transfer full) a copy of the #SignonSecurityContex item.
*/
SignonSecurityContext *
signon_security_context_copy (const SignonSecurityContext *src_ctx)
{
if (!src_ctx)
return NULL;
return signon_security_context_new_from_values (src_ctx->sys_ctx,
src_ctx->app_ctx);
}
/**
* signon_security_context_free:
* @ctx: #SignonSecurityContext to be freed.
*
* Frees a security context item.
*/
void
signon_security_context_free (SignonSecurityContext *ctx)
{
if (ctx == NULL) return;
g_free (ctx->sys_ctx);
g_free (ctx->app_ctx);
g_slice_free (SignonSecurityContext, ctx);
}
/**
* signon_security_context_set_system_context:
* @ctx: #SignonSecurityContext item.
* @system_context: system security context.
*
* Sets the system context part (such as SMACK label or MSSF token) of the
* #SignonSecurityContext.
*/
void
signon_security_context_set_system_context (SignonSecurityContext *ctx,
const gchar *system_context)
{
g_return_if_fail (ctx != NULL);
g_free (ctx->sys_ctx);
ctx->sys_ctx = g_strdup (system_context);
}
/**
* signon_security_context_get_system_context:
* @ctx: #SignonSecurityContext item.
*
* Get the system context part (such as SMACK label or MSSF token) of the
* #SignonSecurityContext.
*
* Returns: (transfer none) system context.
*/
const gchar *
signon_security_context_get_system_context (const SignonSecurityContext *ctx)
{
g_return_val_if_fail (ctx != NULL, NULL);
return ctx->sys_ctx;
}
/**
* signon_security_context_set_application_context:
* @ctx: #SignonSecurityContext item.
* @application_context: application security context.
*
* Sets the application context part (such as a script name or a web page) of
* the #SignonSecurityContext.
*/
void
signon_security_context_set_application_context (SignonSecurityContext *ctx,
const gchar *application_context)
{
g_return_if_fail (ctx != NULL);
g_free (ctx->app_ctx);
ctx->app_ctx = g_strdup (application_context);
}
/**
* signon_security_context_get_application_context:
* @ctx: #SignonSecurityContext item.
*
* Get the application context part (such as script name or a web page) of
* the #SignonSecurityContext.
*
* Returns: (transfer none) application context.
*/
const gchar *
signon_security_context_get_application_context (
const SignonSecurityContext *ctx)
{
g_return_val_if_fail (ctx != NULL, NULL);
return ctx->app_ctx;
}
/**
* signon_security_conetxt_build_variant:
* @ctx: #SignonSecurityContext item.
*
* Build a GVariant of type "(ss)" from a #SignonSecurityContext item.
*
* Returns: (transfer full) GVariant construct of a #SignonSecurityContext.
*/
GVariant *
signon_security_context_build_variant (const SignonSecurityContext *ctx)
{
GVariant *variant;
g_return_val_if_fail (ctx != NULL, NULL);
variant = g_variant_new ("(ss)",
ctx->sys_ctx ? ctx->sys_ctx : "",
ctx->app_ctx ? ctx->app_ctx : "");
return variant;
}
/**
* signon_security_context_deconstruct_variant:
* @variant: GVariant item with a #SignonSecurityContext construct.
*
* Builds a #SignonSecurityContext item from a GVariant of type "(ss)".
*
* Returns: (transfer full) #SignonSecurityContext item.
*/
SignonSecurityContext *
signon_security_context_deconstruct_variant (GVariant *variant)
{
gchar *sys_ctx = NULL;
gchar *app_ctx = NULL;
SignonSecurityContext *ctx;
g_return_val_if_fail (variant != NULL, NULL);
g_variant_get (variant, "(ss)", &sys_ctx, &app_ctx);
ctx = signon_security_context_new_from_values (sys_ctx, app_ctx);
g_free (sys_ctx);
g_free (app_ctx);
return ctx;
}
/**
* signon_security_context_list_build_variant:
* @list: #SignonSecurityContextList item.
*
* Builds a GVariant of type "a(ss)" from a GList of #SignonSecurityContext
* items.
*
* Returns: (transfer full) GVariant construct of a #SignonSecurityContextList.
*/
GVariant *
signon_security_context_list_build_variant (
const SignonSecurityContextList *list)
{
GVariantBuilder builder;
GVariant *variant;
SignonSecurityContext *ctx;
g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
for ( ; list != NULL; list = g_list_next (list))
{
ctx = (SignonSecurityContext *) list->data;
g_variant_builder_add_value (&builder,
signon_security_context_build_variant (ctx));
}
variant = g_variant_builder_end (&builder);
return variant;
}
/**
* signon_security_context_list_deconstruct_variant:
* @variant: GVariant item with a list of security context tuples.
*
* Builds a GList of #SignonSecurityContext items from a GVariant of type
* "a(ss)".
*
* Returns: (transfer full) #SignonSecurityContextList item.
*/
SignonSecurityContextList *
signon_security_context_list_deconstruct_variant (GVariant *variant)
{
SignonSecurityContextList *list = NULL;
GVariantIter iter;
GVariant *value;
g_return_val_if_fail (variant != NULL, NULL);
g_variant_iter_init (&iter, variant);
while ((value = g_variant_iter_next_value (&iter)))
{
list = g_list_append (
list, signon_security_context_deconstruct_variant (value));
g_variant_unref (value);
}
return list;
}
/**
* signon_security_context_list_copy:
* @src_list: source #SignonSecurityContextList.
*
* Copies a GList of #SignonSecurityContext items.
*
* Returns: (transfer full) #SignonSecurityContextList item.
*/
SignonSecurityContextList *
signon_security_context_list_copy (const SignonSecurityContextList *src_list)
{
SignonSecurityContext *ctx;
SignonSecurityContextList *dst_list = NULL;
for ( ; src_list != NULL; src_list = g_list_next (src_list))
{
ctx = (SignonSecurityContext *) src_list->data;
dst_list = g_list_append (
dst_list, signon_security_context_copy (ctx));
}
return dst_list;
}
/**
* signon_security_context_list_free:
* @seclist: (transfer full) #SignonSecurityContextList item.
*
* Frees all items and the GList of #SignonSecurityContext.
*/
void
signon_security_context_list_free (SignonSecurityContextList *seclist)
{
g_list_free_full (seclist, _security_context_free);
}
/* vi: set et sw=4 ts=4 cino=t0,(0: */
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of libsignon-glib
*
* Copyright (C) 2012 Intel Corporation.
*
* Contact: Jussi Laako <jussi.laako@linux.intel.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef _SIGNON_SECURITY_CONTEXT_H_
#define _SIGNON_SECURITY_CONTEXT_H_
#include <glib.h>
G_BEGIN_DECLS
/**
* Security context descriptor.
*
* Practically a string tuple.
*
* @sys_ctx: system context, such as SMACK-label, MSSF token or just a
* binary path.
* @app_ctx: application context, such as a script or a web page.
*/
typedef struct _SignonSecurityContext
{
gchar *sys_ctx;
gchar *app_ctx;
} SignonSecurityContext;
/**
* GList of #SignonSecurityContext items.
*/
typedef GList SignonSecurityContextList;
SignonSecurityContext * signon_security_context_new ();
SignonSecurityContext * signon_security_context_new_from_values (
const gchar *system_context,
const gchar *application_context);
void signon_security_context_free (SignonSecurityContext *ctx);
SignonSecurityContext * signon_security_context_copy (
const SignonSecurityContext *src_ctx);
void signon_security_context_set_system_context (SignonSecurityContext *ctx,
const gchar *system_context);
const gchar * signon_security_context_get_system_context (
const SignonSecurityContext *ctx);
void signon_security_context_set_application_context (
SignonSecurityContext *ctx,
const gchar *application_context);
const gchar * signon_security_context_get_application_context (
const SignonSecurityContext *ctx);
GVariant * signon_security_context_build_variant (
const SignonSecurityContext *ctx);
SignonSecurityContext * signon_security_context_deconstruct_variant (
GVariant *variant);
GVariant * signon_security_context_list_build_variant (
const SignonSecurityContextList *list);
SignonSecurityContextList * signon_security_context_list_deconstruct_variant (
GVariant *variant);
SignonSecurityContextList * signon_security_context_list_copy (
const SignonSecurityContextList *src_list);
void signon_security_context_list_free (SignonSecurityContextList *seclist);
G_END_DECLS
#endif /* _SIGNON_SECURITY_CONTEXT_H_ */
......@@ -107,14 +107,16 @@ GVariant *signon_hash_table_to_variant (const GHashTable *hash_table)
if (G_VALUE_TYPE (value) == G_TYPE_VARIANT)
{
val = g_value_get_variant (value);
g_variant_builder_add (&builder, "{sv}", key, val);
}
else
{
const GVariantType *type;
type = signon_gtype_to_variant_type (G_VALUE_TYPE (value));
val = g_dbus_gvalue_to_gvariant (value, type);
g_variant_builder_add (&builder, "{sv}", key, val);
g_variant_unref (val);
}
g_variant_builder_add (&builder, "{sv}", key, val);
}
return g_variant_builder_end (&builder);
}
......@@ -27,14 +27,10 @@
#include <glib-object.h>
#define SIGNON_RETURN_IF_CANCELLED(error) \
if (error != NULL && \
error->domain == G_IO_ERROR && \
error->code == G_IO_ERROR_CANCELLED) \
{ \