Class: Secret::Item

Inherits:
Gio::DBusProxy
  • Object
show all
Defined in:
(unknown)

Overview

The class for Secret::Item.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service, item_path, flags, cancellable) ⇒ Secret::Item

Get a new item proxy for a secret item in the secret service.

If service is nil, then [funcService.get_sync] will be called to get the default [classService] proxy.

This method may block indefinitely and should not be used in user interface threads.

Parameters:

  • service (Secret::Service)

    a secret service object

  • item_path (String)

    the D-Bus path of the item

  • flags (Secret::ItemFlags)

    initialization flags for the new item

  • cancellable (Gio::Cancellable)

    optional cancellation object

Class Method Details

.create(collection, schema, attributes, label, value, flags, cancellable, callback, user_data) ⇒ nil

Create a new item in the secret service.

If the flags contains %SECRET_ITEM_CREATE_REPLACE, then the secret service will search for an item matching the attributes, and update that item instead of creating a new one.

This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. [methodService.prompt] will be used to handle any prompts that are required.

Parameters:

  • collection (Secret::Collection)

    a secret collection to create this item in

  • schema (Secret::Schema)

    the schema for the attributes

  • attributes (GLib::HashTable<String>)

    attributes for the new item

  • label (String)

    label for the new item

  • value (Secret::Value)

    secret value for the new item

  • flags (Secret::ItemCreateFlags)

    flags for the creation of the new item

  • cancellable (Gio::Cancellable)

    optional cancellation object

  • callback (Gio::AsyncReadyCallback)

    called when the operation completes

  • user_data (GObject)

    data to pass to the callback

Returns:

  • (nil)

.create_finish(result) ⇒ Secret::Item

Finish operation to create a new item in the secret service.

Parameters:

  • result (Gio::AsyncResult)

    the asynchronous result passed to the callback

Returns:

  • (Secret::Item)

    the new item, which should be unreferenced with [methodGObject.Object.unref]

.create_sync(collection, schema, attributes, label, value, flags, cancellable) ⇒ Secret::Item

Create a new item in the secret service.

If the flags contains %SECRET_ITEM_CREATE_REPLACE, then the secret service will search for an item matching the attributes, and update that item instead of creating a new one.

This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. [methodService.prompt] will be used to handle any prompts that are required.

Parameters:

  • collection (Secret::Collection)

    a secret collection to create this item in

  • schema (Secret::Schema)

    the schema for the attributes

  • attributes (GLib::HashTable<String>)

    attributes for the new item

  • label (String)

    label for the new item

  • value (Secret::Value)

    secret value for the new item

  • flags (Secret::ItemCreateFlags)

    flags for the creation of the new item

  • cancellable (Gio::Cancellable)

    optional cancellation object

Returns:

  • (Secret::Item)

    the new item, which should be unreferenced with [methodGObject.Object.unref]

.load_secrets(items, cancellable, callback, user_data) ⇒ nil

Load the secret values for a secret item stored in the service.

The items must all have the same [propertyItem:service] property.

This function returns immediately and completes asynchronously.

Parameters:

  • items (GLib::List<Secret::Item>)

    the items to retrieve secrets for

  • cancellable (Gio::Cancellable)

    optional cancellation object

  • callback (Gio::AsyncReadyCallback)

    called when the operation completes

  • user_data (GObject)

    data to pass to the callback

Returns:

  • (nil)

.load_secrets_finish(result) ⇒ Boolean

Complete asynchronous operation to load the secret values for secret items stored in the service.

Items that are locked will not have their secrets loaded.

Parameters:

  • result (Gio::AsyncResult)

    asynchronous result passed to callback

Returns:

  • (Boolean)

    whether the operation succeeded or not

.load_secrets_sync(items, cancellable) ⇒ Boolean

Load the secret values for a secret item stored in the service.

The items must all have the same [propertyItem:service] property.

This method may block indefinitely and should not be used in user interface threads.

Items that are locked will not have their secrets loaded.

Parameters:

  • items (GLib::List<Secret::Item>)

    the items to retrieve secrets for

  • cancellable (Gio::Cancellable)

    optional cancellation object

Returns:

  • (Boolean)

    whether the operation succeeded or not

.new_for_dbus_path(service, item_path, flags, cancellable, callback, user_data) ⇒ nil

Get a new item proxy for a secret item in the secret service.

If service is nil, then [funcService.get] will be called to get the default [classService] proxy.

This method will return immediately and complete asynchronously.

