| Total Complexity | 70 |
| Total Lines | 791 |
| Duplicated Lines | 0 % |
| Changes | 6 | ||
| Bugs | 0 | Features | 0 |
Complex classes like MobileconfigSuperclass 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 MobileconfigSuperclass, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 44 | abstract class MobileconfigSuperclass extends \core\DeviceConfig |
||
| 45 | { |
||
| 46 | |||
| 47 | /** |
||
| 48 | * institution name in preferred language |
||
| 49 | * |
||
| 50 | * @var string |
||
| 51 | */ |
||
| 52 | private $instName; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * profile name in preferred language |
||
| 56 | * |
||
| 57 | * @var string |
||
| 58 | */ |
||
| 59 | private $profileName; |
||
| 60 | |||
| 61 | /** |
||
| 62 | * institution name, massaged to make it fit into the XML payload descriptor |
||
| 63 | * |
||
| 64 | * @var string |
||
| 65 | */ |
||
| 66 | private $massagedInst; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * profile name, massaged to make it fit into the XML payload descriptor |
||
| 70 | * |
||
| 71 | * @var string |
||
| 72 | */ |
||
| 73 | private $massagedProfile; |
||
| 74 | |||
| 75 | /** |
||
| 76 | * country name, massaged to make it fit into the XML payload descriptor |
||
| 77 | * |
||
| 78 | * @var string |
||
| 79 | */ |
||
| 80 | private $massagedCountry; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * consortium name, massaged to make it fit into the XML payload descriptor |
||
| 84 | * |
||
| 85 | * @var string |
||
| 86 | */ |
||
| 87 | private $massagedConsortium; |
||
| 88 | |||
| 89 | /** |
||
| 90 | * current language, without any .CHARSET suffixes |
||
| 91 | * |
||
| 92 | * @var string |
||
| 93 | */ |
||
| 94 | private $lang; |
||
| 95 | |||
| 96 | /** |
||
| 97 | * if we include a client certificate (silverbullet), the UUID of the certificate |
||
| 98 | * |
||
| 99 | * @var string |
||
| 100 | */ |
||
| 101 | private $clientCertUUID; |
||
| 102 | |||
| 103 | /** |
||
| 104 | * iterator to uniquely identify every Wi-Fi payload with a suffix in the file |
||
| 105 | * |
||
| 106 | * @var integer |
||
| 107 | */ |
||
| 108 | private $serial; |
||
| 109 | |||
| 110 | /** |
||
| 111 | * iterator to uniquely identify every removal payload with a suffix in the file |
||
| 112 | * @var integer |
||
| 113 | */ |
||
| 114 | private $removeSerial; |
||
| 115 | |||
| 116 | /** |
||
| 117 | * iterator to uniquely identify evera CA payload with a suffix in the file |
||
| 118 | * |
||
| 119 | * @var integer |
||
| 120 | */ |
||
| 121 | private $caSerial; |
||
| 122 | |||
| 123 | /** |
||
| 124 | * we need to be cautious not to include a CA twice, even if the admin |
||
| 125 | * included it twice in the CAT config. This variable takes note of all |
||
| 126 | * CA certs we already added to the file. |
||
| 127 | * |
||
| 128 | * @var array |
||
| 129 | */ |
||
| 130 | private $CAsAccountedFor = []; |
||
| 131 | |||
| 132 | /** |
||
| 133 | * we need a globally valid domain anchor, independent of the consortium |
||
| 134 | */ |
||
| 135 | const IPHONE_PAYLOAD_PREFIX = "org.1x-config"; |
||
| 136 | |||
| 137 | |||
| 138 | /** |
||
| 139 | * construct with the standard set of EAP methods we support, and preload |
||
| 140 | * specialities |
||
| 141 | */ |
||
| 142 | public function __construct() |
||
| 143 | { |
||
| 144 | parent::__construct(); |
||
| 145 | \core\common\Entity::intoThePotatoes(); |
||
| 146 | // that's what all variants support. Sub-classes can change it. |
||
| 147 | $this->setSupportedEapMethods([\core\common\EAP::EAPTYPE_PEAP_MSCHAP2, \core\common\EAP::EAPTYPE_TTLS_PAP, \core\common\EAP::EAPTYPE_TTLS_MSCHAP2, \core\common\EAP::EAPTYPE_SILVERBULLET]); |
||
| 148 | foreach(\core\common\EAP::listKnownEAPTypes() as $eapType) { |
||
| 149 | if ($eapType->isPasswordRequired() || $eapType->isPasswordOptional()) { |
||
| 150 | $this->specialities['internal:verify_userinput_suffix'][serialize($eapType->getArrayRep())] = _("It is not possible to actively verify the user input for suffix match; but if there is no 'Terms of Use' configured, the installer will display a corresponding hint to the user instead."); |
||
| 151 | $this->specialities['media:consortium_OI'][serialize($eapType->getArrayRep())] = _("Passpoint networks are not provisioned due to severe UI limitations during install time."); |
||
| 152 | } |
||
| 153 | } |
||
| 154 | \core\common\Entity::outOfThePotatoes(); |
||
| 155 | } |
||
| 156 | |||
| 157 | /** |
||
| 158 | * massage a name so that it becomes acceptable inside the plist XML |
||
| 159 | * |
||
| 160 | * @param string $input the literal name |
||
| 161 | * @return string |
||
| 162 | */ |
||
| 163 | private function massageName($input) |
||
| 164 | { |
||
| 165 | return htmlspecialchars(strtolower(iconv("UTF-8", "US-ASCII//TRANSLIT", preg_replace(['/ /', '/\//'], '_', $input))), ENT_XML1, 'UTF-8'); |
||
| 166 | } |
||
| 167 | |||
| 168 | /** |
||
| 169 | * the general part of a mobileconfig file in plist format |
||
| 170 | * @return string |
||
| 171 | */ |
||
| 172 | private function generalPayload() |
||
| 200 | } |
||
| 201 | |||
| 202 | const FILE_START = "<?xml version=\"1.0\" encoding=\"utf-8\"?> |
||
| 203 | <!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" |
||
| 204 | \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"> |
||
| 205 | <plist version=\"1.0\"> |
||
| 206 | <dict>"; |
||
| 207 | const FILE_END = "</dict></plist>"; |
||
| 208 | const BUFFER_CONSENT_PRE = " |
||
| 209 | <key>ConsentText</key> |
||
| 210 | <dict> |
||
| 211 | <key>default</key> |
||
| 212 | <string>"; |
||
| 213 | const BUFFER_CONSENT_POST = "</string> |
||
| 214 | </dict> |
||
| 215 | "; |
||
| 216 | |||
| 217 | /** |
||
| 218 | * creates a ConsentText block if either Terms of Use are specified or the |
||
| 219 | * user input hints should be displayed. Otherwise, produces nothing. |
||
| 220 | * |
||
| 221 | * @return string |
||
| 222 | */ |
||
| 223 | protected function consentBlock() |
||
| 248 | } |
||
| 249 | |||
| 250 | /** |
||
| 251 | * create the actual installer XML file |
||
| 252 | * |
||
| 253 | * @return string filename of the generated installer |
||
| 254 | */ |
||
| 255 | public function writeInstaller() |
||
| 256 | { |
||
| 257 | \core\common\Entity::intoThePotatoes(); |
||
| 258 | |||
| 259 | $this->loggerInstance->debug(4, "mobileconfig Module Installer start\n"); |
||
| 260 | |||
| 261 | // remove spaces and slashes (filename!), make sure it's simple ASCII only, then lowercase it |
||
| 262 | // also escape htmlspecialchars |
||
| 263 | // not all names and profiles have a name, so be prepared |
||
| 264 | |||
| 265 | $this->loggerInstance->debug(5, "List of available attributes: " . var_export($this->attributes, TRUE)); |
||
| 266 | |||
| 267 | $this->instName = $this->attributes['general:instname'][0] ?? _("Unnamed Organisation"); |
||
| 268 | $this->profileName = $this->attributes['profile:name'][0] ?? _("Unnamed Profile"); |
||
| 269 | |||
| 270 | $this->massagedInst = $this->massageName($this->instName); |
||
| 271 | $this->massagedProfile = $this->massageName($this->profileName); |
||
| 272 | $this->massagedCountry = $this->massageName($this->attributes['internal:country'][0]); |
||
| 273 | $this->massagedConsortium = $this->massageName(\config\ConfAssistant::CONSORTIUM['name']); |
||
| 274 | $this->lang = preg_replace('/\..+/', '', setlocale(LC_ALL, "0")); |
||
| 275 | |||
| 276 | $eapType = $this->selectedEap; |
||
| 277 | |||
| 278 | $outputXml = self::FILE_START; |
||
| 279 | $outputXml .= "<key>PayloadContent</key> |
||
| 280 | <array>"; |
||
| 281 | |||
| 282 | // if we are in silverbullet, we will need a whole own block for the client credential |
||
| 283 | // and also for the profile expiry |
||
| 284 | |||
| 285 | $this->clientCertUUID = NULL; |
||
| 286 | if ($eapType['INNER'] == \core\common\EAP::NE_SILVERBULLET) { |
||
| 287 | $blockinfo = $this->clientP12Block(); |
||
| 288 | $outputXml .= $blockinfo['block']; |
||
| 289 | $this->clientCertUUID = $blockinfo['UUID']; |
||
| 290 | } |
||
| 291 | |||
| 292 | $outputXml .= $this->allCA(); |
||
| 293 | |||
| 294 | $outputXml .= $this->allNetworkBlocks(); |
||
| 295 | |||
| 296 | $outputXml .= "</array>"; |
||
| 297 | $outputXml .= $this->generalPayload(); |
||
| 298 | $outputXml .= $this->consentBlock(); |
||
| 299 | |||
| 300 | if ($eapType['INNER'] == \core\common\EAP::NE_SILVERBULLET) { |
||
| 301 | $outputXml .= $this->expiryBlock(); |
||
| 302 | } |
||
| 303 | $outputXml .= self::FILE_END; |
||
| 304 | |||
| 305 | file_put_contents('installer_profile', $outputXml); |
||
| 306 | |||
| 307 | $fileName = $this->installerBasename . '.mobileconfig'; |
||
| 308 | |||
| 309 | if (!$this->sign) { |
||
| 310 | rename("installer_profile", $fileName); |
||
| 311 | \core\common\Entity::outOfThePotatoes(); |
||
| 312 | return $fileName; |
||
| 313 | } |
||
| 314 | // still here? Then we are signing. |
||
| 315 | $retval = 0; |
||
| 316 | $signing = system($this->sign . " installer_profile '$fileName' > /dev/null", $retval); |
||
| 317 | if ($retval !== 0 || $signing === FALSE) { |
||
| 318 | $this->loggerInstance->debug(2, "Signing the mobileconfig installer $fileName FAILED!\n"); |
||
| 319 | // we are passing a name that will be then used as a path - this will not exist, hence an error will |
||
| 320 | // be generated |
||
| 321 | return("no_go"); |
||
| 322 | } |
||
| 323 | \core\common\Entity::outOfThePotatoes(); |
||
| 324 | return $fileName; |
||
| 325 | } |
||
| 326 | |||
| 327 | /** |
||
| 328 | * produces the HTML text to be displayed when clicking on the "help" button |
||
| 329 | * besides the download button. |
||
| 330 | * |
||
| 331 | * @return string |
||
| 332 | */ |
||
| 333 | public function writeDeviceInfo() |
||
| 334 | { |
||
| 335 | \core\common\Entity::intoThePotatoes(); |
||
| 336 | $ssidCount = 0; |
||
| 337 | $oiCount = 0; |
||
| 338 | foreach ($this->attributes['internal:networks'] as $netDetail) { |
||
| 339 | $ssidCount = $ssidCount + count($netDetail['ssid']); |
||
| 340 | $oiCount = $oiCount + count($netDetail['oi']); |
||
| 341 | } |
||
| 342 | $certCount = count($this->attributes['internal:CAs'][0]); |
||
| 343 | $out = "<p>" . _("For best results, please use the built-in browser (Safari) to open the configuration file.") . "</p>"; |
||
| 344 | $out .= "<p>"; |
||
| 345 | $out .= _("The profile will install itself after you click (or tap) the button. You will be asked for confirmation/input at several points:"); |
||
| 346 | $out .= "<ul>"; |
||
| 347 | $out .= "<li>" . _("to install the profile") . "</li>"; |
||
| 348 | $out .= "<li>" . ngettext("to accept the server certificate authority", "to accept the server certificate authorities", $certCount); |
||
| 349 | if ($certCount > 1) { |
||
| 350 | $out .= " " . sprintf(_("(%d times)"), $certCount); |
||
| 351 | } |
||
| 352 | $out .= "</li>"; |
||
| 353 | $out .= "<li>" . _("to enter the username and password you have been given by your organisation"); |
||
| 354 | if ($ssidCount > 1) { |
||
| 355 | $out .= " " . sprintf(_("(%d times each, because %d SSIDs and %d Passpoint networks are installed)"), $ssidCount+$oiCount, $ssidCount, $oiCount); |
||
| 356 | } |
||
| 357 | $out .= "</li>"; |
||
| 358 | $out .= "</ul>"; |
||
| 359 | $out .= "</p>"; |
||
| 360 | \core\common\Entity::outOfThePotatoes(); |
||
| 361 | return $out; |
||
| 362 | } |
||
| 363 | |||
| 364 | /** |
||
| 365 | * collates a list of the UUIDs of all the CAs which are to be included in |
||
| 366 | * the mobileconfig file |
||
| 367 | * |
||
| 368 | * @return array |
||
| 369 | */ |
||
| 370 | private function listCAUuids() |
||
| 371 | { |
||
| 372 | $retval = []; |
||
| 373 | foreach ($this->attributes['internal:CAs'][0] as $ca) { |
||
| 374 | $retval[] = $ca['uuid']; |
||
| 375 | } |
||
| 376 | return $retval; |
||
| 377 | } |
||
| 378 | |||
| 379 | /** |
||
| 380 | * This is the XML structure subtree of a Network block which contains the |
||
| 381 | * settings specific to Passpoint |
||
| 382 | * |
||
| 383 | * @param array $consortiumOi list of consortiumOi to put into structure |
||
| 384 | * @param string $oiName the pretty-print name of the RCOI |
||
| 385 | * @return string |
||
| 386 | */ |
||
| 387 | private function passPointBlock($consortiumOi, $oiName) |
||
| 388 | { |
||
| 389 | $retval = " |
||
| 390 | <key>IsHotspot</key> |
||
| 391 | <true/> |
||
| 392 | <key>ServiceProviderRoamingEnabled</key> |
||
| 393 | <true/> |
||
| 394 | <key>DisplayedOperatorName</key> |
||
| 395 | <string>" . $oiName . "</string>"; |
||
| 396 | // if we don't know the realm, omit the entire DomainName key |
||
| 397 | if (isset($this->attributes['internal:realm'])) { |
||
| 398 | $retval .= "<key>DomainName</key> |
||
| 399 | <string>"; |
||
| 400 | $retval .= $this->attributes['internal:realm'][0]; |
||
| 401 | $retval .= "</string> |
||
| 402 | "; |
||
| 403 | } |
||
| 404 | $retval .= " <key>RoamingConsortiumOIs</key> |
||
| 405 | <array>"; |
||
| 406 | |||
| 407 | foreach ($consortiumOi as $oneCons) { |
||
| 408 | $retval .= "<string>" . strtoupper($oneCons) . "</string>"; |
||
| 409 | } |
||
| 410 | |||
| 411 | $retval .= "</array>"; |
||
| 412 | // this is an undocumented value found on the net. Does it do something useful? |
||
| 413 | $retval .= "<key>_UsingHotspot20</key> |
||
| 414 | <true/> |
||
| 415 | "; |
||
| 416 | // do we need to set NAIRealmName ? In Rel 1, probably yes, in Rel 2, |
||
| 417 | // no because ConsortiumOI is enough. |
||
| 418 | // but which release is OS X doing? And what should we fill in, given |
||
| 419 | // that we have thousands of realms? Try just eduroam.org |
||
| 420 | // |
||
| 421 | // tests from Hideaki suggest it's better not to set it; if Roaming |
||
| 422 | // consortium OI and NAIRealmNames are both set, connecting to a hotspot |
||
| 423 | // with just RCOI does not work |
||
| 424 | /* if (\config\ConfAssistant::CONSORTIUM['name'] == "eduroam") { |
||
| 425 | $retval .= "<key>NAIRealmNames</key> |
||
| 426 | <array> |
||
| 427 | <string>eduroam.org</string> |
||
| 428 | </array>"; |
||
| 429 | }*/ |
||
| 430 | return $retval; |
||
| 431 | } |
||
| 432 | |||
| 433 | /** |
||
| 434 | * produces the EAP sub-block of a Network block |
||
| 435 | * |
||
| 436 | * @param array $eapType EAP type in array notation |
||
| 437 | * @return string |
||
| 438 | */ |
||
| 439 | private function eapBlock($eapType) |
||
| 440 | { |
||
| 441 | $realm = $this->determineOuterIdString(); |
||
| 442 | $retval = "<key>EAPClientConfiguration</key> |
||
| 443 | <dict> |
||
| 444 | <key>AcceptEAPTypes</key> |
||
| 445 | <array> |
||
| 446 | <integer>" . $eapType['OUTER'] . "</integer> |
||
| 447 | </array> |
||
| 448 | <key>EAPFASTProvisionPAC</key> |
||
| 449 | <true /> |
||
| 450 | <key>EAPFASTUsePAC</key> |
||
| 451 | <true /> |
||
| 452 | <key>EAPFastProvisionPACAnonymously</key> |
||
| 453 | <false /> |
||
| 454 | <key>OneTimeUserPassword</key> |
||
| 455 | <false /> |
||
| 456 | "; |
||
| 457 | if ($realm !== NULL) { |
||
| 458 | $retval .= "<key>OuterIdentity</key> |
||
| 459 | <string>" . htmlspecialchars($realm, ENT_XML1, 'UTF-8') . "</string> |
||
| 460 | "; |
||
| 461 | } |
||
| 462 | $retval .= "<key>PayloadCertificateAnchorUUID</key> |
||
| 463 | <array>"; |
||
| 464 | foreach ($this->listCAUuids() as $uuid) { |
||
| 465 | if (in_array($uuid, $this->CAsAccountedFor)) { |
||
| 466 | $retval .= " |
||
| 467 | <string>$uuid</string>"; |
||
| 468 | } |
||
| 469 | } |
||
| 470 | $retval .= " |
||
| 471 | </array> |
||
| 472 | <key>TLSAllowTrustExceptions</key> |
||
| 473 | <false /> |
||
| 474 | <key>TLSTrustedServerNames</key> |
||
| 475 | <array>"; |
||
| 476 | foreach ($this->attributes['eap:server_name'] as $commonName) { |
||
| 477 | $retval .= " |
||
| 478 | <string>$commonName</string>"; |
||
| 479 | } |
||
| 480 | $retval .= " |
||
| 481 | </array>"; |
||
| 482 | if ($eapType['INNER'] == \core\common\EAP::NE_SILVERBULLET) { |
||
| 483 | $retval .= "<key>UserName</key><string>" . $this->clientCert["certObject"]->username . "</string>"; |
||
| 484 | } |
||
| 485 | $retval .= " |
||
| 486 | <key>TTLSInnerAuthentication</key> |
||
| 487 | <string>" . ($eapType['INNER'] == \core\common\EAP::NE_PAP ? "PAP" : "MSCHAPv2") . "</string> |
||
| 488 | </dict>"; |
||
| 489 | return $retval; |
||
| 490 | } |
||
| 491 | |||
| 492 | /** |
||
| 493 | * produces the Proxy sub-block of a Network block |
||
| 494 | * |
||
| 495 | * @return string |
||
| 496 | */ |
||
| 497 | protected function proxySettings() |
||
| 518 | } |
||
| 519 | |||
| 520 | /** |
||
| 521 | * iOS 8 introduced the new value "WPA2" to lock out WPA ("1"). Make sure |
||
| 522 | * we use it for the most recent gen of mobileconfig for iOS. |
||
| 523 | * |
||
| 524 | * According to reports on the eduroam dev ML, also recent macOS supports it |
||
| 525 | * so add it there, too (spec is silent on macOS versions). |
||
| 526 | * |
||
| 527 | * @return string either "WPA" or "WPA2 |
||
| 528 | */ |
||
| 529 | private function encryptionString() { |
||
| 530 | if ( |
||
| 531 | get_class($this) == "devices\apple_mobileconfig\DeviceMobileconfigIos12plus" || |
||
| 532 | get_class($this) == "devices\apple_mobileconfig\DeviceMobileconfigOsX" |
||
| 533 | ) { |
||
| 534 | return "WPA2"; |
||
| 535 | } else { |
||
| 536 | return "WPA"; |
||
| 537 | } |
||
| 538 | } |
||
| 539 | |||
| 540 | /** |
||
| 541 | * produces an entire Network block |
||
| 542 | * |
||
| 543 | * @param int $blocktype which type of network block is this? |
||
| 544 | * @param string|array|boolean $toBeConfigured variable part of the config. Single SSID or list of ConsortiumOi |
||
| 545 | * @param string $prettyName name with which to present the network to users |
||
| 546 | * @return string |
||
| 547 | * @throws Exception |
||
| 548 | */ |
||
| 549 | private function networkBlock($blocktype, $toBeConfigured, $prettyName) |
||
| 550 | { |
||
| 551 | \core\common\Entity::intoThePotatoes(); |
||
| 552 | $eapType = $this->selectedEap; |
||
| 553 | switch ($blocktype) { |
||
| 554 | case MobileconfigSuperclass::NETWORK_BLOCK_TYPE_SSID: |
||
| 555 | if (!is_string($toBeConfigured)) { |
||
| 556 | throw new Exception("SSID must be a string!"); |
||
| 557 | } |
||
| 558 | $escapedSSID = htmlspecialchars($toBeConfigured, ENT_XML1, 'UTF-8'); |
||
| 559 | $payloadIdentifier = "wifi." . $this->serial; |
||
| 560 | $payloadShortName = sprintf(_("%s - SSID %s"), $prettyName, $escapedSSID); |
||
| 561 | $payloadName = sprintf(_("%s configuration for network name %s"), $prettyName, $escapedSSID); |
||
| 562 | $encryptionTypeString = $this->encryptionString(); |
||
| 563 | $setupModesString = ""; |
||
| 564 | $wifiNetworkIdentification = "<key>SSID_STR</key> |
||
| 565 | <string>$escapedSSID</string>"; |
||
| 566 | break; |
||
| 567 | case MobileconfigSuperclass::NETWORK_BLOCK_TYPE_WIRED: |
||
| 568 | if (!is_bool($toBeConfigured)) { |
||
| 569 | throw new Exception("We expected a TRUE here!"); |
||
| 570 | } |
||
| 571 | $payloadIdentifier = "firstactiveethernet"; |
||
| 572 | $payloadShortName = sprintf(_("%s - Wired Network"), $prettyName); |
||
| 573 | $payloadName = sprintf(_("%s configuration for wired network"), $prettyName); |
||
| 574 | $encryptionTypeString = "any"; |
||
| 575 | $setupModesString = " |
||
| 576 | <key>SetupModes</key> |
||
| 577 | <array> |
||
| 578 | <string>System</string> |
||
| 579 | </array>"; |
||
| 580 | $wifiNetworkIdentification = ""; |
||
| 581 | break; |
||
| 582 | case MobileconfigSuperclass::NETWORK_BLOCK_TYPE_CONSORTIUMOIS: |
||
| 583 | if (!is_array($toBeConfigured)) { |
||
| 584 | throw new Exception("ConsortiumOI must be an array!"); |
||
| 585 | } |
||
| 586 | if (count($toBeConfigured) == 0) { |
||
| 587 | return ""; |
||
| 588 | } |
||
| 589 | $payloadIdentifier = "hs20.".implode('-',$toBeConfigured); |
||
| 590 | $payloadShortName = sprintf(_("%s - RCOI"), $prettyName); |
||
| 591 | $payloadName = sprintf(_("%s configuration (Passpoint RCOI)"),$prettyName); |
||
| 592 | $encryptionTypeString = $this->encryptionString(); |
||
| 593 | $setupModesString = ""; |
||
| 594 | $wifiNetworkIdentification = $this->passPointBlock($toBeConfigured, $prettyName); |
||
| 595 | break; |
||
| 596 | default: |
||
| 597 | throw new Exception("This type of network block is unknown!"); |
||
| 598 | } |
||
| 599 | $retval = "<dict>"; |
||
| 600 | $retval .= $this->eapBlock($eapType); |
||
| 601 | $retval .= "<key>EncryptionType</key> |
||
| 602 | <string>$encryptionTypeString</string> |
||
| 603 | <key>HIDDEN_NETWORK</key> |
||
| 604 | <false /> |
||
| 605 | <key>PayloadDescription</key> |
||
| 606 | <string>$payloadName</string> |
||
| 607 | <key>PayloadDisplayName</key> |
||
| 608 | <string>$payloadShortName</string> |
||
| 609 | <key>PayloadIdentifier</key> |
||
| 610 | <string>" . self::IPHONE_PAYLOAD_PREFIX . ".$this->massagedConsortium.$this->massagedCountry.$this->massagedInst.$this->massagedProfile.$this->lang.$payloadIdentifier</string> |
||
| 611 | <key>PayloadOrganization</key> |
||
| 612 | <string>" . $this->massagedConsortium . ".1x-config.org</string> |
||
| 613 | <key>PayloadType</key> |
||
| 614 | <string>com.apple." . ($blocktype == MobileconfigSuperclass::NETWORK_BLOCK_TYPE_WIRED ? "firstactiveethernet" : "wifi") . ".managed</string>"; |
||
| 615 | $retval .= $this->proxySettings(); |
||
| 616 | $retval .= $setupModesString; |
||
| 617 | if ($eapType['INNER'] == \core\common\EAP::NE_SILVERBULLET) { |
||
| 618 | if ($this->clientCertUUID === NULL) { |
||
| 619 | throw new Exception("Silverbullet REQUIRES a client certificate and we need to know the UUID!"); |
||
| 620 | } |
||
| 621 | $retval .= "<key>PayloadCertificateUUID</key> |
||
| 622 | <string>$this->clientCertUUID</string>"; |
||
| 623 | } |
||
| 624 | $retval .= " |
||
| 625 | <key>PayloadUUID</key> |
||
| 626 | <string>" . \core\common\Entity::uuid() . "</string> |
||
| 627 | <key>PayloadVersion</key> |
||
| 628 | <integer>1</integer> |
||
| 629 | $wifiNetworkIdentification</dict>"; |
||
| 630 | $this->serial = $this->serial + 1; |
||
| 631 | \core\common\Entity::outOfThePotatoes(); |
||
| 632 | return $retval; |
||
| 633 | } |
||
| 634 | |||
| 635 | /** |
||
| 636 | * Produces a Network block which sets a network to manual join (we don't |
||
| 637 | * get any closer to removing a network in mobileconfig) |
||
| 638 | * |
||
| 639 | * @param string $ssid the SSID to set to manual join only |
||
| 640 | * @return string |
||
| 641 | */ |
||
| 642 | private function removenetworkBlock($ssid) |
||
| 643 | { |
||
| 644 | \core\common\Entity::intoThePotatoes(); |
||
| 645 | $retval = " |
||
| 646 | <dict> |
||
| 647 | <key>AutoJoin</key> |
||
| 648 | <false/> |
||
| 649 | <key>EncryptionType</key> |
||
| 650 | <string>None</string> |
||
| 651 | <key>HIDDEN_NETWORK</key> |
||
| 652 | <false/> |
||
| 653 | <key>IsHotspot</key> |
||
| 654 | <false/> |
||
| 655 | <key>PayloadDescription</key> |
||
| 656 | <string>" . sprintf(_("This SSID should not be used after bootstrapping %s"), \config\ConfAssistant::CONSORTIUM['display_name']) . "</string> |
||
| 657 | <key>PayloadDisplayName</key> |
||
| 658 | <string>" . _("Disabled WiFi network") . "</string> |
||
| 659 | <key>PayloadIdentifier</key> |
||
| 660 | <string>" . self::IPHONE_PAYLOAD_PREFIX . ".$this->massagedConsortium.$this->massagedCountry.$this->massagedInst.$this->massagedProfile.$this->lang.wifi.disabled.$this->removeSerial</string> |
||
| 661 | <key>PayloadType</key> |
||
| 662 | <string>com.apple.wifi.managed</string> |
||
| 663 | <key>PayloadUUID</key> |
||
| 664 | <string>" . \core\common\Entity::uuid() . "</string> |
||
| 665 | <key>PayloadVersion</key> |
||
| 666 | <real>1</real>"; |
||
| 667 | $retval .= $this->proxySettings(); |
||
| 668 | $retval .= "<key>SSID_STR</key> |
||
| 669 | <string>$ssid</string> |
||
| 670 | </dict> |
||
| 671 | "; |
||
| 672 | \core\common\Entity::outOfThePotatoes(); |
||
| 673 | return $retval; |
||
| 674 | } |
||
| 675 | |||
| 676 | const NETWORK_BLOCK_TYPE_SSID = 100; |
||
| 677 | const NETWORK_BLOCK_TYPE_CONSORTIUMOIS = 101; |
||
| 678 | const NETWORK_BLOCK_TYPE_WIRED = 102; |
||
| 679 | |||
| 680 | /** |
||
| 681 | * produces the entire series of Network blocks; all for SSID-based, |
||
| 682 | * Passpoint-based, wired, and manual-select only SSIDs |
||
| 683 | * |
||
| 684 | * @return string |
||
| 685 | */ |
||
| 686 | private function allNetworkBlocks() |
||
| 687 | { |
||
| 688 | $retval = ""; |
||
| 689 | $this->serial = 0; |
||
| 690 | foreach ($this->attributes['internal:networks'] as $netName => $netDefinition) { |
||
| 691 | // mobileconfig network blocks can only hold one SSID each, so iterate here |
||
| 692 | foreach ($netDefinition['ssid'] as $ssid) { |
||
| 693 | $retval .= $this->networkBlock(MobileconfigSuperclass::NETWORK_BLOCK_TYPE_SSID, $ssid, $netName); |
||
| 694 | } |
||
| 695 | // mobileconfig network blocks can accommodate a list of RCOIs in one statement, so just call it |
||
| 696 | if ($this->selectedEapObject->isPasswordRequired() === FALSE || $netName != 'eduroam®') { |
||
| 697 | $retval .= $this->networkBlock(MobileconfigSuperclass::NETWORK_BLOCK_TYPE_CONSORTIUMOIS, $netDefinition['oi'], $netName); |
||
| 698 | } |
||
| 699 | } |
||
| 700 | if (isset($this->attributes['media:wired']) && get_class($this) == "devices\apple_mobileconfig\DeviceMobileconfigOsX") { |
||
| 701 | $retval .= $this->networkBlock(MobileconfigSuperclass::NETWORK_BLOCK_TYPE_WIRED, TRUE, \config\ConfAssistant::CONSORTIUM['display_name']); |
||
| 702 | } |
||
| 703 | if (isset($this->attributes['media:remove_SSID'])) { |
||
| 704 | $this->removeSerial = 0; |
||
| 705 | foreach ($this->attributes['media:remove_SSID'] as $removeSSID) { |
||
| 706 | $retval .= $this->removenetworkBlock($removeSSID); |
||
| 707 | $this->removeSerial = $this->removeSerial + 1; |
||
| 708 | } |
||
| 709 | } |
||
| 710 | return $retval; |
||
| 711 | } |
||
| 712 | |||
| 713 | /** |
||
| 714 | * collates a block with all CAs that are to be included in the mobileconfig |
||
| 715 | * |
||
| 716 | * @return string |
||
| 717 | */ |
||
| 718 | private function allCA() |
||
| 719 | { |
||
| 720 | $retval = ""; |
||
| 721 | $this->caSerial = 0; |
||
| 722 | foreach ($this->attributes['internal:CAs'][0] as $ca) { |
||
| 723 | $retval .= $this->caBlob($ca); |
||
| 724 | $this->caSerial = $this->caSerial + 1; |
||
| 725 | } |
||
| 726 | return $retval; |
||
| 727 | } |
||
| 728 | |||
| 729 | /** |
||
| 730 | * creates a Cert block containing a client certificate (used in SB only) |
||
| 731 | * @return array the block itself, and the UUID of the certificate |
||
| 732 | * @throws Exception |
||
| 733 | */ |
||
| 734 | private function clientP12Block() |
||
| 770 | } |
||
| 771 | |||
| 772 | /** |
||
| 773 | * creates an Expiry block. This is only done in SB; the profile expires |
||
| 774 | * when the client cert expires. |
||
| 775 | * |
||
| 776 | * @return string |
||
| 777 | * @throws Exception |
||
| 778 | */ |
||
| 779 | private function expiryBlock() { |
||
| 786 | } |
||
| 787 | |||
| 788 | /** |
||
| 789 | * creates a block for one single CA |
||
| 790 | * |
||
| 791 | * @param array $ca the CA for which to generate the XML block |
||
| 792 | * @return string |
||
| 793 | */ |
||
| 794 | private function caBlob($ca) |
||
| 835 | } |
||
| 836 | |||
| 837 | } |
||
| 838 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths