PolkitAgent.Listener¶
- Subclasses:
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class PolkitAgent.Listener(**kwargs)¶
- Bases:
- Abstract:
Yes
- Structure:
PolkitAgent.Listener
is an abstract base class used for implementing authentication agents. To implement an authentication agent, simply subclassPolkitAgent.Listener
and implement the initiate_authentication and initiate_authentication_finish methods.Typically authentication agents use
PolkitAgent.Session
to authenticate users (via passwords) and communicate back the authentication result to the PolicyKit daemon.To register a
PolkitAgent.Listener
with the PolicyKit daemon, usePolkitAgent.Listener.register
() orPolkitAgent.Listener.register_with_options
().- classmethod unregister(registration_handle)¶
- Parameters:
registration_handle (
object
orNone
) – A handle obtained fromPolkitAgent.Listener.register
().
Unregisters listener.
- initiate_authentication(action_id, message, icon_name, details, cookie, identities, cancellable, callback, *user_data)¶
- Parameters:
action_id (
str
) – The action to authenticate for.message (
str
) – The message to present to the user.icon_name (
str
) – A themed icon name representing the action orNone
.details (
Polkit.Details
) – Details describing the action.cookie (
str
) – The cookie for the authentication request.identities ([
Polkit.Identity
]) – A list ofPolkit.Identity
objects that the user can choose to authenticate as.cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
.callback (
Gio.AsyncReadyCallback
orNone
) – Function to call when the user is done authenticating.
Called on a registered authentication agent (see
PolkitAgent.Listener.register
()) when the user owning the session needs to prove he is one of the identities listed in identities.When the user is done authenticating (for example by dismissing an authentication dialog or by successfully entering a password or otherwise proving the user is one of the identities in identities), callback will be invoked. The caller then calls
PolkitAgent.Listener.initiate_authentication_finish
() to get the result.PolkitAgent.Listener
derived subclasses imlementing this method MUST not ignore cancellable; callers of this function can and will use it. Additionally, callback must be invoked in thethread-default main loop
of the thread that this method is called from.
- initiate_authentication_finish(res)¶
- Parameters:
res (
Gio.AsyncResult
) – AGio.AsyncResult
obtained from theGio.AsyncReadyCallback
function passed toPolkitAgent.Listener.initiate_authentication
().- Raises:
- Returns:
True
if error is set.- Return type:
Finishes an authentication request from the PolicyKit daemon, see
PolkitAgent.Listener.initiate_authentication
() for details.
- register(flags, subject, object_path, cancellable)¶
- Parameters:
flags (
PolkitAgent.RegisterFlags
) – A set of flags from thePolkitAgent.RegisterFlags
enumeration.subject (
Polkit.Subject
) – The subject to become an authentication agent for, typically aPolkit.UnixSession
object.object_path (
str
) – The D-Bus object path to use for the authentication agent orNone
for the default object path.cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
orNone
.
- Raises:
- Returns:
None
if error is set, otherwise a registration handle that can be used withPolkitAgent.Listener.unregister
().- Return type:
Registers self with the PolicyKit daemon as an authentication agent for subject. This is implemented by registering a D-Bus object at object_path on the unique name assigned by the system message bus.
Whenever the PolicyKit daemon needs to authenticate a processes that is related to subject, the methods
PolkitAgent.Listener.initiate_authentication
() andPolkitAgent.Listener.initiate_authentication_finish
() will be invoked on self.Note that registration of an authentication agent can fail; for example another authentication agent may already be registered for subject.
Note that the calling thread is blocked until a reply is received.
- register_with_options(flags, subject, object_path, options, cancellable)¶
- Parameters:
flags (
PolkitAgent.RegisterFlags
) – A set of flags from thePolkitAgent.RegisterFlags
enumeration.subject (
Polkit.Subject
) – The subject to become an authentication agent for, typically aPolkit.UnixSession
object.object_path (
str
) – The D-Bus object path to use for the authentication agent orNone
for the default object path.options (
GLib.Variant
orNone
) – AGLib.Variant
with options orNone
.cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
orNone
.
- Raises:
- Returns:
None
if error is set, otherwise a registration handle that can be used withPolkitAgent.Listener.unregister
().- Return type:
Like
PolkitAgent.Listener.register
() but takes options to influence registration. See the‘RegisterAuthenticationAgentWithOptions() [eggdbus-method-org.freedesktop.PolicyKit1.Authority.RegisterAuthenticationAgentWithOptions]’ D-Bus method for details.
- do_initiate_authentication(action_id, message, icon_name, details, cookie, identities, cancellable, callback, *user_data) virtual¶
- Parameters:
action_id (
str
) – The action to authenticate for.message (
str
) – The message to present to the user.icon_name (
str
) – A themed icon name representing the action orNone
.details (
Polkit.Details
) – Details describing the action.cookie (
str
) – The cookie for the authentication request.identities ([
Polkit.Identity
]) – A list ofPolkit.Identity
objects that the user can choose to authenticate as.cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
.callback (
Gio.AsyncReadyCallback
orNone
) – Function to call when the user is done authenticating.
Called on a registered authentication agent (see
PolkitAgent.Listener.register
()) when the user owning the session needs to prove he is one of the identities listed in identities.When the user is done authenticating (for example by dismissing an authentication dialog or by successfully entering a password or otherwise proving the user is one of the identities in identities), callback will be invoked. The caller then calls
PolkitAgent.Listener.initiate_authentication_finish
() to get the result.PolkitAgent.Listener
derived subclasses imlementing this method MUST not ignore cancellable; callers of this function can and will use it. Additionally, callback must be invoked in thethread-default main loop
of the thread that this method is called from.
- do_initiate_authentication_finish(res) virtual¶
- Parameters:
res (
Gio.AsyncResult
) – AGio.AsyncResult
obtained from theGio.AsyncReadyCallback
function passed toPolkitAgent.Listener.initiate_authentication
().- Returns:
True
if error is set.- Return type:
Finishes an authentication request from the PolicyKit daemon, see
PolkitAgent.Listener.initiate_authentication
() for details.