| Total Complexity | 81 |
| Total Lines | 556 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like Device_W8_10 often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Device_W8_10, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 28 | class Device_W8_10 extends WindowsCommon { |
||
| 29 | final public function __construct() { |
||
| 41 | } |
||
| 42 | public function writeInstaller() { |
||
| 43 | $dom = textdomain(NULL); |
||
| 44 | textdomain("devices"); |
||
| 45 | // create certificate files and save their names in $caFiles arrary |
||
| 46 | $caFiles = $this->saveCertificateFiles('der'); |
||
| 47 | $this->caArray = $this->getAttibute('internal:CAs')[0]; |
||
| 48 | $this->useAnon = $this->attributes['internal:use_anon_outer'] [0] === NULL ? FALSE : TRUE; |
||
| 49 | $this->servers = empty($this->attributes['eap:server_name']) ? '' : implode(';', $this->attributes['eap:server_name']); |
||
| 50 | $allSSID = $this->attributes['internal:SSID']; |
||
| 51 | $delSSIDs = $this->attributes['internal:remove_SSID']; |
||
| 52 | $this->prepareInstallerLang(); |
||
| 53 | $setWired = isset($this->attributes['media:wired'][0]) && $this->attributes['media:wired'][0] == 'on' ? 1 : 0; |
||
| 54 | // create a list of profiles to be deleted after installation |
||
| 55 | $delProfiles = []; |
||
| 56 | foreach ($delSSIDs as $ssid => $cipher) { |
||
| 57 | if ($cipher == 'DEL') { |
||
| 58 | $delProfiles[] = $ssid; |
||
| 59 | } |
||
| 60 | if ($cipher == 'TKIP') { |
||
| 61 | $delProfiles[] = $ssid . ' (TKIP)'; |
||
| 62 | } |
||
| 63 | } |
||
| 64 | $windowsProfile = []; |
||
| 65 | $eapConfig = $this->prepareEapConfig(); |
||
| 66 | $iterator = 0; |
||
| 67 | foreach ($allSSID as $ssid => $cipher) { |
||
| 68 | if ($cipher == 'TKIP') { |
||
| 69 | $windowsProfile[$iterator] = $this->writeWLANprofile($ssid . ' (TKIP)', $ssid, 'WPA', 'TKIP', $eapConfig, $iterator); |
||
| 70 | $iterator++; |
||
| 71 | } |
||
| 72 | $windowsProfile[$iterator] = $this->writeWLANprofile($ssid, $ssid, 'WPA2', 'AES', $eapConfig, $iterator); |
||
| 73 | $iterator++; |
||
| 74 | } |
||
| 75 | if (($this->device_id !== 'w8') && (count($this->attributes['internal:consortia']) > 0 )) { |
||
| 76 | // this SSID name is later used in common.inc so if you decide to chage it here change it there as well |
||
| 77 | $ssid = 'cat-passpoint-profile'; |
||
| 78 | $windowsProfile[$iterator] = $this->writeWLANprofile($ssid, $ssid, 'WPA2', 'AES', $eapConfig, $iterator, TRUE); |
||
| 79 | } |
||
| 80 | if ($setWired) { |
||
| 81 | $this->writeLANprofile($eapConfig); |
||
| 82 | } |
||
| 83 | $this->loggerInstance->debug(4, "windowsProfile"); |
||
| 84 | $this->loggerInstance->debug(4, print_r($windowsProfile, true)); |
||
| 85 | |||
| 86 | $this->writeProfilesNSH($windowsProfile, $caFiles); |
||
| 87 | $this->writeAdditionalDeletes($delProfiles); |
||
| 88 | if ($this->selectedEap == \core\common\EAP::EAPTYPE_SILVERBULLET) { |
||
| 89 | $this->writeClientP12File(); |
||
| 90 | } |
||
| 91 | $this->copyFiles($this->selectedEap); |
||
| 92 | $fedLogo = $this->attributes['fed:logo_file'] ?? NULL; |
||
| 93 | $idpLogo = $this->attributes['internal:logo_file'] ?? NULL; |
||
| 94 | $this->combineLogo($idpLogo, $fedLogo); |
||
| 95 | $this->writeMainNSH($this->selectedEap, $this->attributes); |
||
| 96 | $this->compileNSIS(); |
||
| 97 | $installerPath = $this->signInstaller(); |
||
| 98 | textdomain($dom); |
||
| 99 | return($installerPath); |
||
| 100 | } |
||
| 101 | |||
| 102 | private function setAuthorId() { |
||
| 103 | if ($this->selectedEap['OUTER'] === \core\common\EAP::TTLS) { |
||
| 104 | if ($this->useGeantLink) { |
||
| 105 | $authorId = "67532"; |
||
| 106 | } else { |
||
| 107 | $authorId = "311"; |
||
| 108 | } |
||
| 109 | } else { |
||
| 110 | $authorId = 0; |
||
| 111 | } |
||
| 112 | return($authorId); |
||
| 113 | } |
||
| 114 | |||
| 115 | private function addConsortia() { |
||
| 116 | if ($this->device_id == 'w8') { |
||
| 117 | return(''); |
||
| 118 | } |
||
| 119 | $retval = '<Hotspot2>'; |
||
| 120 | $retval .= '<DomainName>'; |
||
| 121 | if (empty($this->attributes['internal:realm'][0])) { |
||
| 122 | $retval .= CONFIG_CONFASSISTANT['CONSORTIUM']['interworking-domainname-fallback']; |
||
| 123 | } else { |
||
| 124 | $retval .= $this->attributes['internal:realm'][0]; |
||
| 125 | } |
||
| 126 | $retval .= '</DomainName>'; |
||
| 127 | $retval .= '<RoamingConsortium><OUI>' . |
||
| 128 | implode('</OUI><OUI>', $this->attributes['internal:consortia']) . |
||
| 129 | '</OUI></RoamingConsortium>'; |
||
| 130 | $retval .= '</Hotspot2>'; |
||
| 131 | return($retval); |
||
| 132 | } |
||
| 133 | |||
| 134 | private function eapConfigHeader() { |
||
| 135 | $authorId = $this->setAuthorId(); |
||
| 136 | $profileFileCont = '<EAPConfig><EapHostConfig xmlns="http://www.microsoft.com/provisioning/EapHostConfig"> |
||
| 137 | <EapMethod> |
||
| 138 | '; |
||
| 139 | $profileFileCont .= '<Type xmlns="http://www.microsoft.com/provisioning/EapCommon">' . |
||
| 140 | $this->selectedEap["OUTER"] . '</Type> |
||
| 141 | <VendorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</VendorId> |
||
| 142 | <VendorType xmlns="http://www.microsoft.com/provisioning/EapCommon">0</VendorType> |
||
| 143 | <AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">' . $authorId . '</AuthorId> |
||
| 144 | </EapMethod> |
||
| 145 | '; |
||
| 146 | return($profileFileCont); |
||
| 147 | } |
||
| 148 | |||
| 149 | private function tlsServerValidation() { |
||
| 163 | } |
||
| 164 | |||
| 165 | private function msTtlsServerValidation() { |
||
| 166 | $profileFileCont = ' |
||
| 167 | <ServerValidation> |
||
| 168 | '; |
||
| 169 | $profileFileCont .= '<ServerNames>' . $this->servers . '</ServerNames> '; |
||
| 170 | foreach ($this->caArray as $certAuthority) { |
||
| 171 | if ($certAuthority['root']) { |
||
| 172 | $profileFileCont .= "<TrustedRootCAHash>" . chunk_split($certAuthority['sha1'], 2, ' ') . "</TrustedRootCAHash>\n"; |
||
| 173 | } |
||
| 174 | } |
||
| 175 | $profileFileCont .= '<DisablePrompt>true</DisablePrompt> |
||
| 176 | </ServerValidation> |
||
| 177 | '; |
||
| 178 | return($profileFileCont); |
||
| 179 | } |
||
| 180 | |||
| 181 | private function glTtlsServerValidation() { |
||
| 182 | $servers = implode('</ServerName><ServerName>', $this->attributes['eap:server_name']); |
||
| 183 | $profileFileCont = ' |
||
| 184 | <ServerSideCredential> |
||
| 185 | '; |
||
| 186 | foreach ($this->caArray as $ca) { |
||
| 187 | $profileFileCont .= '<CA><format>PEM</format><cert-data>'; |
||
| 188 | $profileFileCont .= base64_encode($ca['der']); |
||
| 189 | $profileFileCont .= '</cert-data></CA> |
||
| 190 | '; |
||
| 191 | } |
||
| 192 | $profileFileCont .= "<ServerName>$servers</ServerName>\n"; |
||
| 193 | |||
| 194 | $profileFileCont .= ' |
||
| 195 | </ServerSideCredential> |
||
| 196 | '; |
||
| 197 | return($profileFileCont); |
||
| 198 | } |
||
| 199 | |||
| 200 | private function peapServerValidation() { |
||
| 201 | $profileFileCont = ' |
||
| 202 | <ServerValidation> |
||
| 203 | <DisableUserPromptForServerValidation>true</DisableUserPromptForServerValidation> |
||
| 204 | <ServerNames>' . $this->servers . '</ServerNames>'; |
||
| 205 | foreach ($this->caArray as $certAuthority) { |
||
| 206 | if ($certAuthority['root']) { |
||
| 207 | $profileFileCont .= "<TrustedRootCA>" . $certAuthority['sha1'] . "</TrustedRootCA>\n"; |
||
| 208 | } |
||
| 209 | } |
||
| 210 | $profileFileCont .= '</ServerValidation> |
||
| 211 | '; |
||
| 212 | return($profileFileCont); |
||
| 213 | } |
||
| 214 | |||
| 215 | private function tlsConfig() { |
||
| 216 | $profileFileCont = ' |
||
| 217 | <Config xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1" |
||
| 218 | xmlns:eapTls="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV1"> |
||
| 219 | <baseEap:Eap> |
||
| 220 | <baseEap:Type>13</baseEap:Type> |
||
| 221 | <eapTls:EapType> |
||
| 222 | <eapTls:CredentialsSource> |
||
| 223 | <eapTls:CertificateStore /> |
||
| 224 | </eapTls:CredentialsSource> |
||
| 225 | '; |
||
| 226 | $profileFileCont .= $this->tlsServerValidation(); |
||
| 227 | if (\core\common\Entity::getAttributeValue($this->attributes, 'eap-specific:tls_use_other_id', 0) === 'on') { |
||
| 228 | $profileFileCont .= '<eapTls:DifferentUsername>true</eapTls:DifferentUsername>'; |
||
| 229 | $this->tlsOtherUsername = 1; |
||
| 230 | } else { |
||
| 231 | $profileFileCont .= '<eapTls:DifferentUsername>false</eapTls:DifferentUsername>'; |
||
| 232 | } |
||
| 233 | $profileFileCont .= ' |
||
| 234 | </eapTls:EapType> |
||
| 235 | </baseEap:Eap> |
||
| 236 | </Config> |
||
| 237 | '; |
||
| 238 | return($profileFileCont); |
||
| 239 | } |
||
| 240 | |||
| 241 | private function msTtlsConfig() { |
||
| 242 | $profileFileCont = '<Config xmlns="http://www.microsoft.com/provisioning/EapHostConfig"> |
||
| 243 | <EapTtls xmlns="http://www.microsoft.com/provisioning/EapTtlsConnectionPropertiesV1"> |
||
| 244 | '; |
||
| 245 | $profileFileCont .= $this->msTtlsServerValidation(); |
||
| 246 | $profileFileCont .= '<Phase2Authentication> |
||
| 247 | '; |
||
| 248 | if ($this->selectedEap == \core\common\EAP::EAPTYPE_TTLS_PAP) { |
||
| 249 | $profileFileCont .= '<PAPAuthentication /> '; |
||
| 250 | } |
||
| 251 | if ($this->selectedEap == \core\common\EAP::EAPTYPE_TTLS_MSCHAP2) { |
||
| 252 | $profileFileCont .= '<MSCHAPv2Authentication> |
||
| 253 | <UseWinlogonCredentials>false</UseWinlogonCredentials> |
||
| 254 | </MSCHAPv2Authentication> |
||
| 255 | '; |
||
| 256 | } |
||
| 257 | $profileFileCont .= '</Phase2Authentication> |
||
| 258 | <Phase1Identity> |
||
| 259 | '; |
||
| 260 | if ($this->useAnon) { |
||
| 261 | $profileFileCont .= '<IdentityPrivacy>true</IdentityPrivacy> |
||
| 262 | '; |
||
| 263 | $profileFileCont .= '<AnonymousIdentity>' . $this->outerId . '</AnonymousIdentity> |
||
| 264 | '; |
||
| 265 | } else { |
||
| 266 | $profileFileCont .= '<IdentityPrivacy>false</IdentityPrivacy> |
||
| 267 | '; |
||
| 268 | } |
||
| 269 | $profileFileCont .= '</Phase1Identity> |
||
| 270 | </EapTtls> |
||
| 271 | </Config> |
||
| 272 | '; |
||
| 273 | return($profileFileCont); |
||
| 274 | } |
||
| 275 | |||
| 276 | private function glTtlsConfig() { |
||
| 277 | $profileFileCont = ' |
||
| 278 | <Config xmlns="http://www.microsoft.com/provisioning/EapHostConfig"> |
||
| 279 | <EAPIdentityProviderList xmlns="urn:ietf:params:xml:ns:yang:ietf-eap-metadata"> |
||
| 280 | <EAPIdentityProvider ID="' . $this->deviceUUID . '" namespace="urn:UUID"> |
||
| 281 | |||
| 282 | <ProviderInfo> |
||
| 283 | <DisplayName>' . $this->translateString($this->attributes['general:instname'][0], $this->codePage) . '</DisplayName> |
||
| 284 | </ProviderInfo> |
||
| 285 | <AuthenticationMethods> |
||
| 286 | <AuthenticationMethod> |
||
| 287 | <EAPMethod>21</EAPMethod> |
||
| 288 | <ClientSideCredential> |
||
| 289 | <allow-save>true</allow-save> |
||
| 290 | '; |
||
| 291 | if ($this->useAnon) { |
||
| 292 | if ($this->outerUser == '') { |
||
| 293 | $profileFileCont .= '<AnonymousIdentity>@</AnonymousIdentity>'; |
||
| 294 | } else { |
||
| 295 | $profileFileCont .= '<AnonymousIdentity>' . $this->outerId . '</AnonymousIdentity>'; |
||
| 296 | } |
||
| 297 | } |
||
| 298 | $profileFileCont .= '</ClientSideCredential> |
||
| 299 | '; |
||
| 300 | $profileFileCont .= $this->glTtlsServerValidation(); |
||
| 301 | $profileFileCont .= ' |
||
| 302 | <InnerAuthenticationMethod> |
||
| 303 | <NonEAPAuthMethod>' . \core\common\EAP::eapDisplayName($this->selectedEap)['INNER'] . '</NonEAPAuthMethod> |
||
| 304 | </InnerAuthenticationMethod> |
||
| 305 | <VendorSpecific> |
||
| 306 | <SessionResumption>false</SessionResumption> |
||
| 307 | </VendorSpecific> |
||
| 308 | </AuthenticationMethod> |
||
| 309 | </AuthenticationMethods> |
||
| 310 | </EAPIdentityProvider> |
||
| 311 | </EAPIdentityProviderList> |
||
| 312 | </Config> |
||
| 313 | '; |
||
| 314 | return($profileFileCont); |
||
| 315 | } |
||
| 316 | |||
| 317 | private function peapConfig() { |
||
| 318 | $nea = (\core\common\Entity::getAttributeValue($this->attributes, 'media:wired', 0) == 'on') ? 'true' : 'false'; |
||
| 319 | $profileFileCont = '<Config xmlns="http://www.microsoft.com/provisioning/EapHostConfig"> |
||
| 320 | <Eap xmlns="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1"> |
||
| 321 | <Type>25</Type> |
||
| 322 | <EapType xmlns="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV1"> |
||
| 323 | '; |
||
| 324 | $profileFileCont .= $this->peapServerValidation(); |
||
| 325 | $profileFileCont .= ' |
||
| 326 | <FastReconnect>true</FastReconnect> |
||
| 327 | <InnerEapOptional>false</InnerEapOptional> |
||
| 328 | <Eap xmlns="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1"> |
||
| 329 | <Type>26</Type> |
||
| 330 | <EapType xmlns="http://www.microsoft.com/provisioning/MsChapV2ConnectionPropertiesV1"> |
||
| 331 | <UseWinLogonCredentials>false</UseWinLogonCredentials> |
||
| 332 | </EapType> |
||
| 333 | </Eap> |
||
| 334 | <EnableQuarantineChecks>' . $nea . '</EnableQuarantineChecks> |
||
| 335 | <RequireCryptoBinding>false</RequireCryptoBinding> |
||
| 336 | '; |
||
| 337 | if ($this->useAnon) { |
||
| 338 | $profileFileCont .= '<PeapExtensions> |
||
| 339 | <IdentityPrivacy xmlns="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV2"> |
||
| 340 | <EnableIdentityPrivacy>true</EnableIdentityPrivacy> |
||
| 341 | '; |
||
| 342 | if ($this->outerUser == '') { |
||
| 343 | $profileFileCont .= '<AnonymousUserName/> |
||
| 344 | '; |
||
| 345 | } else { |
||
| 346 | $profileFileCont .= '<AnonymousUserName>' . $this->outerUser . '</AnonymousUserName> |
||
| 347 | '; |
||
| 348 | } |
||
| 349 | $profileFileCont .= '</IdentityPrivacy> |
||
| 350 | </PeapExtensions> |
||
| 351 | '; |
||
| 352 | } |
||
| 353 | $profileFileCont .= '</EapType> |
||
| 354 | </Eap> |
||
| 355 | </Config> |
||
| 356 | '; |
||
| 357 | return($profileFileCont); |
||
| 358 | } |
||
| 359 | |||
| 360 | private function pwdConfig() { |
||
| 361 | return('<ConfigBlob></ConfigBlob>'); |
||
| 362 | } |
||
| 363 | |||
| 364 | private function prepareEapConfig() { |
||
| 365 | if ($this->useAnon) { |
||
| 366 | $this->outerUser = $this->attributes['internal:anon_local_value'][0]; |
||
| 367 | $this->outerId = $this->outerUser . '@' . $this->attributes['internal:realm'][0]; |
||
| 368 | } |
||
| 369 | if (isset($this->options['args']) && $this->options['args'] == 'gl') { |
||
| 370 | $this->useGeantLink = TRUE; |
||
| 371 | } else { |
||
| 372 | $this->useGeantLink = FALSE; |
||
| 373 | } |
||
| 374 | $profileFileCont = $this->eapConfigHeader(); |
||
| 375 | |||
| 376 | switch ($this->selectedEap['OUTER']) { |
||
| 377 | case \core\common\EAP::TLS: |
||
| 378 | $profileFileCont .= $this->tlsConfig(); |
||
| 379 | break; |
||
| 380 | case \core\common\EAP::PEAP: |
||
| 381 | $profileFileCont .= $this->peapConfig(); |
||
| 382 | break; |
||
| 383 | case \core\common\EAP::TTLS: |
||
| 384 | if ($this->useGeantLink) { |
||
| 385 | $profileFileCont .= $this->glTtlsConfig(); |
||
| 386 | } else { |
||
| 387 | $profileFileCont .= $this->msTtlsConfig(); |
||
| 388 | } |
||
| 389 | break; |
||
| 390 | case \core\common\EAP::PWD: |
||
| 391 | $profileFileCont .= $this->pwdConfig(); |
||
| 392 | break; |
||
| 393 | default: |
||
| 394 | break; |
||
| 395 | } |
||
| 396 | return(['win' => $profileFileCont . '</EapHostConfig></EAPConfig>']); |
||
| 397 | } |
||
| 398 | |||
| 399 | /** |
||
| 400 | * produce PEAP, TLS and TTLS configuration files for Windows 8 |
||
| 401 | * |
||
| 402 | * @param string $wlanProfileName |
||
| 403 | * @param string $ssid |
||
| 404 | * @param string $auth can be one of "WPA", "WPA2" |
||
| 405 | * @param string $encryption can be one of: "TKIP", "AES" |
||
| 406 | * @param array $eapConfig XML configuration block with EAP config data |
||
| 407 | * @param int $profileNumber counter, which profile number is this |
||
| 408 | * @return string |
||
| 409 | */ |
||
| 410 | private function writeWLANprofile($wlanProfileName, $ssid, $auth, $encryption, $eapConfig, $profileNumber, $hs20 = FALSE) { |
||
| 411 | $profileFileCont = '<?xml version="1.0"?> |
||
| 412 | <WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1"> |
||
| 413 | <name>' . $wlanProfileName . '</name> |
||
| 414 | <SSIDConfig> |
||
| 415 | <SSID> |
||
| 416 | <name>' . $ssid . '</name> |
||
| 417 | </SSID> |
||
| 418 | <nonBroadcast>true</nonBroadcast> |
||
| 419 | </SSIDConfig>'; |
||
| 420 | if ($hs20) { |
||
| 421 | $profileFileCont .= $this->addConsortia(); |
||
| 422 | } |
||
| 423 | $profileFileCont .= ' |
||
| 424 | <connectionType>ESS</connectionType> |
||
| 425 | <connectionMode>auto</connectionMode> |
||
| 426 | <autoSwitch>false</autoSwitch> |
||
| 427 | <MSM> |
||
| 428 | <security> |
||
| 429 | <authEncryption> |
||
| 430 | <authentication>' . $auth . '</authentication> |
||
| 431 | <encryption>' . $encryption . '</encryption> |
||
| 432 | <useOneX>true</useOneX> |
||
| 433 | </authEncryption> |
||
| 434 | '; |
||
| 435 | if ($auth == 'WPA2') { |
||
| 436 | $profileFileCont .= '<PMKCacheMode>enabled</PMKCacheMode> |
||
| 437 | <PMKCacheTTL>720</PMKCacheTTL> |
||
| 438 | <PMKCacheSize>128</PMKCacheSize> |
||
| 439 | <preAuthMode>disabled</preAuthMode> |
||
| 440 | '; |
||
| 441 | } |
||
| 442 | $profileFileCont .= '<OneX xmlns="http://www.microsoft.com/networking/OneX/v1"> |
||
| 443 | <cacheUserData>true</cacheUserData> |
||
| 444 | <authMode>user</authMode> |
||
| 445 | '; |
||
| 446 | |||
| 447 | $closing = ' |
||
| 448 | </OneX> |
||
| 449 | </security> |
||
| 450 | </MSM> |
||
| 451 | </WLANProfile> |
||
| 452 | '; |
||
| 453 | |||
| 454 | if (!is_dir('w8')) { |
||
| 455 | mkdir('w8'); |
||
| 456 | } |
||
| 457 | $xmlFname = "w8/wlan_prof-$profileNumber.xml"; |
||
| 458 | file_put_contents($xmlFname, $profileFileCont . $eapConfig['win'] . $closing); |
||
| 459 | $this->loggerInstance->debug(2, "Installer has been written into directory $this->FPATH\n"); |
||
| 460 | return("\"$wlanProfileName\" \"$encryption\""); |
||
| 461 | } |
||
| 462 | |||
| 463 | private function writeLANprofile($eapConfig) { |
||
| 487 | } |
||
| 488 | |||
| 489 | private function writeProfilesNSH($wlanProfiles, $caArray) { |
||
| 490 | $this->loggerInstance->debug(4, "writeProfilesNSH"); |
||
| 491 | $this->loggerInstance->debug(4, $wlanProfiles); |
||
| 492 | $fcontentsProfile = ''; |
||
| 493 | foreach ($wlanProfiles as $wlanProfile) { |
||
| 494 | $fcontentsProfile .= "!insertmacro define_wlan_profile $wlanProfile\n"; |
||
| 495 | } |
||
| 496 | |||
| 497 | file_put_contents('profiles.nsh', $fcontentsProfile); |
||
| 498 | |||
| 499 | $fcontentsCerts = ''; |
||
| 500 | $fileHandleCerts = fopen('certs.nsh', 'w'); |
||
| 501 | if ($fileHandleCerts === FALSE) { |
||
| 502 | throw new Exception("Unable to open new certs.nsh file for writing CAs."); |
||
| 503 | } |
||
| 504 | foreach ($caArray as $certAuthority) { |
||
| 505 | $store = $certAuthority['root'] ? "root" : "ca"; |
||
| 506 | $fcontentsCerts .= '!insertmacro install_ca_cert "' . $certAuthority['file'] . '" "' . $certAuthority['sha1'] . '" "' . $store . "\"\n"; |
||
| 507 | } |
||
| 508 | fwrite($fileHandleCerts, $fcontentsCerts); |
||
| 509 | fclose($fileHandleCerts); |
||
| 510 | } |
||
| 511 | |||
| 512 | private function writeMainNSH($eap, $attr) { |
||
| 513 | $this->loggerInstance->debug(4, "writeMainNSH"); |
||
| 514 | $this->loggerInstance->debug(4, $attr); |
||
| 515 | $this->loggerInstance->debug(4, "Device_id = " . $this->device_id . "\n"); |
||
| 516 | $fcontents = "!define W8\n"; |
||
| 517 | if ($this->device_id == 'w10') { |
||
| 518 | $fcontents .= "!define W10\n"; |
||
| 519 | } |
||
| 520 | if (CONFIG_CONFASSISTANT['NSIS_VERSION'] >= 3) { |
||
| 521 | $fcontents .= "Unicode true\n"; |
||
| 522 | } |
||
| 523 | $eapOptions = [ |
||
| 524 | \core\common\EAP::PEAP => ['str' => 'PEAP', 'exec' => 'user'], |
||
| 525 | \core\common\EAP::TLS => ['str' => 'TLS', 'exec' => 'user'], |
||
| 526 | \core\common\EAP::TTLS => ['str' => 'TTLS', 'exec' => 'user'], |
||
| 527 | \core\common\EAP::PWD => ['str' => 'PWD', 'exec' => 'user'], |
||
| 528 | ]; |
||
| 529 | if (isset($this->options['args']) && $this->options['args'] == 'gl') { |
||
| 530 | $eapOptions[\core\common\EAP::TTLS]['str'] = 'GEANTLink'; |
||
| 531 | } |
||
| 532 | |||
| 533 | // Uncomment the line below if you want this module to run under XP (only displaying a warning) |
||
| 534 | // $fcontents .= "!define ALLOW_XP\n"; |
||
| 535 | // Uncomment the line below if you want this module to produce debugging messages on the client |
||
| 536 | // $fcontents .= "!define DEBUG_CAT\n"; |
||
| 537 | if ($this->tlsOtherUsername == 1) { |
||
| 538 | $fcontents .= "!define PFX_USERNAME\n"; |
||
| 539 | } |
||
| 540 | $execLevel = $eapOptions[$eap["OUTER"]]['exec']; |
||
| 541 | $eapStr = $eapOptions[$eap["OUTER"]]['str']; |
||
| 542 | if ($eap == \core\common\EAP::EAPTYPE_SILVERBULLET) { |
||
| 543 | $fcontents .= "!define SILVERBULLET\n"; |
||
| 544 | } |
||
| 545 | $fcontents .= '!define ' . $eapStr; |
||
| 546 | $fcontents .= "\n" . '!define EXECLEVEL "' . $execLevel . '"'; |
||
| 547 | $fcontents .= $this->writeNsisDefines($attr); |
||
| 548 | file_put_contents('main.nsh', $fcontents); |
||
| 549 | } |
||
| 550 | |||
| 551 | private function copyStandardNsi() { |
||
| 552 | if (!$this->translateFile('eap_w8.inc', 'cat.NSI', $this->codePage)) { |
||
| 553 | throw new Exception("Translating needed file eap_w8.inc failed!"); |
||
| 554 | } |
||
| 555 | } |
||
| 556 | |||
| 557 | private function copyFiles($eap) { |
||
| 576 | } |
||
| 577 | |||
| 578 | private $tlsOtherUsername = 0; |
||
| 579 | private $caArray; |
||
| 580 | private $useAnon; |
||
| 581 | private $servers; |
||
| 582 | private $outerUser; |
||
| 583 | private $outerId; |
||
| 584 | |||
| 585 | } |
||
| 587 |