Class Secret
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringExtension point for the secret backend.static final StringAn alias to the default collection.static final StringAn alias to the session collection, which will be cleared when the user ends the session.static final intThe major version of libsecret.static final intThe micro version of libsecret.static final intThe minor version of libsecret. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionattributesBuild(Schema schema, Object... varargs) Build up a hash table of attribute values.static booleanattributesValidate(Schema schema, HashTable<MemorySegment, MemorySegment> attributes) Check if attributes are valid according to the provided schema.static SchemagetSchema(SchemaType type) Get a secret storage schema of the giventype.static voidstatic voidpasswordClear(@Nullable Schema schema, HashTable<String, String> attributes, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Remove unlocked matching passwords from the secret service.static booleanpasswordClearFinish(AsyncResult result) Finish an asynchronous operation to remove passwords from the secret service.static booleanpasswordClearSync(@Nullable Schema schema, HashTable<String, String> attributes, @Nullable Cancellable cancellable) Remove unlocked matching passwords from the secret service.static voidpasswordFree(@Nullable String password) Clear the memory used by a password, and then free it.static voidpasswordLookup(@Nullable Schema schema, HashTable<String, String> attributes, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Lookup a password in the secret service.static ValueFinish an asynchronous operation to lookup a password in the secret service.static ValuepasswordLookupBinarySync(Schema schema, @Nullable Cancellable cancellable, GError[] error, Object... varargs) Lookup a password in the secret service.static StringpasswordLookupFinish(AsyncResult result) Finish an asynchronous operation to lookup a password in the secret service.static StringFinish an asynchronous operation to lookup a password in the secret service.static StringpasswordLookupNonpageableSync(Schema schema, @Nullable Cancellable cancellable, GError[] error, Object... varargs) Lookup a password in the secret service.static StringpasswordLookupSync(@Nullable Schema schema, HashTable<String, String> attributes, @Nullable Cancellable cancellable) Lookup a password in the secret service.static ValuepasswordLookupvBinarySync(@Nullable Schema schema, HashTable<String, String> attributes, @Nullable Cancellable cancellable) Lookup a password in the secret service.static StringpasswordLookupvNonpageableSync(@Nullable Schema schema, HashTable<String, String> attributes, @Nullable Cancellable cancellable) Lookup a password in the secret service.static voidpasswordSearch(@Nullable Schema schema, HashTable<String, String> attributes, Set<SearchFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Search for items in the secret service.static voidpasswordSearch(@Nullable Schema schema, HashTable<String, String> attributes, SearchFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Search for items in the secret service.static List<Retrievable> passwordSearchFinish(AsyncResult result) Finish an asynchronous operation to search for items in the secret service.static List<Retrievable> passwordSearchSync(@Nullable Schema schema, HashTable<String, String> attributes, Set<SearchFlags> flags, @Nullable Cancellable cancellable) Search for items in the secret service.static List<Retrievable> passwordSearchSync(@Nullable Schema schema, HashTable<String, String> attributes, SearchFlags flags, @Nullable Cancellable cancellable) Search for items in the secret service.static voidpasswordStore(@Nullable Schema schema, HashTable<String, String> attributes, @Nullable String collection, String label, String password, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Store a password in the secret service.static voidpasswordStoreBinary(@Nullable Schema schema, HashTable<String, String> attributes, @Nullable String collection, String label, Value value, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Store a password in the secret service.static booleanpasswordStoreBinarySync(@Nullable Schema schema, HashTable<String, String> attributes, @Nullable String collection, String label, Value value, @Nullable Cancellable cancellable) Store a password in the secret service.static booleanpasswordStoreFinish(AsyncResult result) Finish asynchronous operation to store a password in the secret service.static booleanpasswordStoreSync(@Nullable Schema schema, HashTable<String, String> attributes, @Nullable String collection, String label, String password, @Nullable Cancellable cancellable) Store a password in the secret service.static voidpasswordWipe(@Nullable String password) Clear the memory used by a password.
-
Field Details
-
BACKEND_EXTENSION_POINT_NAME
Extension point for the secret backend.- See Also:
-
COLLECTION_DEFAULT
An alias to the default collection.This can be passed to
passwordStore(org.gnome.secret.Schema, org.gnome.glib.HashTable<java.lang.String, java.lang.String>, java.lang.String, java.lang.String, java.lang.String, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)Collection.forAlias(org.gnome.secret.Service, java.lang.String, java.util.Set<org.gnome.secret.CollectionFlags>, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback).- See Also:
-
COLLECTION_SESSION
An alias to the session collection, which will be cleared when the user ends the session.This can be passed to
passwordStore(org.gnome.secret.Schema, org.gnome.glib.HashTable<java.lang.String, java.lang.String>, java.lang.String, java.lang.String, java.lang.String, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback),Collection.forAlias(org.gnome.secret.Service, java.lang.String, java.util.Set<org.gnome.secret.CollectionFlags>, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback)or similar functions.- See Also:
-
MAJOR_VERSION
public static final int MAJOR_VERSIONThe major version of libsecret.- See Also:
-
MICRO_VERSION
public static final int MICRO_VERSIONThe micro version of libsecret.- See Also:
-
MINOR_VERSION
public static final int MINOR_VERSIONThe minor version of libsecret.- See Also:
-
-
Constructor Details
-
Secret
public Secret()
-
-
Method Details
-
javagi$ensureInitialized
public static void javagi$ensureInitialized() -
attributesBuild
Build up a hash table of attribute values.The variable argument list should contain pairs of a) The attribute name as a null-terminated string, followed by b) attribute value, either a character string, an int number, or a gboolean value, as defined in the password
schema.The list of attributes should be terminated with anull.- Parameters:
schema- the schema for the attributesvarargs- the attribute keys and values, terminated withnull- Returns:
- a new table of
attributes, to be released with
HashTable.unref()
-
attributesValidate
public static boolean attributesValidate(Schema schema, HashTable<MemorySegment, MemorySegment> attributes) throws GErrorExceptionCheck if attributes are valid according to the provided schema.Verifies schema name if available, attribute names and parsing of attribute values.
- Parameters:
schema- the schema for the attributesattributes- the attributes to be validated- Returns:
- whether or not the given attributes table is valid
- Throws:
GErrorException- seeGError- Since:
- 0.21.2
-
getSchema
Get a secret storage schema of the giventype.C code may access the schemas (such as
SECRET_SCHEMA_NOTE) directly, but language bindings cannot, and must use this accessor.- Parameters:
type- type of schema to get- Returns:
- schema type
- Since:
- 0.18.6
-
passwordClearFinish
Finish an asynchronous operation to remove passwords from the secret service.- Parameters:
result- the asynchronous result passed to the callback- Returns:
- whether any passwords were removed
- Throws:
GErrorException- seeGError
-
passwordClear
public static void passwordClear(@Nullable Schema schema, HashTable<String, String> attributes, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Remove unlocked matching passwords from the secret service.The
attributesshould be a set of key and value string pairs.All unlocked items that match the attributes will be deleted.
This method will return immediately and complete asynchronously.
- Parameters:
schema- the schema for the attributesattributes- the attribute keys and valuescancellable- optional cancellation objectcallback- called when the operation completes
-
passwordClearSync
public static boolean passwordClearSync(@Nullable Schema schema, HashTable<String, String> attributes, @Nullable Cancellable cancellable) throws GErrorExceptionRemove unlocked matching passwords from the secret service.The
attributesshould be a set of key and value string pairs.All unlocked items that match the attributes will be deleted.
This method may block indefinitely and should not be used in user interface threads.
- Parameters:
schema- the schema for the attributesattributes- the attribute keys and valuescancellable- optional cancellation object- Returns:
- whether any passwords were removed
- Throws:
GErrorException- seeGError
-
passwordFree
Clear the memory used by a password, and then free it.This function must be used to free nonpageable memory returned by
passwordLookupNonpageableFinish(org.gnome.gio.AsyncResult),passwordLookupNonpageableSync(org.gnome.secret.Schema, org.gnome.gio.Cancellable, org.gnome.glib.GError[], java.lang.Object...)orpasswordLookupvNonpageableSync(org.gnome.secret.Schema, org.gnome.glib.HashTable<java.lang.String, java.lang.String>, org.gnome.gio.Cancellable).- Parameters:
password- password to free
-
passwordLookupBinaryFinish
Finish an asynchronous operation to lookup a password in the secret service.- Parameters:
result- the asynchronous result passed to the callback- Returns:
- a newly allocated
Value, which should be released withValue.unref(), ornullif no secret found - Throws:
GErrorException- seeGError- Since:
- 0.19.0
-
passwordLookupBinarySync
public static Value passwordLookupBinarySync(Schema schema, @Nullable Cancellable cancellable, GError[] error, Object... varargs) Lookup a password in the secret service.This is similar to
passwordLookupSync(org.gnome.secret.Schema, org.gnome.glib.HashTable<java.lang.String, java.lang.String>, org.gnome.gio.Cancellable), but returns aValueinstead of a null-terminated password.This method may block indefinitely and should not be used in user interface threads.
- Parameters:
schema- the schema for the attributescancellable- optional cancellation objecterror- location to place an error on failurevarargs- the attribute keys and values, terminated withnull- Returns:
- a newly allocated
Value, which should be released withValue.unref(), ornullif no secret found - Since:
- 0.19.0
-
passwordLookupFinish
Finish an asynchronous operation to lookup a password in the secret service.- Parameters:
result- the asynchronous result passed to the callback- Returns:
- a new password string which should be freed with
passwordFree(java.lang.String)or may be freed withGLib.free(java.lang.foreign.MemorySegment)when done - Throws:
GErrorException- seeGError
-
passwordLookupNonpageableFinish
Finish an asynchronous operation to lookup a password in the secret service.- Parameters:
result- the asynchronous result passed to the callback- Returns:
- a new password string stored in nonpageable memory
which must be freed with
passwordFree(java.lang.String)when done - Throws:
GErrorException- seeGError
-
passwordLookupNonpageableSync
public static String passwordLookupNonpageableSync(Schema schema, @Nullable Cancellable cancellable, GError[] error, Object... varargs) Lookup a password in the secret service.The variable argument list should contain pairs of a) The attribute name as a null-terminated string, followed by b) attribute value, either a character string, an int number, or a gboolean value, as defined in the password
schema.The list of attributes should be terminated with anull.If no secret is found then
nullis returned.This method may block indefinitely and should not be used in user interface threads.
- Parameters:
schema- the schema for the attributescancellable- optional cancellation objecterror- location to place an error on failurevarargs- the attribute keys and values, terminated withnull- Returns:
- a new password string stored in nonpageable memory
which must be freed with
passwordFree(java.lang.String)when done
-
passwordLookup
public static void passwordLookup(@Nullable Schema schema, HashTable<String, String> attributes, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Lookup a password in the secret service.The
attributesshould be a set of key and value string pairs.If no secret is found then
nullis returned.This method will return immediately and complete asynchronously.
- Parameters:
schema- the schema for attributesattributes- the attribute keys and valuescancellable- optional cancellation objectcallback- called when the operation completes
-
passwordLookupvBinarySync
public static Value passwordLookupvBinarySync(@Nullable Schema schema, HashTable<String, String> attributes, @Nullable Cancellable cancellable) throws GErrorExceptionLookup a password in the secret service.This is similar to
org.gnome.secret.Secret#passwordLookupvSync, but returns aValueinstead of a null-terminated password.This method may block indefinitely and should not be used in user interface threads.
- Parameters:
schema- the schema for attributesattributes- the attribute keys and valuescancellable- optional cancellation object- Returns:
- a newly allocated
Value, which should be released withValue.unref(), ornullif no secret found - Throws:
GErrorException- seeGError- Since:
- 0.19.0
-
passwordLookupvNonpageableSync
public static String passwordLookupvNonpageableSync(@Nullable Schema schema, HashTable<String, String> attributes, @Nullable Cancellable cancellable) throws GErrorExceptionLookup a password in the secret service.The
attributesshould be a set of key and value string pairs.If no secret is found then
nullis returned.This method may block indefinitely and should not be used in user interface threads.
- Parameters:
schema- the schema for attributesattributes- the attribute keys and valuescancellable- optional cancellation object- Returns:
- a new password string stored in non pageable memory
which should be freed with
passwordFree(java.lang.String)when done - Throws:
GErrorException- seeGError
-
passwordLookupSync
public static String passwordLookupSync(@Nullable Schema schema, HashTable<String, String> attributes, @Nullable Cancellable cancellable) throws GErrorExceptionLookup a password in the secret service.The
attributesshould be a set of key and value string pairs.If no secret is found then
nullis returned.This method may block indefinitely and should not be used in user interface threads.
- Parameters:
schema- the schema for attributesattributes- the attribute keys and valuescancellable- optional cancellation object- Returns:
- a new password string which should be freed with
passwordFree(java.lang.String)or may be freed withGLib.free(java.lang.foreign.MemorySegment)when done - Throws:
GErrorException- seeGError
-
passwordSearchFinish
Finish an asynchronous operation to search for items in the secret service.- Parameters:
result- the asynchronous result passed to the callback- Returns:
- a list of
Retrievablecontaining attributes of the matched items - Throws:
GErrorException- seeGError- Since:
- 0.19.0
-
passwordSearch
public static void passwordSearch(@Nullable Schema schema, HashTable<String, String> attributes, Set<SearchFlags> flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Search for items in the secret service.The
attributesshould be a set of key and value string pairs.This method will return immediately and complete asynchronously.
- Parameters:
schema- the schema for attributesattributes- the attribute keys and valuesflags- search option flagscancellable- optional cancellation objectcallback- called when the operation completes- Since:
- 0.19.0
-
passwordSearch
public static void passwordSearch(@Nullable Schema schema, HashTable<String, String> attributes, SearchFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Search for items in the secret service.The
attributesshould be a set of key and value string pairs.This method will return immediately and complete asynchronously.
- Parameters:
schema- the schema for attributesattributes- the attribute keys and valuesflags- search option flagscancellable- optional cancellation objectcallback- called when the operation completes- Since:
- 0.19.0
-
passwordSearchSync
public static List<Retrievable> passwordSearchSync(@Nullable Schema schema, HashTable<String, String> attributes, Set<SearchFlags> flags, @Nullable Cancellable cancellable) throws GErrorExceptionSearch for items in the secret service.The
attributesshould be a set of key and value string pairs.If no secret is found then
nullis returned.This method may block indefinitely and should not be used in user interface threads.
- Parameters:
schema- the schema for attributesattributes- the attribute keys and valuesflags- search option flagscancellable- optional cancellation object- Returns:
- a list of
Retrievablecontaining attributes of the matched items - Throws:
GErrorException- seeGError- Since:
- 0.19.0
-
passwordSearchSync
public static List<Retrievable> passwordSearchSync(@Nullable Schema schema, HashTable<String, String> attributes, SearchFlags flags, @Nullable Cancellable cancellable) throws GErrorExceptionSearch for items in the secret service.The
attributesshould be a set of key and value string pairs.If no secret is found then
nullis returned.This method may block indefinitely and should not be used in user interface threads.
- Parameters:
schema- the schema for attributesattributes- the attribute keys and valuesflags- search option flagscancellable- optional cancellation object- Returns:
- a list of
Retrievablecontaining attributes of the matched items - Throws:
GErrorException- seeGError- Since:
- 0.19.0
-
passwordStoreFinish
Finish asynchronous operation to store a password in the secret service.- Parameters:
result- the asynchronous result passed to the callback- Returns:
- whether the storage was successful or not
- Throws:
GErrorException- seeGError
-
passwordStore
public static void passwordStore(@Nullable Schema schema, HashTable<String, String> attributes, @Nullable String collection, String label, String password, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Store a password in the secret service.The
attributesshould 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
collectionisnull, then the default collection will be used. UseCOLLECTION_SESSIONto 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 for attributesattributes- the attribute keys and valuescollection- a collection alias, or D-Bus object path of the collection where to store the secretlabel- label for the secretpassword- the null-terminated password to storecancellable- optional cancellation objectcallback- called when the operation completes
-
passwordStoreBinary
public static void passwordStoreBinary(@Nullable Schema schema, HashTable<String, String> attributes, @Nullable String collection, String label, Value value, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Store a password in the secret service.This is similar to
org.gnome.secret.Secret#passwordStorev, but takes aValueas the argument instead of a null-terminated password.This method will return immediately and complete asynchronously.
- Parameters:
schema- the schema for attributesattributes- the attribute keys and valuescollection- a collection alias, or D-Bus object path of the collection where to store the secretlabel- label for the secretvalue- aValuecancellable- optional cancellation objectcallback- called when the operation completes- Since:
- 0.19.0
-
passwordStoreBinarySync
public static boolean passwordStoreBinarySync(@Nullable Schema schema, HashTable<String, String> attributes, @Nullable String collection, String label, Value value, @Nullable Cancellable cancellable) throws GErrorExceptionStore a password in the secret service.This is similar to
org.gnome.secret.Secret#passwordStorevSync, but takes aValueas the argument instead of a null-terminated passwords.This method may block indefinitely and should not be used in user interface threads.
- Parameters:
schema- the schema for attributesattributes- the attribute keys and valuescollection- a collection alias, or D-Bus object path of the collection where to store the secretlabel- label for the secretvalue- aValuecancellable- optional cancellation object- Returns:
- whether the storage was successful or not
- Throws:
GErrorException- seeGError- Since:
- 0.19.0
-
passwordStoreSync
public static boolean passwordStoreSync(@Nullable Schema schema, HashTable<String, String> attributes, @Nullable String collection, String label, String password, @Nullable Cancellable cancellable) throws GErrorExceptionStore a password in the secret service.The
attributesshould 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
collectionisnull, then the default collection will be used. UseCOLLECTION_SESSIONto store the password in the session collection, which doesn't get stored across login sessions.This method may block indefinitely and should not be used in user interface threads.
- Parameters:
schema- the schema for attributesattributes- the attribute keys and valuescollection- a collection alias, or D-Bus object path of the collection where to store the secretlabel- label for the secretpassword- the null-terminated password to storecancellable- optional cancellation object- Returns:
- whether the storage was successful or not
- Throws:
GErrorException- seeGError
-
passwordWipe
Clear the memory used by a password.- Parameters:
password- password to clear
-