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 8 installers |
14
|
|
|
* It supports EAP-TLS, TTLS, PEAP and EAP-pwd |
15
|
|
|
* @author Tomasz Wolniewicz <[email protected]> |
16
|
|
|
* |
17
|
|
|
* @package ModuleWriting |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace devices\ms; |
21
|
|
|
use \Exception; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* |
25
|
|
|
* @author Tomasz Wolniewicz <[email protected]> |
26
|
|
|
* @package ModuleWriting |
27
|
|
|
*/ |
28
|
|
|
class Device_W10 extends WindowsCommon { |
29
|
|
|
|
30
|
|
|
final public function __construct() { |
31
|
|
|
parent::__construct(); |
32
|
|
|
$this->setSupportedEapMethods([\core\common\EAP::EAPTYPE_TLS, \core\common\EAP::EAPTYPE_PEAP_MSCHAP2, \core\common\EAP::EAPTYPE_TTLS_PAP, \core\common\EAP::EAPTYPE_TTLS_MSCHAP2, \core\common\EAP::EAPTYPE_PWD, \core\common\EAP::EAPTYPE_SILVERBULLET]); |
33
|
|
|
$this->specialities['anon_id'][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
|
|
|
$allSSID = $this->attributes['internal:SSID']; |
42
|
|
|
$delSSIDs = $this->attributes['internal:remove_SSID']; |
43
|
|
|
$this->prepareInstallerLang(); |
44
|
|
|
$setWired = isset($this->attributes['media:wired'][0]) && $this->attributes['media:wired'][0] == 'on' ? 1 : 0; |
45
|
|
|
// create a list of profiles to be deleted after installation |
46
|
|
|
$delProfiles = []; |
47
|
|
|
foreach ($delSSIDs as $ssid => $cipher) { |
48
|
|
|
if ($cipher == 'DEL') { |
49
|
|
|
$delProfiles[] = $ssid; |
50
|
|
|
} |
51
|
|
|
if ($cipher == 'TKIP') { |
52
|
|
|
$delProfiles[] = $ssid . ' (TKIP)'; |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
|
57
|
|
|
if (in_array($this->selectedEap, [\core\common\EAP::EAPTYPE_TLS, |
58
|
|
|
\core\common\EAP::EAPTYPE_PEAP_MSCHAP2, |
59
|
|
|
\core\common\EAP::EAPTYPE_TTLS_PAP, |
60
|
|
|
\core\common\EAP::EAPTYPE_TTLS_MSCHAP2, |
61
|
|
|
\core\common\EAP::EAPTYPE_PWD, |
62
|
|
|
\core\common\EAP::EAPTYPE_SILVERBULLET])) { |
63
|
|
|
$windowsProfile = []; |
64
|
|
|
$eapConfig = $this->prepareEapConfig($this->attributes); |
65
|
|
|
$iterator = 0; |
66
|
|
|
foreach ($allSSID as $ssid => $cipher) { |
67
|
|
|
if ($cipher == 'TKIP') { |
68
|
|
|
$windowsProfile[$iterator] = $this->writeWLANprofile($ssid . ' (TKIP)', $ssid, 'WPA', 'TKIP', $eapConfig, $iterator); |
69
|
|
|
$iterator++; |
70
|
|
|
} |
71
|
|
|
$windowsProfile[$iterator] = $this->writeWLANprofile($ssid, $ssid, 'WPA2', 'AES', $eapConfig, $iterator); |
72
|
|
|
$iterator++; |
73
|
|
|
} |
74
|
|
|
if ($setWired) { |
75
|
|
|
$this->writeLANprofile($eapConfig); |
76
|
|
|
} |
77
|
|
|
} else { |
78
|
|
|
print(" this EAP type is not handled yet.\n"); |
79
|
|
|
return; |
80
|
|
|
} |
81
|
|
|
$this->loggerInstance->debug(4, "windowsProfile"); |
82
|
|
|
$this->loggerInstance->debug(4, print_r($windowsProfile, true)); |
83
|
|
|
|
84
|
|
|
$this->writeProfilesNSH($windowsProfile, $caFiles, $setWired); |
85
|
|
|
$this->writeAdditionalDeletes($delProfiles); |
86
|
|
|
if (isset($additionalDeletes) && count($additionalDeletes)) { |
|
|
|
|
87
|
|
|
$this->writeAdditionalDeletes($additionalDeletes); |
88
|
|
|
} |
89
|
|
|
if ($this->selectedEap == \core\common\EAP::EAPTYPE_SILVERBULLET) { |
90
|
|
|
$this->writeClientP12File(); |
91
|
|
|
} |
92
|
|
|
$this->copyFiles($this->selectedEap); |
93
|
|
|
$fedLogo = $this->attributes['fed:logo_file'] ?? NULL; |
94
|
|
|
if (isset($this->attributes['internal:logo_file'])) { |
95
|
|
|
$this->combineLogo($this->attributes['internal:logo_file'], $fedLogo); |
96
|
|
|
} |
97
|
|
|
$this->writeMainNSH($this->selectedEap, $this->attributes); |
98
|
|
|
$this->compileNSIS(); |
99
|
|
|
$installerPath = $this->signInstaller(); |
100
|
|
|
|
101
|
|
|
textdomain($dom); |
102
|
|
|
return($installerPath); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
private function prepareEapConfig($attr) { |
106
|
|
|
$eap = $this->selectedEap; |
107
|
|
|
$w10Ext = ''; |
108
|
|
|
// there is only one caller to this function, and it will always call |
109
|
|
|
// with exactly one of exactly the EAP types below. Let's assert() that |
110
|
|
|
// rather than returning void, otherwise this is a condition that needs |
111
|
|
|
// to be caught later on. |
112
|
|
|
assert(in_array($eap, [\core\common\EAP::EAPTYPE_TLS, |
113
|
|
|
\core\common\EAP::EAPTYPE_PEAP_MSCHAP2, |
114
|
|
|
\core\common\EAP::EAPTYPE_PWD, |
115
|
|
|
\core\common\EAP::EAPTYPE_TTLS_PAP, |
116
|
|
|
\core\common\EAP::EAPTYPE_TTLS_MSCHAP2, |
117
|
|
|
\core\common\EAP::EAPTYPE_SILVERBULLET]), new Exception("prepareEapConfig called for an EAP type it cannot handle!")); |
118
|
|
|
|
119
|
|
|
$useAnon = $attr['internal:use_anon_outer'] [0]; |
120
|
|
View Code Duplication |
if ($useAnon) { |
|
|
|
|
121
|
|
|
$outerUser = $attr['internal:anon_local_value'][0]; |
122
|
|
|
$outerId = $outerUser . '@' . $attr['internal:realm'][0]; |
123
|
|
|
} |
124
|
|
|
// $servers = preg_quote(implode(';',$attr['eap:server_name'])); |
|
|
|
|
125
|
|
|
$servers = implode(';', $attr['eap:server_name']); |
126
|
|
|
$caArray = $attr['internal:CAs'][0]; |
127
|
|
|
$authorId = "0"; |
128
|
|
|
if ($eap == \core\common\EAP::EAPTYPE_TTLS_PAP || $eap == \core\common\EAP::EAPTYPE_TTLS_MSCHAP2) { |
129
|
|
|
if ($this->useGeantLink) { |
130
|
|
|
$authorId = "67532"; |
131
|
|
|
$servers = implode('</ServerName><ServerName>', $attr['eap:server_name']); |
132
|
|
|
} else { |
133
|
|
|
$authorId = "311"; |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
$profileFileCont = '<EAPConfig><EapHostConfig xmlns="http://www.microsoft.com/provisioning/EapHostConfig"> |
138
|
|
|
<EapMethod> |
139
|
|
|
'; |
140
|
|
|
|
141
|
|
|
$profileFileCont .= '<Type xmlns="http://www.microsoft.com/provisioning/EapCommon">' . |
142
|
|
|
$this->selectedEap["OUTER"] . '</Type> |
143
|
|
|
<VendorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</VendorId> |
144
|
|
|
<VendorType xmlns="http://www.microsoft.com/provisioning/EapCommon">0</VendorType> |
145
|
|
|
<AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">' . $authorId . '</AuthorId> |
146
|
|
|
</EapMethod> |
147
|
|
|
'; |
148
|
|
|
if ($eap == \core\common\EAP::EAPTYPE_TLS || $eap == \core\common\EAP::EAPTYPE_SILVERBULLET) { |
149
|
|
|
$profileFileCont .= ' |
150
|
|
|
|
151
|
|
|
<Config xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1" |
152
|
|
|
xmlns:eapTls="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV1"> |
153
|
|
|
<baseEap:Eap> |
154
|
|
|
<baseEap:Type>13</baseEap:Type> |
155
|
|
|
<eapTls:EapType> |
156
|
|
|
<eapTls:CredentialsSource> |
157
|
|
|
<eapTls:CertificateStore /> |
158
|
|
|
</eapTls:CredentialsSource> |
159
|
|
|
<eapTls:ServerValidation> |
160
|
|
|
<eapTls:DisableUserPromptForServerValidation>true</eapTls:DisableUserPromptForServerValidation> |
161
|
|
|
<eapTls:ServerNames>' . $servers . '</eapTls:ServerNames>'; |
162
|
|
View Code Duplication |
if ($caArray) { |
|
|
|
|
163
|
|
|
foreach ($caArray as $certAuthority) { |
164
|
|
|
if ($certAuthority['root']) { |
165
|
|
|
$profileFileCont .= "<eapTls:TrustedRootCA>" . $certAuthority['sha1'] . "</eapTls:TrustedRootCA>\n"; |
166
|
|
|
} |
167
|
|
|
} |
168
|
|
|
} |
169
|
|
|
$profileFileCont .= '</eapTls:ServerValidation> |
170
|
|
|
'; |
171
|
|
View Code Duplication |
if (isset($attr['eap-specific:tls_use_other_id']) && $attr['eap-specific:tls_use_other_id'][0] == 'on') { |
|
|
|
|
172
|
|
|
$profileFileCont .= '<eapTls:DifferentUsername>true</eapTls:DifferentUsername>'; |
173
|
|
|
$this->tlsOtherUsername = 1; |
174
|
|
|
} else { |
175
|
|
|
$profileFileCont .= '<eapTls:DifferentUsername>false</eapTls:DifferentUsername>'; |
176
|
|
|
} |
177
|
|
|
$profileFileCont .= ' |
178
|
|
|
</eapTls:EapType> |
179
|
|
|
</baseEap:Eap> |
180
|
|
|
</Config> |
181
|
|
|
'; |
182
|
|
View Code Duplication |
} elseif ($eap == \core\common\EAP::EAPTYPE_PEAP_MSCHAP2) { |
|
|
|
|
183
|
|
|
if (isset($attr['eap:enable_nea']) && $attr['eap:enable_nea'][0] == 'on') { |
184
|
|
|
$nea = 'true'; |
185
|
|
|
} else { |
186
|
|
|
$nea = 'false'; |
187
|
|
|
} |
188
|
|
|
$w10Ext = '<Config xmlns="http://www.microsoft.com/provisioning/EapHostConfig"> |
189
|
|
|
<Eap xmlns="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1"> |
190
|
|
|
<Type>25</Type> |
191
|
|
|
<EapType xmlns="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV1"> |
192
|
|
|
<ServerValidation> |
193
|
|
|
<DisableUserPromptForServerValidation>true</DisableUserPromptForServerValidation> |
194
|
|
|
<ServerNames>' . $servers . '</ServerNames>'; |
195
|
|
|
if ($caArray) { |
196
|
|
|
foreach ($caArray as $certAuthority) { |
197
|
|
|
if ($certAuthority['root']) { |
198
|
|
|
$w10Ext .= "<TrustedRootCA>" . $certAuthority['sha1'] . "</TrustedRootCA>\n"; |
199
|
|
|
} |
200
|
|
|
} |
201
|
|
|
} |
202
|
|
|
$w10Ext .= '</ServerValidation> |
203
|
|
|
<FastReconnect>true</FastReconnect> |
204
|
|
|
<InnerEapOptional>false</InnerEapOptional> |
205
|
|
|
<Eap xmlns="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1"> |
206
|
|
|
<Type>26</Type> |
207
|
|
|
<EapType xmlns="http://www.microsoft.com/provisioning/MsChapV2ConnectionPropertiesV1"> |
208
|
|
|
<UseWinLogonCredentials>false</UseWinLogonCredentials> |
209
|
|
|
</EapType> |
210
|
|
|
</Eap> |
211
|
|
|
<EnableQuarantineChecks>' . $nea . '</EnableQuarantineChecks> |
212
|
|
|
<RequireCryptoBinding>false</RequireCryptoBinding> |
213
|
|
|
'; |
214
|
|
|
if ($useAnon == 1) { |
215
|
|
|
$w10Ext .= '<PeapExtensions> |
216
|
|
|
<IdentityPrivacy xmlns="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV2"> |
217
|
|
|
<EnableIdentityPrivacy>true</EnableIdentityPrivacy> |
218
|
|
|
'; |
219
|
|
|
if (isset($outerUser) && $outerUser) { |
220
|
|
|
$w10Ext .= '<AnonymousUserName>' . $outerUser . '</AnonymousUserName> |
221
|
|
|
'; |
222
|
|
|
} else { |
223
|
|
|
$w10Ext .= '<AnonymousUserName/> |
224
|
|
|
'; |
225
|
|
|
} |
226
|
|
|
$w10Ext .= '</IdentityPrivacy> |
227
|
|
|
</PeapExtensions> |
228
|
|
|
'; |
229
|
|
|
} |
230
|
|
|
$w10Ext .= '</EapType> |
231
|
|
|
</Eap> |
232
|
|
|
</Config> |
233
|
|
|
'; |
234
|
|
|
} elseif ($eap == \core\common\EAP::EAPTYPE_TTLS_PAP || $eap == \core\common\EAP::EAPTYPE_TTLS_MSCHAP2) { |
235
|
|
|
if ($this->useGeantLink) { |
236
|
|
|
$innerMethod = 'MSCHAPv2'; |
237
|
|
|
if ($eap == \core\common\EAP::EAPTYPE_TTLS_PAP) { |
238
|
|
|
$innerMethod = 'PAP'; |
239
|
|
|
} |
240
|
|
|
$profileFileCont .= ' |
241
|
|
|
<Config xmlns="http://www.microsoft.com/provisioning/EapHostConfig"> |
242
|
|
|
<EAPIdentityProviderList xmlns="urn:ietf:params:xml:ns:yang:ietf-eap-metadata"> |
243
|
|
|
<EAPIdentityProvider ID="' . $this->deviceUUID . '" namespace="urn:UUID"> |
244
|
|
|
|
245
|
|
|
<ProviderInfo> |
246
|
|
|
<DisplayName>' . $this->translateString($attr['general:instname'][0], $this->code_page) . '</DisplayName> |
|
|
|
|
247
|
|
|
</ProviderInfo> |
248
|
|
|
<AuthenticationMethods> |
249
|
|
|
<AuthenticationMethod> |
250
|
|
|
<EAPMethod>21</EAPMethod> |
251
|
|
|
<ClientSideCredential> |
252
|
|
|
<allow-save>true</allow-save> |
253
|
|
|
'; |
254
|
|
|
if ($use_anon == 1) { |
|
|
|
|
255
|
|
|
if ($outer_user == '') |
|
|
|
|
256
|
|
|
$profileFileCont .= '<AnonymousIdentity>@</AnonymousIdentity>'; |
257
|
|
|
else |
258
|
|
|
$profileFileCont .= '<AnonymousIdentity>' . $outer_id . '</AnonymousIdentity>'; |
|
|
|
|
259
|
|
|
} |
260
|
|
|
$profileFileCont .= '</ClientSideCredential> |
261
|
|
|
<ServerSideCredential> |
262
|
|
|
'; |
263
|
|
|
|
264
|
|
View Code Duplication |
foreach ($caArray as $ca) { |
|
|
|
|
265
|
|
|
$profileFileCont .= '<CA><format>PEM</format><cert-data>'; |
266
|
|
|
$profileFileCont .= base64_encode($ca['der']); |
267
|
|
|
$profileFileCont .= '</cert-data></CA> |
268
|
|
|
'; |
269
|
|
|
} |
270
|
|
|
$profileFileCont .= "<ServerName>$servers</ServerName>\n"; |
271
|
|
|
|
272
|
|
|
$profileFileCont .= ' |
273
|
|
|
</ServerSideCredential> |
274
|
|
|
<InnerAuthenticationMethod> |
275
|
|
|
<NonEAPAuthMethod>' . $innerMethod . '</NonEAPAuthMethod> |
276
|
|
|
</InnerAuthenticationMethod> |
277
|
|
|
<VendorSpecific> |
278
|
|
|
<SessionResumption>false</SessionResumption> |
279
|
|
|
</VendorSpecific> |
280
|
|
|
</AuthenticationMethod> |
281
|
|
|
</AuthenticationMethods> |
282
|
|
|
</EAPIdentityProvider> |
283
|
|
|
</EAPIdentityProviderList> |
284
|
|
|
</Config> |
285
|
|
|
'; |
286
|
|
|
} else { |
287
|
|
|
$w10Ext = '<Config xmlns="http://www.microsoft.com/provisioning/EapHostConfig"> |
288
|
|
|
<EapTtls xmlns="http://www.microsoft.com/provisioning/EapTtlsConnectionPropertiesV1"> |
289
|
|
|
<ServerValidation> |
290
|
|
|
<ServerNames>' . $servers . '</ServerNames> '; |
291
|
|
|
if ($caArray) { |
292
|
|
|
foreach ($caArray as $certAuthority) { |
293
|
|
|
if ($certAuthority['root']) { |
294
|
|
|
$w10Ext .= "<TrustedRootCAHash>" . chunk_split($certAuthority['sha1'], 2, ' ') . "</TrustedRootCAHash>\n"; |
295
|
|
|
} |
296
|
|
|
} |
297
|
|
|
} |
298
|
|
|
$w10Ext .= '<DisablePrompt>true</DisablePrompt> |
299
|
|
|
</ServerValidation> |
300
|
|
|
<Phase2Authentication> |
301
|
|
|
'; |
302
|
|
|
if ($eap == \core\common\EAP::EAPTYPE_TTLS_PAP) { |
303
|
|
|
$w10Ext .= '<PAPAuthentication /> '; |
304
|
|
|
} |
305
|
|
|
if ($eap == \core\common\EAP::EAPTYPE_TTLS_MSCHAP2) { |
306
|
|
|
$w10Ext .= '<MSCHAPv2Authentication> |
307
|
|
|
<UseWinlogonCredentials>false</UseWinlogonCredentials> |
308
|
|
|
</MSCHAPv2Authentication> |
309
|
|
|
'; |
310
|
|
|
} |
311
|
|
|
$w10Ext .= '</Phase2Authentication> |
312
|
|
|
<Phase1Identity> |
313
|
|
|
'; |
314
|
|
|
if ($useAnon == 1) { |
315
|
|
|
$w10Ext .= '<IdentityPrivacy>true</IdentityPrivacy> |
316
|
|
|
'; |
317
|
|
|
if (isset($outerId) && $outerId) { |
318
|
|
|
$w10Ext .= '<AnonymousIdentity>' . $outerId . '</AnonymousIdentity> |
319
|
|
|
'; |
320
|
|
|
} else { |
321
|
|
|
$w10Ext .= '<AnonymousIdentity/> |
322
|
|
|
'; |
323
|
|
|
} |
324
|
|
|
} else { |
325
|
|
|
$w10Ext .= '<IdentityPrivacy>false</IdentityPrivacy> |
326
|
|
|
'; |
327
|
|
|
} |
328
|
|
|
$w10Ext .= '</Phase1Identity> |
329
|
|
|
</EapTtls> |
330
|
|
|
</Config> |
331
|
|
|
'; |
332
|
|
|
} |
333
|
|
|
} elseif ($eap == \core\common\EAP::EAPTYPE_PWD) { |
334
|
|
|
$profileFileCont .= '<ConfigBlob></ConfigBlob>'; |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
$profileFileContEnd = '</EapHostConfig></EAPConfig>'; |
338
|
|
|
$returnArray = []; |
339
|
|
|
$returnArray['w10'] = $profileFileCont . $w10Ext . $profileFileContEnd; |
340
|
|
|
return $returnArray; |
341
|
|
|
} |
342
|
|
|
|
343
|
|
|
/** |
344
|
|
|
* produce PEAP, TLS and TTLS configuration files for Windows 8 |
345
|
|
|
* |
346
|
|
|
* @param string $wlanProfileName |
347
|
|
|
* @param string $ssid |
348
|
|
|
* @param string $auth can be one of "WPA", "WPA2" |
349
|
|
|
* @param string $encryption can be one of: "TKIP", "AES" |
350
|
|
|
* @param array $eapConfig XML configuration block with EAP config data |
351
|
|
|
* @param int $profileNumber counter, which profile number is this |
352
|
|
|
* @return string |
353
|
|
|
*/ |
354
|
|
View Code Duplication |
private function writeWLANprofile($wlanProfileName, $ssid, $auth, $encryption, $eapConfig, $profileNumber) { |
|
|
|
|
355
|
|
|
$profileFileCont = '<?xml version="1.0"?> |
356
|
|
|
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1"> |
357
|
|
|
<name>' . $wlanProfileName . '</name> |
358
|
|
|
<SSIDConfig> |
359
|
|
|
<SSID> |
360
|
|
|
<name>' . $ssid . '</name> |
361
|
|
|
</SSID> |
362
|
|
|
<nonBroadcast>true</nonBroadcast> |
363
|
|
|
</SSIDConfig> |
364
|
|
|
<connectionType>ESS</connectionType> |
365
|
|
|
<connectionMode>auto</connectionMode> |
366
|
|
|
<autoSwitch>false</autoSwitch> |
367
|
|
|
<MSM> |
368
|
|
|
<security> |
369
|
|
|
<authEncryption> |
370
|
|
|
<authentication>' . $auth . '</authentication> |
371
|
|
|
<encryption>' . $encryption . '</encryption> |
372
|
|
|
<useOneX>true</useOneX> |
373
|
|
|
</authEncryption> |
374
|
|
|
'; |
375
|
|
|
if ($auth == 'WPA2') { |
376
|
|
|
$profileFileCont .= '<PMKCacheMode>enabled</PMKCacheMode> |
377
|
|
|
<PMKCacheTTL>720</PMKCacheTTL> |
378
|
|
|
<PMKCacheSize>128</PMKCacheSize> |
379
|
|
|
<preAuthMode>disabled</preAuthMode> |
380
|
|
|
'; |
381
|
|
|
} |
382
|
|
|
$profileFileCont .= '<OneX xmlns="http://www.microsoft.com/networking/OneX/v1"> |
383
|
|
|
<cacheUserData>true</cacheUserData> |
384
|
|
|
<authMode>user</authMode> |
385
|
|
|
'; |
386
|
|
|
|
387
|
|
|
$closing = ' |
388
|
|
|
</OneX> |
389
|
|
|
</security> |
390
|
|
|
</MSM> |
391
|
|
|
</WLANProfile> |
392
|
|
|
'; |
393
|
|
|
|
394
|
|
|
if (!is_dir('w8')) { |
395
|
|
|
mkdir('w8'); |
396
|
|
|
} |
397
|
|
|
$xmlFname = "w8/wlan_prof-$profileNumber.xml"; |
398
|
|
|
$xmlF = fopen($xmlFname, 'w'); |
399
|
|
|
fwrite($xmlF, $profileFileCont . $eapConfig['w10'] . $closing); |
400
|
|
|
fclose($xmlF); |
401
|
|
|
$this->loggerInstance->debug(2, "Installer has been written into directory $this->FPATH\n"); |
402
|
|
|
$this->loggerInstance->debug(4, "WWWWLAN_Profile:$wlanProfileName:$encryption\n"); |
403
|
|
|
return("\"$wlanProfileName\" \"$encryption\""); |
404
|
|
|
} |
405
|
|
|
|
406
|
|
View Code Duplication |
private function writeLANprofile($eapConfig) { |
|
|
|
|
407
|
|
|
$profileFileCont = '<?xml version="1.0"?> |
408
|
|
|
<LANProfile xmlns="http://www.microsoft.com/networking/LAN/profile/v1"> |
409
|
|
|
<MSM> |
410
|
|
|
<security> |
411
|
|
|
<OneXEnforced>false</OneXEnforced> |
412
|
|
|
<OneXEnabled>true</OneXEnabled> |
413
|
|
|
<OneX xmlns="http://www.microsoft.com/networking/OneX/v1"> |
414
|
|
|
<cacheUserData>true</cacheUserData> |
415
|
|
|
<authMode>user</authMode> |
416
|
|
|
'; |
417
|
|
|
$closing = ' |
418
|
|
|
</OneX> |
419
|
|
|
</security> |
420
|
|
|
</MSM> |
421
|
|
|
</LANProfile> |
422
|
|
|
'; |
423
|
|
|
|
424
|
|
|
if (!is_dir('w8')) { |
425
|
|
|
mkdir('w8'); |
426
|
|
|
} |
427
|
|
|
$xmlFname = "w8/lan_prof.xml"; |
428
|
|
|
$xmlF = fopen($xmlFname, 'w'); |
429
|
|
|
fwrite($xmlF, $profileFileCont . $eapConfig['w10'] . $closing); |
430
|
|
|
fclose($xmlF); |
431
|
|
|
$this->loggerInstance->debug(2, "Installer has been written into directory $this->FPATH\n"); |
432
|
|
|
} |
433
|
|
|
|
434
|
|
|
private function writeMainNSH($eap, $attr) { |
435
|
|
|
$this->loggerInstance->debug(4, "writeMainNSH"); |
436
|
|
|
$this->loggerInstance->debug(4, $attr); |
437
|
|
|
$fcontents = "!define W10\n"; |
438
|
|
|
$fcontents .= "!define W8\n"; |
439
|
|
|
if (CONFIG_CONFASSISTANT['NSIS_VERSION'] >= 3) { |
440
|
|
|
$fcontents .= "Unicode true\n"; |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
$eapOptions = [ |
444
|
|
|
\core\common\EAP::PEAP => ['str' => 'PEAP', 'exec' => 'user'], |
445
|
|
|
\core\common\EAP::TLS => ['str' => 'TLS', 'exec' => 'user'], |
446
|
|
|
\core\common\EAP::TTLS => ['str' => 'TTLS', 'exec' => 'user'], |
447
|
|
|
\core\common\EAP::PWD => ['str' => 'PWD', 'exec' => 'user'], |
448
|
|
|
]; |
449
|
|
|
if (isset($this->options['args']) && $this->options['args'] == 'gl') { |
450
|
|
|
$eapOptions[\core\common\EAP::TTLS]['strnnnnnnn/w'] = 'GEANTLink'; |
451
|
|
|
} |
452
|
|
|
|
453
|
|
|
// Uncomment the line below if you want this module to run under XP (only displaying a warning) |
454
|
|
|
// $fcontents .= "!define ALLOW_XP\n"; |
455
|
|
|
// Uncomment the line below if you want this module to produce debugging messages on the client |
456
|
|
|
// $fcontents .= "!define DEBUG_CAT\n"; |
457
|
|
|
if ($this->tlsOtherUsername == 1) { |
458
|
|
|
$fcontents .= "!define PFX_USERNAME\n"; |
459
|
|
|
} |
460
|
|
|
$execLevel = $eapOptions[$eap["OUTER"]]['exec']; |
461
|
|
|
$eapStr = $eapOptions[$eap["OUTER"]]['str']; |
462
|
|
|
if ($eap == \core\common\EAP::EAPTYPE_SILVERBULLET) { |
463
|
|
|
$fcontents .= "!define SILVERBULLET\n"; |
464
|
|
|
} |
465
|
|
|
$fcontents .= '!define ' . $eapStr; |
466
|
|
|
$fcontents .= "\n" . '!define EXECLEVEL "' . $execLevel . '"'; |
467
|
|
|
|
468
|
|
View Code Duplication |
if ($attr['internal:profile_count'][0] > 1) { |
|
|
|
|
469
|
|
|
$fcontents .= "\n" . '!define USER_GROUP "' . $this->translateString(str_replace('"', '$\\"', $attr['profile:name'][0]), $this->codePage) . '"'; |
470
|
|
|
} |
471
|
|
|
$fcontents .= ' |
472
|
|
|
Caption "' . $this->translateString(sprintf(WindowsCommon::sprint_nsi(_("%s installer for %s")), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name'], $attr['general:instname'][0]), $this->codePage) . '" |
473
|
|
|
!define APPLICATION "' . $this->translateString(sprintf(WindowsCommon::sprint_nsi(_("%s installer for %s")), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name'], $attr['general:instname'][0]), $this->codePage) . '" |
474
|
|
|
!define VERSION "' . \core\CAT::VERSION_MAJOR . '.' . \core\CAT::VERSION_MINOR . '" |
475
|
|
|
!define INSTALLER_NAME "installer.exe" |
476
|
|
|
!define LANG "' . $this->lang . '" |
477
|
|
|
!define LOCALE "' . preg_replace('/\..*$/', '', CONFIG['LANGUAGES'][$this->languageInstance->getLang()]['locale']) . '" |
478
|
|
|
'; |
479
|
|
|
$fcontents .= $this->msInfoFile($attr); |
480
|
|
|
|
481
|
|
|
$fcontents .= ';-------------------------------- |
482
|
|
|
!define ORGANISATION "' . $this->translateString($attr['general:instname'][0], $this->codePage) . '" |
483
|
|
|
!define SUPPORT "' . ((isset($attr['support:email'][0]) && $attr['support:email'][0] ) ? $attr['support:email'][0] : $this->translateString($this->support_email_substitute, $this->codePage)) . '" |
484
|
|
|
!define URL "' . ((isset($attr['support:url'][0]) && $attr['support:url'][0] ) ? $attr['support:url'][0] : $this->translateString($this->support_url_substitute, $this->codePage)) . '" |
485
|
|
|
|
486
|
|
|
!ifdef TLS |
487
|
|
|
'; |
488
|
|
|
//TODO this must be changed with a new option |
489
|
|
|
if ($eap != \core\common\EAP::EAPTYPE_SILVERBULLET) { |
490
|
|
|
$fcontents .= '!define TLS_CERT_STRING "certyfikaty.umk.pl" |
491
|
|
|
'; |
492
|
|
|
} |
493
|
|
|
$fcontents .= '!define TLS_FILE_NAME "cert*.p12" |
494
|
|
|
!endif |
495
|
|
|
'; |
496
|
|
|
|
497
|
|
View Code Duplication |
if (isset($this->attributes['media:wired'][0]) && $attr['media:wired'][0] == 'on') { |
|
|
|
|
498
|
|
|
$fcontents .= '!define WIRED |
499
|
|
|
'; |
500
|
|
|
} |
501
|
|
|
$fcontents .= '!define PROVIDERID "urn:UUID:' . $this->deviceUUID . '" |
502
|
|
|
'; |
503
|
|
|
$fileHandle = fopen('main.nsh', 'w'); |
504
|
|
|
fwrite($fileHandle, $fcontents); |
505
|
|
|
fclose($fileHandle); |
506
|
|
|
} |
507
|
|
|
|
508
|
|
View Code Duplication |
private function writeProfilesNSH($wlanProfiles, $caArray, $wired = 0) { |
|
|
|
|
509
|
|
|
$this->loggerInstance->debug(4, "writeProfilesNSH"); |
510
|
|
|
$this->loggerInstance->debug(4, $wlanProfiles); |
511
|
|
|
$fcontentsProfile = ''; |
512
|
|
|
foreach ($wlanProfiles as $wlanProfile) { |
513
|
|
|
$fcontentsProfile .= "!insertmacro define_wlan_profile $wlanProfile\n"; |
514
|
|
|
} |
515
|
|
|
|
516
|
|
|
$fileHandleProfiles = fopen('profiles.nsh', 'w'); |
517
|
|
|
fwrite($fileHandleProfiles, $fcontentsProfile); |
518
|
|
|
fclose($fileHandleProfiles); |
519
|
|
|
|
520
|
|
|
$fcontentsCerts = ''; |
521
|
|
|
$fileHandleCerts = fopen('certs.nsh', 'w'); |
522
|
|
|
if ($caArray) { |
523
|
|
|
foreach ($caArray as $certAuthority) { |
524
|
|
|
$store = $certAuthority['root'] ? "root" : "ca"; |
525
|
|
|
$fcontentsCerts .= '!insertmacro install_ca_cert "' . $certAuthority['file'] . '" "' . $certAuthority['sha1'] . '" "' . $store . "\"\n"; |
526
|
|
|
} |
527
|
|
|
fwrite($fileHandleCerts, $fcontentsCerts); |
528
|
|
|
} |
529
|
|
|
fclose($fileHandleCerts); |
530
|
|
|
} |
531
|
|
|
|
532
|
|
|
//private function write |
533
|
|
|
|
534
|
|
|
private function copyFiles($eap) { |
535
|
|
|
$this->loggerInstance->debug(4, "copyFiles start\n"); |
536
|
|
|
$this->copyBasicFiles(); |
537
|
|
|
switch ($eap["OUTER"]) { |
538
|
|
|
case \core\common\EAP::TTLS: |
539
|
|
|
if (isset($this->options['args']) && $this->options['args'] == 'gl') { |
540
|
|
|
$this->copyGeantLinkFiles(); |
541
|
|
|
} |
542
|
|
|
break; |
543
|
|
|
case \core\common\EAP::PWD: |
544
|
|
|
$this->copyPwdFiles(); |
545
|
|
|
break; |
546
|
|
|
default: |
547
|
|
|
if (!$this->translateFile('eap_w8.inc', 'cat.NSI', $this->codePage)) { |
548
|
|
|
throw new Exception("Translating needed file eap_w8.inc failed!"); |
549
|
|
|
} |
550
|
|
|
} |
551
|
|
|
$this->loggerInstance->debug(4, "copyFiles end\n"); |
552
|
|
|
return TRUE; |
553
|
|
|
} |
554
|
|
|
|
555
|
|
|
private $tlsOtherUsername = 0; |
556
|
|
|
|
557
|
|
|
} |
558
|
|
|
|
This check looks for calls to
isset(...)
orempty()
on variables that are yet undefined. These calls will always produce the same result and can be removed.This is most likely caused by the renaming of a variable or the removal of a function/method parameter.