Commit 653f11c6 authored by David Zeuthen's avatar David Zeuthen

add infrastructure for CheckClaim() method

parent 454d6da4
......@@ -71,3 +71,15 @@ polkit_backend_authority_enumerate_groups (PolkitBackendAuthority *authority,
klass->enumerate_groups (authority, pending_call);
}
void
polkit_backend_authority_check_claim (PolkitBackendAuthority *authority,
PolkitAuthorizationClaim *claim,
PolkitBackendPendingCall *pending_call)
{
PolkitBackendAuthorityClass *klass;
klass = POLKIT_BACKEND_AUTHORITY_GET_CLASS (authority);
klass->check_claim (authority, claim, pending_call);
}
......@@ -61,6 +61,10 @@ struct _PolkitBackendAuthorityClass
void (*enumerate_groups) (PolkitBackendAuthority *authority,
PolkitBackendPendingCall *pending_call);
void (*check_claim) (PolkitBackendAuthority *authority,
PolkitAuthorizationClaim *claim,
PolkitBackendPendingCall *pending_call);
/*< private >*/
/* Padding for future expansion */
void (*_polkit_reserved1) (void);
......@@ -75,24 +79,36 @@ struct _PolkitBackendAuthorityClass
GType polkit_backend_authority_get_type (void) G_GNUC_CONST;
void polkit_backend_authority_enumerate_actions (PolkitBackendAuthority *authority,
const gchar *locale,
PolkitBackendPendingCall *pending_call);
/* --- */
void polkit_backend_authority_enumerate_actions (PolkitBackendAuthority *authority,
const gchar *locale,
PolkitBackendPendingCall *pending_call);
void polkit_backend_authority_enumerate_users (PolkitBackendAuthority *authority,
PolkitBackendPendingCall *pending_call);
void polkit_backend_authority_enumerate_groups (PolkitBackendAuthority *authority,
PolkitBackendPendingCall *pending_call);
void polkit_backend_authority_check_claim (PolkitBackendAuthority *authority,
PolkitAuthorizationClaim *claim,
PolkitBackendPendingCall *pending_call);
/* --- */
void polkit_backend_authority_enumerate_users (PolkitBackendAuthority *authority,
PolkitBackendPendingCall *pending_call);
void polkit_backend_authority_enumerate_actions_finish (PolkitBackendPendingCall *pending_call,
GList *actions);
void polkit_backend_authority_enumerate_groups (PolkitBackendAuthority *authority,
PolkitBackendPendingCall *pending_call);
void polkit_backend_authority_enumerate_users_finish (PolkitBackendPendingCall *pending_call,
GList *users);
void polkit_backend_authority_enumerate_actions_finish (PolkitBackendPendingCall *pending_call,
GList *actions);
void polkit_backend_authority_enumerate_groups_finish (PolkitBackendPendingCall *pending_call,
GList *groups);
void polkit_backend_authority_enumerate_users_finish (PolkitBackendPendingCall *pending_call,
GList *users);
void polkit_backend_authority_check_claim_finish (PolkitBackendPendingCall *pending_call,
PolkitAuthorizationResult result);
void polkit_backend_authority_enumerate_groups_finish (PolkitBackendPendingCall *pending_call,
GList *groups);
G_END_DECLS
......
......@@ -45,6 +45,10 @@ static void polkit_backend_local_authority_enumerate_users (PolkitBackendAutho
static void polkit_backend_local_authority_enumerate_groups (PolkitBackendAuthority *authority,
PolkitBackendPendingCall *pending_call);
static void polkit_backend_local_authority_check_claim (PolkitBackendAuthority *authority,
PolkitAuthorizationClaim *claim,
PolkitBackendPendingCall *pending_call);
G_DEFINE_TYPE (PolkitBackendLocalAuthority, polkit_backend_local_authority, POLKIT_BACKEND_TYPE_AUTHORITY);
#define POLKIT_BACKEND_LOCAL_AUTHORITY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), POLKIT_BACKEND_TYPE_LOCAL_AUTHORITY, PolkitBackendLocalAuthorityPrivate))
......@@ -91,6 +95,7 @@ polkit_backend_local_authority_class_init (PolkitBackendLocalAuthorityClass *kla
authority_class->enumerate_actions = polkit_backend_local_authority_enumerate_actions;
authority_class->enumerate_users = polkit_backend_local_authority_enumerate_users;
authority_class->enumerate_groups = polkit_backend_local_authority_enumerate_groups;
authority_class->check_claim = polkit_backend_local_authority_check_claim;
g_type_class_add_private (klass, sizeof (PolkitBackendLocalAuthorityPrivate));
}
......@@ -209,3 +214,15 @@ polkit_backend_local_authority_enumerate_groups (PolkitBackendAuthority *autho
out:
;
}
static void
polkit_backend_local_authority_check_claim (PolkitBackendAuthority *authority,
PolkitAuthorizationClaim *claim,
PolkitBackendPendingCall *pending_call)
{
polkit_backend_pending_call_return_error (pending_call,
POLKIT_ERROR,
POLKIT_ERROR_NOT_SUPPORTED,
"Not implemented");
}
......@@ -164,6 +164,8 @@ polkit_backend_authority_enumerate_users_finish (PolkitBackendPendingCall *pendi
g_list_foreach (users, (GFunc) g_object_unref, NULL);
g_list_free (users);
g_object_unref (pending_call);
}
static void
......@@ -203,6 +205,43 @@ polkit_backend_authority_enumerate_groups_finish (PolkitBackendPendingCall *pend
g_list_foreach (groups, (GFunc) g_object_unref, NULL);
g_list_free (groups);
g_object_unref (pending_call);
}
static void
authority_handle_check_claim (_PolkitAuthority *instance,
_PolkitAuthorizationClaim *real_claim,
EggDBusMethodInvocation *method_invocation)
{
PolkitBackendServer *server = POLKIT_BACKEND_SERVER (instance);
PolkitBackendPendingCall *pending_call;
PolkitAuthorizationClaim *claim;
pending_call = _polkit_backend_pending_call_new (method_invocation, server);
claim = polkit_authorization_claim_new_for_real (real_claim);
g_object_set_data_full (G_OBJECT (pending_call), "claim", claim, (GDestroyNotify) g_object_unref);
polkit_backend_authority_check_claim (server->authority, claim, pending_call);
}
void
polkit_backend_authority_check_claim_finish (PolkitBackendPendingCall *pending_call,
PolkitAuthorizationResult result)
{
EggDBusHashMap *attributes;
attributes = egg_dbus_hash_map_new (G_TYPE_STRING, g_free, G_TYPE_STRING, g_free);
_polkit_authority_handle_check_claim_finish (_polkit_backend_pending_call_get_method_invocation (pending_call),
result,
attributes);
g_object_unref (attributes);
g_object_unref (pending_call);
}
static void
......@@ -211,4 +250,5 @@ authority_iface_init (_PolkitAuthorityIface *authority_iface)
authority_iface->handle_enumerate_actions = authority_handle_enumerate_actions;
authority_iface->handle_enumerate_users = authority_handle_enumerate_users;
authority_iface->handle_enumerate_groups = authority_handle_enumerate_groups;
authority_iface->handle_check_claim = authority_handle_check_claim;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment