2020-08-17 14:01:53 +00:00
|
|
|
package session
|
|
|
|
|
|
|
|
import (
|
2023-03-07 10:38:56 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/acl"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/status"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/proto"
|
2020-08-17 14:01:53 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type CreateRequestBody struct {
|
|
|
|
ownerID *refs.OwnerID
|
|
|
|
|
2020-08-20 10:32:02 +00:00
|
|
|
expiration uint64
|
2020-08-17 14:01:53 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
type CreateRequest struct {
|
|
|
|
body *CreateRequestBody
|
|
|
|
|
|
|
|
RequestHeaders
|
|
|
|
}
|
|
|
|
|
2020-08-17 14:01:53 +00:00
|
|
|
type CreateResponseBody struct {
|
|
|
|
id []byte
|
|
|
|
|
|
|
|
sessionKey []byte
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
type CreateResponse struct {
|
|
|
|
body *CreateResponseBody
|
|
|
|
|
|
|
|
ResponseHeaders
|
|
|
|
}
|
|
|
|
|
2020-08-20 10:32:02 +00:00
|
|
|
type XHeader struct {
|
|
|
|
key, val string
|
|
|
|
}
|
|
|
|
|
|
|
|
type TokenLifetime struct {
|
|
|
|
exp, nbf, iat uint64
|
|
|
|
}
|
|
|
|
|
|
|
|
type ObjectSessionVerb uint32
|
|
|
|
|
2022-09-16 15:09:25 +00:00
|
|
|
type objectSessionContextTarget struct {
|
|
|
|
cnr *refs.ContainerID
|
|
|
|
|
|
|
|
objs []refs.ObjectID
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
_ = iota
|
|
|
|
fNumObjectTargetContainer
|
|
|
|
fNumObjectTargetObjects
|
|
|
|
)
|
|
|
|
|
|
|
|
func (x objectSessionContextTarget) StableMarshal(buf []byte) []byte {
|
|
|
|
if buf == nil {
|
|
|
|
buf = make([]byte, x.StableSize())
|
|
|
|
}
|
|
|
|
|
|
|
|
offset := proto.NestedStructureMarshal(fNumObjectTargetContainer, buf, x.cnr)
|
|
|
|
|
|
|
|
for i := range x.objs {
|
|
|
|
offset += proto.NestedStructureMarshal(fNumObjectTargetObjects, buf[offset:], &x.objs[i])
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x objectSessionContextTarget) StableSize() (size int) {
|
|
|
|
size += proto.NestedStructureSize(fNumObjectTargetContainer, x.cnr)
|
|
|
|
|
|
|
|
for i := range x.objs {
|
|
|
|
size += proto.NestedStructureSize(fNumObjectTargetObjects, &x.objs[i])
|
|
|
|
}
|
|
|
|
|
|
|
|
return size
|
|
|
|
}
|
|
|
|
|
2020-08-20 10:32:02 +00:00
|
|
|
type ObjectSessionContext struct {
|
|
|
|
verb ObjectSessionVerb
|
|
|
|
|
2022-09-16 15:09:25 +00:00
|
|
|
cnr *refs.ContainerID
|
|
|
|
|
|
|
|
objs []refs.ObjectID
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
type TokenContext interface {
|
2020-08-20 10:32:02 +00:00
|
|
|
sessionTokenContext()
|
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
// Deprecated: use TokenContext instead.
|
2022-09-15 05:20:13 +00:00
|
|
|
//
|
2022-02-25 07:36:46 +00:00
|
|
|
//nolint:revive
|
|
|
|
type SessionTokenContext = TokenContext
|
|
|
|
|
|
|
|
type TokenBody struct {
|
2020-08-20 10:32:02 +00:00
|
|
|
id []byte
|
|
|
|
|
|
|
|
ownerID *refs.OwnerID
|
|
|
|
|
|
|
|
lifetime *TokenLifetime
|
|
|
|
|
|
|
|
sessionKey []byte
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
ctx TokenContext
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
// Deprecated: use TokenBody instead.
|
2022-09-15 05:20:13 +00:00
|
|
|
//
|
2022-02-25 07:36:46 +00:00
|
|
|
//nolint:revive
|
|
|
|
type SessionTokenBody = TokenBody
|
|
|
|
|
|
|
|
type Token struct {
|
|
|
|
body *TokenBody
|
2020-08-20 10:32:02 +00:00
|
|
|
|
|
|
|
sig *refs.Signature
|
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
// Deprecated: use Token instead.
|
2022-09-15 05:20:13 +00:00
|
|
|
//
|
2022-02-25 07:36:46 +00:00
|
|
|
//nolint:revive
|
|
|
|
type SessionToken = Token
|
|
|
|
|
2020-08-20 10:32:02 +00:00
|
|
|
type RequestVerificationHeader struct {
|
|
|
|
bodySig, metaSig, originSig *refs.Signature
|
|
|
|
|
|
|
|
origin *RequestVerificationHeader
|
|
|
|
}
|
|
|
|
|
|
|
|
type RequestMetaHeader struct {
|
|
|
|
version *refs.Version
|
|
|
|
|
|
|
|
ttl uint32
|
|
|
|
|
|
|
|
epoch uint64
|
|
|
|
|
2022-03-02 08:01:03 +00:00
|
|
|
xHeaders []XHeader
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
sessionToken *Token
|
2020-08-20 10:32:02 +00:00
|
|
|
|
|
|
|
bearerToken *acl.BearerToken
|
|
|
|
|
|
|
|
origin *RequestMetaHeader
|
2022-01-13 12:25:03 +00:00
|
|
|
|
|
|
|
netMagic uint64
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type ResponseVerificationHeader struct {
|
|
|
|
bodySig, metaSig, originSig *refs.Signature
|
|
|
|
|
|
|
|
origin *ResponseVerificationHeader
|
|
|
|
}
|
|
|
|
|
|
|
|
type ResponseMetaHeader struct {
|
|
|
|
version *refs.Version
|
|
|
|
|
|
|
|
ttl uint32
|
|
|
|
|
|
|
|
epoch uint64
|
|
|
|
|
2022-03-02 08:01:03 +00:00
|
|
|
xHeaders []XHeader
|
2020-08-20 10:32:02 +00:00
|
|
|
|
|
|
|
origin *ResponseMetaHeader
|
2021-11-06 10:40:15 +00:00
|
|
|
|
|
|
|
status *status.Status
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
ObjectVerbUnknown ObjectSessionVerb = iota
|
|
|
|
ObjectVerbPut
|
|
|
|
ObjectVerbGet
|
|
|
|
ObjectVerbHead
|
|
|
|
ObjectVerbSearch
|
|
|
|
ObjectVerbDelete
|
|
|
|
ObjectVerbRange
|
|
|
|
ObjectVerbRangeHash
|
|
|
|
)
|
|
|
|
|
2020-08-17 14:01:53 +00:00
|
|
|
func (c *CreateRequestBody) GetOwnerID() *refs.OwnerID {
|
|
|
|
if c != nil {
|
|
|
|
return c.ownerID
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *CreateRequestBody) SetOwnerID(v *refs.OwnerID) {
|
2022-03-23 11:42:57 +00:00
|
|
|
c.ownerID = v
|
2020-08-17 14:01:53 +00:00
|
|
|
}
|
|
|
|
|
2020-08-20 10:32:02 +00:00
|
|
|
func (c *CreateRequestBody) GetExpiration() uint64 {
|
2020-08-17 14:01:53 +00:00
|
|
|
if c != nil {
|
2020-08-20 10:32:02 +00:00
|
|
|
return c.expiration
|
2020-08-17 14:01:53 +00:00
|
|
|
}
|
|
|
|
|
2020-08-20 10:32:02 +00:00
|
|
|
return 0
|
2020-08-17 14:01:53 +00:00
|
|
|
}
|
|
|
|
|
2020-08-20 10:32:02 +00:00
|
|
|
func (c *CreateRequestBody) SetExpiration(v uint64) {
|
2022-03-23 11:42:57 +00:00
|
|
|
c.expiration = v
|
2020-08-17 14:01:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *CreateRequest) GetBody() *CreateRequestBody {
|
|
|
|
if c != nil {
|
|
|
|
return c.body
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *CreateRequest) SetBody(v *CreateRequestBody) {
|
2022-03-23 11:42:57 +00:00
|
|
|
c.body = v
|
2020-08-17 14:01:53 +00:00
|
|
|
}
|
|
|
|
|
2020-08-20 10:32:02 +00:00
|
|
|
func (c *CreateRequest) GetMetaHeader() *RequestMetaHeader {
|
2020-08-17 14:01:53 +00:00
|
|
|
if c != nil {
|
|
|
|
return c.metaHeader
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-08-20 10:32:02 +00:00
|
|
|
func (c *CreateRequest) SetMetaHeader(v *RequestMetaHeader) {
|
2022-03-23 11:42:57 +00:00
|
|
|
c.metaHeader = v
|
2020-08-17 14:01:53 +00:00
|
|
|
}
|
|
|
|
|
2020-08-20 10:32:02 +00:00
|
|
|
func (c *CreateRequest) GetVerificationHeader() *RequestVerificationHeader {
|
2020-08-17 14:01:53 +00:00
|
|
|
if c != nil {
|
|
|
|
return c.verifyHeader
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-08-20 10:32:02 +00:00
|
|
|
func (c *CreateRequest) SetVerificationHeader(v *RequestVerificationHeader) {
|
2022-03-23 11:42:57 +00:00
|
|
|
c.verifyHeader = v
|
2020-08-17 14:01:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *CreateResponseBody) GetID() []byte {
|
|
|
|
if c != nil {
|
|
|
|
return c.id
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *CreateResponseBody) SetID(v []byte) {
|
2022-03-23 11:42:57 +00:00
|
|
|
c.id = v
|
2020-08-17 14:01:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *CreateResponseBody) GetSessionKey() []byte {
|
|
|
|
if c != nil {
|
|
|
|
return c.sessionKey
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *CreateResponseBody) SetSessionKey(v []byte) {
|
2022-03-23 11:42:57 +00:00
|
|
|
c.sessionKey = v
|
2020-08-17 14:01:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *CreateResponse) GetBody() *CreateResponseBody {
|
|
|
|
if c != nil {
|
|
|
|
return c.body
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *CreateResponse) SetBody(v *CreateResponseBody) {
|
2022-03-23 11:42:57 +00:00
|
|
|
c.body = v
|
2020-08-17 14:01:53 +00:00
|
|
|
}
|
|
|
|
|
2020-08-20 10:32:02 +00:00
|
|
|
func (c *CreateResponse) GetMetaHeader() *ResponseMetaHeader {
|
2020-08-17 14:01:53 +00:00
|
|
|
if c != nil {
|
|
|
|
return c.metaHeader
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-08-20 10:32:02 +00:00
|
|
|
func (c *CreateResponse) SetMetaHeader(v *ResponseMetaHeader) {
|
2022-03-23 11:42:57 +00:00
|
|
|
c.metaHeader = v
|
2020-08-17 14:01:53 +00:00
|
|
|
}
|
|
|
|
|
2020-08-20 10:32:02 +00:00
|
|
|
func (c *CreateResponse) GetVerificationHeader() *ResponseVerificationHeader {
|
2020-08-17 14:01:53 +00:00
|
|
|
if c != nil {
|
|
|
|
return c.verifyHeader
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-08-20 10:32:02 +00:00
|
|
|
func (c *CreateResponse) SetVerificationHeader(v *ResponseVerificationHeader) {
|
2022-03-23 11:42:57 +00:00
|
|
|
c.verifyHeader = v
|
2020-08-17 14:01:53 +00:00
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
|
|
|
func (x *XHeader) GetKey() string {
|
|
|
|
if x != nil {
|
|
|
|
return x.key
|
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *XHeader) SetKey(v string) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.key = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (x *XHeader) GetValue() string {
|
|
|
|
if x != nil {
|
|
|
|
return x.val
|
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *XHeader) SetValue(v string) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.val = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RequestVerificationHeader) GetBodySignature() *refs.Signature {
|
|
|
|
if r != nil {
|
|
|
|
return r.bodySig
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RequestVerificationHeader) SetBodySignature(v *refs.Signature) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.bodySig = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RequestVerificationHeader) GetMetaSignature() *refs.Signature {
|
|
|
|
if r != nil {
|
|
|
|
return r.metaSig
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RequestVerificationHeader) SetMetaSignature(v *refs.Signature) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.metaSig = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RequestVerificationHeader) GetOriginSignature() *refs.Signature {
|
|
|
|
if r != nil {
|
|
|
|
return r.originSig
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RequestVerificationHeader) SetOriginSignature(v *refs.Signature) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.originSig = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RequestVerificationHeader) GetOrigin() *RequestVerificationHeader {
|
|
|
|
if r != nil {
|
|
|
|
return r.origin
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RequestVerificationHeader) SetOrigin(v *RequestVerificationHeader) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.origin = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RequestMetaHeader) GetVersion() *refs.Version {
|
|
|
|
if r != nil {
|
|
|
|
return r.version
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RequestMetaHeader) SetVersion(v *refs.Version) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.version = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RequestMetaHeader) GetTTL() uint32 {
|
|
|
|
if r != nil {
|
|
|
|
return r.ttl
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RequestMetaHeader) SetTTL(v uint32) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.ttl = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RequestMetaHeader) GetEpoch() uint64 {
|
|
|
|
if r != nil {
|
|
|
|
return r.epoch
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RequestMetaHeader) SetEpoch(v uint64) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.epoch = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2022-03-02 08:01:03 +00:00
|
|
|
func (r *RequestMetaHeader) GetXHeaders() []XHeader {
|
2020-08-20 10:32:02 +00:00
|
|
|
if r != nil {
|
|
|
|
return r.xHeaders
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-03-02 08:01:03 +00:00
|
|
|
func (r *RequestMetaHeader) SetXHeaders(v []XHeader) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.xHeaders = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (r *RequestMetaHeader) GetSessionToken() *Token {
|
2020-08-20 10:32:02 +00:00
|
|
|
if r != nil {
|
|
|
|
return r.sessionToken
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (r *RequestMetaHeader) SetSessionToken(v *Token) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.sessionToken = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RequestMetaHeader) GetBearerToken() *acl.BearerToken {
|
|
|
|
if r != nil {
|
|
|
|
return r.bearerToken
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RequestMetaHeader) SetBearerToken(v *acl.BearerToken) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.bearerToken = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RequestMetaHeader) GetOrigin() *RequestMetaHeader {
|
|
|
|
if r != nil {
|
|
|
|
return r.origin
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RequestMetaHeader) SetOrigin(v *RequestMetaHeader) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.origin = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2022-01-13 12:25:03 +00:00
|
|
|
// GetNetworkMagic returns NeoFS network magic.
|
|
|
|
func (r *RequestMetaHeader) GetNetworkMagic() uint64 {
|
|
|
|
if r != nil {
|
|
|
|
return r.netMagic
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNetworkMagic sets NeoFS network magic.
|
|
|
|
func (r *RequestMetaHeader) SetNetworkMagic(v uint64) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.netMagic = v
|
2022-01-13 12:25:03 +00:00
|
|
|
}
|
|
|
|
|
2020-08-20 10:32:02 +00:00
|
|
|
func (l *TokenLifetime) GetExp() uint64 {
|
|
|
|
if l != nil {
|
|
|
|
return l.exp
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *TokenLifetime) SetExp(v uint64) {
|
2022-03-23 11:42:57 +00:00
|
|
|
l.exp = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (l *TokenLifetime) GetNbf() uint64 {
|
|
|
|
if l != nil {
|
|
|
|
return l.nbf
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *TokenLifetime) SetNbf(v uint64) {
|
2022-03-23 11:42:57 +00:00
|
|
|
l.nbf = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (l *TokenLifetime) GetIat() uint64 {
|
|
|
|
if l != nil {
|
|
|
|
return l.iat
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *TokenLifetime) SetIat(v uint64) {
|
2022-03-23 11:42:57 +00:00
|
|
|
l.iat = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ResponseVerificationHeader) GetBodySignature() *refs.Signature {
|
|
|
|
if r != nil {
|
|
|
|
return r.bodySig
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ResponseVerificationHeader) SetBodySignature(v *refs.Signature) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.bodySig = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ResponseVerificationHeader) GetMetaSignature() *refs.Signature {
|
|
|
|
if r != nil {
|
|
|
|
return r.metaSig
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ResponseVerificationHeader) SetMetaSignature(v *refs.Signature) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.metaSig = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ResponseVerificationHeader) GetOriginSignature() *refs.Signature {
|
|
|
|
if r != nil {
|
|
|
|
return r.originSig
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ResponseVerificationHeader) SetOriginSignature(v *refs.Signature) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.originSig = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ResponseVerificationHeader) GetOrigin() *ResponseVerificationHeader {
|
|
|
|
if r != nil {
|
|
|
|
return r.origin
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ResponseVerificationHeader) SetOrigin(v *ResponseVerificationHeader) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.origin = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ResponseMetaHeader) GetVersion() *refs.Version {
|
|
|
|
if r != nil {
|
|
|
|
return r.version
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ResponseMetaHeader) SetVersion(v *refs.Version) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.version = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ResponseMetaHeader) GetTTL() uint32 {
|
|
|
|
if r != nil {
|
|
|
|
return r.ttl
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ResponseMetaHeader) SetTTL(v uint32) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.ttl = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ResponseMetaHeader) GetEpoch() uint64 {
|
|
|
|
if r != nil {
|
|
|
|
return r.epoch
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ResponseMetaHeader) SetEpoch(v uint64) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.epoch = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2022-03-02 08:01:03 +00:00
|
|
|
func (r *ResponseMetaHeader) GetXHeaders() []XHeader {
|
2020-08-20 10:32:02 +00:00
|
|
|
if r != nil {
|
|
|
|
return r.xHeaders
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-03-02 08:01:03 +00:00
|
|
|
func (r *ResponseMetaHeader) SetXHeaders(v []XHeader) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.xHeaders = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ResponseMetaHeader) GetOrigin() *ResponseMetaHeader {
|
|
|
|
if r != nil {
|
|
|
|
return r.origin
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ResponseMetaHeader) SetOrigin(v *ResponseMetaHeader) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.origin = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2021-11-06 10:40:15 +00:00
|
|
|
// GetStatus returns response status.
|
|
|
|
func (r *ResponseMetaHeader) GetStatus() *status.Status {
|
|
|
|
if r != nil {
|
|
|
|
return r.status
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetStatus sets response status.
|
|
|
|
func (r *ResponseMetaHeader) SetStatus(v *status.Status) {
|
2022-03-23 11:42:57 +00:00
|
|
|
r.status = v
|
2021-11-06 10:40:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetStatus sets status of the message which can carry ResponseMetaHeader.
|
|
|
|
//
|
|
|
|
// Sets status field on the "highest" level of meta headers.
|
|
|
|
// If meta header is missing in message, it is allocated.
|
|
|
|
func SetStatus(msg interface {
|
|
|
|
GetMetaHeader() *ResponseMetaHeader
|
|
|
|
SetMetaHeader(*ResponseMetaHeader)
|
|
|
|
}, st *status.Status) {
|
|
|
|
meta := msg.GetMetaHeader()
|
|
|
|
if meta == nil {
|
|
|
|
meta = new(ResponseMetaHeader)
|
|
|
|
msg.SetMetaHeader(meta)
|
|
|
|
}
|
|
|
|
|
|
|
|
meta.SetStatus(st)
|
|
|
|
}
|
|
|
|
|
2020-08-20 10:32:02 +00:00
|
|
|
func (c *ObjectSessionContext) sessionTokenContext() {}
|
|
|
|
|
|
|
|
func (c *ObjectSessionContext) GetVerb() ObjectSessionVerb {
|
|
|
|
if c != nil {
|
|
|
|
return c.verb
|
|
|
|
}
|
|
|
|
|
|
|
|
return ObjectVerbUnknown
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *ObjectSessionContext) SetVerb(v ObjectSessionVerb) {
|
2022-03-23 11:42:57 +00:00
|
|
|
c.verb = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2022-09-16 15:09:25 +00:00
|
|
|
func (c *ObjectSessionContext) GetContainer() *refs.ContainerID {
|
|
|
|
if c != nil {
|
|
|
|
return c.cnr
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *ObjectSessionContext) GetObjects() []refs.ObjectID {
|
2020-08-20 10:32:02 +00:00
|
|
|
if c != nil {
|
2022-09-16 15:09:25 +00:00
|
|
|
return c.objs
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-09-16 15:09:25 +00:00
|
|
|
func (c *ObjectSessionContext) SetTarget(cnr *refs.ContainerID, objs ...refs.ObjectID) {
|
|
|
|
c.cnr = cnr
|
|
|
|
c.objs = objs
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (t *TokenBody) GetID() []byte {
|
2020-08-20 10:32:02 +00:00
|
|
|
if t != nil {
|
|
|
|
return t.id
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (t *TokenBody) SetID(v []byte) {
|
2022-03-23 11:42:57 +00:00
|
|
|
t.id = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (t *TokenBody) GetOwnerID() *refs.OwnerID {
|
2020-08-20 10:32:02 +00:00
|
|
|
if t != nil {
|
|
|
|
return t.ownerID
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (t *TokenBody) SetOwnerID(v *refs.OwnerID) {
|
2022-03-23 11:42:57 +00:00
|
|
|
t.ownerID = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (t *TokenBody) GetLifetime() *TokenLifetime {
|
2020-08-20 10:32:02 +00:00
|
|
|
if t != nil {
|
|
|
|
return t.lifetime
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (t *TokenBody) SetLifetime(v *TokenLifetime) {
|
2022-03-23 11:42:57 +00:00
|
|
|
t.lifetime = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (t *TokenBody) GetSessionKey() []byte {
|
2020-08-20 10:32:02 +00:00
|
|
|
if t != nil {
|
|
|
|
return t.sessionKey
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (t *TokenBody) SetSessionKey(v []byte) {
|
2022-03-23 11:42:57 +00:00
|
|
|
t.sessionKey = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (t *TokenBody) GetContext() TokenContext {
|
2020-08-20 10:32:02 +00:00
|
|
|
if t != nil {
|
|
|
|
return t.ctx
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (t *TokenBody) SetContext(v TokenContext) {
|
2022-03-23 11:42:57 +00:00
|
|
|
t.ctx = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (t *Token) GetBody() *TokenBody {
|
2020-08-20 10:32:02 +00:00
|
|
|
if t != nil {
|
|
|
|
return t.body
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (t *Token) SetBody(v *TokenBody) {
|
2022-03-23 11:42:57 +00:00
|
|
|
t.body = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (t *Token) GetSignature() *refs.Signature {
|
2020-08-20 10:32:02 +00:00
|
|
|
if t != nil {
|
|
|
|
return t.sig
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-02-25 07:36:46 +00:00
|
|
|
func (t *Token) SetSignature(v *refs.Signature) {
|
2022-03-23 11:42:57 +00:00
|
|
|
t.sig = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
2021-05-24 14:46:39 +00:00
|
|
|
|
|
|
|
// ContainerSessionVerb represents NeoFS API v2
|
|
|
|
// session.ContainerSessionContext.Verb enumeration.
|
|
|
|
type ContainerSessionVerb uint32
|
|
|
|
|
|
|
|
const (
|
|
|
|
// ContainerVerbUnknown corresponds to VERB_UNSPECIFIED enum value.
|
|
|
|
ContainerVerbUnknown ContainerSessionVerb = iota
|
|
|
|
|
|
|
|
// ContainerVerbPut corresponds to PUT enum value.
|
|
|
|
ContainerVerbPut
|
|
|
|
|
|
|
|
// ContainerVerbDelete corresponds to DELETE enum value.
|
|
|
|
ContainerVerbDelete
|
|
|
|
|
|
|
|
// ContainerVerbSetEACL corresponds to SETEACL enum value.
|
|
|
|
ContainerVerbSetEACL
|
|
|
|
)
|
|
|
|
|
|
|
|
// ContainerSessionContext represents structure of the
|
|
|
|
// NeoFS API v2 session.ContainerSessionContext message.
|
|
|
|
type ContainerSessionContext struct {
|
|
|
|
verb ContainerSessionVerb
|
|
|
|
|
|
|
|
wildcard bool
|
|
|
|
|
|
|
|
cid *refs.ContainerID
|
|
|
|
}
|
|
|
|
|
|
|
|
func (x *ContainerSessionContext) sessionTokenContext() {}
|
|
|
|
|
|
|
|
// Verb returns type of request for which the token is issued.
|
|
|
|
func (x *ContainerSessionContext) Verb() ContainerSessionVerb {
|
|
|
|
if x != nil {
|
|
|
|
return x.verb
|
|
|
|
}
|
|
|
|
|
|
|
|
return ContainerVerbUnknown
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetVerb sets type of request for which the token is issued.
|
|
|
|
func (x *ContainerSessionContext) SetVerb(v ContainerSessionVerb) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.verb = v
|
2021-05-24 14:46:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Wildcard returns wildcard flag of the container session.
|
|
|
|
func (x *ContainerSessionContext) Wildcard() bool {
|
|
|
|
if x != nil {
|
|
|
|
return x.wildcard
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetWildcard sets wildcard flag of the container session.
|
|
|
|
func (x *ContainerSessionContext) SetWildcard(v bool) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.wildcard = v
|
2021-05-24 14:46:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ContainerID returns identifier of the container related to the session.
|
|
|
|
func (x *ContainerSessionContext) ContainerID() *refs.ContainerID {
|
|
|
|
if x != nil {
|
|
|
|
return x.cid
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetContainerID sets identifier of the container related to the session.
|
|
|
|
func (x *ContainerSessionContext) SetContainerID(v *refs.ContainerID) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.cid = v
|
2021-05-24 14:46:39 +00:00
|
|
|
}
|