collection.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package keychainlinker
  2. import "github.com/godbus/dbus/v5"
  3. type Collection struct {
  4. /*
  5. Implying the org.freedesktop.Secret.Collection interface as per the v0.2 spec:
  6. https://specifications.freedesktop.org/secret-service-spec/latest-single/#org.freedesktop.Secret.Collection
  7. */
  8. Items []dbus.ObjectPath // items in the collection
  9. Private string // specifies whether the collection is private or not
  10. Label string // The displayable label of this collection.
  11. Locked string // Whether the collection is locked and must be authenticated by the client application.
  12. Created uint64 // The unix time when the collection was created.
  13. Modified uint64 // The unix time when the collection was last modified.
  14. }
  15. // deletes the collection, returning an object path tied to a prompt incase it is necessary.
  16. func (c *Collection) Delete() (dbus.ObjectPath, *dbus.Error) {
  17. return dbus.ObjectPath("prompt"), nil
  18. }
  19. /*
  20. Searches the collection for matching items
  21. :param attr: the attributes to attempt to match to a key in the collection
  22. */
  23. func (c *Collection) SearchItems(attr map[string]string) ([]dbus.ObjectPath, *dbus.Error) {
  24. // implement a recursive searching thing
  25. return []dbus.ObjectPath{}, nil
  26. }
  27. /*
  28. Creates a new item in the collection with the properties defined in 'props'.
  29. Returns the items dbus object path, as well as a path to a dbus prompt incase it is required to edit
  30. :param fields: a map of properties to assign to the item. Will be used to match during lookups
  31. :param secret: the secret to encode into the collection
  32. :param replace: replace secret if a matching one is found in the store
  33. */
  34. func (c *Collection) CreateItem(fields map[string]dbus.Variant, secret SecretStruct, replace bool) (dbus.ObjectPath, dbus.ObjectPath, *dbus.Error) {
  35. return dbus.ObjectPath("/"), dbus.ObjectPath("/"), nil
  36. }