|
| 1 | +package org.purejava.secret.interfaces; |
| 2 | + |
| 3 | +import org.freedesktop.dbus.DBusPath; |
| 4 | +import org.freedesktop.dbus.annotations.DBusInterfaceName; |
| 5 | +import org.freedesktop.dbus.exceptions.DBusException; |
| 6 | +import org.freedesktop.dbus.interfaces.DBusInterface; |
| 7 | +import org.freedesktop.dbus.messages.DBusSignal; |
| 8 | +import org.freedesktop.dbus.types.UInt64; |
| 9 | +import org.freedesktop.dbus.types.Variant; |
| 10 | + |
| 11 | +import java.util.List; |
| 12 | +import java.util.Map; |
| 13 | + |
| 14 | +@DBusInterfaceName("org.freedesktop.Secret.Collection") |
| 15 | +public interface Collection extends DBusInterface { |
| 16 | + |
| 17 | + class ItemCreated extends DBusSignal { |
| 18 | + public final DBusPath item; |
| 19 | + |
| 20 | + /** |
| 21 | + * A new item in this collection was created. |
| 22 | + * |
| 23 | + * @param path The path to the object this is emitted from. |
| 24 | + * @param item The item that was created. |
| 25 | + * @throws DBusException Could not communicate properly with the D-Bus. |
| 26 | + */ |
| 27 | + public ItemCreated(String path, DBusPath item) throws DBusException { |
| 28 | + super(path, item); |
| 29 | + this.item = item; |
| 30 | + } |
| 31 | + } |
| 32 | + |
| 33 | + class ItemDeleted extends DBusSignal { |
| 34 | + public final DBusPath item; |
| 35 | + |
| 36 | + /** |
| 37 | + * An item in this collection was deleted. |
| 38 | + * |
| 39 | + * @param path The path to the object this is emitted from. |
| 40 | + * @param item The item that was deleted. |
| 41 | + * @throws DBusException Could not communicate properly with the D-Bus. |
| 42 | + */ |
| 43 | + public ItemDeleted(String path, DBusPath item) throws DBusException { |
| 44 | + super(path, item); |
| 45 | + this.item = item; |
| 46 | + } |
| 47 | + } |
| 48 | + |
| 49 | + class ItemChanged extends DBusSignal { |
| 50 | + public final DBusPath item; |
| 51 | + |
| 52 | + /** |
| 53 | + * An item in this collection changed. |
| 54 | + * |
| 55 | + * @param path The path to the object this is emitted from. |
| 56 | + * @param item The item that was changed. |
| 57 | + * @throws DBusException Could not communicate properly with the D-Bus. |
| 58 | + */ |
| 59 | + public ItemChanged(String path, DBusPath item) throws DBusException { |
| 60 | + super(path, item); |
| 61 | + this.item = item; |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | + /** |
| 66 | + * Delete this collection. |
| 67 | + * |
| 68 | + * @return prompt — A prompt to delete the collection, or the special value '/' when no prompt is necessary. |
| 69 | + * @see DBusPath |
| 70 | + */ |
| 71 | + DBusPath delete(); |
| 72 | + |
| 73 | + /** |
| 74 | + * Search for items in this collection matching the lookup attributes. |
| 75 | + * |
| 76 | + * @param attributes Attributes to match. |
| 77 | + * @return results — Items that matched the attributes. |
| 78 | + * @see DBusPath |
| 79 | + */ |
| 80 | + List<DBusPath> searchItems(Map<String, String> attributes); |
| 81 | + |
| 82 | + /** |
| 83 | + * Create an item with the given attributes, secret and label. If replace is set, then it replaces an item already |
| 84 | + * present with the same values for the attributes. |
| 85 | + * |
| 86 | + * @param properties The properties for the new item. |
| 87 | + * |
| 88 | + * <p>This allows setting the new item's properties upon its creation. All READWRITE properties |
| 89 | + * are useable. Specify the property names in full <code>interface.Property</code> form.</p> |
| 90 | + * |
| 91 | + * <p> |
| 92 | + * <b>Example 13.2. Example for properties of an item:</b><br> |
| 93 | + * <code> |
| 94 | + * properties = {<br> |
| 95 | + * "org.freedesktop.Secret.Item.Label": "MyItem",<br> |
| 96 | + * "org.freedesktop.Secret.Item.Attributes": {<br> |
| 97 | + * "Attribute1": "Value1",<br> |
| 98 | + * "Attribute2": "Value2"<br> |
| 99 | + * }<br> |
| 100 | + * }<br> |
| 101 | + * </code></p> |
| 102 | + * |
| 103 | + * <p> |
| 104 | + * <b>Note:</b> |
| 105 | + * Please note that there is a distinction between the terms <i>Property</i>, which refers |
| 106 | + * to D-Bus properties of an object, and <i>Attribute</i>, which refers to one of a |
| 107 | + * secret item's string-valued attributes. |
| 108 | + * </p> |
| 109 | + * |
| 110 | + * @param secret The secret to store in the item, encoded with the included session. |
| 111 | + * @param replace Whether to replace an item with the same attributes or not. |
| 112 | + * @return Pair<item, prompt><br> |
| 113 | + * <br> |
| 114 | + * item — The item created, or the special value '/' if a prompt is necessary.<br> |
| 115 | + * <br> |
| 116 | + * prompt — A prompt object, or the special value '/' if no prompt is necessary.<br> |
| 117 | + * @see DBusPath |
| 118 | + */ |
| 119 | + Pair<DBusPath, DBusPath> createItem(Map<String, Variant<?>> properties, Secret secret, boolean replace); |
| 120 | + |
| 121 | + /** |
| 122 | + * <p>It is accessed using the <code>org.freedesktop.DBus.Properties</code> interface.</p> |
| 123 | + * @return Items in this collection. |
| 124 | + */ |
| 125 | + List<DBusPath> items(); |
| 126 | + |
| 127 | + /** |
| 128 | + * <p>It is accessed using the <code>org.freedesktop.DBus.Properties</code> interface.</p> |
| 129 | + * @return The displayable label of this collection. |
| 130 | + */ |
| 131 | + String label(); |
| 132 | + |
| 133 | + /** |
| 134 | + * <p>It is accessed using the <code>org.freedesktop.DBus.Properties</code> interface.</p> |
| 135 | + * @return Whether the collection is locked and must be authenticated by the client application. |
| 136 | + */ |
| 137 | + boolean locked(); |
| 138 | + |
| 139 | + /** |
| 140 | + * <p>It is accessed using the <code>org.freedesktop.DBus.Properties</code> interface.</p> |
| 141 | + * @return The unix time when the collection was created. |
| 142 | + */ |
| 143 | + UInt64 created(); |
| 144 | + |
| 145 | + /** |
| 146 | + * <p>It is accessed using the <code>org.freedesktop.DBus.Properties</code> interface.</p> |
| 147 | + * @return The unix time when the collection was last modified. |
| 148 | + */ |
| 149 | + UInt64 modified(); |
| 150 | + |
| 151 | +} |
0 commit comments