-
Notifications
You must be signed in to change notification settings - Fork 6
/
auth_result.go
47 lines (40 loc) · 1.05 KB
/
auth_result.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package message
import (
"github.com/cyverse/go-irodsclient/irods/common"
"github.com/cyverse/go-irodsclient/irods/types"
"golang.org/x/xerrors"
)
// IRODSMessageAuthResult stores authentication result
type IRODSMessageAuthResult struct {
// empty structure
Result int
}
// CheckError returns error if server returned an error
func (msg *IRODSMessageAuthResult) CheckError() error {
if msg.Result < 0 {
return types.NewIRODSError(common.ErrorCode(msg.Result))
}
return nil
}
// GetMessage builds a message
func (msg *IRODSMessageAuthResult) GetMessage() (*IRODSMessage, error) {
msgHeader := IRODSMessageHeader{
Type: RODS_MESSAGE_API_REPLY_TYPE,
MessageLen: 0,
ErrorLen: 0,
BsLen: 0,
IntInfo: int32(msg.Result),
}
return &IRODSMessage{
Header: &msgHeader,
Body: nil,
}, nil
}
// FromMessage returns struct from IRODSMessage
func (msg *IRODSMessageAuthResult) FromMessage(msgIn *IRODSMessage) error {
if msgIn.Body == nil {
return xerrors.Errorf("empty message body")
}
msg.Result = int(msgIn.Body.IntInfo)
return nil
}