Class Service

All Implemented Interfaces:
AsyncInitable, DBusInterface, Initable, Backend, Proxy

@Generated("org.javagi.JavaGI") public class Service extends DBusProxy implements AsyncInitable, DBusInterface, Initable, Backend

A proxy object representing the Secret Service.

A SecretService object either represents an implementation of the org.freedesktop.Secret D-Bus service or a file that is encrypted using a master secret that was provided by the secret portal.

Normally a single SecretService object can be shared between multiple callers. The get(Set, Cancellable, AsyncReadyCallback) method is used to access this SecretService object. If a new independent SecretService object is required, use open(Type, String, Set, Cancellable, AsyncReadyCallback).

In order to securely transfer secrets to the Sercret Service, a session is established. This session can be established while initializing a SecretService object by passing the ServiceFlags.OPEN_SESSION flag to the get(Set, Cancellable, AsyncReadyCallback) or open(Type, String, Set, Cancellable, AsyncReadyCallback) functions. In order to establish a session on an already existing SecretService, use the ensureSession(Cancellable, AsyncReadyCallback) function.

To search for items, use the search(Schema, HashTable, Set, Cancellable, AsyncReadyCallback) method.

Multiple collections can exist in the Secret Service, each of which contains secret items. In order to instantiate Collection objects which represent those collections while initializing a SecretService then pass the ServiceFlags.LOAD_COLLECTIONS flag to the get(Set, Cancellable, AsyncReadyCallback) or open(Type, String, Set, Cancellable, AsyncReadyCallback) functions. In order to establish a session on an already existing SecretService, use the loadCollections(Cancellable, AsyncReadyCallback) function. To access the list of collections use getCollections().

Certain actions on the Secret Service require user prompting to complete, such as creating a collection, or unlocking a collection. When such a prompt is necessary, then a Prompt object is created by this library, and passed to the prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) method. In this way it is handled automatically.

