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 {
return b.metaHeader
}
@ -87,13 +87,13 @@ func (b *BalanceRequest) GetRequestMetaHeader() *service.RequestMetaHeader {
return nil
}
func (b *BalanceRequest) SetRequestMetaHeader(v *service.RequestMetaHeader) {
func (b *BalanceRequest) SetMetaHeader(v *service.RequestMetaHeader) {
if b != nil {
b.metaHeader = v
}
}
func (b *BalanceRequest) GetRequestVerificationHeader() *service.RequestVerificationHeader {
func (b *BalanceRequest) GetVerificationHeader() *service.RequestVerificationHeader {
if b != nil {
return b.verifyHeader
}
@ -101,7 +101,7 @@ func (b *BalanceRequest) GetRequestVerificationHeader() *service.RequestVerifica
return nil
}
func (b *BalanceRequest) SetRequestVerificationHeader(v *service.RequestVerificationHeader) {
func (b *BalanceRequest) SetVerificationHeader(v *service.RequestVerificationHeader) {
if b != nil {
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 {
return br.metaHeader
}
@ -171,13 +171,13 @@ func (br *BalanceResponse) GetResponseMetaHeader() *service.ResponseMetaHeader {
return nil
}
func (br *BalanceResponse) SetResponseMetaHeader(v *service.ResponseMetaHeader) {
func (br *BalanceResponse) SetMetaHeader(v *service.ResponseMetaHeader) {
if br != nil {
br.metaHeader = v
}
}
func (br *BalanceResponse) GetResponseVerificationHeader() *service.ResponseVerificationHeader {
func (br *BalanceResponse) GetVerificationHeader() *service.ResponseVerificationHeader {
if br != nil {
return br.verifyHeader
}
@ -185,7 +185,7 @@ func (br *BalanceResponse) GetResponseVerificationHeader() *service.ResponseVeri
return nil
}
func (br *BalanceResponse) SetResponseVerificationHeader(v *service.ResponseVerificationHeader) {
func (br *BalanceResponse) SetVerificationHeader(v *service.ResponseVerificationHeader) {
if br != nil {
br.verifyHeader = v
}

View file

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

View file

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