Class SimpleCollection

    • Constructor Detail

      • SimpleCollection

        public SimpleCollection()
                         throws IOException
        The 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 collection

        NOTE: 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.
      • 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 item
        password - The password of the new item
        attributes - 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 item
        password - 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 item
        label - The displayable label of the new item
        password - The password of the new item
        attributes - 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