Parameters:

  • service (Secret::Service)

    a secret service object

  • item_path (String)

    the D-Bus path of the collection

  • flags (Secret::ItemFlags)

    initialization flags for the new item

  • cancellable (Gio::Cancellable)

    optional cancellation object

  • callback (Gio::AsyncReadyCallback)

    called when the operation completes

  • user_data (GObject)

    data to be passed to the callback

Returns:

  • (nil)

Instance Method Details

#attributesGLib::HashTable<String>

Set the attributes of this item.

The attributes are a mapping of string keys to string values. Attributes are used to search for items. Attributes are not stored or transferred securely by the secret service.

Do not modify the attributes returned by this method. Use [methodItem.set_attributes] instead.

Returns:

  • (GLib::HashTable<String>)

    a new reference to the attributes, which should not be modified, and released with [funcGLib.HashTable.unref]

#attributes_finish=(result) ⇒ Boolean

Complete operation to set the attributes of this item.

Parameters:

  • result (Gio::AsyncResult)

    asynchronous result passed to the callback

Returns:

  • (Boolean)

    whether the change was successful or not

#createdInteger

Get the created date and time of the item.

The return value is the number of seconds since the unix epoch, January 1st 1970.

Returns:

  • (Integer)

    the created date and time

#delete(cancellable, callback, user_data) ⇒ nil

Delete this item.

This method returns immediately and completes asynchronously. The secret service may prompt the user. [methodService.prompt] will be used to handle any prompts that show up.

Parameters:

  • cancellable (Gio::Cancellable)

    optional cancellation object

  • callback (Gio::AsyncReadyCallback)

    called when the operation completes

  • user_data (GObject)

    data to pass to the callback

Returns:

  • (nil)

#delete_finish(result) ⇒ Boolean

Complete asynchronous operation to delete the secret item.

Parameters:

  • result (Gio::AsyncResult)

    asynchronous result passed to the callback

Returns:

  • (Boolean)

    whether the item was successfully deleted or not

#delete_sync(cancellable) ⇒ Boolean

Delete this secret item.

This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. [methodService.prompt] will be used to handle any prompts that show up.

Parameters:

  • cancellable (Gio::Cancellable)

    optional cancellation object

Returns:

  • (Boolean)

    whether the item was successfully deleted or not

#flagsSecret::ItemFlags

A set of flags describing which parts of the secret item have been initialized.

Returns:

#flags=(flags) ⇒ Secret::ItemFlags

A set of flags describing which parts of the secret item have been initialized.

Parameters:

Returns:

#labelString

Get the label of this item.

Returns:

  • (String)

    the label, which should be freed with [funcGLib.free]

#label_finish=(result) ⇒ Boolean

Complete asynchronous operation to set the label of this collection.

Parameters:

  • result (Gio::AsyncResult)

    asynchronous result passed to callback

Returns:

  • (Boolean)

    whether the change was successful or not

#load_secret(cancellable, callback, user_data) ⇒ nil

Load the secret value of this item.

Each item has a single secret which might be a password or some other secret binary value.

This function will fail if the secret item is locked.

This function returns immediately and completes asynchronously.

Parameters:

  • cancellable (Gio::Cancellable)

    optional cancellation object

  • callback (Gio::AsyncReadyCallback)

    called when the operation completes

  • user_data (GObject)

    data to pass to the callback

Returns:

  • (nil)

#load_secret_finish(result) ⇒ Boolean

Complete asynchronous operation to load the secret value of this item.

The newly loaded secret value can be accessed by calling [methodItem.get_secret].

Parameters:

  • result (Gio::AsyncResult)

    asynchronous result passed to callback

Returns:

  • (Boolean)

    whether the secret item successfully loaded or not

#load_secret_sync(cancellable) ⇒ Boolean

Load the secret value of this item.

Each item has a single secret which might be a password or some other secret binary value.

This function may block indefinitely. Use the asynchronous version in user interface threads.

Parameters:

  • cancellable (Gio::Cancellable)

    optional cancellation object

Returns:

  • (Boolean)

    whether the secret item successfully loaded or not

#lockedBoolean

Get whether the item is locked or not.

Depending on the secret service an item may not be able to be locked independently from the collection that it is in.

Returns:

  • (Boolean)

    whether the item is locked or not

#locked=(locked) ⇒ Boolean

Whether the item is locked or not.

An item may not be independently lockable separate from other items in its collection.

To lock or unlock a item use the [methodService.lock] or [methodService.unlock] functions.

Parameters:

  • locked (Boolean)

