2020-08-14 16:00:16 +00:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
2020-08-17 13:14:30 +00:00
|
|
|
"fmt"
|
|
|
|
|
2020-08-17 10:04:21 +00:00
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/acl"
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/refs"
|
2020-08-14 16:00:16 +00:00
|
|
|
service "github.com/nspcc-dev/neofs-api-go/v2/service/grpc"
|
|
|
|
)
|
|
|
|
|
|
|
|
func VersionToGRPCMessage(v *Version) *service.Version {
|
|
|
|
if v == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
msg := new(service.Version)
|
|
|
|
|
|
|
|
msg.SetMajor(v.GetMajor())
|
|
|
|
msg.SetMinor(v.GetMinor())
|
|
|
|
|
|
|
|
return msg
|
|
|
|
}
|
|
|
|
|
|
|
|
func VersionFromGRPCMessage(m *service.Version) *Version {
|
|
|
|
if m == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
v := new(Version)
|
|
|
|
|
|
|
|
v.SetMajor(m.GetMajor())
|
|
|
|
v.SetMinor(m.GetMinor())
|
|
|
|
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
func XHeaderToGRPCMessage(x *XHeader) *service.XHeader {
|
|
|
|
if x == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
m := new(service.XHeader)
|
|
|
|
|
|
|
|
m.SetKey(x.GetKey())
|
|
|
|
m.SetValue(x.GetValue())
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func XHeaderFromGRPCMessage(m *service.XHeader) *XHeader {
|
|
|
|
if m == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
x := new(XHeader)
|
|
|
|
|
|
|
|
x.SetKey(m.GetKey())
|
|
|
|
x.SetValue(m.GetValue())
|
|
|
|
|
|
|
|
return x
|
|
|
|
}
|
|
|
|
|
|
|
|
func SessionTokenToGRPCMessage(t *SessionToken) *service.SessionToken {
|
2020-08-17 13:14:30 +00:00
|
|
|
if t == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
m := new(service.SessionToken)
|
|
|
|
|
|
|
|
m.SetBody(
|
|
|
|
SessionTokenBodyToGRPCMessage(t.GetBody()),
|
|
|
|
)
|
|
|
|
|
|
|
|
m.SetSignature(
|
|
|
|
SignatureToGRPCMessage(t.GetSignature()),
|
|
|
|
)
|
|
|
|
|
|
|
|
return m
|
2020-08-14 16:00:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func SessionTokenFromGRPCMessage(m *service.SessionToken) *SessionToken {
|
2020-08-17 13:14:30 +00:00
|
|
|
if m == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
t := new(SessionToken)
|
|
|
|
|
|
|
|
t.SetBody(
|
|
|
|
SessionTokenBodyFromGRPCMessage(m.GetBody()),
|
|
|
|
)
|
|
|
|
|
|
|
|
t.SetSignature(
|
|
|
|
SignatureFromGRPCMessage(m.GetSignature()),
|
|
|
|
)
|
|
|
|
|
|
|
|
return t
|
2020-08-14 16:00:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func BearerTokenToGRPCMessage(t *BearerToken) *service.BearerToken {
|
2020-08-17 10:04:21 +00:00
|
|
|
if t == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
m := new(service.BearerToken)
|
|
|
|
|
|
|
|
m.SetBody(
|
|
|
|
BearerTokenBodyToGRPCMessage(t.GetBody()),
|
|
|
|
)
|
|
|
|
|
|
|
|
m.SetSignature(
|
|
|
|
SignatureToGRPCMessage(t.GetSignature()),
|
|
|
|
)
|
|
|
|
|
|
|
|
return m
|
2020-08-14 16:00:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func BearerTokenFromGRPCMessage(m *service.BearerToken) *BearerToken {
|
2020-08-17 10:04:21 +00:00
|
|
|
if m == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
bt := new(BearerToken)
|
|
|
|
|
|
|
|
bt.SetBody(
|
|
|
|
BearerTokenBodyFromGRPCMessage(m.GetBody()),
|
|
|
|
)
|
|
|
|
|
|
|
|
bt.SetSignature(
|
|
|
|
SignatureFromGRPCMessage(m.GetSignature()),
|
|
|
|
)
|
|
|
|
|
|
|
|
return bt
|
2020-08-14 16:00:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func RequestVerificationHeaderToGRPCMessage(r *RequestVerificationHeader) *service.RequestVerificationHeader {
|
|
|
|
if r == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
m := new(service.RequestVerificationHeader)
|
|
|
|
|
|
|
|
m.SetBodySignature(
|
|
|
|
SignatureToGRPCMessage(r.GetBodySignature()),
|
|
|
|
)
|
|
|
|
|
|
|
|
m.SetMetaSignature(
|
|
|
|
SignatureToGRPCMessage(r.GetMetaSignature()),
|
|
|
|
)
|
|
|
|
|
|
|
|
m.SetOriginSignature(
|
|
|
|
SignatureToGRPCMessage(r.GetOriginSignature()),
|
|
|
|
)
|
|
|
|
|
|
|
|
m.SetOrigin(
|
|
|
|
RequestVerificationHeaderToGRPCMessage(r.GetOrigin()),
|
|
|
|
)
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func RequestVerificationHeaderFromGRPCMessage(m *service.RequestVerificationHeader) *RequestVerificationHeader {
|
|
|
|
if m == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
r := new(RequestVerificationHeader)
|
|
|
|
|
|
|
|
r.SetBodySignature(
|
|
|
|
SignatureFromGRPCMessage(m.GetBodySignature()),
|
|
|
|
)
|
|
|
|
|
|
|
|
r.SetMetaSignature(
|
|
|
|
SignatureFromGRPCMessage(m.GetMetaSignature()),
|
|
|
|
)
|
|
|
|
|
|
|
|
r.SetOriginSignature(
|
|
|
|
SignatureFromGRPCMessage(m.GetOriginSignature()),
|
|
|
|
)
|
|
|
|
|
|
|
|
r.SetOrigin(
|
|
|
|
RequestVerificationHeaderFromGRPCMessage(m.GetOrigin()),
|
|
|
|
)
|
|
|
|
|
|
|
|
return r
|
|
|
|
}
|
|
|
|
|
|
|
|
func RequestMetaHeaderToGRPCMessage(r *RequestMetaHeader) *service.RequestMetaHeader {
|
|
|
|
if r == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
m := new(service.RequestMetaHeader)
|
|
|
|
|
|
|
|
m.SetTtl(r.GetTTL())
|
|
|
|
m.SetEpoch(r.GetEpoch())
|
|
|
|
|
|
|
|
m.SetVersion(
|
|
|
|
VersionToGRPCMessage(r.GetVersion()),
|
|
|
|
)
|
|
|
|
|
|
|
|
m.SetSessionToken(
|
|
|
|
SessionTokenToGRPCMessage(r.GetSessionToken()),
|
|
|
|
)
|
|
|
|
|
|
|
|
m.SetBearerToken(
|
|
|
|
BearerTokenToGRPCMessage(r.GetBearerToken()),
|
|
|
|
)
|
|
|
|
|
|
|
|
m.SetOrigin(
|
|
|
|
RequestMetaHeaderToGRPCMessage(r.GetOrigin()),
|
|
|
|
)
|
|
|
|
|
|
|
|
xHeaders := r.GetXHeaders()
|
|
|
|
xHdrMsg := make([]*service.XHeader, 0, len(xHeaders))
|
|
|
|
|
|
|
|
for i := range xHeaders {
|
|
|
|
xHdrMsg = append(xHdrMsg, XHeaderToGRPCMessage(xHeaders[i]))
|
|
|
|
}
|
|
|
|
|
2020-08-17 17:23:42 +00:00
|
|
|
m.SetXHeaders(xHdrMsg)
|
|
|
|
|
2020-08-14 16:00:16 +00:00
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func RequestMetaHeaderFromGRPCMessage(m *service.RequestMetaHeader) *RequestMetaHeader {
|
|
|
|
if m == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
r := new(RequestMetaHeader)
|
|
|
|
|
|
|
|
r.SetTTL(m.GetTtl())
|
|
|
|
r.SetEpoch(m.GetEpoch())
|
|
|
|
|
|
|
|
r.SetVersion(
|
|
|
|
VersionFromGRPCMessage(m.GetVersion()),
|
|
|
|
)
|
|
|
|
|
|
|
|
r.SetSessionToken(
|
|
|
|
SessionTokenFromGRPCMessage(m.GetSessionToken()),
|
|
|
|
)
|
|
|
|
|
|
|
|
r.SetBearerToken(
|
|
|
|
BearerTokenFromGRPCMessage(m.GetBearerToken()),
|
|
|
|
)
|
|
|
|
|
|
|
|
r.SetOrigin(
|
|
|
|
RequestMetaHeaderFromGRPCMessage(m.GetOrigin()),
|
|
|
|
)
|
|
|
|
|
|
|
|
xHdrMsg := m.GetXHeaders()
|
|
|
|
xHeaders := make([]*XHeader, 0, len(xHdrMsg))
|
|
|
|
|
|
|
|
for i := range xHdrMsg {
|
|
|
|
xHeaders = append(xHeaders, XHeaderFromGRPCMessage(xHdrMsg[i]))
|
|
|
|
}
|
|
|
|
|
2020-08-17 17:23:42 +00:00
|
|
|
r.SetXHeaders(xHeaders)
|
|
|
|
|
2020-08-14 16:00:16 +00:00
|
|
|
return r
|
|
|
|
}
|
2020-08-17 09:34:49 +00:00
|
|
|
|
|
|
|
func SignatureToGRPCMessage(s *Signature) *service.Signature {
|
|
|
|
if s == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
m := new(service.Signature)
|
|
|
|
|
|
|
|
m.SetKey(s.GetKey())
|
|
|
|
m.SetSign(s.GetSign())
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func SignatureFromGRPCMessage(m *service.Signature) *Signature {
|
|
|
|
if m == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
s := new(Signature)
|
|
|
|
|
|
|
|
s.SetKey(m.GetKey())
|
|
|
|
s.SetSign(m.GetSign())
|
|
|
|
|
|
|
|
return s
|
|
|
|
}
|
2020-08-17 10:04:21 +00:00
|
|
|
|
|
|
|
func TokenLifetimeToGRPCMessage(tl *TokenLifetime) *service.TokenLifetime {
|
|
|
|
if tl == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
m := new(service.TokenLifetime)
|
|
|
|
|
|
|
|
m.SetExp(tl.GetExp())
|
|
|
|
m.SetNbf(tl.GetNbf())
|
|
|
|
m.SetIat(tl.GetIat())
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func TokenLifetimeFromGRPCMessage(m *service.TokenLifetime) *TokenLifetime {
|
|
|
|
if m == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
tl := new(TokenLifetime)
|
|
|
|
|
|
|
|
tl.SetExp(m.GetExp())
|
|
|
|
tl.SetNbf(m.GetNbf())
|
|
|
|
tl.SetIat(m.GetIat())
|
|
|
|
|
|
|
|
return tl
|
|
|
|
}
|
|
|
|
|
|
|
|
func BearerTokenBodyToGRPCMessage(v *BearerTokenBody) *service.BearerToken_Body {
|
|
|
|
if v == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
m := new(service.BearerToken_Body)
|
|
|
|
|
|
|
|
m.SetEaclTable(
|
|
|
|
acl.TableToGRPCMessage(v.GetEACL()),
|
|
|
|
)
|
|
|
|
|
|
|
|
m.SetOwnerId(
|
|
|
|
refs.OwnerIDToGRPCMessage(v.GetOwnerID()),
|
|
|
|
)
|
|
|
|
|
|
|
|
m.SetLifetime(
|
|
|
|
TokenLifetimeToGRPCMessage(v.GetLifetime()),
|
|
|
|
)
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func BearerTokenBodyFromGRPCMessage(m *service.BearerToken_Body) *BearerTokenBody {
|
|
|
|
if m == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
bt := new(BearerTokenBody)
|
|
|
|
|
|
|
|
bt.SetEACL(
|
|
|
|
acl.TableFromGRPCMessage(m.GetEaclTable()),
|
|
|
|
)
|
|
|
|
|
|
|
|
bt.SetOwnerID(
|
|
|
|
refs.OwnerIDFromGRPCMessage(m.GetOwnerId()),
|
|
|
|
)
|
|
|
|
|
|
|
|
bt.SetLifetime(
|
|
|
|
TokenLifetimeFromGRPCMessage(m.GetLifetime()),
|
|
|
|
)
|
|
|
|
|
|
|
|
return bt
|
|
|
|
}
|
2020-08-17 10:11:44 +00:00
|
|
|
|
|
|
|
func RequestHeadersToGRPC(
|
|
|
|
src interface {
|
2020-08-17 10:43:17 +00:00
|
|
|
GetMetaHeader() *RequestMetaHeader
|
|
|
|
GetVerificationHeader() *RequestVerificationHeader
|
2020-08-17 10:11:44 +00:00
|
|
|
},
|
|
|
|
dst interface {
|
|
|
|
SetMetaHeader(*service.RequestMetaHeader)
|
|
|
|
SetVerifyHeader(*service.RequestVerificationHeader)
|
|
|
|
},
|
|
|
|
) {
|
|
|
|
dst.SetMetaHeader(
|
2020-08-17 10:43:17 +00:00
|
|
|
RequestMetaHeaderToGRPCMessage(src.GetMetaHeader()),
|
2020-08-17 10:11:44 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
dst.SetVerifyHeader(
|
2020-08-17 10:43:17 +00:00
|
|
|
RequestVerificationHeaderToGRPCMessage(src.GetVerificationHeader()),
|
2020-08-17 10:11:44 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func RequestHeadersFromGRPC(
|
|
|
|
src interface {
|
|
|
|
GetMetaHeader() *service.RequestMetaHeader
|
|
|
|
GetVerifyHeader() *service.RequestVerificationHeader
|
|
|
|
},
|
|
|
|
dst interface {
|
2020-08-17 10:43:17 +00:00
|
|
|
SetMetaHeader(*RequestMetaHeader)
|
|
|
|
SetVerificationHeader(*RequestVerificationHeader)
|
2020-08-17 10:11:44 +00:00
|
|
|
},
|
|
|
|
) {
|
2020-08-17 10:43:17 +00:00
|
|
|
dst.SetMetaHeader(
|
2020-08-17 10:11:44 +00:00
|
|
|
RequestMetaHeaderFromGRPCMessage(src.GetMetaHeader()),
|
|
|
|
)
|
|
|
|
|
2020-08-17 10:43:17 +00:00
|
|
|
dst.SetVerificationHeader(
|
2020-08-17 10:11:44 +00:00
|
|
|
RequestVerificationHeaderFromGRPCMessage(src.GetVerifyHeader()),
|
|
|
|
)
|
|
|
|
}
|
2020-08-17 10:23:41 +00:00
|
|
|
|
|
|
|
func ResponseVerificationHeaderToGRPCMessage(r *ResponseVerificationHeader) *service.ResponseVerificationHeader {
|
|
|
|
if r == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
m := new(service.ResponseVerificationHeader)
|
|
|
|
|
|
|
|
m.SetBodySignature(
|
|
|
|
SignatureToGRPCMessage(r.GetBodySignature()),
|
|
|
|
)
|
|
|
|
|
|
|
|
m.SetMetaSignature(
|
|
|
|
SignatureToGRPCMessage(r.GetMetaSignature()),
|
|
|
|
)
|
|
|
|
|
|
|
|
m.SetOriginSignature(
|
|
|
|
SignatureToGRPCMessage(r.GetOriginSignature()),
|
|
|
|
)
|
|
|
|
|
|
|
|
m.SetOrigin(
|
|
|
|
ResponseVerificationHeaderToGRPCMessage(r.GetOrigin()),
|
|
|
|
)
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func ResponseVerificationHeaderFromGRPCMessage(m *service.ResponseVerificationHeader) *ResponseVerificationHeader {
|
|
|
|
if m == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
r := new(ResponseVerificationHeader)
|
|
|
|
|
|
|
|
r.SetBodySignature(
|
|
|
|
SignatureFromGRPCMessage(m.GetBodySignature()),
|
|
|
|
)
|
|
|
|
|
|
|
|
r.SetMetaSignature(
|
|
|
|
SignatureFromGRPCMessage(m.GetMetaSignature()),
|
|
|
|
)
|
|
|
|
|
|
|
|
r.SetOriginSignature(
|
|
|
|
SignatureFromGRPCMessage(m.GetOriginSignature()),
|
|
|
|
)
|
|
|
|
|
|
|
|
r.SetOrigin(
|
|
|
|
ResponseVerificationHeaderFromGRPCMessage(m.GetOrigin()),
|
|
|
|
)
|
|
|
|
|
|
|
|
return r
|
|
|
|
}
|
|
|
|
|
|
|
|
func ResponseMetaHeaderToGRPCMessage(r *ResponseMetaHeader) *service.ResponseMetaHeader {
|
|
|
|
if r == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
m := new(service.ResponseMetaHeader)
|
|
|
|
|
|
|
|
m.SetTtl(r.GetTTL())
|
|
|
|
m.SetEpoch(r.GetEpoch())
|
|
|
|
|
|
|
|
m.SetVersion(
|
|
|
|
VersionToGRPCMessage(r.GetVersion()),
|
|
|
|
)
|
|
|
|
|
|
|
|
m.SetOrigin(
|
|
|
|
ResponseMetaHeaderToGRPCMessage(r.GetOrigin()),
|
|
|
|
)
|
|
|
|
|
|
|
|
xHeaders := r.GetXHeaders()
|
|
|
|
xHdrMsg := make([]*service.XHeader, 0, len(xHeaders))
|
|
|
|
|
|
|
|
for i := range xHeaders {
|
|
|
|
xHdrMsg = append(xHdrMsg, XHeaderToGRPCMessage(xHeaders[i]))
|
|
|
|
}
|
|
|
|
|
2020-08-17 17:23:42 +00:00
|
|
|
m.SetXHeaders(xHdrMsg)
|
|
|
|
|
2020-08-17 10:23:41 +00:00
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func ResponseMetaHeaderFromGRPCMessage(m *service.ResponseMetaHeader) *ResponseMetaHeader {
|
|
|
|
if m == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
r := new(ResponseMetaHeader)
|
|
|
|
|
|
|
|
r.SetTTL(m.GetTtl())
|
|
|
|
r.SetEpoch(m.GetEpoch())
|
|
|
|
|
|
|
|
r.SetVersion(
|
|
|
|
VersionFromGRPCMessage(m.GetVersion()),
|
|
|
|
)
|
|
|
|
|
|
|
|
r.SetOrigin(
|
|
|
|
ResponseMetaHeaderFromGRPCMessage(m.GetOrigin()),
|
|
|
|
)
|
|
|
|
|
|
|
|
xHdrMsg := m.GetXHeaders()
|
|
|
|
xHeaders := make([]*XHeader, 0, len(xHdrMsg))
|
|
|
|
|
|
|
|
for i := range xHdrMsg {
|
|
|
|
xHeaders = append(xHeaders, XHeaderFromGRPCMessage(xHdrMsg[i]))
|
|
|
|
}
|
|
|
|
|
2020-08-17 17:23:42 +00:00
|
|
|
r.SetXHeaders(xHeaders)
|
|
|
|
|
2020-08-17 10:23:41 +00:00
|
|
|
return r
|
|
|
|
}
|
|
|
|
|
|
|
|
func ResponseHeadersToGRPC(
|
|
|
|
src interface {
|
2020-08-17 10:43:17 +00:00
|
|
|
GetMetaHeader() *ResponseMetaHeader
|
|
|
|
GetVerificationHeader() *ResponseVerificationHeader
|
2020-08-17 10:23:41 +00:00
|
|
|
},
|
|
|
|
dst interface {
|
|
|
|
SetMetaHeader(*service.ResponseMetaHeader)
|
|
|
|
SetVerifyHeader(*service.ResponseVerificationHeader)
|
|
|
|
},
|
|
|
|
) {
|
|
|
|
dst.SetMetaHeader(
|
2020-08-17 10:43:17 +00:00
|
|
|
ResponseMetaHeaderToGRPCMessage(src.GetMetaHeader()),
|
2020-08-17 10:23:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
dst.SetVerifyHeader(
|
2020-08-17 10:43:17 +00:00
|
|
|
ResponseVerificationHeaderToGRPCMessage(src.GetVerificationHeader()),
|
2020-08-17 10:23:41 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func ResponseHeadersFromGRPC(
|
|
|
|
src interface {
|
|
|
|
GetMetaHeader() *service.ResponseMetaHeader
|
|
|
|
GetVerifyHeader() *service.ResponseVerificationHeader
|
|
|
|
},
|
|
|
|
dst interface {
|
2020-08-17 10:43:17 +00:00
|
|
|
SetMetaHeader(*ResponseMetaHeader)
|
|
|
|
SetVerificationHeader(*ResponseVerificationHeader)
|
2020-08-17 10:23:41 +00:00
|
|
|
},
|
|
|
|
) {
|
2020-08-17 10:43:17 +00:00
|
|
|
dst.SetMetaHeader(
|
2020-08-17 10:23:41 +00:00
|
|
|
ResponseMetaHeaderFromGRPCMessage(src.GetMetaHeader()),
|
|
|
|
)
|
|
|
|
|
2020-08-17 10:43:17 +00:00
|
|
|
dst.SetVerificationHeader(
|
2020-08-17 10:23:41 +00:00
|
|
|
ResponseVerificationHeaderFromGRPCMessage(src.GetVerifyHeader()),
|
|
|
|
)
|
|
|
|
}
|
2020-08-17 13:14:30 +00:00
|
|
|
|
2020-08-18 12:48:39 +00:00
|
|
|
func ObjectSessionVerbToGRPCField(v ObjectSessionVerb) service.ObjectSessionContext_Verb {
|
2020-08-17 13:14:30 +00:00
|
|
|
switch v {
|
|
|
|
case ObjectVerbPut:
|
2020-08-18 12:48:39 +00:00
|
|
|
return service.ObjectSessionContext_PUT
|
2020-08-17 13:14:30 +00:00
|
|
|
case ObjectVerbGet:
|
2020-08-18 12:48:39 +00:00
|
|
|
return service.ObjectSessionContext_GET
|
2020-08-17 13:14:30 +00:00
|
|
|
case ObjectVerbHead:
|
2020-08-18 12:48:39 +00:00
|
|
|
return service.ObjectSessionContext_HEAD
|
2020-08-17 13:14:30 +00:00
|
|
|
case ObjectVerbSearch:
|
2020-08-18 12:48:39 +00:00
|
|
|
return service.ObjectSessionContext_SEARCH
|
2020-08-17 13:14:30 +00:00
|
|
|
case ObjectVerbDelete:
|
2020-08-18 12:48:39 +00:00
|
|
|
return service.ObjectSessionContext_DELETE
|
2020-08-17 13:14:30 +00:00
|
|
|
case ObjectVerbRange:
|
2020-08-18 12:48:39 +00:00
|
|
|
return service.ObjectSessionContext_RANGE
|
2020-08-17 13:14:30 +00:00
|
|
|
case ObjectVerbRangeHash:
|
2020-08-18 12:48:39 +00:00
|
|
|
return service.ObjectSessionContext_RANGEHASH
|
2020-08-17 13:14:30 +00:00
|
|
|
default:
|
2020-08-18 12:48:39 +00:00
|
|
|
return service.ObjectSessionContext_VERB_UNSPECIFIED
|
2020-08-17 13:14:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-18 12:48:39 +00:00
|
|
|
func ObjectSessionVerbFromGRPCField(v service.ObjectSessionContext_Verb) ObjectSessionVerb {
|
2020-08-17 13:14:30 +00:00
|
|
|
switch v {
|
2020-08-18 12:48:39 +00:00
|
|
|
case service.ObjectSessionContext_PUT:
|
2020-08-17 13:14:30 +00:00
|
|
|
return ObjectVerbPut
|
2020-08-18 12:48:39 +00:00
|
|
|
case service.ObjectSessionContext_GET:
|
2020-08-17 13:14:30 +00:00
|
|
|
return ObjectVerbGet
|
2020-08-18 12:48:39 +00:00
|
|
|
case service.ObjectSessionContext_HEAD:
|
2020-08-17 13:14:30 +00:00
|
|
|
return ObjectVerbHead
|
2020-08-18 12:48:39 +00:00
|
|
|
case service.ObjectSessionContext_SEARCH:
|
2020-08-17 13:14:30 +00:00
|
|
|
return ObjectVerbSearch
|
2020-08-18 12:48:39 +00:00
|
|
|
case service.ObjectSessionContext_DELETE:
|
2020-08-17 13:14:30 +00:00
|
|
|
return ObjectVerbDelete
|
2020-08-18 12:48:39 +00:00
|
|
|
case service.ObjectSessionContext_RANGE:
|
2020-08-17 13:14:30 +00:00
|
|
|
return ObjectVerbRange
|
2020-08-18 12:48:39 +00:00
|
|
|
case service.ObjectSessionContext_RANGEHASH:
|
2020-08-17 13:14:30 +00:00
|
|
|
return ObjectVerbRangeHash
|
|
|
|
default:
|
|
|
|
return ObjectVerbUnknown
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-18 12:48:39 +00:00
|
|
|
func ObjectSessionContextToGRPCMessage(c *ObjectSessionContext) *service.ObjectSessionContext {
|
2020-08-17 13:14:30 +00:00
|
|
|
if c == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-08-18 12:48:39 +00:00
|
|
|
m := new(service.ObjectSessionContext)
|
2020-08-17 13:14:30 +00:00
|
|
|
|
|
|
|
m.SetVerb(
|
|
|
|
ObjectSessionVerbToGRPCField(c.GetVerb()),
|
|
|
|
)
|
|
|
|
|
|
|
|
m.SetAddress(
|
|
|
|
refs.AddressToGRPCMessage(c.GetAddress()),
|
|
|
|
)
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2020-08-18 12:48:39 +00:00
|
|
|
func ObjectSessionContextFromGRPCMessage(m *service.ObjectSessionContext) *ObjectSessionContext {
|
2020-08-17 13:14:30 +00:00
|
|
|
if m == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
c := new(ObjectSessionContext)
|
|
|
|
|
|
|
|
c.SetVerb(
|
|
|
|
ObjectSessionVerbFromGRPCField(m.GetVerb()),
|
|
|
|
)
|
|
|
|
|
|
|
|
c.SetAddress(
|
|
|
|
refs.AddressFromGRPCMessage(m.GetAddress()),
|
|
|
|
)
|
|
|
|
|
|
|
|
return c
|
|
|
|
}
|
|
|
|
|
|
|
|
func SessionTokenBodyToGRPCMessage(t *SessionTokenBody) *service.SessionToken_Body {
|
|
|
|
if t == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
m := new(service.SessionToken_Body)
|
|
|
|
|
|
|
|
switch v := t.GetContext(); t := v.(type) {
|
|
|
|
case nil:
|
|
|
|
case *ObjectSessionContext:
|
|
|
|
m.SetObjectServiceContext(
|
|
|
|
ObjectSessionContextToGRPCMessage(t),
|
|
|
|
)
|
|
|
|
default:
|
|
|
|
panic(fmt.Sprintf("unknown session context %T", t))
|
|
|
|
}
|
|
|
|
|
|
|
|
m.SetId(t.GetID())
|
|
|
|
|
|
|
|
m.SetOwnerId(
|
|
|
|
refs.OwnerIDToGRPCMessage(t.GetOwnerID()),
|
|
|
|
)
|
|
|
|
|
|
|
|
m.SetLifetime(
|
|
|
|
TokenLifetimeToGRPCMessage(t.GetLifetime()),
|
|
|
|
)
|
|
|
|
|
|
|
|
m.SetSessionKey(t.GetSessionKey())
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func SessionTokenBodyFromGRPCMessage(m *service.SessionToken_Body) *SessionTokenBody {
|
|
|
|
if m == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
t := new(SessionTokenBody)
|
|
|
|
|
|
|
|
switch v := m.GetContext().(type) {
|
|
|
|
case nil:
|
2020-08-18 12:48:39 +00:00
|
|
|
case *service.SessionToken_Body_Object:
|
2020-08-17 13:14:30 +00:00
|
|
|
t.SetContext(
|
2020-08-18 12:48:39 +00:00
|
|
|
ObjectSessionContextFromGRPCMessage(v.Object),
|
2020-08-17 13:14:30 +00:00
|
|
|
)
|
|
|
|
default:
|
|
|
|
panic(fmt.Sprintf("unknown session context %T", v))
|
|
|
|
}
|
|
|
|
|
|
|
|
t.SetID(m.GetId())
|
|
|
|
|
|
|
|
t.SetOwnerID(
|
|
|
|
refs.OwnerIDFromGRPCMessage(m.GetOwnerId()),
|
|
|
|
)
|
|
|
|
|
|
|
|
t.SetLifetime(
|
|
|
|
TokenLifetimeFromGRPCMessage(m.GetLifetime()),
|
|
|
|
)
|
|
|
|
|
|
|
|
t.SetSessionKey(m.GetSessionKey())
|
|
|
|
|
|
|
|
return t
|
|
|
|
}
|