Package org.freedesktop.secret.simple
Class SimpleCollection
- java.lang.Object
-
- org.freedesktop.secret.simple.SimpleCollection
-
- All Implemented Interfaces:
AutoCloseable
public final class SimpleCollection extends Object implements AutoCloseable
-
-
Constructor Summary
Constructors Constructor Description SimpleCollection()The default collection.SimpleCollection(String label, CharSequence password)A user specified collection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears the private key of the transport encryption and the passphrase of the collection.voidclose()StringcreateItem(String label, CharSequence password)Creates an item with the provided properties in this collection.StringcreateItem(String label, CharSequence password, Map<String,String> attributes)Creates an item with the provided properties in this collection.voiddelete()Delete this collection.voiddeleteItem(String objectPath)Delete an item from this collection.voiddeleteItems(List<String> objectPaths)Delete specified items from this collection.Map<String,String>getAttributes(String objectPath)Get the user specified attributes of an item.List<String>getItems(Map<String,String> attributes)Get the object paths of items with given attributes.StringgetLabel(String objectPath)Get the displayable label of an item.char[]getSecret(String objectPath)Get the secret of the item.Map<String,char[]>getSecrets()Get the secrets from this collection.voidupdateItem(String objectPath, String label, CharSequence password, Map<String,String> attributes)Updates an item with the provided properties.
-
-
-
Constructor Detail
-
SimpleCollection
public SimpleCollection() throws IOExceptionThe default collection.- Throws:
IOException- Could not communicate properly with the D-Bus. Check the logs.
-
SimpleCollection
public SimpleCollection(String label, CharSequence password) throws IOException
A user specified collection.- Parameters:
label- The displayable label of the collectionNOTE: The 'label' of a collection may differ from the 'id' of a collection. The 'id' is assigned by the Secret Service and used in the DBus object path of a collection or item.
A SimpleCollection can't handle collections with the same label, but different ids correctly.
password- Password of the collection- Throws:
IOException- Could not communicate properly with the D-Bus. Check the logs.
-
-
Method Detail
-
clear
public void clear()
Clears the private key of the transport encryption and the passphrase of the collection.
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable
-
delete
public void delete() throws AccessControlExceptionDelete this collection.- Throws:
AccessControlException
-
createItem
public String createItem(String label, CharSequence password, Map<String,String> attributes) throws IllegalArgumentException
Creates an item with the provided properties in this collection.- Parameters:
label- The displayable label of the new itempassword- The password of the new itemattributes- The attributes of the new item- Returns:
- DBus object path
- Throws:
IllegalArgumentException- The label and password are non nullable.
-
createItem
public String createItem(String label, CharSequence password) throws IllegalArgumentException
Creates an item with the provided properties in this collection.- Parameters:
label- The displayable label of the new itempassword- The password of the new item- Returns:
- DBus object path
- Throws:
IllegalArgumentException- The label and password are non nullable.
-
updateItem
public void updateItem(String objectPath, String label, CharSequence password, Map<String,String> attributes) throws IllegalArgumentException
Updates an item with the provided properties.- Parameters:
objectPath- The DBus object path of the itemlabel- The displayable label of the new itempassword- The password of the new itemattributes- The attributes of the new item- Throws:
IllegalArgumentException- The object path, label and password are non nullable.
-
getLabel
public String getLabel(String objectPath)
Get the displayable label of an item.- Parameters:
objectPath- The DBus object path of the item- Returns:
- label
-
getAttributes
public Map<String,String> getAttributes(String objectPath)
Get the user specified attributes of an item. NOTE:The attributes can contain an additional 'xdg:schema' key-value pair.
- Parameters:
objectPath- The DBus object path of the item- Returns:
- item attributes
-
getItems
public List<String> getItems(Map<String,String> attributes)
Get the object paths of items with given attributes.- Parameters:
attributes- The attributes of the secret- Returns:
- object paths
-
getSecret
public char[] getSecret(String objectPath)
Get the secret of the item.- Parameters:
objectPath- The DBus object path of the item- Returns:
- plain chars
-
getSecrets
public Map<String,char[]> getSecrets() throws AccessControlException
Get the secrets from this collection. NOTE:Retrieving all passwords form a collection requires user permission.
- Returns:
- Mapping of DBus object paths and plain chars
- Throws:
AccessControlException
-
deleteItem
public void deleteItem(String objectPath) throws AccessControlException
Delete an item from this collection. NOTE:Deleting a password form a collection requires user permission.
- Parameters:
objectPath- The DBus object path of the item- Throws:
AccessControlException
-
deleteItems
public void deleteItems(List<String> objectPaths) throws AccessControlException
Delete specified items from this collection. NOTE:Deleting passwords form a collection requires user permission.
- Parameters:
objectPaths- The DBus object paths of the items- Throws:
AccessControlException
-
-