Add GetSecrets method to connection

This commit is contained in:
jkirkwood 2019-07-10 15:37:19 -04:00
parent 744dfb200e
commit 2c7e6be272

View file

@ -46,6 +46,12 @@ type Connection interface {
// separately using the GetSecrets() method.
GetSettings() (ConnectionSettings, error)
// Get the secrets belonging to this network configuration. Only secrets from
// persistent storage or a Secret Agent running in the requestor's session
// will be returned. The user will never be prompted for secrets as a result
// of this request.
GetSecrets(settingName string) (ConnectionSettings, error)
// Clear the secrets belonging to this network connection profile.
ClearSecrets() error
@ -110,6 +116,27 @@ func (c *connection) GetSettings() (ConnectionSettings, error) {
return rv, nil
}
func (c *connection) GetSecrets(settingName string) (ConnectionSettings, error) {
var settings map[string]map[string]dbus.Variant
err := c.callWithReturn(&settings, ConnectionGetSecrets, settingName)
if err != nil {
return nil, err
}
rv := make(ConnectionSettings)
for k1, v1 := range settings {
rv[k1] = make(map[string]interface{})
for k2, v2 := range v1 {
rv[k1][k2] = v2.Value()
}
}
return rv, nil
}
func (c *connection) ClearSecrets() error {
return c.call(ConnectionClearSecrets)
}