|
@@ -7,9 +7,10 @@ import (
|
|
|
"time"
|
|
|
|
|
|
"github.com/godbus/dbus/v5"
|
|
|
+ "github.com/godbus/dbus/v5/introspect"
|
|
|
)
|
|
|
|
|
|
-const DEFAULT_COLLECTION = "/org/freedesktop/secrets/aliases/default"
|
|
|
+const DEFAULT_COLLECTION = "/org/freedesktop/secrets/collections/default"
|
|
|
|
|
|
type Cache struct {
|
|
|
Collections map[dbus.ObjectPath]Collection
|
|
@@ -30,7 +31,7 @@ type Service struct {
|
|
|
|
|
|
// implementing method to read the object property
|
|
|
func (s *Service) Get(iface, property string) (dbus.Variant, *dbus.Error) {
|
|
|
- if iface != "org/freedesktop/secret/service" {
|
|
|
+ if iface != "/org/freedesktop/secrets/service" {
|
|
|
return dbus.Variant{}, dbus.MakeFailedError(dbus.ErrMsgUnknownInterface)
|
|
|
}
|
|
|
switch property {
|
|
@@ -43,7 +44,7 @@ func (s *Service) Get(iface, property string) (dbus.Variant, *dbus.Error) {
|
|
|
|
|
|
// implementing method to read the object property
|
|
|
func (s *Service) Set(iface, property string, value dbus.Variant) *dbus.Error {
|
|
|
- if iface != "org/freedesktop/secret/service" {
|
|
|
+ if iface != "/org/freedesktop/secrets/service" {
|
|
|
return dbus.MakeFailedError(dbus.ErrMsgUnknownInterface)
|
|
|
}
|
|
|
switch property {
|
|
@@ -62,7 +63,7 @@ func (s *Service) Set(iface, property string, value dbus.Variant) *dbus.Error {
|
|
|
|
|
|
// implementing the get all method for the dbus interface
|
|
|
func (s *Service) GetAll(iface string) (map[string]dbus.Variant, *dbus.Error) {
|
|
|
- if iface != "org.freedesktop.secret.Service" {
|
|
|
+ if iface != "/org/freedesktop/secrets/service" {
|
|
|
return nil, dbus.MakeFailedError(dbus.ErrMsgUnknownInterface)
|
|
|
}
|
|
|
|
|
@@ -143,6 +144,7 @@ Creates a collection with the Service object
|
|
|
:param alias: the shortname of the collection
|
|
|
*/
|
|
|
func (s *Service) CreateCollection(properties map[string]dbus.Variant, alias string) (dbus.ObjectPath, dbus.ObjectPath, *dbus.Error) {
|
|
|
+ fmt.Printf("CreateCollection called with: %+v (alias: %s)\n", properties, alias)
|
|
|
collPath := dbus.ObjectPath(path.Join(s.CollectionBase, strconv.Itoa(s.PathCount+1)))
|
|
|
s.Collections = append(s.Collections, collPath)
|
|
|
s.PathCount = s.PathCount + 1
|
|
@@ -222,3 +224,113 @@ func (s *Service) SetAlias(name string, collection dbus.ObjectPath) *dbus.Error
|
|
|
return nil
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+var ServiceNode = introspect.Node{
|
|
|
+ Interfaces: []introspect.Interface{
|
|
|
+ {
|
|
|
+ Name: "org.freedesktop.Secret.Service",
|
|
|
+ Methods: []introspect.Method{
|
|
|
+ {
|
|
|
+ Name: "OpenSession",
|
|
|
+ Args: []introspect.Arg{
|
|
|
+ {Name: "algorithm", Type: "s", Direction: "in"},
|
|
|
+ {Name: "input", Type: "v", Direction: "in"},
|
|
|
+ {Name: "output", Type: "(sv)", Direction: "out"},
|
|
|
+ {Name: "session_path", Type: "o", Direction: "out"},
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Name: "CreateCollection",
|
|
|
+ Args: []introspect.Arg{
|
|
|
+ {Name: "properties", Type: "a{sv}", Direction: "in"},
|
|
|
+ {Name: "alias", Type: "s", Direction: "in"},
|
|
|
+ {Name: "collection", Type: "o", Direction: "out"},
|
|
|
+ {Name: "prompt", Type: "o", Direction: "out"},
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Name: "SearchItems",
|
|
|
+ Args: []introspect.Arg{
|
|
|
+ {Name: "attributes", Type: "a{ss}", Direction: "in"},
|
|
|
+ {Name: "locked", Type: "ao", Direction: "out"},
|
|
|
+ {Name: "unlocked", Type: "ao", Direction: "out"},
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Name: "Unlock",
|
|
|
+ Args: []introspect.Arg{
|
|
|
+ {Name: "objects", Type: "ao", Direction: "in"},
|
|
|
+ {Name: "unlocked", Type: "ao", Direction: "out"},
|
|
|
+ {Name: "prompt", Type: "o", Direction: "out"},
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Name: "Lock",
|
|
|
+ Args: []introspect.Arg{
|
|
|
+ {Name: "objects", Type: "ao", Direction: "in"},
|
|
|
+ {Name: "locked", Type: "ao", Direction: "out"},
|
|
|
+ {Name: "prompt", Type: "o", Direction: "out"},
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Name: "GetSecrets",
|
|
|
+ Args: []introspect.Arg{
|
|
|
+ {Name: "items", Type: "ao", Direction: "in"},
|
|
|
+ {Name: "session", Type: "o", Direction: "in"},
|
|
|
+ {Name: "secrets", Type: "a{oa(yays)}", Direction: "out"},
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Name: "ReadAlias",
|
|
|
+ Args: []introspect.Arg{
|
|
|
+ {Name: "name", Type: "s", Direction: "in"},
|
|
|
+ {Name: "collection", Type: "o", Direction: "out"},
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Name: "SetAlias",
|
|
|
+ Args: []introspect.Arg{
|
|
|
+ {Name: "name", Type: "s", Direction: "in"},
|
|
|
+ {Name: "collection", Type: "o", Direction: "in"},
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ Properties: []introspect.Property{
|
|
|
+ {
|
|
|
+ Name: "Collections",
|
|
|
+ Type: "ao",
|
|
|
+ Access: "read",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Name: "org.freedesktop.DBus.Properties",
|
|
|
+ Methods: []introspect.Method{
|
|
|
+ {
|
|
|
+ Name: "Get",
|
|
|
+ Args: []introspect.Arg{
|
|
|
+ {Name: "interface_name", Type: "s", Direction: "in"},
|
|
|
+ {Name: "property_name", Type: "s", Direction: "in"},
|
|
|
+ {Name: "value", Type: "v", Direction: "out"},
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Name: "Set",
|
|
|
+ Args: []introspect.Arg{
|
|
|
+ {Name: "interface_name", Type: "s", Direction: "in"},
|
|
|
+ {Name: "property_name", Type: "s", Direction: "in"},
|
|
|
+ {Name: "value", Type: "v", Direction: "in"},
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ Name: "GetAll",
|
|
|
+ Args: []introspect.Arg{
|
|
|
+ {Name: "interface_name", Type: "s", Direction: "in"},
|
|
|
+ {Name: "props", Type: "a{sv}", Direction: "out"},
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ introspect.IntrospectData,
|
|
|
+ },
|
|
|
+}
|