forked from pulse-vadc/go-vtm
/
config_rule_authenticator.go
136 lines (116 loc) · 4.24 KB
/
config_rule_authenticator.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// Copyright (C) 2018-2019, Pulse Secure, LLC.
// Licensed under the terms of the MPL 2.0. See LICENSE file for details.
// Go library for Pulse Virtual Traffic Manager REST version 6.0.
package vtm
import (
"encoding/json"
)
type RuleAuthenticator struct {
connector *vtmConnector
RuleAuthenticatorProperties `json:"properties"`
}
func (vtm VirtualTrafficManager) GetRuleAuthenticator(name string) (*RuleAuthenticator, *vtmErrorResponse) {
if name == "" {
panic("Provided an empty \"name\" parameter to VirtualTrafficManager.GetRuleAuthenticator(name)")
}
conn := vtm.connector.getChildConnector("/tm/6.0/config/active/rule_authenticators/" + name)
data, ok := conn.get()
if ok != true {
object := new(vtmErrorResponse)
json.NewDecoder(data).Decode(object)
return nil, object
}
object := new(RuleAuthenticator)
object.connector = conn
if err := json.NewDecoder(data).Decode(object); err != nil {
panic(err)
}
return object, nil
}
func (object RuleAuthenticator) Apply() (*RuleAuthenticator, *vtmErrorResponse) {
marshalled, err := json.Marshal(object)
if err != nil {
panic(err)
}
data, ok := object.connector.put(string(marshalled), STANDARD_OBJ)
if ok != true {
object := new(vtmErrorResponse)
json.NewDecoder(data).Decode(object)
return nil, object
}
if err := json.NewDecoder(data).Decode(&object); err != nil {
panic(err)
}
return &object, nil
}
func (vtm VirtualTrafficManager) NewRuleAuthenticator(name string) *RuleAuthenticator {
object := new(RuleAuthenticator)
conn := vtm.connector.getChildConnector("/tm/6.0/config/active/rule_authenticators/" + name)
object.connector = conn
return object
}
func (vtm VirtualTrafficManager) DeleteRuleAuthenticator(name string) *vtmErrorResponse {
conn := vtm.connector.getChildConnector("/tm/6.0/config/active/rule_authenticators/" + name)
data, ok := conn.delete()
if ok != true {
object := new(vtmErrorResponse)
json.NewDecoder(data).Decode(object)
return object
}
return nil
}
func (vtm VirtualTrafficManager) ListRuleAuthenticators() (*[]string, *vtmErrorResponse) {
conn := vtm.connector.getChildConnector("/tm/6.0/config/active/rule_authenticators")
data, ok := conn.get()
if ok != true {
object := new(vtmErrorResponse)
json.NewDecoder(data).Decode(object)
return nil, object
}
objectList := new(vtmObjectChildren)
if err := json.NewDecoder(data).Decode(objectList); err != nil {
panic(err)
}
var stringList []string
for _, obj := range objectList.Children {
stringList = append(stringList, obj.Name)
}
return &stringList, nil
}
type RuleAuthenticatorProperties struct {
Basic struct {
// The hostname or IP address of the remote authenticator.
Host *string `json:"host,omitempty"`
// A description of the authenticator.
Note *string `json:"note,omitempty"`
// The port on which the remote authenticator should be contacted.
Port *int `json:"port,omitempty"`
} `json:"basic"`
Ldap struct {
// A list of attributes to return from the search. If blank, no
// attributes will be returned. If set to '*' then all user attributes
// will be returned.
Attributes *[]string `json:"attributes,omitempty"`
// The distinguished name (DN) of the 'bind' user. The traffic manager
// will connect to the LDAP server as this user when searching for
// user records.
BindDn *string `json:"bind_dn,omitempty"`
// The password for the bind user.
BindPassword *string `json:"bind_password,omitempty"`
// The filter used to locate the LDAP record for the user being
// authenticated. Any occurrences of '"%u"' in the filter will be
// replaced by the name of the user being authenticated.
Filter *string `json:"filter,omitempty"`
// The base distinguished name (DN) under which user records are
// located on the server.
FilterBaseDn *string `json:"filter_base_dn,omitempty"`
// The SSL certificate that the traffic manager should use to validate
// the remote server. If no certificate is specified then no signature
// validation will be performed.
SslCert *string `json:"ssl_cert,omitempty"`
// Whether or not to enable SSL encryption to the LDAP server.
SslEnabled *bool `json:"ssl_enabled,omitempty"`
// The type of LDAP SSL encryption to use.
SslType *string `json:"ssl_type,omitempty"`
} `json:"ldap"`
}