v2/service: Rename header setters

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-08-17 13:43:17 +03:00 committed by Stanislav Bogatyrev
parent e84c8aee2c
commit e599468420
3 changed files with 32 additions and 32 deletions

View file

@ -79,7 +79,7 @@ func (b *BalanceRequest) SetBody(v *BalanceRequestBody) {
} }
} }
func (b *BalanceRequest) GetRequestMetaHeader() *service.RequestMetaHeader { func (b *BalanceRequest) GetMetaHeader() *service.RequestMetaHeader {
if b != nil { if b != nil {
return b.metaHeader return b.metaHeader
} }
@ -87,13 +87,13 @@ func (b *BalanceRequest) GetRequestMetaHeader() *service.RequestMetaHeader {
return nil return nil
} }
func (b *BalanceRequest) SetRequestMetaHeader(v *service.RequestMetaHeader) { func (b *BalanceRequest) SetMetaHeader(v *service.RequestMetaHeader) {
if b != nil { if b != nil {
b.metaHeader = v b.metaHeader = v
} }
} }
func (b *BalanceRequest) GetRequestVerificationHeader() *service.RequestVerificationHeader { func (b *BalanceRequest) GetVerificationHeader() *service.RequestVerificationHeader {
if b != nil { if b != nil {
return b.verifyHeader return b.verifyHeader
} }
@ -101,7 +101,7 @@ func (b *BalanceRequest) GetRequestVerificationHeader() *service.RequestVerifica
return nil return nil
} }
func (b *BalanceRequest) SetRequestVerificationHeader(v *service.RequestVerificationHeader) { func (b *BalanceRequest) SetVerificationHeader(v *service.RequestVerificationHeader) {
if b != nil { if b != nil {
b.verifyHeader = v b.verifyHeader = v
} }
@ -163,7 +163,7 @@ func (br *BalanceResponse) SetBody(v *BalanceResponseBody) {
} }
} }
func (br *BalanceResponse) GetResponseMetaHeader() *service.ResponseMetaHeader { func (br *BalanceResponse) GetMetaHeader() *service.ResponseMetaHeader {
if br != nil { if br != nil {
return br.metaHeader return br.metaHeader
} }
@ -171,13 +171,13 @@ func (br *BalanceResponse) GetResponseMetaHeader() *service.ResponseMetaHeader {
return nil return nil
} }
func (br *BalanceResponse) SetResponseMetaHeader(v *service.ResponseMetaHeader) { func (br *BalanceResponse) SetMetaHeader(v *service.ResponseMetaHeader) {
if br != nil { if br != nil {
br.metaHeader = v br.metaHeader = v
} }
} }
func (br *BalanceResponse) GetResponseVerificationHeader() *service.ResponseVerificationHeader { func (br *BalanceResponse) GetVerificationHeader() *service.ResponseVerificationHeader {
if br != nil { if br != nil {
return br.verifyHeader return br.verifyHeader
} }
@ -185,7 +185,7 @@ func (br *BalanceResponse) GetResponseVerificationHeader() *service.ResponseVeri
return nil return nil
} }
func (br *BalanceResponse) SetResponseVerificationHeader(v *service.ResponseVerificationHeader) { func (br *BalanceResponse) SetVerificationHeader(v *service.ResponseVerificationHeader) {
if br != nil { if br != nil {
br.verifyHeader = v br.verifyHeader = v
} }

View file

@ -328,8 +328,8 @@ func BearerTokenBodyFromGRPCMessage(m *service.BearerToken_Body) *BearerTokenBod
func RequestHeadersToGRPC( func RequestHeadersToGRPC(
src interface { src interface {
GetRequestMetaHeader() *RequestMetaHeader GetMetaHeader() *RequestMetaHeader
GetRequestVerificationHeader() *RequestVerificationHeader GetVerificationHeader() *RequestVerificationHeader
}, },
dst interface { dst interface {
SetMetaHeader(*service.RequestMetaHeader) SetMetaHeader(*service.RequestMetaHeader)
@ -337,11 +337,11 @@ func RequestHeadersToGRPC(
}, },
) { ) {
dst.SetMetaHeader( dst.SetMetaHeader(
RequestMetaHeaderToGRPCMessage(src.GetRequestMetaHeader()), RequestMetaHeaderToGRPCMessage(src.GetMetaHeader()),
) )
dst.SetVerifyHeader( dst.SetVerifyHeader(
RequestVerificationHeaderToGRPCMessage(src.GetRequestVerificationHeader()), RequestVerificationHeaderToGRPCMessage(src.GetVerificationHeader()),
) )
} }
@ -351,15 +351,15 @@ func RequestHeadersFromGRPC(
GetVerifyHeader() *service.RequestVerificationHeader GetVerifyHeader() *service.RequestVerificationHeader
}, },
dst interface { dst interface {
SetRequestMetaHeader(*RequestMetaHeader) SetMetaHeader(*RequestMetaHeader)
SetRequestVerificationHeader(*RequestVerificationHeader) SetVerificationHeader(*RequestVerificationHeader)
}, },
) { ) {
dst.SetRequestMetaHeader( dst.SetMetaHeader(
RequestMetaHeaderFromGRPCMessage(src.GetMetaHeader()), RequestMetaHeaderFromGRPCMessage(src.GetMetaHeader()),
) )
dst.SetRequestVerificationHeader( dst.SetVerificationHeader(
RequestVerificationHeaderFromGRPCMessage(src.GetVerifyHeader()), RequestVerificationHeaderFromGRPCMessage(src.GetVerifyHeader()),
) )
} }
@ -474,8 +474,8 @@ func ResponseMetaHeaderFromGRPCMessage(m *service.ResponseMetaHeader) *ResponseM
func ResponseHeadersToGRPC( func ResponseHeadersToGRPC(
src interface { src interface {
GetResponseMetaHeader() *ResponseMetaHeader GetMetaHeader() *ResponseMetaHeader
GetResponseVerificationHeader() *ResponseVerificationHeader GetVerificationHeader() *ResponseVerificationHeader
}, },
dst interface { dst interface {
SetMetaHeader(*service.ResponseMetaHeader) SetMetaHeader(*service.ResponseMetaHeader)
@ -483,11 +483,11 @@ func ResponseHeadersToGRPC(
}, },
) { ) {
dst.SetMetaHeader( dst.SetMetaHeader(
ResponseMetaHeaderToGRPCMessage(src.GetResponseMetaHeader()), ResponseMetaHeaderToGRPCMessage(src.GetMetaHeader()),
) )
dst.SetVerifyHeader( dst.SetVerifyHeader(
ResponseVerificationHeaderToGRPCMessage(src.GetResponseVerificationHeader()), ResponseVerificationHeaderToGRPCMessage(src.GetVerificationHeader()),
) )
} }
@ -497,15 +497,15 @@ func ResponseHeadersFromGRPC(
GetVerifyHeader() *service.ResponseVerificationHeader GetVerifyHeader() *service.ResponseVerificationHeader
}, },
dst interface { dst interface {
SetResponseMetaHeader(*ResponseMetaHeader) SetMetaHeader(*ResponseMetaHeader)
SetResponseVerificationHeader(*ResponseVerificationHeader) SetVerificationHeader(*ResponseVerificationHeader)
}, },
) { ) {
dst.SetResponseMetaHeader( dst.SetMetaHeader(
ResponseMetaHeaderFromGRPCMessage(src.GetMetaHeader()), ResponseMetaHeaderFromGRPCMessage(src.GetMetaHeader()),
) )
dst.SetResponseVerificationHeader( dst.SetVerificationHeader(
ResponseVerificationHeaderFromGRPCMessage(src.GetVerifyHeader()), ResponseVerificationHeaderFromGRPCMessage(src.GetVerifyHeader()),
) )
} }

