de.swiesend.secretservice.interfaces.Collection Maven / Gradle / Ivy
Show all versions of secret-service Show documentation
package de.swiesend.secretservice.interfaces;
import org.freedesktop.dbus.DBusPath;
import org.freedesktop.dbus.ObjectPath;
import org.freedesktop.dbus.annotations.DBusInterfaceName;
import org.freedesktop.dbus.exceptions.DBusException;
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.freedesktop.dbus.messages.DBusSignal;
import org.freedesktop.dbus.types.UInt64;
import org.freedesktop.dbus.types.Variant;
import de.swiesend.secretservice.Pair;
import de.swiesend.secretservice.Secret;
import de.swiesend.secretservice.Static;
import java.util.List;
import java.util.Map;
@DBusInterfaceName(Static.Interfaces.COLLECTION)
public interface Collection extends DBusInterface {
/**
* The key of the D-Bus properties for the label of a collection.
*/
public static final String LABEL = "org.freedesktop.Secret.Collection.Label";
public static class ItemCreated extends DBusSignal {
public final DBusPath item;
/**
* A new item in this collection was created.
*
* @param path The path to the object this is emitted from.
* @param item The item that was created.
*
* @throws DBusException Could not communicate properly with the D-Bus.
*/
public ItemCreated(String path, DBusPath item) throws DBusException {
super(path, item);
this.item = item;
}
}
public static class ItemDeleted extends DBusSignal {
public final DBusPath item;
/**
* An item in this collection was deleted.
*
* @param path The path to the object this is emitted from.
* @param item The item that was deleted.
*
* @throws DBusException Could not communicate properly with the D-Bus.
*/
public ItemDeleted(String path, DBusPath item) throws DBusException {
super(path, item);
this.item = item;
}
}
public static class ItemChanged extends DBusSignal {
public final DBusPath item;
/**
* An item in this collection changed.
*
* @param path The path to the object this is emitted from.
* @param item The item that was changed.
*
* @throws DBusException Could not communicate properly with the D-Bus.
*/
public ItemChanged(String path, DBusPath item) throws DBusException {
super(path, item);
this.item = item;
}
}
/**
* Delete this collection.
*
* @return prompt — A prompt to delete the collection, or the special value '/' when no prompt is necessary.
*
* @see ObjectPath
*/
abstract public ObjectPath delete();
/**
* Search for items in this collection matching the lookup attributes.
*
* @param attributes Attributes to match.
*
* @return results — Items that matched the attributes.
*
* @see ObjectPath
* @see Secret
* @see Item
*/
abstract public List searchItems(Map attributes);
/**
* Create an item with the given attributes, secret and label. If replace is set, then it replaces an item already
* present with the same values for the attributes.
*
* @param properties The properties for the new item.
*
* This allows setting the new item's properties upon its creation. All READWRITE properties
* are useable. Specify the property names in full interface.Property
form.
*
*
* Example 13.2. Example for properties of an item:
*
* properties = {
* "org.freedesktop.Secret.Item.Label": "MyItem",
* "org.freedesktop.Secret.Item.Attributes": {
* "Attribute1": "Value1",
* "Attribute2": "Value2"
* }
* }
*
*
*
* Note:
* Please note that there is a distinction between the terms Property, which refers
* to D-Bus properties of an object, and Attribute, which refers to one of a
* secret item's string-valued attributes.
*
*
* @param secret The secret to store in the item, encoded with the included session.
*
* @param replace Whether to replace an item with the same attributes or not.
*
* @return Pair<item, prompt>
*
* item — The item created, or the special value '/' if a prompt is necessary.
*
* prompt — A prompt object, or the special value '/' if no prompt is necessary.
*
*
* See Also:
* {@link de.swiesend.secretservice.Collection#createProperties(String label)}
* {@link de.swiesend.secretservice.Item#createProperties(String label, Map attributes)}
* @see Pair
* @see ObjectPath
* @see Secret
* @see Item
*/
abstract public Pair createItem(Map properties, Secret secret, boolean replace);
/**
* Items is a D-Bus Property.
*
* It is managed by using the org.freedesktop.DBus.Properties
interface.
*
* @return Items in this collection.
*/
abstract public List getItems();
/**
* Label is a D-Bus Property.
*
* It is managed by using the org.freedesktop.DBus.Properties
interface.
*
* @return The displayable label of this collection.
*
*
* Note:
* The displayable label
can differ from the actual name
of a collection.
*
*/
abstract public String getLabel();
/**
* Label is a D-Bus Property.
*
* It is managed by using the org.freedesktop.DBus.Properties
interface.
*
* @param label The displayable label of this collection.
*
*
* Note:
* The displayable label
can differ from the actual name
of a collection.
*
*/
abstract public void setLabel(String label);
/**
* @return Whether the collection is locked and must be authenticated by the client application.
*/
abstract public boolean isLocked();
/**
* @return The unix time when the collection was created.
*/
abstract public UInt64 created();
/**
* @return The unix time when the collection was last modified.
*/
abstract public UInt64 modified();
}