/
pkixname.go
99 lines (72 loc) · 2.58 KB
/
pkixname.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package gaia
import (
"fmt"
"github.com/mitchellh/copystructure"
"go.aporeto.io/elemental"
)
// PKIXName represents the model of a pkixname
type PKIXName struct {
// Represents the Common Name field.
CommonName string `json:"commonName" msgpack:"commonName" bson:"-" mapstructure:"commonName,omitempty"`
// Represents the Country field.
Country []string `json:"country" msgpack:"country" bson:"-" mapstructure:"country,omitempty"`
// Represents the Locality field.
Locality []string `json:"locality" msgpack:"locality" bson:"-" mapstructure:"locality,omitempty"`
// Represents the Organization field.
Organization []string `json:"organization" msgpack:"organization" bson:"-" mapstructure:"organization,omitempty"`
// Represents the Organizational Unit field.
OrganizationalUnit []string `json:"organizationalUnit" msgpack:"organizationalUnit" bson:"-" mapstructure:"organizationalUnit,omitempty"`
// Represents the Postal Code field.
PostalCode []string `json:"postalCode" msgpack:"postalCode" bson:"-" mapstructure:"postalCode,omitempty"`
// Represents the Province field.
Province []string `json:"province" msgpack:"province" bson:"-" mapstructure:"province,omitempty"`
// Represents the Street Address field.
StreetAddress []string `json:"streetAddress" msgpack:"streetAddress" bson:"-" mapstructure:"streetAddress,omitempty"`
ModelVersion int `json:"-" msgpack:"-" bson:"_modelversion"`
}
// NewPKIXName returns a new *PKIXName
func NewPKIXName() *PKIXName {
return &PKIXName{
ModelVersion: 1,
Country: []string{},
Locality: []string{},
Organization: []string{},
OrganizationalUnit: []string{},
PostalCode: []string{},
Province: []string{},
StreetAddress: []string{},
}
}
// BleveType implements the bleve.Classifier Interface.
func (o *PKIXName) BleveType() string {
return "pkixname"
}
// DeepCopy returns a deep copy if the PKIXName.
func (o *PKIXName) DeepCopy() *PKIXName {
if o == nil {
return nil
}
out := &PKIXName{}
o.DeepCopyInto(out)
return out
}
// DeepCopyInto copies the receiver into the given *PKIXName.
func (o *PKIXName) DeepCopyInto(out *PKIXName) {
target, err := copystructure.Copy(o)
if err != nil {
panic(fmt.Sprintf("Unable to deepcopy PKIXName: %s", err))
}
*out = *target.(*PKIXName)
}
// Validate valides the current information stored into the structure.
func (o *PKIXName) Validate() error {
errors := elemental.Errors{}
requiredErrors := elemental.Errors{}
if len(requiredErrors) > 0 {
return requiredErrors
}
if len(errors) > 0 {
return errors
}
return nil
}