-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.go
More file actions
53 lines (42 loc) · 929 Bytes
/
base.go
File metadata and controls
53 lines (42 loc) · 929 Bytes
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
48
49
50
51
52
53
package document
import (
"fmt"
"strings"
"time"
)
const BaseType = SchemaLocation + "/base.json"
type Base struct {
Type string `json:"@type"`
Timestamp time.Time `json:"@timestamp"`
ID string `json:"@id,omitempty"`
Certificate string `json:"@certificate,omitempty"`
Realm string `json:"@realm,omitempty"`
raw []byte
}
func NewBase() *Base {
return &Base{
Type: BaseType,
Timestamp: time.Now().UTC(),
}
}
func (b *Base) GetTimestamp() time.Time {
return b.Timestamp
}
func (b *Base) GetCertificate() string {
return b.Certificate
}
func (b *Base) GetType() string {
return b.Type
}
func (b *Base) GetRaw() []byte {
return b.raw
}
func (b *Base) SetRaw(raw []byte) {
b.raw = raw
}
func (b *Base) SubType() string {
return strings.Split(b.Type, "#")[1]
}
func (b *Base) SetSubType(subType string) {
b.Type = fmt.Sprintf("%s#%s", b.Type, subType)
}