Returns:

  • (Boolean)

    locked

  • (Boolean)

    locked

#locked?Boolean

Whether the item is locked or not.

An item may not be independently lockable separate from other items in its collection.

To lock or unlock a item use the [methodService.lock] or [methodService.unlock] functions.

Returns:

  • (Boolean)

    locked

#modifiedInteger

Get the modified date and time of the item.

The return value is the number of seconds since the unix epoch, January 1st 1970.

Returns:

  • (Integer)

    the modified date and time

#refreshnil

Refresh the properties on this item.

This fires off a request to refresh, and the properties will be updated later.

Calling this method is not normally necessary, as the secret service will notify the client when properties change.

Returns:

  • (nil)

#schema_nameString

Gets the name of the schema that this item was stored with. This is also available at the xdg:schema attribute.

Returns:

  • (String)

    the schema name

#secretSecret::Value

Get the secret value of this item.

If this item is locked or the secret has not yet been loaded then this will return nil.

To load the secret call the [methodItem.load_secret] method.

Returns:

  • (Secret::Value)

    the secret value which should be released with [methodValue.unref], or nil

#secret_finish=(result) ⇒ Boolean

Complete asynchronous operation to set the secret value of this item.

Parameters:

  • result (Gio::AsyncResult)

    asynchronous result passed to callback

Returns:

  • (Boolean)

    whether the change was successful or not

#serviceSecret::Service

The [classService] object that this item is associated with and uses to interact with the actual D-Bus Secret Service.

Returns:

#service=(service) ⇒ Secret::Service

The [classService] object that this item is associated with and uses to interact with the actual D-Bus Secret Service.

Parameters:

Returns:

#set_attributes(schema, attributes, cancellable, callback, user_data) ⇒ nil

Set the attributes of this item.

The attributes are a mapping of string keys to string values. Attributes are used to search for items. Attributes are not stored or transferred securely by the secret service.

This function returns immediately and completes asynchronously.

Parameters:

  • schema (Secret::Schema)

    the schema for the attributes

  • attributes (GLib::HashTable<String>)

    a new set of attributes

  • cancellable (Gio::Cancellable)

    optional cancellation object

  • callback (Gio::AsyncReadyCallback)

    called when the asynchronous operation completes

  • user_data (GObject)

    data to pass to the callback

Returns:

  • (nil)

#set_attributes_sync(schema, attributes, cancellable) ⇒ Boolean

Set the attributes of this item.

The attributes are a mapping of string keys to string values. Attributes are used to search for items. Attributes are not stored or transferred securely by the secret service.

This function may block indefinitely. Use the asynchronous version in user interface threads.

Parameters:

  • schema (Secret::Schema)

    the schema for the attributes

  • attributes (GLib::HashTable<String>)

    a new set of attributes

  • cancellable (Gio::Cancellable)

    optional cancellation object

Returns:

  • (Boolean)

    whether the change was successful or not

#set_label(label, cancellable, callback, user_data) ⇒ nil

Set the label of this item.

This function returns immediately and completes asynchronously.

Parameters:

  • label (String)

    a new label

  • cancellable (Gio::Cancellable)

    optional cancellation object

  • callback (Gio::AsyncReadyCallback)

    called when the operation completes

  • user_data (GObject)

    data to pass to the callback

Returns:

  • (nil)

#set_label_sync(label, cancellable) ⇒ Boolean

Set the label of this item.

This function may block indefinitely. Use the asynchronous version in user interface threads.

Parameters:

  • label (String)

    a new label

  • cancellable (Gio::Cancellable)

    optional cancellation object

Returns:

  • (Boolean)

    whether the change was successful or not

#set_secret(value, cancellable, callback, user_data) ⇒ nil

Set the secret value of this item.

Each item has a single secret which might be a password or some other secret binary value.

This function returns immediately and completes asynchronously.

Parameters:

  • value (Secret::Value)

    a new secret value

  • cancellable (Gio::Cancellable)

    optional cancellation object

  • callback (Gio::AsyncReadyCallback)

    called when the operation completes

  • user_data (GObject)

    data to pass to the callback

Returns:

  • (nil)

#set_secret_sync(value, cancellable) ⇒ Boolean

Set the secret value of this item.

Each item has a single secret which might be a password or some other secret binary value.

This function may block indefinitely. Use the asynchronous version in user interface threads.

Parameters:

  • value (Secret::Value)

    a new secret value

  • cancellable (Gio::Cancellable)

    optional cancellation object

Returns:

  • (Boolean)

    whether the change was successful or not