View file

@ -11,9 +11,9 @@ import (
) )
type SignedRequest interface { type SignedRequest interface {
GetRequestMetaHeader() *service.RequestMetaHeader GetMetaHeader() *service.RequestMetaHeader
GetRequestVerificationHeader() *service.RequestVerificationHeader GetVerificationHeader() *service.RequestVerificationHeader
SetRequestVerificationHeader(*service.RequestVerificationHeader) SetVerificationHeader(*service.RequestVerificationHeader)
} }
type stableMarshaler interface { type stableMarshaler interface {
@ -64,7 +64,7 @@ func SignRequest(key *ecdsa.PrivateKey, req SignedRequest) error {
verifyHdr := new(service.RequestVerificationHeader) verifyHdr := new(service.RequestVerificationHeader)
// attach the previous matryoshka // attach the previous matryoshka
verifyHdr.SetOrigin(req.GetRequestVerificationHeader()) verifyHdr.SetOrigin(req.GetVerificationHeader())
// sign request body // sign request body
if err := signRequestPart(key, requestBody(req), verifyHdr.SetBodySignature); err != nil { if err := signRequestPart(key, requestBody(req), verifyHdr.SetBodySignature); err != nil {
@ -72,7 +72,7 @@ func SignRequest(key *ecdsa.PrivateKey, req SignedRequest) error {
} }
// sign meta header // sign meta header
if err := signRequestPart(key, req.GetRequestMetaHeader(), verifyHdr.SetMetaSignature); err != nil { if err := signRequestPart(key, req.GetMetaHeader(), verifyHdr.SetMetaSignature); err != nil {
return errors.Wrap(err, "could not sign request meta header") return errors.Wrap(err, "could not sign request meta header")
} }
@ -82,7 +82,7 @@ func SignRequest(key *ecdsa.PrivateKey, req SignedRequest) error {
} }
// make a new top of the matryoshka // make a new top of the matryoshka
req.SetRequestVerificationHeader(verifyHdr) req.SetVerificationHeader(verifyHdr)
return nil return nil
} }
@ -106,7 +106,7 @@ func signRequestPart(key *ecdsa.PrivateKey, part stableMarshaler, sigWrite func(
} }
func VerifyRequest(req SignedRequest) error { func VerifyRequest(req SignedRequest) error {
verifyHdr := req.GetRequestVerificationHeader() verifyHdr := req.GetVerificationHeader()
// verify body signature // verify body signature
if err := verifyRequestPart(requestBody(req), verifyHdr.GetBodySignature); err != nil { if err := verifyRequestPart(requestBody(req), verifyHdr.GetBodySignature); err != nil {
@ -114,7 +114,7 @@ func VerifyRequest(req SignedRequest) error {
} }
// verify meta header // verify meta header
if err := verifyRequestPart(req.GetRequestMetaHeader(), verifyHdr.GetMetaSignature); err != nil { if err := verifyRequestPart(req.GetMetaHeader(), verifyHdr.GetMetaSignature); err != nil {
return errors.Wrap(err, "could not verify request meta header") return errors.Wrap(err, "could not verify request meta header")
} }