|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright (C) 2016 SURFnet. |
|
4
|
|
|
* |
|
5
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
6
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
7
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
8
|
|
|
* License, or (at your option) any later version. |
|
9
|
|
|
* |
|
10
|
|
|
* This program is distributed in the hope that it will be useful, |
|
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13
|
|
|
* GNU Affero General Public License for more details. |
|
14
|
|
|
* |
|
15
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
16
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17
|
|
|
*/ |
|
18
|
|
|
namespace SURFnet\VPN\Common\HttpClient; |
|
19
|
|
|
|
|
20
|
|
|
class ServerClient extends BaseClient |
|
21
|
|
|
{ |
|
22
|
|
|
public function __construct(HttpClientInterface $httpClient, $baseUri) |
|
23
|
|
|
{ |
|
24
|
|
|
parent::__construct($httpClient, $baseUri); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function clientConnections() |
|
28
|
|
|
{ |
|
29
|
|
|
return $this->get('client_connections'); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function log($dataTime, $ipAddress) |
|
33
|
|
|
{ |
|
34
|
|
|
return $this->get( |
|
35
|
|
|
'log', |
|
36
|
|
|
[ |
|
37
|
|
|
'date_time' => $dataTime, |
|
38
|
|
|
'ip_address' => $ipAddress, |
|
39
|
|
|
] |
|
40
|
|
|
); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function stats() |
|
44
|
|
|
{ |
|
45
|
|
|
return $this->get('stats'); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function disabledUsers() |
|
49
|
|
|
{ |
|
50
|
|
|
return $this->get('disabled_users'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function isDisabledUser($userId) |
|
54
|
|
|
{ |
|
55
|
|
|
return $this->get('is_disabled_user', ['user_id' => $userId]); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function enableUser($userId) |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->post('enable_user', ['user_id' => $userId]); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function disableUser($userId) |
|
64
|
|
|
{ |
|
65
|
|
|
return $this->post('disable_user', ['user_id' => $userId]); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function hasOtpSecret($userId) |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->get('has_otp_secret', ['user_id' => $userId]); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function disabledCommonNames() |
|
74
|
|
|
{ |
|
75
|
|
|
return $this->get('disabled_common_names'); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function isDisabledCommonName($commonName) |
|
79
|
|
|
{ |
|
80
|
|
|
return $this->get('is_disabled_common_name', ['common_name' => $commonName]); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
public function disableCommonName($commonName) |
|
84
|
|
|
{ |
|
85
|
|
|
return $this->post('disable_common_name', ['common_name' => $commonName]); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
public function enableCommonName($commonName) |
|
89
|
|
|
{ |
|
90
|
|
|
return $this->post('enable_common_name', ['common_name' => $commonName]); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
public function killClient($commonName) |
|
94
|
|
|
{ |
|
95
|
|
|
return $this->post('kill_client', ['common_name' => $commonName]); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
public function serverPool($poolId) |
|
99
|
|
|
{ |
|
100
|
|
|
return $this->get('server_pool', ['pool_id' => $poolId]); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
public function serverPools() |
|
104
|
|
|
{ |
|
105
|
|
|
return $this->get('server_pools'); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
public function instanceNumber() |
|
109
|
|
|
{ |
|
110
|
|
|
return $this->get('instance_number'); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
public function userGroups($userId) |
|
114
|
|
|
{ |
|
115
|
|
|
return $this->get('user_groups', ['user_id' => $userId]); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
public function hasVootToken($userId) |
|
119
|
|
|
{ |
|
120
|
|
|
return $this->get('has_voot_token', ['user_id' => $userId]); |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
public function setVootToken($userId, $vootToken) |
|
124
|
|
|
{ |
|
125
|
|
|
return $this->post( |
|
126
|
|
|
'set_voot_token', |
|
127
|
|
|
[ |
|
128
|
|
|
'user_id' => $userId, |
|
129
|
|
|
'voot_token' => $vootToken, |
|
130
|
|
|
] |
|
131
|
|
|
); |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
public function deleteOtpSecret($userId) |
|
135
|
|
|
{ |
|
136
|
|
|
return $this->post('delete_otp_secret', ['user_id' => $userId]); |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
public function setOtpSecret($userId, $otpSecret, $otpKey) |
|
140
|
|
|
{ |
|
141
|
|
|
return $this->post( |
|
142
|
|
|
'set_otp_secret', |
|
143
|
|
|
[ |
|
144
|
|
|
'user_id' => $userId, |
|
145
|
|
|
'otp_secret' => $otpSecret, |
|
146
|
|
|
'otp_key' => $otpKey, |
|
147
|
|
|
] |
|
148
|
|
|
); |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
public function verifyOtpKey($userId, $otpKey) |
|
152
|
|
|
{ |
|
153
|
|
|
return $this->post( |
|
154
|
|
|
'verify_otp_key', |
|
155
|
|
|
[ |
|
156
|
|
|
'user_id' => $userId, |
|
157
|
|
|
'otp_key' => $otpKey, |
|
158
|
|
|
] |
|
159
|
|
|
); |
|
160
|
|
|
} |
|
161
|
|
|
} |
|
162
|
|
|
|