[#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>
This commit is contained in:
parent
4713e6b2b8
commit
55c83454b6
1 changed files with 30 additions and 0 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue