Polkit-Qt-1  0.95.0
Public Types | Signals | Public Member Functions | Static Public Member Functions | Friends
PolkitQt1::Authority Class Reference

Convenience class for Qt/KDE applications. More...

#include <Authority>

Inherits QObject.

Public Types

enum  Result { Unknown = 0x00, Yes = 0x01, No = 0x02, Challenge = 0x03 }
 
enum  AuthorizationFlag { None = 0x00, AllowUserInteraction = 0x01 }
 
enum  ErrorCode {
  E_None = 0x00, E_GetAuthority = 0x01, E_CheckFailed = 0x02, E_WrongSubject = 0x03,
  E_UnknownResult = 0x04, E_EnumFailed = 0x05, E_RegisterFailed = 0x06, E_UnregisterFailed = 0x07,
  E_CookieOrIdentityEmpty = 0x08, E_AgentResponseFailed = 0x09, E_RevokeFailed = 0x0A
}
 

Signals

void configChanged ()
 
void consoleKitDBChanged ()
 
void checkAuthorizationFinished (PolkitQt1::Authority::Result)
 
void enumerateActionsFinished (PolkitQt1::ActionDescription::List)
 
void registerAuthenticationAgentFinished (bool)
 
void unregisterAuthenticationAgentFinished (bool)
 
void authenticationAgentResponseFinished (bool)
 
void enumerateTemporaryAuthorizationsFinished (PolkitQt1::TemporaryAuthorization::List)
 
void revokeTemporaryAuthorizationsFinished (bool)
 
void revokeTemporaryAuthorizationFinished (bool)
 

Public Member Functions

bool hasError () const
 
ErrorCode lastError () const
 
const QString errorDetails () const
 
void clearError ()
 
PolkitAuthority * polkitAuthority () const
 
void checkAuthorization (const QString &actionId, const Subject &subject, AuthorizationFlags flags)
 
Result checkAuthorizationSync (const QString &actionId, const Subject &subject, AuthorizationFlags flags)
 
void checkAuthorizationCancel ()
 
void enumerateActions ()
 
ActionDescription::List enumerateActionsSync ()
 
void enumerateActionsCancel ()
 
void registerAuthenticationAgent (const Subject &subject, const QString &locale, const QString &objectPath)
 
bool registerAuthenticationAgentSync (const Subject &subject, const QString &locale, const QString &objectPath)
 
void registerAuthenticationAgentCancel ()
 
void unregisterAuthenticationAgent (const Subject &subject, const QString &objectPath)
 
bool unregisterAuthenticationAgentSync (const Subject &subject, const QString &objectPath)
 
void unregisterAuthenticationAgentCancel ()
 
void authenticationAgentResponse (const QString &cookie, const Identity &identity)
 
bool authenticationAgentResponseSync (const QString &cookie, const PolkitQt1::Identity &identity)
 
void authenticationAgentResponseCancel ()
 
void enumerateTemporaryAuthorizations (const Subject &subject)
 
TemporaryAuthorization::List enumerateTemporaryAuthorizationsSync (const Subject &subject)
 
void enumerateTemporaryAuthorizationsCancel ()
 
void revokeTemporaryAuthorizations (const Subject &subject)
 
bool revokeTemporaryAuthorizationsSync (const Subject &subject)
 
void revokeTemporaryAuthorizationsCancel ()
 
void revokeTemporaryAuthorization (const QString &id)
 
bool revokeTemporaryAuthorizationSync (const QString &id)
 
void revokeTemporaryAuthorizationCancel ()
 

Static Public Member Functions

static Authorityinstance (PolkitAuthority *authority=0)
 Returns the instance of Authority. More...
 

Friends

class Private
 

Detailed Description

Convenience class for Qt/KDE applications.

Author
Daniel Nicoletti dantt.nosp@m.i85-.nosp@m.pk@ya.nosp@m.hoo..nosp@m.com.b.nosp@m.r
Dario Freddi drf@k.nosp@m.de.o.nosp@m.rg
Jaroslav Reznik jrezn.nosp@m.ik@r.nosp@m.edhat.nosp@m..com

