1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* ****************************************************************************** |
5
|
|
|
* Copyright 2011-2017 DANTE Ltd. and GÉANT on behalf of the GN3, GN3+, GN4-1 |
6
|
|
|
* and GN4-2 consortia |
7
|
|
|
* |
8
|
|
|
* License: see the web/copyright.php file in the file structure |
9
|
|
|
* ****************************************************************************** |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* This file creates MS Windows Vista and MS Windows 7 installers |
14
|
|
|
* It supports EAP-TLS, PEAP and EAP-pwd (with external software) |
15
|
|
|
* @author Tomasz Wolniewicz <[email protected]> |
16
|
|
|
* |
17
|
|
|
* @package ModuleWriting |
18
|
|
|
*/ |
19
|
|
|
/** |
20
|
|
|
* necessary includes |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
namespace devices\ms; |
24
|
|
|
use \Exception; |
25
|
|
|
|
26
|
|
|
class Device_Vista7 extends WindowsCommon { |
27
|
|
|
|
28
|
|
|
final public function __construct() { |
29
|
|
|
parent::__construct(); |
30
|
|
|
$this->setSupportedEapMethods([\core\common\EAP::EAPTYPE_TLS, \core\common\EAP::EAPTYPE_PEAP_MSCHAP2, \core\common\EAP::EAPTYPE_PWD, \core\common\EAP::EAPTYPE_TTLS_PAP, \core\common\EAP::EAPTYPE_TTLS_MSCHAP2, \core\common\EAP::EAPTYPE_SILVERBULLET]); |
31
|
|
|
$this->loggerInstance->debug(4, "This device supports the following EAP methods: "); |
32
|
|
|
$this->loggerInstance->debug(4, $this->supportedEapMethods); |
33
|
|
|
$this->specialities['internal:use_anon_outer'][serialize(\core\common\EAP::EAPTYPE_PEAP_MSCHAP2)] = _("Anonymous identities do not use the realm as specified in the profile - it is derived from the suffix of the user's username input instead."); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function writeInstaller() { |
37
|
|
|
$dom = textdomain(NULL); |
38
|
|
|
textdomain("devices"); |
39
|
|
|
// create certificate files and save their names in $caFiles arrary |
40
|
|
|
$caFiles = $this->saveCertificateFiles('der'); |
41
|
|
|
|
42
|
|
|
$allSSID = $this->attributes['internal:SSID']; |
43
|
|
|
$delSSIDs = $this->attributes['internal:remove_SSID']; |
44
|
|
|
$this->prepareInstallerLang(); |
45
|
|
|
$setWired = isset($this->attributes['media:wired'][0]) && $this->attributes['media:wired'][0] == 'on' ? 1 : 0; |
46
|
|
|
// create a list of profiles to be deleted after installation |
47
|
|
|
$delProfiles = []; |
48
|
|
|
foreach ($delSSIDs as $ssid => $cipher) { |
49
|
|
|
if ($cipher == 'DEL') { |
50
|
|
|
$delProfiles[] = $ssid; |
51
|
|
|
} |
52
|
|
|
if ($cipher == 'TKIP') { |
53
|
|
|
$delProfiles[] = $ssid . ' (TKIP)'; |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
if ($this->selectedEap == \core\common\EAP::EAPTYPE_TLS || $this->selectedEap == \core\common\EAP::EAPTYPE_PEAP_MSCHAP2 || $this->selectedEap == \core\common\EAP::EAPTYPE_PWD || $this->selectedEap == \core\common\EAP::EAPTYPE_TTLS_PAP || $this->selectedEap == \core\common\EAP::EAPTYPE_SILVERBULLET) { |
58
|
|
|
$windowsProfile = []; |
59
|
|
|
$eapConfig = $this->prepareEapConfig($this->attributes); |
60
|
|
|
$iterator = 0; |
61
|
|
|
foreach ($allSSID as $ssid => $cipher) { |
62
|
|
|
if ($cipher == 'TKIP') { |
63
|
|
|
$windowsProfile[$iterator] = $this->writeWLANprofile($ssid . ' (TKIP)', $ssid, 'WPA', 'TKIP', $eapConfig, $iterator); |
64
|
|
|
$iterator++; |
65
|
|
|
} |
66
|
|
|
$windowsProfile[$iterator] = $this->writeWLANprofile($ssid, $ssid, 'WPA2', 'AES', $eapConfig, $iterator); |
67
|
|
|
$iterator++; |
68
|
|
|
} |
69
|
|
|
if ($setWired) { |
70
|
|
|
$this->writeLANprofile($eapConfig); |
71
|
|
|
} |
72
|
|
|
} else { |
73
|
|
|
print(" this EAP type is not handled yet.\n"); |
74
|
|
|
return; |
75
|
|
|
} |
76
|
|
|
$this->loggerInstance->debug(4, "windowsProfile"); |
77
|
|
|
$this->loggerInstance->debug(4, $windowsProfile); |
78
|
|
|
|
79
|
|
|
$this->writeProfilesNSH($windowsProfile, $caFiles, $setWired); |
80
|
|
|
$this->writeAdditionalDeletes($delProfiles); |
81
|
|
|
if ($this->selectedEap == \core\common\EAP::EAPTYPE_SILVERBULLET) { |
82
|
|
|
$this->writeClientP12File(); |
83
|
|
|
} |
84
|
|
|
$this->copyFiles($this->selectedEap); |
85
|
|
|
$fedLogo = $this->attributes['fed:logo_file'] ?? NULL; |
86
|
|
|
$idpLogo = $this->attributes['internal:logo_file'] ?? NULL; |
87
|
|
|
$this->combineLogo($idpLogo, $fedLogo); |
88
|
|
|
$this->writeMainNSH($this->selectedEap, $this->attributes); |
89
|
|
|
$this->compileNSIS(); |
90
|
|
|
$installerPath = $this->signInstaller(); |
91
|
|
|
|
92
|
|
|
textdomain($dom); |
93
|
|
|
return($installerPath); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
private function prepareEapConfig($attr) { |
97
|
|
|
$vistaExt = ''; |
98
|
|
|
$w7Ext = ''; |
99
|
|
|
$useAnon = $attr['internal:use_anon_outer'] [0]; |
100
|
|
|
$realm = $attr['internal:realm'] [0]; |
101
|
|
|
if ($useAnon) { |
102
|
|
|
$outerUser = $attr['internal:anon_local_value'][0]; |
103
|
|
|
} |
104
|
|
|
// $servers = preg_quote(implode(';',$attr['eap:server_name'])); |
|
|
|
|
105
|
|
|
$servers = implode(';', $attr['eap:server_name']); |
106
|
|
|
$caArray = $attr['internal:CAs'][0]; |
107
|
|
|
$authorId = "0"; |
108
|
|
|
if ($this->selectedEap == \core\common\EAP::EAPTYPE_TTLS_PAP || $this->selectedEap == \core\common\EAP::EAPTYPE_TTLS_MSCHAP2) { |
109
|
|
|
$authorId = "67532"; |
110
|
|
|
$servers = implode('</ServerName><ServerName>', $attr['eap:server_name']); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
$profileFileCont = '<EAPConfig><EapHostConfig xmlns="http://www.microsoft.com/provisioning/EapHostConfig"> |
114
|
|
|
<EapMethod> |
115
|
|
|
<Type xmlns="http://www.microsoft.com/provisioning/EapCommon">' . |
116
|
|
|
$this->selectedEap["OUTER"] . '</Type> |
117
|
|
|
<VendorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</VendorId> |
118
|
|
|
<VendorType xmlns="http://www.microsoft.com/provisioning/EapCommon">0</VendorType> |
119
|
|
|
<AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">' . $authorId . '</AuthorId> |
120
|
|
|
</EapMethod> |
121
|
|
|
'; |
122
|
|
|
|
123
|
|
|
|
124
|
|
|
if ($this->selectedEap == \core\common\EAP::EAPTYPE_TTLS_PAP || $this->selectedEap == \core\common\EAP::EAPTYPE_TTLS_MSCHAP2) { |
125
|
|
|
$innerMethod = 'MSCHAPv2'; |
|
|
|
|
126
|
|
|
if ($this->selectedEap == \core\common\EAP::EAPTYPE_TTLS_PAP) { |
127
|
|
|
$innerMethod = 'PAP'; |
|
|
|
|
128
|
|
|
} |
129
|
|
|
$profileFileCont .= ' |
130
|
|
|
<Config xmlns="http://www.microsoft.com/provisioning/EapHostConfig"> |
131
|
|
|
<EAPIdentityProviderList xmlns="urn:ietf:params:xml:ns:yang:ietf-eap-metadata"> |
132
|
|
|
<EAPIdentityProvider ID="' . $this->deviceUUID . '" namespace="urn:UUID"> |
133
|
|
|
<ProviderInfo> |
134
|
|
|
<DisplayName>' . $this->translateString($attr['general:instname'][0], $this->code_page) . '</DisplayName> |
|
|
|
|
135
|
|
|
</ProviderInfo> |
136
|
|
|
<AuthenticationMethods> |
137
|
|
|
<AuthenticationMethod> |
138
|
|
|
<EAPMethod>21</EAPMethod> |
139
|
|
|
<ClientSideCredential> |
140
|
|
|
<allow-save>true</allow-save> |
141
|
|
|
'; |
142
|
|
|
if ($useAnon == 1) { |
143
|
|
|
if ($outerUser == '') { |
144
|
|
|
$profileFileCont .= '<AnonymousIdentity>@</AnonymousIdentity>'; |
145
|
|
|
} else { |
146
|
|
|
$profileFileCont .= '<AnonymousIdentity>' . $outerUser . '@' . $realm . '</AnonymousIdentity>'; |
|
|
|
|
147
|
|
|
} |
148
|
|
|
} |
149
|
|
|
$profileFileCont .= '</ClientSideCredential> |
150
|
|
|
<ServerSideCredential> |
151
|
|
|
'; |
152
|
|
|
|
153
|
|
View Code Duplication |
foreach ($caArray as $ca) { |
|
|
|
|
154
|
|
|
$profileFileCont .= '<CA><format>PEM</format><cert-data>'; |
155
|
|
|
$profileFileCont .= base64_encode($ca['der']); |
156
|
|
|
$profileFileCont .= '</cert-data></CA> |
157
|
|
|
'; |
158
|
|
|
} |
159
|
|
|
$profileFileCont .= "<ServerName>$servers</ServerName>\n"; |
160
|
|
|
|
161
|
|
|
$profileFileCont .= ' |
162
|
|
|
</ServerSideCredential> |
163
|
|
|
<InnerAuthenticationMethod> |
164
|
|
|
<NonEAPAuthMethod>' . $inner_method . '</NonEAPAuthMethod> |
|
|
|
|
165
|
|
|
</InnerAuthenticationMethod> |
166
|
|
|
<VendorSpecific> |
167
|
|
|
<SessionResumption>false</SessionResumption> |
168
|
|
|
</VendorSpecific> |
169
|
|
|
</AuthenticationMethod> |
170
|
|
|
</AuthenticationMethods> |
171
|
|
|
</EAPIdentityProvider> |
172
|
|
|
</EAPIdentityProviderList> |
173
|
|
|
</Config> |
174
|
|
|
'; |
175
|
|
|
} elseif ($this->selectedEap == \core\common\EAP::EAPTYPE_TLS || $this->selectedEap == \core\common\EAP::EAPTYPE_SILVERBULLET) { |
176
|
|
|
|
177
|
|
|
$profileFileCont .= ' |
178
|
|
|
|
179
|
|
|
<Config xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1" |
180
|
|
|
xmlns:eapTls="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV1"> |
181
|
|
|
<baseEap:Eap> |
182
|
|
|
<baseEap:Type>13</baseEap:Type> |
183
|
|
|
<eapTls:EapType> |
184
|
|
|
<eapTls:CredentialsSource> |
185
|
|
|
<eapTls:CertificateStore /> |
186
|
|
|
</eapTls:CredentialsSource> |
187
|
|
|
<eapTls:ServerValidation> |
188
|
|
|
<eapTls:DisableUserPromptForServerValidation>true</eapTls:DisableUserPromptForServerValidation> |
189
|
|
|
<eapTls:ServerNames>' . $servers . '</eapTls:ServerNames>'; |
190
|
|
View Code Duplication |
if ($caArray) { |
|
|
|
|
191
|
|
|
foreach ($caArray as $certAuthority) { |
192
|
|
|
if ($certAuthority['root']) { |
193
|
|
|
$profileFileCont .= "<eapTls:TrustedRootCA>" . $certAuthority['sha1'] . "</eapTls:TrustedRootCA>\n"; |
194
|
|
|
} |
195
|
|
|
} |
196
|
|
|
} |
197
|
|
|
$profileFileCont .= '</eapTls:ServerValidation> |
198
|
|
|
'; |
199
|
|
View Code Duplication |
if (isset($attr['eap-specific:tls_use_other_id']) && $attr['eap-specific:tls_use_other_id'][0] == 'on') { |
|
|
|
|
200
|
|
|
$profileFileCont .= '<eapTls:DifferentUsername>true</eapTls:DifferentUsername>'; |
201
|
|
|
$this->tlsOtherUsername = 1; |
202
|
|
|
} else { |
203
|
|
|
$profileFileCont .= '<eapTls:DifferentUsername>false</eapTls:DifferentUsername>'; |
204
|
|
|
} |
205
|
|
|
$profileFileCont .= ' |
206
|
|
|
</eapTls:EapType> |
207
|
|
|
</baseEap:Eap> |
208
|
|
|
</Config> |
209
|
|
|
'; |
210
|
|
|
} elseif ($this->selectedEap == \core\common\EAP::EAPTYPE_PEAP_MSCHAP2) { |
211
|
|
|
if (isset($attr['eap:enable_nea']) && $attr['eap:enable_nea'][0] == 'on') { |
212
|
|
|
$nea = 'true'; |
213
|
|
|
} else { |
214
|
|
|
$nea = 'false'; |
215
|
|
|
} |
216
|
|
|
$vistaExt = '<Config xmlns:eapUser="http://www.microsoft.com/provisioning/EapUserPropertiesV1" |
217
|
|
|
xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1" |
218
|
|
|
xmlns:msPeap="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV1" |
219
|
|
|
xmlns:msChapV2="http://www.microsoft.com/provisioning/MsChapV2ConnectionPropertiesV1"> |
220
|
|
|
<baseEap:Eap> |
221
|
|
|
<baseEap:Type>25</baseEap:Type> |
222
|
|
|
<msPeap:EapType> |
223
|
|
|
<msPeap:ServerValidation> |
224
|
|
|
<msPeap:DisableUserPromptForServerValidation>true</msPeap:DisableUserPromptForServerValidation> |
225
|
|
|
<msPeap:ServerNames>' . $servers . '</msPeap:ServerNames>'; |
226
|
|
|
if ($caArray) { |
227
|
|
|
foreach ($caArray as $certAuthority) { |
228
|
|
|
if ($certAuthority['root']) { |
229
|
|
|
$vistaExt .= "<msPeap:TrustedRootCA>" . $certAuthority['sha1'] . "</msPeap:TrustedRootCA>\n"; |
230
|
|
|
} |
231
|
|
|
} |
232
|
|
|
} |
233
|
|
|
$vistaExt .= '</msPeap:ServerValidation> |
234
|
|
|
<msPeap:FastReconnect>true</msPeap:FastReconnect> |
235
|
|
|
<msPeap:InnerEapOptional>0</msPeap:InnerEapOptional> |
236
|
|
|
<baseEap:Eap> |
237
|
|
|
<baseEap:Type>26</baseEap:Type> |
238
|
|
|
<msChapV2:EapType> |
239
|
|
|
<msChapV2:UseWinLogonCredentials>false</msChapV2:UseWinLogonCredentials> |
240
|
|
|
</msChapV2:EapType> |
241
|
|
|
</baseEap:Eap> |
242
|
|
|
<msPeap:EnableQuarantineChecks>' . $nea . '</msPeap:EnableQuarantineChecks> |
243
|
|
|
<msPeap:RequireCryptoBinding>false</msPeap:RequireCryptoBinding> |
244
|
|
|
</msPeap:EapType> |
245
|
|
|
</baseEap:Eap> |
246
|
|
|
</Config> |
247
|
|
|
'; |
248
|
|
|
$w7Ext = '<Config xmlns="http://www.microsoft.com/provisioning/EapHostConfig"> |
249
|
|
|
<Eap xmlns="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1"> |
250
|
|
|
<Type>25</Type> |
251
|
|
|
<EapType xmlns="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV1"> |
252
|
|
|
<ServerValidation> |
253
|
|
|
<DisableUserPromptForServerValidation>true</DisableUserPromptForServerValidation> |
254
|
|
|
<ServerNames>' . $servers . '</ServerNames>'; |
255
|
|
|
if ($caArray) { |
256
|
|
|
foreach ($caArray as $certAuthority) { |
257
|
|
|
if ($certAuthority['root']) { |
258
|
|
|
$w7Ext .= "<TrustedRootCA>" . $certAuthority['sha1'] . "</TrustedRootCA>\n"; |
259
|
|
|
} |
260
|
|
|
} |
261
|
|
|
} |
262
|
|
|
$w7Ext .= '</ServerValidation> |
263
|
|
|
<FastReconnect>true</FastReconnect> |
264
|
|
|
<InnerEapOptional>false</InnerEapOptional> |
265
|
|
|
<Eap xmlns="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1"> |
266
|
|
|
<Type>26</Type> |
267
|
|
|
<EapType xmlns="http://www.microsoft.com/provisioning/MsChapV2ConnectionPropertiesV1"> |
268
|
|
|
<UseWinLogonCredentials>false</UseWinLogonCredentials> |
269
|
|
|
</EapType> |
270
|
|
|
</Eap> |
271
|
|
|
<EnableQuarantineChecks>' . $nea . '</EnableQuarantineChecks> |
272
|
|
|
<RequireCryptoBinding>false</RequireCryptoBinding> |
273
|
|
|
'; |
274
|
|
|
if ($useAnon == 1) { |
275
|
|
|
$w7Ext .= '<PeapExtensions> |
276
|
|
|
<IdentityPrivacy xmlns="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV2"> |
277
|
|
|
<EnableIdentityPrivacy>true</EnableIdentityPrivacy> |
278
|
|
|
<AnonymousUserName>' . $outerUser . '</AnonymousUserName> |
279
|
|
|
</IdentityPrivacy> |
280
|
|
|
</PeapExtensions> |
281
|
|
|
'; |
282
|
|
|
} |
283
|
|
|
$w7Ext .= '</EapType> |
284
|
|
|
</Eap> |
285
|
|
|
</Config> |
286
|
|
|
'; |
287
|
|
|
} elseif ($this->selectedEap == \core\common\EAP::EAPTYPE_PWD) { |
288
|
|
|
$profileFileCont .= '<ConfigBlob></ConfigBlob>'; |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
|
292
|
|
|
|
293
|
|
|
$profileFileContEnd = '</EapHostConfig></EAPConfig> |
294
|
|
|
'; |
295
|
|
|
$returnArray = []; |
296
|
|
|
$returnArray['vista'] = $profileFileCont . $vistaExt . $profileFileContEnd; |
297
|
|
|
$returnArray['w7'] = $profileFileCont . $w7Ext . $profileFileContEnd; |
298
|
|
|
return $returnArray; |
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
/** |
302
|
|
|
* produce PEAP, TLS and TTLS configuration files for Vista and Windows 7 |
303
|
|
|
* |
304
|
|
|
* @param string $wlanProfileName |
305
|
|
|
* @param string $ssid |
306
|
|
|
* @param string $auth can be one of "WPA", "WPA2" |
307
|
|
|
* @param string $encryption can be one of: "TKIP", "AES" |
308
|
|
|
* @param array $eapConfig XML configuration block with EAP config data (two entries, one for Vista, one for 7) |
309
|
|
|
* @param int $profileNumber counter, which profile number is this |
310
|
|
|
* @return string |
311
|
|
|
*/ |
312
|
|
|
private function writeWLANprofile($wlanProfileName, $ssid, $auth, $encryption, $eapConfig, $profileNumber) { |
313
|
|
|
$profileFileCont = '<?xml version="1.0"?> |
314
|
|
|
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1"> |
315
|
|
|
<name>' . $wlanProfileName . '</name> |
316
|
|
|
<SSIDConfig> |
317
|
|
|
<SSID> |
318
|
|
|
<name>' . $ssid . '</name> |
319
|
|
|
</SSID> |
320
|
|
|
<nonBroadcast>true</nonBroadcast> |
321
|
|
|
</SSIDConfig> |
322
|
|
|
<connectionType>ESS</connectionType> |
323
|
|
|
<connectionMode>auto</connectionMode> |
324
|
|
|
<autoSwitch>false</autoSwitch> |
325
|
|
|
<MSM> |
326
|
|
|
<security> |
327
|
|
|
<authEncryption> |
328
|
|
|
<authentication>' . $auth . '</authentication> |
329
|
|
|
<encryption>' . $encryption . '</encryption> |
330
|
|
|
<useOneX>true</useOneX> |
331
|
|
|
</authEncryption> |
332
|
|
|
'; |
333
|
|
|
if ($auth == 'WPA2') { |
334
|
|
|
$profileFileCont .= '<PMKCacheMode>enabled</PMKCacheMode> |
335
|
|
|
<PMKCacheTTL>720</PMKCacheTTL> |
336
|
|
|
<PMKCacheSize>128</PMKCacheSize> |
337
|
|
|
<preAuthMode>disabled</preAuthMode> |
338
|
|
|
'; |
339
|
|
|
} |
340
|
|
|
$profileFileCont .= '<OneX xmlns="http://www.microsoft.com/networking/OneX/v1"> |
341
|
|
|
<cacheUserData>true</cacheUserData> |
342
|
|
|
<authMode>user</authMode> |
343
|
|
|
'; |
344
|
|
|
|
345
|
|
|
$closing = ' |
346
|
|
|
</OneX> |
347
|
|
|
</security> |
348
|
|
|
</MSM> |
349
|
|
|
</WLANProfile> |
350
|
|
|
'; |
351
|
|
|
|
352
|
|
|
if (!is_dir('w7')) { |
353
|
|
|
mkdir('w7'); |
354
|
|
|
} |
355
|
|
|
if (!is_dir('vista')) { |
356
|
|
|
mkdir('vista'); |
357
|
|
|
} |
358
|
|
|
$vistaFileName = "vista/wlan_prof-$profileNumber.xml"; |
359
|
|
|
$vistaFileHandle = fopen($vistaFileName, 'w'); |
360
|
|
|
fwrite($vistaFileHandle, $profileFileCont . $eapConfig['vista'] . $closing); |
361
|
|
|
fclose($vistaFileHandle); |
362
|
|
|
$sevenFileName = "w7/wlan_prof-$profileNumber.xml"; |
363
|
|
|
$sevenFileHandle = fopen($sevenFileName, 'w'); |
364
|
|
|
fwrite($sevenFileHandle, $profileFileCont . $eapConfig['w7'] . $closing); |
365
|
|
|
fclose($sevenFileHandle); |
366
|
|
|
$this->loggerInstance->debug(2, "Installer has been written into directory $this->FPATH\n"); |
367
|
|
|
$this->loggerInstance->debug(4, "WLAN_Profile:$wlanProfileName:$encryption\n"); |
368
|
|
|
return("\"$wlanProfileName\" \"$encryption\""); |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
private function writeLANprofile($eapConfig) { |
372
|
|
|
$profileFileCont = '<?xml version="1.0"?> |
373
|
|
|
<LANProfile xmlns="http://www.microsoft.com/networking/LAN/profile/v1"> |
374
|
|
|
<MSM> |
375
|
|
|
<security> |
376
|
|
|
<OneXEnforced>false</OneXEnforced> |
377
|
|
|
<OneXEnabled>true</OneXEnabled> |
378
|
|
|
<OneX xmlns="http://www.microsoft.com/networking/OneX/v1"> |
379
|
|
|
<cacheUserData>true</cacheUserData> |
380
|
|
|
<authMode>user</authMode> |
381
|
|
|
'; |
382
|
|
|
$closing = ' |
383
|
|
|
</OneX> |
384
|
|
|
</security> |
385
|
|
|
</MSM> |
386
|
|
|
</LANProfile> |
387
|
|
|
'; |
388
|
|
|
if (!is_dir('w7')) { |
389
|
|
|
mkdir('w7'); |
390
|
|
|
} |
391
|
|
|
if (!is_dir('vista')) { |
392
|
|
|
mkdir('vista'); |
393
|
|
|
} |
394
|
|
|
$vistaFileName = "vista/lan_prof.xml"; |
395
|
|
|
$vistaFileHandle = fopen($vistaFileName, 'w'); |
396
|
|
|
fwrite($vistaFileHandle, $profileFileCont . $eapConfig['vista'] . $closing); |
397
|
|
|
fclose($vistaFileHandle); |
398
|
|
|
$sevenFileName = "w7/lan_prof.xml"; |
399
|
|
|
$sevenFileHandle = fopen($sevenFileName, 'w'); |
400
|
|
|
fwrite($sevenFileHandle, $profileFileCont . $eapConfig['w7'] . $closing); |
401
|
|
|
fclose($sevenFileHandle); |
402
|
|
|
} |
403
|
|
|
|
404
|
|
|
private function writeMainNSH($eap, $attr) { |
405
|
|
|
$this->loggerInstance->debug(4, "writeMainNSH"); |
406
|
|
|
$this->loggerInstance->debug(4, $attr); |
407
|
|
|
$this->loggerInstance->debug(4, "MYLANG=" . $this->lang . "\n"); |
408
|
|
|
|
409
|
|
|
$eapOptions = [ |
410
|
|
|
\core\common\EAP::PEAP => ['str' => 'PEAP', 'exec' => 'user'], |
411
|
|
|
\core\common\EAP::TLS => ['str' => 'TLS', 'exec' => 'user'], |
412
|
|
|
// TODO for TW: the following line doesn't work - that constant is an array, which can't be a key for another array |
413
|
|
|
// generated a PHP Warning but doesn't seem to have any catastrophic effect? |
414
|
|
|
// \core\common\EAP::EAPTYPE_SILVERBULLET => ['str' => 'TLS', 'exec' => 'user'], |
415
|
|
|
\core\common\EAP::TTLS => ['str' => 'GEANTLink', 'exec' => 'user'], |
416
|
|
|
\core\common\EAP::PWD => ['str' => 'PWD', 'exec' => 'user'], |
417
|
|
|
]; |
418
|
|
|
$fcontents = ''; |
419
|
|
|
if (CONFIG_CONFASSISTANT['NSIS_VERSION'] >= 3) { |
420
|
|
|
$fcontents .= "Unicode true\n"; |
421
|
|
|
} |
422
|
|
|
|
423
|
|
|
// Uncomment the line below if you want this module to run under XP (only displaying a warning) |
424
|
|
|
// $fcontents .= "!define ALLOW_XP\n"; |
425
|
|
|
// Uncomment the line below if you want this module to produce debugging messages on the client |
426
|
|
|
// $fcontents .= "!define DEBUG_CAT\n"; |
427
|
|
|
if ($this->tlsOtherUsername == 1) { |
428
|
|
|
$fcontents .= "!define PFX_USERNAME\n"; |
429
|
|
|
} |
430
|
|
|
$execLevel = $eapOptions[$eap["OUTER"]]['exec']; |
431
|
|
|
$eapStr = $eapOptions[$eap["OUTER"]]['str']; |
432
|
|
|
if ($eap == \core\common\EAP::EAPTYPE_SILVERBULLET) { |
433
|
|
|
$fcontents .= "!define SILVERBULLET\n"; |
434
|
|
|
} |
435
|
|
|
$this->loggerInstance->debug(4, "EAP_STR=$eapStr\n"); |
436
|
|
|
$this->loggerInstance->debug(4, $eap); |
437
|
|
|
|
438
|
|
|
$fcontents .= '!define ' . $eapStr; |
439
|
|
|
$fcontents .= "\n" . '!define EXECLEVEL "' . $execLevel . '"'; |
440
|
|
|
$fcontents .= $this->writeNsisDefines($eap, $attr); |
441
|
|
|
$fileHandle = fopen('main.nsh', 'w'); |
442
|
|
|
fwrite($fileHandle, $fcontents); |
443
|
|
|
fclose($fileHandle); |
444
|
|
|
} |
445
|
|
|
|
446
|
|
View Code Duplication |
private function writeProfilesNSH($wlanProfiles, $caArray, $wired = 0) { |
|
|
|
|
447
|
|
|
$this->loggerInstance->debug(4, "writeProfilesNSH"); |
448
|
|
|
$this->loggerInstance->debug(4, $wlanProfiles); |
449
|
|
|
$contentWlan = ''; |
450
|
|
|
foreach ($wlanProfiles as $wlanProfile) { |
451
|
|
|
$contentWlan .= "!insertmacro define_wlan_profile $wlanProfile\n"; |
452
|
|
|
} |
453
|
|
|
|
454
|
|
|
$fileHandleProfiles = fopen('profiles.nsh', 'w'); |
455
|
|
|
fwrite($fileHandleProfiles, $contentWlan); |
456
|
|
|
fclose($fileHandleProfiles); |
457
|
|
|
|
458
|
|
|
$contentCerts = ''; |
459
|
|
|
$fileHandleCerts = fopen('certs.nsh', 'w'); |
460
|
|
|
if ($caArray) { |
461
|
|
|
foreach ($caArray as $certAuthority) { |
462
|
|
|
$store = $certAuthority['root'] ? "root" : "ca"; |
463
|
|
|
$contentCerts .= '!insertmacro install_ca_cert "' . $certAuthority['file'] . '" "' . $certAuthority['sha1'] . '" "' . $store . "\"\n"; |
464
|
|
|
} |
465
|
|
|
fwrite($fileHandleCerts, $contentCerts); |
466
|
|
|
} |
467
|
|
|
fclose($fileHandleCerts); |
468
|
|
|
} |
469
|
|
|
|
470
|
|
|
private function copyFiles($eap) { |
471
|
|
|
$this->loggerInstance->debug(4, "copyFiles start\n"); |
472
|
|
|
$this->loggerInstance->debug(4, "code_page=" . $this->codePage . "\n"); |
473
|
|
|
$this->copyBasicFiles(); |
474
|
|
|
|
475
|
|
View Code Duplication |
switch ($eap["OUTER"]) { |
|
|
|
|
476
|
|
|
case \core\common\EAP::TTLS: |
477
|
|
|
$this->copyGeantLinkFiles(); |
478
|
|
|
break; |
479
|
|
|
case \core\common\EAP::PWD: |
480
|
|
|
$this->copyPwdFiles(); |
481
|
|
|
break; |
482
|
|
|
default: |
483
|
|
|
if (!$this->translateFile('peap_tls.inc', 'cat.NSI', $this->codePage)) { |
484
|
|
|
throw new Exception("Translating needed file peap_tls.inc failed!"); |
485
|
|
|
} |
486
|
|
|
} |
487
|
|
|
$this->loggerInstance->debug(4, "copyFiles end\n"); |
488
|
|
|
return TRUE; |
489
|
|
|
} |
490
|
|
|
|
491
|
|
|
private $tlsOtherUsername = 0; |
492
|
|
|
|
493
|
|
|
} |
494
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.