[#556] morph/neofsid: Implement key management on client wrapper

Implement method `ClientWrapper.ManageKeys` method which provides the
interface to add/remove keys to/from NeoFS account.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
remotes/KirillovDenis/release/v0.21.1
Leonard Lyubich 2021-05-31 20:44:23 +03:00 committed by Alex Vanin
parent 4713e6b2b8
commit 55c83454b6
1 changed files with 30 additions and 0 deletions

View File

@ -36,3 +36,33 @@ func (x *ClientWrapper) AccountKeys(id *owner.ID) (keys.PublicKeys, error) {
return ks, nil
}
// ManageKeys adds/removes list of public keys to/from NeoFS account.
func (x *ClientWrapper) ManageKeys(ownerID []byte, ks [][]byte, add bool) error {
type args interface {
SetOwnerID([]byte)
SetKeys([][]byte)
}
var (
a args
call func(args) error
)
if add {
a = new(neofsid.AddKeysArgs)
call = func(a args) error {
return (*neofsid.Client)(x).AddKeys(*a.(*neofsid.AddKeysArgs))
}
} else {
a = new(neofsid.RemoveKeysArgs)
call = func(a args) error {
return (*neofsid.Client)(x).RemoveKeys(*a.(*neofsid.RemoveKeysArgs))
}
}
a.SetOwnerID(ownerID)
a.SetKeys(ks)
return call(a)
}