This class is a singleton that provides makes easy the usage of PolKitAuthority. It emits configChanged() whenever PolicyKit files change (e.g. the PolicyKit.conf or .policy files) or when ConsoleKit reports activities changes.

Note
This class is a singleton, its constructor is private. Call Authority::instance() to get an instance of the Authority object. Do not delete Authority::instance(), cleanup will be done automatically.

Member Enumeration Documentation

◆ AuthorizationFlag

Enumerator
None 

No flags set

AllowUserInteraction 

If the subject can obtain the authorization through authentication, and an authentication agent is available, then attempt to do so.

Note, this means that the method used for checking authorization is likely to block for a long time.

◆ ErrorCode

Error codes for the authority class

Enumerator
E_None 

No error occurred

E_GetAuthority 

Authority cannot be obtained

E_CheckFailed 

Authority check failed

E_WrongSubject 

Wrong or empty subject was given

E_UnknownResult 

Action returned unknown result

E_EnumFailed 

Enumerating actions failed

E_RegisterFailed 

Registration of authentication agent failed

E_UnregisterFailed 

Unregistration of authentication agent failed

E_CookieOrIdentityEmpty 

Cookie or polkitqt1-identity.handled to the action is empty

E_AgentResponseFailed 

Response of auth agent failed

E_RevokeFailed 

Revoke temporary authorizations failed

◆ Result

Enumerator
Unknown 

Result unknown

Yes 

The subject is authorized for the specified action

No 

The subject is not authorized for the specified action

Challenge 

The subject is authorized if more information is provided

Member Function Documentation

◆ authenticationAgentResponse()

void PolkitQt1::Authority::authenticationAgentResponse ( const QString &  cookie,
const Identity identity 
)

Provide response that identity successfully authenticated for the authentication request identified by cookie.

See also
authenticationAgentResponseSync Synchronous version of this method.
authenticationAgentResponseFinished Signal that is emitted when this method finishes.
authenticationAgentResponseCancel Use it to cancel execution of this method.
Parameters
cookieThe cookie passed to the authentication agent from the authority.
identityThe identity that was authenticated.

◆ authenticationAgentResponseCancel()

void PolkitQt1::Authority::authenticationAgentResponseCancel ( )

This method can be used to cancel the authenticationAgentResponseAsync method.

◆ authenticationAgentResponseFinished

void PolkitQt1::Authority::authenticationAgentResponseFinished ( bool  _t1)
signal

This signal is emitted when asynchronous method authenticationAgentResponse finishes.

The argument is true if authority acknowledged the call, false if error is set.

◆ authenticationAgentResponseSync()

bool PolkitQt1::Authority::authenticationAgentResponseSync ( const QString &  cookie,
const PolkitQt1::Identity identity 
)

Provide response that identity successfully authenticated for the authentication request identified by cookie.

See also
authenticationAgentResponse Asynchronous version of this method.
Parameters
cookieThe cookie passed to the authentication agent from the authority.
identityThe identity that was authenticated.
Returns
true if authority acknowledged the call, false if error is set.

◆ checkAuthorization()

void PolkitQt1::Authority::checkAuthorization ( const QString &  actionId,
const Subject subject,
AuthorizationFlags  flags 
)

This function should be used by mechanisms (e.g.: helper applications). It returns the action should be carried out, so if the caller was actually authorized to perform it. The result is in form of a Result, so that you can have more control over the whole process, and detect an eventual error. Most of the times you simply want to check if the result is == to Result::Yes, if you don't have specific needs.

It is CRITICAL that you call this function and check what it returns before doing anything in your helper, since otherwise you could be actually performing an action from an unknown or unauthorized caller.

When operation is finished, signal checkAuthorizationFinish is emitted with result of authorization check in its parameter.