In order to customize prompt handling, override the promptAsync(Prompt, VariantType, Cancellable, AsyncReadyCallback) and promptFinish(AsyncResult) virtual methods of the SecretService class.

  • Constructor Details

    • Service

      public Service(MemorySegment address)
      Create a Service instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • Service

      public Service()
      Create a new Service.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the Service class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected Service asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class DBusProxy
      Returns:
      the instance as if it were its parent type
    • disconnect

      public static void disconnect()

      Disconnect the default SecretService proxy returned by get(Set, Cancellable, AsyncReadyCallback) and getSync(Set, Cancellable).

      It is not necessary to call this function, but you may choose to do so at program exit. It is useful for testing that memory is not leaked.

      This function is safe to call at any time. But if other objects in this library are still referenced, then this will not result in all memory being freed.

    • get

      public static void get(Set<ServiceFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Get a SecretService proxy for the Secret Service.

      If such a proxy object already exists, then the same proxy is returned.

      If flags contains any flags of which parts of the secret service to ensure are initialized, then those will be initialized before completing.

      This method will return immediately and complete asynchronously.

      Parameters:
      flags - flags for which service functionality to ensure is initialized
      cancellable - optional cancellation object
      callback - called when the operation completes
    • get

      public static void get(ServiceFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Get a SecretService proxy for the Secret Service.

      If such a proxy object already exists, then the same proxy is returned.

      If flags contains any flags of which parts of the secret service to ensure are initialized, then those will be initialized before completing.

      This method will return immediately and complete asynchronously.

      Parameters:
      flags - flags for which service functionality to ensure is initialized
      cancellable - optional cancellation object
      callback - called when the operation completes
    • getFinish

      public static Service getFinish(AsyncResult result) throws GErrorException
      Complete an asynchronous operation to get a SecretService proxy for the Secret Service.
      Parameters:
      result - the asynchronous result passed to the callback
      Returns:
      a new reference to a SecretService proxy, which should be released with GObject#unref.
      Throws:
      GErrorException - see GError
    • getSync

      public static Service getSync(Set<ServiceFlags> flags, @Nullable Cancellable cancellable) throws GErrorException

      Get a SecretService proxy for the Secret Service.

      If such a proxy object already exists, then the same proxy is returned.

      If flags contains any flags of which parts of the secret service to ensure are initialized, then those will be initialized before returning.

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

      Parameters:
      flags - flags for which service functionality to ensure is initialized
      cancellable - optional cancellation object
      Returns:
      a new reference to a SecretService proxy, which should be released with GObject#unref.
      Throws:
      GErrorException - see GError
    • getSync

      public static Service getSync(ServiceFlags flags, @Nullable Cancellable cancellable) throws GErrorException

      Get a SecretService proxy for the Secret Service.

      If such a proxy object already exists, then the same proxy is returned.

      If flags contains any flags of which parts of the secret service to ensure are initialized, then those will be initialized before returning.

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

      Parameters:
      flags - flags for which service functionality to ensure is initialized
      cancellable - optional cancellation object
      Returns:
      a new reference to a SecretService proxy, which should be released with GObject#unref.
      Throws:
      GErrorException - see GError
    • open

      public static void open(Type serviceGtype, @Nullable String serviceBusName, Set<ServiceFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Create a new SecretService proxy for the Secret Service.

      This function is rarely used, see get(Set, Cancellable, AsyncReadyCallback) instead.

      The serviceGtype argument should be set to SECRET_TYPE_SERVICE or a the type of a derived class.

      If flags contains any flags of which parts of the secret service to ensure are initialized, then those will be initialized before returning.

      If serviceBusName is null then the default is used.

      This method will return immediately and complete asynchronously.

      Parameters:
      serviceGtype - the GType of the new secret service
      serviceBusName - the D-Bus service name of the secret service
      flags - flags for which service functionality to ensure is initialized
      cancellable - optional cancellation object
      callback - called when the operation completes
    • open

      public static void open(Type serviceGtype, @Nullable String serviceBusName, ServiceFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Create a new SecretService proxy for the Secret Service.

      This function is rarely used, see get(Set, Cancellable, AsyncReadyCallback) instead.

      The serviceGtype argument should be set to SECRET_TYPE_SERVICE or a the type of a derived class.

      If flags contains any flags of which parts of the secret service to ensure are initialized, then those will be initialized before returning.

      If serviceBusName is null then the default is used.

      This method will return immediately and complete asynchronously.

      Parameters:
      serviceGtype - the GType of the new secret service
      serviceBusName - the D-Bus service name of the secret service
      flags - flags for which service functionality to ensure is initialized
      cancellable - optional cancellation object
      callback - called when the operation completes
    • openFinish

      public static Service openFinish(AsyncResult result) throws GErrorException
      Complete an asynchronous operation to create a new SecretService proxy for the Secret Service.
      Parameters:
      result - the asynchronous result passed to the callback
      Returns:
      a new reference to a SecretService proxy, which should be released with GObject#unref.
      Throws:
      GErrorException - see GError
    • openSync

      public static Service openSync(Type serviceGtype, @Nullable String serviceBusName, Set<ServiceFlags> flags, @Nullable Cancellable cancellable) throws GErrorException

      Create a new SecretService proxy for the Secret Service.

      This function is rarely used, see getSync(Set, Cancellable) instead.

      The serviceGtype argument should be set to SECRET_TYPE_SERVICE or a the type of a derived class.

      If flags contains any flags of which parts of the secret service to ensure are initialized, then those will be initialized before returning.

      If serviceBusName is null then the default is used.

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

      Parameters:
      serviceGtype - the GType of the new secret service
      serviceBusName - the D-Bus service name of the secret service
      flags - flags for which service functionality to ensure is initialized
      cancellable - optional cancellation object
      Returns:
      a new reference to a SecretService proxy, which should be released with GObject#unref.
      Throws:
      GErrorException - see GError
    • openSync

      public static Service openSync(Type serviceGtype, @Nullable String serviceBusName, ServiceFlags flags, @Nullable Cancellable cancellable) throws GErrorException

      Create a new SecretService proxy for the Secret Service.

      This function is rarely used, see getSync(Set, Cancellable) instead.

      The serviceGtype argument should be set to SECRET_TYPE_SERVICE or a the type of a derived class.

      If flags contains any flags of which parts of the secret service to ensure are initialized, then those will be initialized before returning.

      If serviceBusName is null then the default is used.

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

      Parameters:
      serviceGtype - the GType of the new secret service
      serviceBusName - the D-Bus service name of the secret service
      flags - flags for which service functionality to ensure is initialized
      cancellable - optional cancellation object
      Returns:
      a new reference to a SecretService proxy, which should be released with GObject#unref.
      Throws:
      GErrorException - see GError
    • clear

      public void clear(@Nullable Schema schema, HashTable<String,String> attributes, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Remove unlocked items which match the attributes from the secret service.

      The attributes should be a set of key and value string pairs.

      If this Service is null, then get(Set, Cancellable, AsyncReadyCallback) will be called to get the default Service proxy.

      This method will return immediately and complete asynchronously.

      Parameters:
      schema - the schema for the attributes
      attributes - the attribute keys and values
      cancellable - optional cancellation object
      callback - called when the operation completes
    • clearFinish

      public boolean clearFinish(AsyncResult result) throws GErrorException
      Finish asynchronous operation to remove items from the secret service.
      Parameters:
      result - the asynchronous result passed to the callback
      Returns:
      whether items were removed or not
      Throws:
      GErrorException - see GError
    • clearSync

      public boolean clearSync(@Nullable Schema schema, HashTable<String,String> attributes, @Nullable Cancellable cancellable) throws GErrorException

      Remove unlocked items which match the attributes from the secret service.

      The attributes should be a set of key and value string pairs.

      If this Service is null, then getSync(Set, Cancellable) will be called to get the default Service proxy.

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

      Parameters:
      schema - the schema for the attributes
      attributes - the attribute keys and values
      cancellable - optional cancellation object
      Returns:
      whether items were removed or not
      Throws:
      GErrorException - see GError
    • createCollectionDbusPath

      public void createCollectionDbusPath(HashTable<String,Variant> properties, @Nullable String alias, Set<CollectionCreateFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Create a new collection in the secret service, and return its path.

      Using this method requires that you setup a correct hash table of D-Bus properties for the new collection. You may prefer to use Collection.create(Service, String, String, Set, Cancellable, AsyncReadyCallback) which does handles this for you.

      An alias is a well-known tag for a collection, such as 'default' (ie: the default collection to store items in). This allows other applications to easily identify and share a collection. If a collection with the alias already exists, then instead of creating a new collection, the existing collection will be returned. If no collection with this alias exists, then a new collection will be created and this alias will be assigned to it.

      properties is a set of properties for the new collection. The keys in the hash table should be interface.property strings like org.freedesktop.Secret.Collection.Label. The values in the hash table should be GLib.Variant values of the properties.

      If you wish to have a

      This method will return immediately and complete asynchronously. The secret service may prompt the user. prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) will be used to handle any prompts that are required.

      Parameters:
      properties - hash table of properties for the new collection
      alias - an alias to check for before creating the new collection, or to assign to the new collection
      flags - not currently used
      cancellable - optional cancellation object
      callback - called when the operation completes
    • createCollectionDbusPath

      public void createCollectionDbusPath(HashTable<String,Variant> properties, @Nullable String alias, CollectionCreateFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Create a new collection in the secret service, and return its path.

      Using this method requires that you setup a correct hash table of D-Bus properties for the new collection. You may prefer to use Collection.create(Service, String, String, Set, Cancellable, AsyncReadyCallback) which does handles this for you.

      An alias is a well-known tag for a collection, such as 'default' (ie: the default collection to store items in). This allows other applications to easily identify and share a collection. If a collection with the alias already exists, then instead of creating a new collection, the existing collection will be returned. If no collection with this alias exists, then a new collection will be created and this alias will be assigned to it.

      properties is a set of properties for the new collection. The keys in the hash table should be interface.property strings like org.freedesktop.Secret.Collection.Label. The values in the hash table should be GLib.Variant values of the properties.

      If you wish to have a

      This method will return immediately and complete asynchronously. The secret service may prompt the user. prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) will be used to handle any prompts that are required.

      Parameters:
      properties - hash table of properties for the new collection
      alias - an alias to check for before creating the new collection, or to assign to the new collection
      flags - not currently used
      cancellable - optional cancellation object
      callback - called when the operation completes
    • createCollectionDbusPathFinish

      public String createCollectionDbusPathFinish(AsyncResult result) throws GErrorException
      Finish asynchronous operation to create a new collection in the secret service.
      Parameters:
      result - the asynchronous result passed to the callback
      Returns:
      a new string containing the D-Bus object path of the collection
      Throws:
      GErrorException - see GError
    • createCollectionDbusPathSync

      public String createCollectionDbusPathSync(HashTable<String,Variant> properties, @Nullable String alias, Set<CollectionCreateFlags> flags, @Nullable Cancellable cancellable) throws GErrorException

      Create a new collection in the secret service and return its path.

      Using this method requires that you setup a correct hash table of D-Bus properties for the new collection. You may prefer to use Collection.create(Service, String, String, Set, Cancellable, AsyncReadyCallback) which does handles this for you.

      An alias is a well-known tag for a collection, such as 'default' (ie: the default collection to store items in). This allows other applications to easily identify and share a collection. If a collection with the alias already exists, then instead of creating a new collection, the existing collection will be returned. If no collection with this alias exists, then a new collection will be created and this alias will be assigned to it.

      properties is a set of properties for the new collection. The keys in the hash table should be interface.property strings like org.freedesktop.Secret.Collection.Label. The values in the hash table should be GLib.Variant values of the properties.

      This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) will be used to handle any prompts that are required.

      Parameters:
      properties - hash table of D-Bus properties for the new collection
      alias - an alias to check for before creating the new collection, or to assign to the new collection
      flags - not currently used
      cancellable - optional cancellation object
      Returns:
      a new string containing the D-Bus object path of the collection
      Throws:
      GErrorException - see GError
    • createCollectionDbusPathSync

      public String createCollectionDbusPathSync(HashTable<String,Variant> properties, @Nullable String alias, CollectionCreateFlags flags, @Nullable Cancellable cancellable) throws GErrorException

      Create a new collection in the secret service and return its path.

      Using this method requires that you setup a correct hash table of D-Bus properties for the new collection. You may prefer to use Collection.create(Service, String, String, Set, Cancellable, AsyncReadyCallback) which does handles this for you.

      An alias is a well-known tag for a collection, such as 'default' (ie: the default collection to store items in). This allows other applications to easily identify and share a collection. If a collection with the alias already exists, then instead of creating a new collection, the existing collection will be returned. If no collection with this alias exists, then a new collection will be created and this alias will be assigned to it.

      properties is a set of properties for the new collection. The keys in the hash table should be interface.property strings like org.freedesktop.Secret.Collection.Label. The values in the hash table should be GLib.Variant values of the properties.

      This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) will be used to handle any prompts that are required.

      Parameters:
      properties - hash table of D-Bus properties for the new collection
      alias - an alias to check for before creating the new collection, or to assign to the new collection
      flags - not currently used
      cancellable - optional cancellation object
      Returns:
      a new string containing the D-Bus object path of the collection
      Throws:
      GErrorException - see GError
    • createItemDbusPath

      public void createItemDbusPath(String collectionPath, HashTable<String,Variant> properties, Value value, Set<ItemCreateFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Create a new item in a secret service collection and return its D-Bus object path.

      It is often easier to use Secret.passwordStore(Schema, HashTable, String, String, String, Cancellable, AsyncReadyCallback) or Item.create(Collection, Schema, HashTable, String, Value, Set, Cancellable, AsyncReadyCallback) rather than using this function. Using this method requires that you setup a correct hash table of D-Bus properties for the new collection.

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

      properties is a set of properties for the new collection. The keys in the hash table should be interface.property strings like org.freedesktop.Secret.Item.Label. The values in the hash table should be GLib.Variant values of the properties.

      This method will return immediately and complete asynchronously. The secret service may prompt the user. prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) will be used to handle any prompts that are required.

      Parameters:
      collectionPath - the D-Bus object path of the collection in which to create item
      properties - hash table of D-Bus properties for the new collection
      value - the secret value to store in the item
      flags - flags for the creation of the new item
      cancellable - optional cancellation object
      callback - called when the operation completes
    • createItemDbusPath

      public void createItemDbusPath(String collectionPath, HashTable<String,Variant> properties, Value value, ItemCreateFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Create a new item in a secret service collection and return its D-Bus object path.

      It is often easier to use Secret.passwordStore(Schema, HashTable, String, String, String, Cancellable, AsyncReadyCallback) or Item.create(Collection, Schema, HashTable, String, Value, Set, Cancellable, AsyncReadyCallback) rather than using this function. Using this method requires that you setup a correct hash table of D-Bus properties for the new collection.

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

      properties is a set of properties for the new collection. The keys in the hash table should be interface.property strings like org.freedesktop.Secret.Item.Label. The values in the hash table should be GLib.Variant values of the properties.

      This method will return immediately and complete asynchronously. The secret service may prompt the user. prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) will be used to handle any prompts that are required.

      Parameters:
      collectionPath - the D-Bus object path of the collection in which to create item
      properties - hash table of D-Bus properties for the new collection
      value - the secret value to store in the item
      flags - flags for the creation of the new item
      cancellable - optional cancellation object
      callback - called when the operation completes
    • createItemDbusPathFinish

      public String createItemDbusPathFinish(AsyncResult result) throws GErrorException
      Finish asynchronous operation to create a new item in the secret service.
      Parameters:
      result - the asynchronous result passed to the callback
      Returns:
      a new string containing the D-Bus object path of the item
      Throws:
      GErrorException - see GError
    • createItemDbusPathSync

      public String createItemDbusPathSync(String collectionPath, HashTable<String,Variant> properties, Value value, Set<ItemCreateFlags> flags, @Nullable Cancellable cancellable) throws GErrorException

      Create a new item in a secret service collection and return its D-Bus object path.

      It is often easier to use Secret.passwordStoreSync(Schema, HashTable, String, String, String, Cancellable) or Item.createSync(Collection, Schema, HashTable, String, Value, Set, Cancellable) rather than using this function. Using this method requires that you setup a correct hash table of D-Bus properties for the new collection.

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

      properties is a set of properties for the new collection. The keys in the hash table should be interface.property strings like org.freedesktop.Secret.Item.Label. The values in the hash table should be GLib.Variant values of the properties.

      This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) will be used to handle any prompts that are required.

      Parameters:
      collectionPath - the D-Bus path of the collection in which to create item
      properties - hash table of D-Bus properties for the new collection
      value - the secret value to store in the item
      flags - flags for the creation of the new item
      cancellable - optional cancellation object
      Returns:
      a new string containing the D-Bus object path of the item
      Throws:
      GErrorException - see GError
    • createItemDbusPathSync

      public String createItemDbusPathSync(String collectionPath, HashTable<String,Variant> properties, Value value, ItemCreateFlags flags, @Nullable Cancellable cancellable) throws GErrorException

      Create a new item in a secret service collection and return its D-Bus object path.

      It is often easier to use Secret.passwordStoreSync(Schema, HashTable, String, String, String, Cancellable) or Item.createSync(Collection, Schema, HashTable, String, Value, Set, Cancellable) rather than using this function. Using this method requires that you setup a correct hash table of D-Bus properties for the new collection.

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

      properties is a set of properties for the new collection. The keys in the hash table should be interface.property strings like org.freedesktop.Secret.Item.Label. The values in the hash table should be GLib.Variant values of the properties.

      This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) will be used to handle any prompts that are required.

      Parameters:
      collectionPath - the D-Bus path of the collection in which to create item
      properties - hash table of D-Bus properties for the new collection
      value - the secret value to store in the item
      flags - flags for the creation of the new item
      cancellable - optional cancellation object
      Returns:
      a new string containing the D-Bus object path of the item
      Throws:
      GErrorException - see GError
    • decodeDbusSecret

      public Value decodeDbusSecret(Variant value)

      Decode a Value into GLib.Variant received with the Secret Service DBus API.

      The GLib.Variant should have a (oayays) signature.

      A session must have already been established by the Service, and the encoded secret must be valid for that session.

      Parameters:
      value - the encoded secret
      Returns:
      the decoded secret value
    • deleteItemDbusPath

      public void deleteItemDbusPath(String itemPath, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Delete a secret item from the secret service.

      The item is represented by its D-Bus object path. If you already have a Item proxy objects, use use Item.delete(Cancellable, AsyncReadyCallback) instead.

      This method will return immediately and complete asynchronously.

      Parameters:
      itemPath - the D-Bus path of item to delete
      cancellable - optional cancellation object
      callback - called when the operation completes
    • deleteItemDbusPathFinish

      public boolean deleteItemDbusPathFinish(AsyncResult result) throws GErrorException
      Complete an asynchronous operation to delete a secret item from the secret service.
      Parameters:
      result - the asynchronous result passed to the callback
      Returns:
      whether the deletion was successful or not
      Throws:
      GErrorException - see GError
    • deleteItemDbusPathSync

      public boolean deleteItemDbusPathSync(String itemPath, @Nullable Cancellable cancellable) throws GErrorException

      Delete a secret item from the secret service.

      The item is represented by its D-Bus object path. If you already have a Item proxy objects, use use Item.deleteSync(Cancellable) instead.

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

      Parameters:
      itemPath - the D-Bus path of item to delete
      cancellable - optional cancellation object
      Returns:
      whether the deletion was successful or not
      Throws:
      GErrorException - see GError
    • encodeDbusSecret

      public Variant encodeDbusSecret(Value value)

      Encodes a Value into GLib.Variant for use with the Secret Service DBus API.

      The resulting GLib.Variant will have a (oayays) signature.

      A session must have already been established by the Service.

      Parameters:
      value - the secret value
      Returns:
      the encoded secret
    • ensureSession

      public void ensureSession(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Ensure that the SecretService proxy has established a session with the Secret Service.

      This session is used to transfer secrets.

      It is not normally necessary to call this method, as the session is established as necessary. You can also pass the ServiceFlags.OPEN_SESSION to get(Set, Cancellable, AsyncReadyCallback) in order to ensure that a session has been established by the time you get the SecretService proxy.

      This method will return immediately and complete asynchronously.

      Parameters:
      cancellable - optional cancellation object
      callback - called when the operation completes
    • ensureSessionFinish

      public boolean ensureSessionFinish(AsyncResult result) throws GErrorException
      Finish an asynchronous operation to ensure that the SecretService proxy has established a session with the Secret Service.
      Parameters:
      result - the asynchronous result passed to the callback
      Returns:
      whether a session is established or not
      Throws:
      GErrorException - see GError
    • ensureSessionSync

      public boolean ensureSessionSync(@Nullable Cancellable cancellable) throws GErrorException

      Ensure that the SecretService proxy has established a session with the Secret Service.

      This session is used to transfer secrets.

      It is not normally necessary to call this method, as the session is established as necessary. You can also pass the ServiceFlags.OPEN_SESSION to getSync(Set, Cancellable) in order to ensure that a session has been established by the time you get the SecretService proxy.

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

      Parameters:
      cancellable - optional cancellation object
      Returns:
      whether a session is established or not
      Throws:
      GErrorException - see GError
    • getCollectionGtype

      public Type getCollectionGtype()

      Get the GObject type for collections instantiated by this service.

      This will always be either Collection or derived from it.

      Returns:
      the gobject type for collections
    • getCollections

      public @Nullable List<Collection> getCollections()

      Get a list of Collection objects representing all the collections in the secret service.

      If the ServiceFlags.LOAD_COLLECTIONS flag was not specified when initializing SecretService proxy object, then this method will return null. Use loadCollections(Cancellable, AsyncReadyCallback) to load the collections.

      Returns:
      a list of the collections in the secret service
    • getServiceFlags

      public Set<ServiceFlags> getServiceFlags()

      Get the flags representing what features of the SecretService proxy have been initialized.

      Use ensureSession(Cancellable, AsyncReadyCallback) or loadCollections(Cancellable, AsyncReadyCallback) to initialize further features and change the flags.

      Returns:
      the flags for features initialized
    • getItemGtype

      public Type getItemGtype()

      Get the GObject type for items instantiated by this service.

      This will always be either Item or derived from it.

      Returns:
      the gobject type for items
    • getSecretForDbusPath

      public void getSecretForDbusPath(String itemPath, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Get the secret value for a secret item stored in the service.

      The item is represented by its D-Bus object path. If you already have a Item proxy object, use use Item.getSecret() to more simply get its secret value.

      This function returns immediately and completes asynchronously.

      Parameters:
      itemPath - the D-Bus path to item to retrieve secret for
      cancellable - optional cancellation object
      callback - called when the operation completes
    • getSecretForDbusPathFinish

      public @Nullable Value getSecretForDbusPathFinish(AsyncResult result) throws GErrorException

      Complete asynchronous operation to get the secret value for an secret item stored in the service.

      Will return null if the item is locked.

      Parameters:
      result - asynchronous result passed to callback
      Returns:
      the newly allocated secret value for the item, which should be released with Value.unref()
      Throws:
      GErrorException - see GError
    • getSecretForDbusPathSync

      public @Nullable Value getSecretForDbusPathSync(String itemPath, @Nullable Cancellable cancellable) throws GErrorException

      Get the secret value for a secret item stored in the service.

      The item is represented by its D-Bus object path. If you already have a Item proxy object, use use Item.loadSecretSync(Cancellable) to more simply get its secret value.

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

      Will return null if the item is locked.

      Parameters:
      itemPath - the D-Bus path to item to retrieve secret for
      cancellable - optional cancellation object
      Returns:
      the newly allocated secret value the item, which should be released with Value.unref()
      Throws:
      GErrorException - see GError
    • getSecretsForDbusPaths

      public void getSecretsForDbusPaths(String[] itemPaths, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

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

      The items are represented by their D-Bus object paths. If you already have Item proxy objects, use use Item.loadSecrets(List, Cancellable, AsyncReadyCallback) to more simply get their secret values.

      This function returns immediately and completes asynchronously.

      Parameters:
      itemPaths - the D-Bus paths to items to retrieve secrets for
      cancellable - optional cancellation object
      callback - called when the operation completes
    • getSecretsForDbusPathsFinish

      public HashTable<String,Value> getSecretsForDbusPathsFinish(AsyncResult result) throws GErrorException

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

      Items that are locked will not be included the results.

      Parameters:
      result - asynchronous result passed to callback
      Returns:
      a newly allocated hash table of item path keys to Value values.
      Throws:
      GErrorException - see GError
    • getSecretsForDbusPathsSync

      public HashTable<String,Value> getSecretsForDbusPathsSync(String[] itemPaths, @Nullable Cancellable cancellable) throws GErrorException

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

      The items are represented by their D-Bus object paths. If you already have Item proxy objects, use use Item.loadSecretsSync(List, Cancellable) to more simply get their secret values.

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

      Items that are locked will not be included the results.

      Parameters:
      itemPaths - the D-Bus paths to items to retrieve secrets for
      cancellable - optional cancellation object
      Returns:
      a newly allocated hash table of item_path keys to Value values.
      Throws:
      GErrorException - see GError
    • getSessionAlgorithms

      public @Nullable String getSessionAlgorithms()

      Get the set of algorithms being used to transfer secrets between this secret service proxy and the Secret Service itself.

      This will be null if no session has been established. Use ensureSession(Cancellable, AsyncReadyCallback) to establish a session.

      Returns:
      a string representing the algorithms for transferring secrets
    • getSessionDbusPath

      public @Nullable String getSessionDbusPath()

      Get the D-Bus object path of the session object being used to transfer secrets between this secret service proxy and the Secret Service itself.

      This will be null if no session has been established. Use ensureSession(Cancellable, AsyncReadyCallback) to establish a session.

      Returns:
      a string representing the D-Bus object path of the session
    • loadCollections

      public void loadCollections(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Ensure that the SecretService proxy has loaded all the collections present in the Secret Service.

      This affects the result of getCollections().

      You can also pass the ServiceFlags.LOAD_COLLECTIONS to getSync(Set, Cancellable) in order to ensure that the collections have been loaded by the time you get the SecretService proxy.

      This method will return immediately and complete asynchronously.

      Parameters:
      cancellable - optional cancellation object
      callback - called when the operation completes
    • loadCollectionsFinish

      public boolean loadCollectionsFinish(AsyncResult result) throws GErrorException
      Complete an asynchronous operation to ensure that the SecretService proxy has loaded all the collections present in the Secret Service.
      Parameters:
      result - the asynchronous result passed to the callback
      Returns:
      whether the load was successful or not
      Throws:
      GErrorException - see GError
    • loadCollectionsSync

      public boolean loadCollectionsSync(@Nullable Cancellable cancellable) throws GErrorException

      Ensure that the SecretService proxy has loaded all the collections present in the Secret Service.

      This affects the result of getCollections().

      You can also pass the ServiceFlags.LOAD_COLLECTIONS to getSync(Set, Cancellable) in order to ensure that the collections have been loaded by the time you get the SecretService proxy.

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

      Parameters:
      cancellable - optional cancellation object
      Returns:
      whether the load was successful or not
      Throws:
      GErrorException - see GError
    • lock

      public void lock(List<DBusProxy> objects, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Lock items or collections in the secret service.

      The secret service may not be able to lock items individually, and may lock an entire collection instead.

      If this Service is null, then get(Set, Cancellable, AsyncReadyCallback) will be called to get the default Service proxy.

      This method returns immediately and completes asynchronously. The secret service may prompt the user. prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) will be used to handle any prompts that show up.

      Parameters:
      objects - the items or collections to lock
      cancellable - optional cancellation object
      callback - called when the operation completes
    • lockDbusPaths

      public void lockDbusPaths(@Nullable String @Nullable [] paths, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Lock items or collections in the secret service.

      The items or collections are represented by their D-Bus object paths. If you already have Item and Collection proxy objects, use use lock(List, Cancellable, AsyncReadyCallback) instead.

      The secret service may not be able to lock items individually, and may lock an entire collection instead.

      This method returns immediately and completes asynchronously. The secret service may prompt the user. prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) will be used to handle any prompts that show up.

      Parameters:
      paths - the D-Bus paths for items or collections to lock
      cancellable - optional cancellation object
      callback - called when the operation completes
    • lockDbusPathsFinish

      public int lockDbusPathsFinish(AsyncResult result, @Nullable Out<String[]> locked) throws GErrorException

      Complete asynchronous operation to lock items or collections in the secret service.

      The secret service may not be able to lock items individually, and may lock an entire collection instead.

      Parameters:
      result - asynchronous result passed to the callback
      locked - location to place array of D-Bus paths of items or collections that were locked
      Returns:
      the number of items or collections that were locked
      Throws:
      GErrorException - see GError
    • lockDbusPathsSync

      public int lockDbusPathsSync(@Nullable String @Nullable [] paths, @Nullable Cancellable cancellable, @Nullable Out<String[]> locked) throws GErrorException

      Lock items or collections in the secret service.

      The items or collections are represented by their D-Bus object paths. If you already have Item and Collection proxy objects, use use lockSync(List, Cancellable, Out) instead.

      The secret service may not be able to lock items individually, and may lock an entire collection instead.

      This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) will be used to handle any prompts that show up.

      Parameters:
      paths - the D-Bus object paths of the items or collections to lock
      cancellable - optional cancellation object
      locked - location to place array of D-Bus paths of items or collections that were locked
      Returns:
      the number of items or collections that were locked
      Throws:
      GErrorException - see GError
    • lockFinish

      public int lockFinish(AsyncResult result, @Nullable Out<List<DBusProxy>> locked) throws GErrorException

      Complete asynchronous operation to lock items or collections in the secret service.

      The secret service may not be able to lock items individually, and may lock an entire collection instead.

      Parameters:
      result - asynchronous result passed to the callback
      locked - location to place list of items or collections that were locked
      Returns:
      the number of items or collections that were locked
      Throws:
      GErrorException - see GError
    • lockSync

      public int lockSync(List<DBusProxy> objects, @Nullable Cancellable cancellable, @Nullable Out<List<DBusProxy>> locked) throws GErrorException

      Lock items or collections in the secret service.

      The secret service may not be able to lock items individually, and may lock an entire collection instead.

      If this Service is null, then getSync(Set, Cancellable) will be called to get the default Service proxy.

      This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) will be used to handle any prompts that show up.

      Parameters:
      objects - the items or collections to lock
      cancellable - optional cancellation object
      locked - location to place list of items or collections that were locked
      Returns:
      the number of items or collections that were locked
      Throws:
      GErrorException - see GError
    • lookup

      public void lookup(@Nullable Schema schema, HashTable<String,String> attributes, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Lookup a secret value in the secret service.

      The attributes should be a set of key and value string pairs.

      If this Service is null, then get(Set, Cancellable, AsyncReadyCallback) will be called to get the default Service proxy.

      This method will return immediately and complete asynchronously.

      Parameters:
      schema - the schema for the attributes
      attributes - the attribute keys and values
      cancellable - optional cancellation object
      callback - called when the operation completes
    • lookupFinish

      public Value lookupFinish(AsyncResult result) throws GErrorException

      Finish asynchronous operation to lookup a secret value in the secret service.

      If no secret is found then null is returned.

      Parameters:
      result - the asynchronous result passed to the callback
      Returns:
      a newly allocated Value, which should be released with Value.unref(), or null if no secret found
      Throws:
      GErrorException - see GError
    • lookupSync

      public Value lookupSync(@Nullable Schema schema, HashTable<String,String> attributes, @Nullable Cancellable cancellable) throws GErrorException

      Lookup a secret value in the secret service.

      The attributes should be a set of key and value string pairs.

      If this Service is null, then getSync(Set, Cancellable) will be called to get the default Service proxy.

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

      Parameters:
      schema - the schema for the attributes
      attributes - the attribute keys and values
      cancellable - optional cancellation object
      Returns:
      a newly allocated Value, which should be released with Value.unref(), or null if no secret found
      Throws:
      GErrorException - see GError
    • prompt

      public void prompt(Prompt prompt, @Nullable VariantType returnType, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Perform prompting for a Prompt.

      This function is called by other parts of this library to handle prompts for the various actions that can require prompting.

      Override the SecretServiceClass promptAsync(Prompt, VariantType, Cancellable, AsyncReadyCallback) virtual method to change the behavior of the prompting. The default behavior is to simply run Prompt.perform(String, VariantType, Cancellable, AsyncReadyCallback) on the prompt.

      Parameters:
      prompt - the prompt
      returnType - the variant type of the prompt result
      cancellable - optional cancellation object
      callback - called when the operation completes
    • promptAtDbusPath

      public void promptAtDbusPath(String promptPath, @Nullable VariantType returnType, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Perform prompting for a Prompt.

      This function is called by other parts of this library to handle prompts for the various actions that can require prompting.

      Override the SecretServiceClass promptAsync(Prompt, VariantType, Cancellable, AsyncReadyCallback) virtual method to change the behavior of the propmting. The default behavior is to simply run Prompt.perform(String, VariantType, Cancellable, AsyncReadyCallback) on the prompt.

      Parameters:
      promptPath - the D-Bus object path of the prompt
      returnType - the variant type of the prompt result
      cancellable - optional cancellation object
      callback - called when the operation completes
    • promptAtDbusPathFinish

      public @Nullable Variant promptAtDbusPathFinish(AsyncResult result) throws GErrorException

      Complete asynchronous operation to perform prompting for a Prompt.

      Returns a variant result if the prompt was completed and not dismissed. The type of result depends on the action the prompt is completing, and is defined in the Secret Service DBus API specification.

      Parameters:
      result - the asynchronous result passed to the callback
      Returns:
      null if the prompt was dismissed or an error occurred, a variant result if the prompt was successful
      Throws:
      GErrorException - see GError
    • promptAtDbusPathSync

      public @Nullable Variant promptAtDbusPathSync(String promptPath, @Nullable Cancellable cancellable, @Nullable VariantType returnType) throws GErrorException

      Perform prompting for a Prompt.

      Override the SecretServiceClass promptAsync(Prompt, VariantType, Cancellable, AsyncReadyCallback) virtual method to change the behavior of the propmting. The default behavior is to simply run Prompt.perform(String, VariantType, Cancellable, AsyncReadyCallback) on the prompt.

      Returns a variant result if the prompt was completed and not dismissed. The type of result depends on the action the prompt is completing, and is defined in the Secret Service DBus API specification.

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

      Parameters:
      promptPath - the D-Bus object path of the prompt
      cancellable - optional cancellation object
      returnType - the variant type of the prompt result
      Returns:
      null if the prompt was dismissed or an error occurred, a variant result if the prompt was successful
      Throws:
      GErrorException - see GError
    • promptFinish

      public Variant promptFinish(AsyncResult result) throws GErrorException

      Complete asynchronous operation to perform prompting for a Prompt.

      Returns a variant result if the prompt was completed and not dismissed. The type of result depends on the action the prompt is completing, and is defined in the Secret Service DBus API specification.

      Parameters:
      result - the asynchronous result passed to the callback
      Returns:
      null if the prompt was dismissed or an error occurred, a variant result if the prompt was successful
      Throws:
      GErrorException - see GError
    • promptSync

      public Variant promptSync(Prompt prompt, @Nullable Cancellable cancellable, VariantType returnType) throws GErrorException

      Perform prompting for a Prompt.

      Runs a prompt and performs the prompting. Returns a variant result if the prompt was completed and not dismissed. The type of result depends on the action the prompt is completing, and is defined in the Secret Service DBus API specification.

      This function is called by other parts of this library to handle prompts for the various actions that can require prompting.

      Override the SecretServiceClass promptSync(Prompt, Cancellable, VariantType) virtual method to change the behavior of the prompting. The default behavior is to simply run Prompt.performSync(String, Cancellable, VariantType) on the prompt with a null window_id.

      Parameters:
      prompt - the prompt
      cancellable - optional cancellation object
      returnType - the variant type of the prompt result
      Returns:
      null if the prompt was dismissed or an error occurred, a variant result if the prompt was successful
      Throws:
      GErrorException - see GError
    • readAliasDbusPath

      public void readAliasDbusPath(String alias, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Lookup which collection is assigned to this alias.

      Aliases help determine well known collections, such as 'default'. This method looks up the dbus object path of the well known collection.

      This method will return immediately and complete asynchronously.

      Parameters:
      alias - the alias to lookup
      cancellable - optional cancellation object
      callback - called when the operation completes
    • readAliasDbusPathFinish

      public @Nullable String readAliasDbusPathFinish(AsyncResult result) throws GErrorException

      Finish an asynchronous operation to lookup which collection is assigned to an alias.

      This method returns the DBus object path of the collection

      Parameters:
      result - asynchronous result passed to callback
      Returns:
      the collection dbus object path, or null if none assigned to the alias
      Throws:
      GErrorException - see GError
    • readAliasDbusPathSync

      public @Nullable String readAliasDbusPathSync(String alias, @Nullable Cancellable cancellable) throws GErrorException

      Lookup which collection is assigned to this alias.

      Aliases help determine well known collections, such as 'default'. This method returns the dbus object path of the collection.

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

      Parameters:
      alias - the alias to lookup
      cancellable - optional cancellation object
      Returns:
      the collection dbus object path, or null if none assigned to the alias
      Throws:
      GErrorException - see GError
    • search

      public void search(@Nullable Schema schema, HashTable<String,String> attributes, Set<SearchFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Search for items matching the attributes.

      All collections are searched. The attributes should be a table of string keys and string values.

      If this Service is null, then get(Set, Cancellable, AsyncReadyCallback) will be called to get the default Service proxy.

      If SearchFlags.ALL is set in flags, then all the items matching the search will be returned. Otherwise only the first item will be returned. This is almost always the unlocked item that was most recently stored.

      If SearchFlags.UNLOCK is set in flags, then items will be unlocked if necessary. In either case, locked and unlocked items will match the search and be returned. If the unlock fails, the search does not fail.

      If SearchFlags.LOAD_SECRETS is set in flags, then the items will have their secret values loaded and available via Item.getSecret().

      This function returns immediately and completes asynchronously.

      Parameters:
      schema - the schema for the attributes
      attributes - search for items matching these attributes
      flags - search option flags
      cancellable - optional cancellation object
      callback - called when the operation completes
    • search

      public void search(@Nullable Schema schema, HashTable<String,String> attributes, SearchFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Search for items matching the attributes.

      All collections are searched. The attributes should be a table of string keys and string values.

      If this Service is null, then get(Set, Cancellable, AsyncReadyCallback) will be called to get the default Service proxy.

      If SearchFlags.ALL is set in flags, then all the items matching the search will be returned. Otherwise only the first item will be returned. This is almost always the unlocked item that was most recently stored.

      If SearchFlags.UNLOCK is set in flags, then items will be unlocked if necessary. In either case, locked and unlocked items will match the search and be returned. If the unlock fails, the search does not fail.

      If SearchFlags.LOAD_SECRETS is set in flags, then the items will have their secret values loaded and available via Item.getSecret().

      This function returns immediately and completes asynchronously.

      Parameters:
      schema - the schema for the attributes
      attributes - search for items matching these attributes
      flags - search option flags
      cancellable - optional cancellation object
      callback - called when the operation completes
    • searchFinish

      public List<Item> searchFinish(AsyncResult result) throws GErrorException
      Complete asynchronous operation to search for items.
      Parameters:
      result - asynchronous result passed to callback
      Returns:
      a list of items that matched the search
      Throws:
      GErrorException - see GError
    • searchForDbusPaths

      public void searchForDbusPaths(@Nullable Schema schema, HashTable<String,String> attributes, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Search for items matching the attributes, and return their D-Bus object paths.

      All collections are searched. The attributes should be a table of string keys and string values.

      This function returns immediately and completes asynchronously.

      When your callback is called use searchForDbusPathsFinish(AsyncResult, Out, Out) to get the results of this function. Only the D-Bus object paths of the items will be returned. If you would like Item objects to be returned instead, then use the search(Schema, HashTable, Set, Cancellable, AsyncReadyCallback) function.

      Parameters:
      schema - the schema for the attributes
      attributes - search for items matching these attributes
      cancellable - optional cancellation object
      callback - called when the operation completes
    • searchForDbusPathsFinish

      public boolean searchForDbusPathsFinish(AsyncResult result, @Nullable Out<String[]> unlocked, @Nullable Out<String[]> locked) throws GErrorException

      Complete asynchronous operation to search for items, and return their D-Bus object paths.

      Matching items that are locked or unlocked, have their D-Bus paths placed in the locked or unlocked arrays respectively.

      D-Bus object paths of the items will be returned in the unlocked or locked arrays. If you would to have Item objects to be returned instead, then us the search(Schema, HashTable, Set, Cancellable, AsyncReadyCallback) and searchFinish(AsyncResult) functions.

      Parameters:
      result - asynchronous result passed to callback
      unlocked - location to place an array of D-Bus object paths for matching items which were locked.
      locked - location to place an array of D-Bus object paths for matching items which were locked.
      Returns:
      whether the search was successful or not
      Throws:
      GErrorException - see GError
    • searchForDbusPathsSync

      public boolean searchForDbusPathsSync(@Nullable Schema schema, HashTable<String,String> attributes, @Nullable Cancellable cancellable, @Nullable Out<String[]> unlocked, @Nullable Out<String[]> locked) throws GErrorException

      Search for items matching the attributes, and return their D-Bus object paths.

      All collections are searched. The attributes should be a table of string keys and string values.

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

      Matching items that are locked or unlocked, have their D-Bus paths placed in the locked or unlocked arrays respectively.

      D-Bus object paths of the items will be returned in the unlocked or locked arrays. If you would to have Item objects to be returned instead, then use the searchSync(Schema, HashTable, Set, Cancellable) function.

      Parameters:
      schema - the schema for the attributes
      attributes - search for items matching these attributes
      cancellable - optional cancellation object
      unlocked - location to place an array of D-Bus object paths for matching items which were locked.
      locked - location to place an array of D-Bus object paths for matching items which were locked.
      Returns:
      whether the search was successful or not
      Throws:
      GErrorException - see GError
    • searchSync

      public List<Item> searchSync(@Nullable Schema schema, HashTable<String,String> attributes, Set<SearchFlags> flags, @Nullable Cancellable cancellable) throws GErrorException

      Search for items matching the attributes.

      All collections are searched. The attributes should be a table of string keys and string values.

      If this Service is null, then getSync(Set, Cancellable) will be called to get the default Service proxy.

      If SearchFlags.ALL is set in flags, then all the items matching the search will be returned. Otherwise only the first item will be returned. This is almost always the unlocked item that was most recently stored.

      If SearchFlags.UNLOCK is set in flags, then items will be unlocked if necessary. In either case, locked and unlocked items will match the search and be returned. If the unlock fails, the search does not fail.

      If SearchFlags.LOAD_SECRETS is set in flags, then the items' secret values will be loaded for any unlocked items. Loaded item secret values are available via Item.getSecret(). If the load of a secret values fail, then the

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

      Parameters:
      schema - the schema for the attributes
      attributes - search for items matching these attributes
      flags - search option flags
      cancellable - optional cancellation object
      Returns:
      a list of items that matched the search
      Throws:
      GErrorException - see GError
    • searchSync

      public List<Item> searchSync(@Nullable Schema schema, HashTable<String,String> attributes, SearchFlags flags, @Nullable Cancellable cancellable) throws GErrorException

      Search for items matching the attributes.

      All collections are searched. The attributes should be a table of string keys and string values.

      If this Service is null, then getSync(Set, Cancellable) will be called to get the default Service proxy.

      If SearchFlags.ALL is set in flags, then all the items matching the search will be returned. Otherwise only the first item will be returned. This is almost always the unlocked item that was most recently stored.

      If SearchFlags.UNLOCK is set in flags, then items will be unlocked if necessary. In either case, locked and unlocked items will match the search and be returned. If the unlock fails, the search does not fail.

      If SearchFlags.LOAD_SECRETS is set in flags, then the items' secret values will be loaded for any unlocked items. Loaded item secret values are available via Item.getSecret(). If the load of a secret values fail, then the

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

      Parameters:
      schema - the schema for the attributes
      attributes - search for items matching these attributes
      flags - search option flags
      cancellable - optional cancellation object
      Returns:
      a list of items that matched the search
      Throws:
      GErrorException - see GError
    • setAlias

      public void setAlias(String alias, @Nullable Collection collection, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Assign a collection to this alias.

      Aliases help determine well known collections, such as 'default'.

      If this Service is null, then get(Set, Cancellable, AsyncReadyCallback) will be called to get the default Service proxy.

      This method will return immediately and complete asynchronously.

      Parameters:
      alias - the alias to assign the collection to
      collection - the collection to assign to the alias
      cancellable - optional cancellation object
      callback - called when the operation completes
    • setAliasFinish

      public boolean setAliasFinish(AsyncResult result) throws GErrorException
      Finish an asynchronous operation to assign a collection to an alias.
      Parameters:
      result - asynchronous result passed to callback
      Returns:
      true if successful
      Throws:
      GErrorException - see GError
    • setAliasSync

      public boolean setAliasSync(String alias, @Nullable Collection collection, @Nullable Cancellable cancellable) throws GErrorException

      Assign a collection to this alias. Aliases help determine well known collections, such as 'default'.

      If this Service is null, then getSync(Set, Cancellable) will be called to get the default Service proxy.

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

      Parameters:
      alias - the alias to assign the collection to
      collection - the collection to assign to the alias
      cancellable - optional cancellation object
      Returns:
      true if successful
      Throws:
      GErrorException - see GError
    • setAliasToDbusPath

      public void setAliasToDbusPath(String alias, @Nullable String collectionPath, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Assign a collection to this alias. Aliases help determine well known collections, such as 'default'. This method takes the dbus object path of the collection to assign to the alias.

      This method will return immediately and complete asynchronously.

      Parameters:
      alias - the alias to assign the collection to
      collectionPath - the dbus object path of the collection to assign to the alias
      cancellable - optional cancellation object
      callback - called when the operation completes
    • setAliasToDbusPathFinish

      public boolean setAliasToDbusPathFinish(AsyncResult result) throws GErrorException
      Finish an asynchronous operation to assign a collection to an alias.
      Parameters:
      result - asynchronous result passed to callback
      Returns:
      true if successful
      Throws:
      GErrorException - see GError
    • setAliasToDbusPathSync

      public boolean setAliasToDbusPathSync(String alias, @Nullable String collectionPath, @Nullable Cancellable cancellable) throws GErrorException

      Assign a collection to this alias.

      Aliases help determine well known collections, such as 'default'. This method takes the dbus object path of the collection to assign to the alias.

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

      Parameters:
      alias - the alias to assign the collection to
      collectionPath - the D-Bus object path of the collection to assign to the alias
      cancellable - optional cancellation object
      Returns:
      true if successful
      Throws:
      GErrorException - see GError
    • store

      public void store(@Nullable Schema schema, HashTable<String,String> attributes, @Nullable String collection, String label, Value value, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Store a secret value in the secret service.

      The attributes should be a set of key and value string pairs.

      If the attributes match a secret item already stored in the collection, then the item will be updated with these new values.

      If this Service is null, then get(Set, Cancellable, AsyncReadyCallback) will be called to get the default Service proxy.

      If collection is not specified, then the default collection will be used. Use COLLECTION_SESSION to store the password in the session collection, which doesn't get stored across login sessions.

      This method will return immediately and complete asynchronously.

      Parameters:
      schema - the schema to use to check attributes
      attributes - the attribute keys and values
      collection - a collection alias, or D-Bus object path of the collection where to store the secret
      label - label for the secret
      value - the secret value
      cancellable - optional cancellation object
      callback - called when the operation completes
    • storeFinish

      public boolean storeFinish(AsyncResult result) throws GErrorException
      Finish asynchronous operation to store a secret value in the secret service.
      Parameters:
      result - the asynchronous result passed to the callback
      Returns:
      whether the storage was successful or not
      Throws:
      GErrorException - see GError
    • storeSync

      public boolean storeSync(@Nullable Schema schema, HashTable<String,String> attributes, @Nullable String collection, String label, Value value, @Nullable Cancellable cancellable) throws GErrorException

      Store a secret value in the secret service.

      The attributes should be a set of key and value string pairs.

      If the attributes match a secret item already stored in the collection, then the item will be updated with these new values.

      If collection is null, then the default collection will be used. Use COLLECTION_SESSION to store the password in the session collection, which doesn't get stored across login sessions.

      If this Service is null, then getSync(Set, Cancellable) will be called to get the default Service proxy.

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

      Parameters:
      schema - the schema for the attributes
      attributes - the attribute keys and values
      collection - a collection alias, or D-Bus object path of the collection where to store the secret
      label - label for the secret
      value - the secret value
      cancellable - optional cancellation object
      Returns:
      whether the storage was successful or not
      Throws:
      GErrorException - see GError
    • unlock

      public void unlock(List<DBusProxy> objects, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Unlock items or collections in the secret service.

      The secret service may not be able to unlock items individually, and may unlock an entire collection instead.

      If this Service is null, then get(Set, Cancellable, AsyncReadyCallback) will be called to get the default Service proxy.

      This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) will be used to handle any prompts that show up.

      Parameters:
      objects - the items or collections to unlock
      cancellable - optional cancellation object
      callback - called when the operation completes
    • unlockDbusPaths

      public void unlockDbusPaths(@Nullable String @Nullable [] paths, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Unlock items or collections in the secret service.

      The items or collections are represented by their D-Bus object paths. If you already have Item and Collection proxy objects, use use unlock(List, Cancellable, AsyncReadyCallback) instead.

      The secret service may not be able to unlock items individually, and may unlock an entire collection instead.

      This method returns immediately and completes asynchronously. The secret service may prompt the user. prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) will be used to handle any prompts that show up.

      Parameters:
      paths - the D-Bus paths for items or collections to unlock
      cancellable - optional cancellation object
      callback - called when the operation completes
    • unlockDbusPathsFinish

      public int unlockDbusPathsFinish(AsyncResult result, @Nullable Out<String[]> unlocked) throws GErrorException

      Complete asynchronous operation to unlock items or collections in the secret service.

      The secret service may not be able to unlock items individually, and may unlock an entire collection instead.

      Parameters:
      result - asynchronous result passed to the callback
      unlocked - location to place array of D-Bus paths of items or collections that were unlocked
      Returns:
      the number of items or collections that were unlocked
      Throws:
      GErrorException - see GError
    • unlockDbusPathsSync

      public int unlockDbusPathsSync(@Nullable String @Nullable [] paths, @Nullable Cancellable cancellable, @Nullable Out<String[]> unlocked) throws GErrorException

      Unlock items or collections in the secret service.

      The items or collections are represented by their D-Bus object paths. If you already have Item and Collection proxy objects, use use unlockSync(List, Cancellable, Out) instead.

      The secret service may not be able to unlock items individually, and may unlock an entire collection instead.

      This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) will be used to handle any prompts that show up.

      Parameters:
      paths - the D-Bus object paths of the items or collections to unlock
      cancellable - optional cancellation object
      unlocked - location to place array of D-Bus paths of items or collections that were unlocked
      Returns:
      the number of items or collections that were unlocked
      Throws:
      GErrorException - see GError
    • unlockFinish

      public int unlockFinish(AsyncResult result, @Nullable Out<List<DBusProxy>> unlocked) throws GErrorException

      Complete asynchronous operation to unlock items or collections in the secret service.

      The secret service may not be able to unlock items individually, and may unlock an entire collection instead.

      Parameters:
      result - asynchronous result passed to the callback
      unlocked - location to place list of items or collections that were unlocked
      Returns:
      the number of items or collections that were unlocked
      Throws:
      GErrorException - see GError
    • unlockSync

      public int unlockSync(List<DBusProxy> objects, @Nullable Cancellable cancellable, @Nullable Out<List<DBusProxy>> unlocked) throws GErrorException

      Unlock items or collections in the secret service.

      The secret service may not be able to unlock items individually, and may unlock an entire collection instead.

      If this Service is null, then getSync(Set, Cancellable) will be called to get the default Service proxy.

      This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. prompt(Prompt, VariantType, Cancellable, AsyncReadyCallback) will be used to handle any prompts that show up.

      Parameters:
      objects - the items or collections to unlock
      cancellable - optional cancellation object
      unlocked - location to place list of items or collections that were unlocked
      Returns:
      the number of items or collections that were unlocked
      Throws:
      GErrorException - see GError
    • promptAsync

      protected void promptAsync(Prompt prompt, VariantType returnType, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)
      called to perform asynchronous prompting when necessary
    • builder

      public static Service.Builder<? extends Service.Builder> builder()
      A Service.Builder object constructs a Service with the specified properties. Use the various set...() methods to set properties, and finish construction with Service.Builder.build().
      Returns:
      the builder object