[#525] morph/container: Parse session token, key and signature in EACL

`EACL` method of `Container` contract returns binary session token, key and
signature along with eACL table.

Provide `Signature`, `PublicKey` and `SessionToken` getters from
`EACLValues` structure. Parse and set all values in `Client.EACL` methods.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-05-25 19:35:41 +03:00 committed by Leonard Lyubich
parent 4ef369732a
commit 7ca6f601ef

View file

@ -20,6 +20,8 @@ type EACLValues struct {
signature []byte // RFC-6979 signature of extended ACL table
publicKey []byte // public key of the extended ACL table signer
token []byte // token of the session within which the eACL table was set
}
// SetCID sets the container identifier
@ -44,6 +46,12 @@ func (g *EACLValues) PublicKey() []byte {
return g.publicKey
}
// SessionToken returns token of the session within which
// the eACl table was set in a NeoFS API binary format.
func (g *EACLValues) SessionToken() []byte {
return g.token
}
// EACL performs the test invoke of get eACL
// method of NeoFS Container contract.
func (c *Client) EACL(args EACLArgs) (*EACLValues, error) {
@ -81,9 +89,15 @@ func (c *Client) EACL(args EACLArgs) (*EACLValues, error) {
return nil, fmt.Errorf("could not get byte array of eACL public key (%s): %w", c.eaclMethod, err)
}
tok, err := client.BytesFromStackItem(arr[3])
if err != nil {
return nil, fmt.Errorf("could not get byte array of eACL session token (%s): %w", c.eaclMethod, err)
}
return &EACLValues{
eacl: eacl,
signature: sig,
publicKey: pub,
token: tok,
}, nil
}