See also
checkAuthorizationSync Synchronous version of this method.
checkAuthorizationFinished Signal that is emitted when this method finishes.
checkAuthorizationCancel Use it to cancel execution of this method.
Parameters
actionIdthe Id of the action in question
subjectsubject that the action is authorized for (e.g. unix process)
flagsflags that influences the authorization checking
Returns
Result::Yes if the caller is authorized and the action should be performed otherwise if the caller was not authorized and the action should not be performed, or an error has occurred

◆ checkAuthorizationCancel()

void PolkitQt1::Authority::checkAuthorizationCancel ( )

This method can be used to cancel last authorization check.

◆ checkAuthorizationFinished

void PolkitQt1::Authority::checkAuthorizationFinished ( PolkitQt1::Authority::Result  _t1)
signal

This signal is emitted when asynchronous method checkAuthorization finishes.

The argument is the result of authorization.

◆ checkAuthorizationSync()

Authority::Result PolkitQt1::Authority::checkAuthorizationSync ( const QString &  actionId,
const Subject subject,
AuthorizationFlags  flags 
)

Synchronous version of the checkAuthorization method.

Parameters
actionIdthe Id of the action in question
subjectsubject that the action is authorized for (e.g. unix process)
flagsflags that influences the authorization checking
See also
checkAuthorization Asynchronous version of this method.

◆ clearError()

void PolkitQt1::Authority::clearError ( )

Use this method to clear the error message.

◆ configChanged

void PolkitQt1::Authority::configChanged ( )
signal

This signal will be emitted when a configuration file gets changed (e.g. /etc/PolicyKit/PolicyKit.conf or .policy files). Connect to this signal if you want to track down actions.

◆ consoleKitDBChanged

void PolkitQt1::Authority::consoleKitDBChanged ( )
signal

This signal is emitted when ConsoleKit configuration changes. This might happen when a session becomes active or inactive.

If you want to track your actions directly you should connect to this signal, as this might change the return value PolicyKit will give you.

Note
If you use Action you'll probably prefer to use the dataChanged() signal to track Action changes.

◆ enumerateActions()

void PolkitQt1::Authority::enumerateActions ( )

Asynchronously retrieves all registered actions.

When operation is finished, signal checkAuthorizationFinish is emitted with result of authorization check in its parameter.

See also
enumerateActionsSync Synchronous version of this method.
enumerateActionsFinished Signal that is emitted when this method finishes.
enumerateActionsCancel Use it to cancel execution of this method.

◆ enumerateActionsCancel()

void PolkitQt1::Authority::enumerateActionsCancel ( )

This method can be used to cancel enumeration of actions

◆ enumerateActionsFinished

void PolkitQt1::Authority::enumerateActionsFinished ( PolkitQt1::ActionDescription::List  _t1)
signal

This signal is emitted when asynchronous method enumerateActions finishes.

The argument is the list of all Action IDs.

◆ enumerateActionsSync()

ActionDescription::List PolkitQt1::Authority::enumerateActionsSync ( )

Synchronously retrieves all registered actions.

See also
enumerateActions Asynchronous version of this method.
Returns
a list of Action IDs

◆ enumerateTemporaryAuthorizations()

void PolkitQt1::Authority::enumerateTemporaryAuthorizations ( const Subject subject)

Retrieves all temporary action that applies to subject.

See also
enumerateTemporaryAuthorizationsSync Synchronous version of this method.
enumerateTemporaryAuthorizationsFinished Signal that is emitted when this method finishes.
enumerateTemporaryAuthorizationsCancel Use it to cancel execution of this method.
Parameters
subjectthe subject to get temporary authorizations for

◆ enumerateTemporaryAuthorizationsCancel()

void PolkitQt1::Authority::enumerateTemporaryAuthorizationsCancel ( )

This method can be used to cancel the enumerateTemporaryAuthorizationsAsync method.

◆ enumerateTemporaryAuthorizationsFinished

void PolkitQt1::Authority::enumerateTemporaryAuthorizationsFinished ( PolkitQt1::TemporaryAuthorization::List  _t1)
signal

This signal is emmited when asynchronous method enumerateTemporaryAuthorizations finishes.

The argument is list of all temporary authorizations.

Note
Free all TemporaryAuthorization objects using delete operator.

◆ enumerateTemporaryAuthorizationsSync()

TemporaryAuthorization::List PolkitQt1::Authority::enumerateTemporaryAuthorizationsSync ( const Subject subject)

Retrieves all temporary action that applies to subject

See also
enumerateTemporaryAuthorizations Asynchronous version of this method.
Parameters
subjectthe subject to get temporary authorizations for
Note
Free all TemporaryAuthorization objects using delete operator.
Returns
List of all temporary authorizations

◆ errorDetails()

const QString PolkitQt1::Authority::errorDetails ( ) const

Get detail information about error that occurred.

Returns
detail message

◆ hasError()

bool PolkitQt1::Authority::hasError ( ) const

You should always call this method after every action. No action will be allowed if the object is in error state. Use clearError() to clear the error message.

See also
lastError
clearError
Returns
true if an error occurred, false if the library is ready

◆ instance()

Authority * PolkitQt1::Authority::instance ( PolkitAuthority *  authority = 0)
static

Returns the instance of Authority.

Returns the current instance of Authority. Call this function whenever you need to access the Authority class.

Note
Authority is a singleton. Memory is handled by polkit-qt, so you just need to call this function to get a working instance of Authority. Don't delete the object after having used it.
Parameters
authorityuse this if you want to set an explicit PolkitAuthority. If you don't know what this implies, simply ignore the parameter. In case you want to use it, be sure of streaming it the first time you call this function, otherwise it will have no effect.
Returns
The current authority instance

◆ lastError()

Authority::ErrorCode PolkitQt1::Authority::lastError ( ) const
Returns
the code of last error

◆ polkitAuthority()

PolkitAuthority * PolkitQt1::Authority::polkitAuthority ( ) const

Returns the current instance of PolkitAuthority. If you are handling it through Polkit-qt (which is quite likely, since you are calling this function), DO NOT use any PolicyKit API's specific method that modifies the instance on it, unless you're completely aware of what you're doing and of the possible consequencies. Use this instance only to gather information.

Returns
the current PolkitAuthority instance

◆ registerAuthenticationAgent()

void PolkitQt1::Authority::registerAuthenticationAgent ( const Subject subject,
const QString &  locale,
const QString &  objectPath 
)

Registers an authentication agent.

See also
registerAuthenticationAgentSync Synchronous version of this method.
registerAuthenticationAgentFinished Signal that is emitted when this method finishes.
registerAuthenticationAgentCancel Use it to cancel execution of this method.
Parameters
subjectcaller subject
localethe locale of the authentication agent
objectPaththe object path for the authentication agent

◆ registerAuthenticationAgentCancel()

void PolkitQt1::Authority::registerAuthenticationAgentCancel ( )

This method can be used to cancel the registration of the authentication agent.

◆ registerAuthenticationAgentFinished

void PolkitQt1::Authority::registerAuthenticationAgentFinished ( bool  _t1)
signal

This signal is emitted when asynchronous method registerAuthenticationAgent finishes.

The argument is true if the Authentication agent has been successfully registered false if the Authentication agent registration failed

◆ registerAuthenticationAgentSync()

bool PolkitQt1::Authority::registerAuthenticationAgentSync ( const Subject subject,
const QString &  locale,
const QString &  objectPath 
)

Registers an authentication agent.

See also
registerAuthenticationAgent Asynchronous version of this method.
Parameters
subjectcaller subject
localethe locale of the authentication agent
objectPaththe object path for the authentication agent
Returns
true if the Authentication agent has been successfully registered false if the Authentication agent registration failed

◆ revokeTemporaryAuthorization()

void PolkitQt1::Authority::revokeTemporaryAuthorization ( const QString &  id)

Revokes temporary authorization by id

See also
revokeTemporaryAuthorizationSync Synchronous version of this method.
revokeTemporaryAuthorizationFinished Signal that is emitted when this method finishes.
revokeTemporaryAuthorizationCancel Use it to cancel execution of this method.
Parameters
idthe identifier of the temporary authorization

