...
1 package pgproto3
2
3 import (
4 "encoding/binary"
5 "encoding/json"
6 "errors"
7
8 "github.com/jackc/pgx/v5/internal/pgio"
9 )
10
11 type AuthenticationGSS struct{}
12
13 func (a *AuthenticationGSS) Backend() {}
14
15 func (a *AuthenticationGSS) AuthenticationResponse() {}
16
17 func (a *AuthenticationGSS) Decode(src []byte) error {
18 if len(src) < 4 {
19 return errors.New("authentication message too short")
20 }
21
22 authType := binary.BigEndian.Uint32(src)
23
24 if authType != AuthTypeGSS {
25 return errors.New("bad auth type")
26 }
27 return nil
28 }
29
30 func (a *AuthenticationGSS) Encode(dst []byte) ([]byte, error) {
31 dst, sp := beginMessage(dst, 'R')
32 dst = pgio.AppendUint32(dst, AuthTypeGSS)
33 return finishMessage(dst, sp)
34 }
35
36 func (a *AuthenticationGSS) MarshalJSON() ([]byte, error) {
37 return json.Marshal(struct {
38 Type string
39 Data []byte
40 }{
41 Type: "AuthenticationGSS",
42 })
43 }
44
45 func (a *AuthenticationGSS) UnmarshalJSON(data []byte) error {
46
47 if string(data) == "null" {
48 return nil
49 }
50
51 var msg struct {
52 Type string
53 }
54 if err := json.Unmarshal(data, &msg); err != nil {
55 return err
56 }
57 return nil
58 }
59
View as plain text