From 7ca6f601ef5d42b2058cdcbf148c08a918bb0f64 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 25 May 2021 19:35:41 +0300 Subject: [PATCH] [#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 --- pkg/morph/client/container/eacl.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/morph/client/container/eacl.go b/pkg/morph/client/container/eacl.go index fad12768e3..4ec76d394d 100644 --- a/pkg/morph/client/container/eacl.go +++ b/pkg/morph/client/container/eacl.go @@ -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 }