◆ revokeTemporaryAuthorizationCancel()

void PolkitQt1::Authority::revokeTemporaryAuthorizationCancel ( )

This method can be used to cancel the method revokeTemporaryAuthorizationAsync.

◆ revokeTemporaryAuthorizationFinished

void PolkitQt1::Authority::revokeTemporaryAuthorizationFinished ( bool  _t1)
signal

This signal is emmited when asynchronous method revokeTemporaryAuthorization finishes.

Returns
true if the temporary authorization was revoked false if the revoking failed

◆ revokeTemporaryAuthorizations()

void PolkitQt1::Authority::revokeTemporaryAuthorizations ( const Subject subject)

Revokes all temporary authorizations that applies to subject

See also
revokeTemporaryAuthorizationsSync Synchronous version of this method.
revokeTemporaryAuthorizationsFinished Signal that is emitted when this method finishes.
revokeTemporaryAuthorizationsCancel Use it to cancel execution of this method.
Parameters
subjectthe subject to revoke temporary authorizations from

◆ revokeTemporaryAuthorizationsCancel()

void PolkitQt1::Authority::revokeTemporaryAuthorizationsCancel ( )

This method can be used to cancel the method revokeTemporaryAuthorizationsAsync.

◆ revokeTemporaryAuthorizationsFinished

void PolkitQt1::Authority::revokeTemporaryAuthorizationsFinished ( bool  _t1)
signal

This signal is emmited when asynchronous method revokeTemporaryAuthorizations finishes.

The argument is true if all temporary authorizations were revoked false if the revoking failed

◆ revokeTemporaryAuthorizationsSync()

bool PolkitQt1::Authority::revokeTemporaryAuthorizationsSync ( const Subject subject)

Revokes all temporary authorizations that applies to subject

See also
revokeTemporaryAuthorizations Asynchronous version of this method.
Parameters
subjectthe subject to revoke temporary authorizations from
Returns
true if all temporary authorization were revoked false if the revoking failed

◆ revokeTemporaryAuthorizationSync()

bool PolkitQt1::Authority::revokeTemporaryAuthorizationSync ( const QString &  id)

Revokes temporary authorization by id

See also
revokeTemporaryAuthorization Asynchronous version of this method.
Parameters
idthe identifier of the temporary authorization
Returns
true if the temporary authorization was revoked false if the revoking failed

◆ unregisterAuthenticationAgent()

void PolkitQt1::Authority::unregisterAuthenticationAgent ( const Subject subject,
const QString &  objectPath 
)

Unregisters an Authentication agent.

See also
unregisterAuthenticationAgentSync Synchronous version of this method.
unregisterAuthenticationAgentFinished Signal that is emitted when this method finishes.
unregisterAuthenticationAgentCancel Use it to cancel execution of this method.
Parameters
subjectcaller subject
objectPaththe object path for the Authentication agent
Returns
true if the Authentication agent has been successfully unregistered false if the Authentication agent unregistration failed

◆ unregisterAuthenticationAgentCancel()

void PolkitQt1::Authority::unregisterAuthenticationAgentCancel ( )

This method can be used to cancel the unregistration of the authentication agent.

◆ unregisterAuthenticationAgentFinished

void PolkitQt1::Authority::unregisterAuthenticationAgentFinished ( bool  _t1)
signal

This signal is emitted when asynchronous method unregisterAuthenticationAgent finishes.

The argument is true if the Authentication agent has been successfully unregistered false if the Authentication agent unregistration failed

◆ unregisterAuthenticationAgentSync()

bool PolkitQt1::Authority::unregisterAuthenticationAgentSync ( const Subject subject,
const QString &  objectPath 
)

Unregisters an Authentication agent.

See also
unregisterAuthenticationAgent Asynchronous version of this method.
Parameters
subjectcaller subject
objectPaththe object path for the Authentication agent
Returns
true if the Authentication agent has been successfully unregistered false if the Authentication agent unregistration failed

The documentation for this class was generated from the following files: