| Total Complexity | 78 |
| Total Lines | 651 |
| Duplicated Lines | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
Complex classes like DeviceConfig 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 DeviceConfig, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 57 | abstract class DeviceConfig extends \core\common\Entity { |
||
| 58 | |||
| 59 | /** |
||
| 60 | * stores the path to the temporary working directory for a module instance |
||
| 61 | * @var string $FPATH |
||
| 62 | */ |
||
| 63 | public $FPATH; |
||
| 64 | |||
| 65 | /** |
||
| 66 | * array of specialities - will be displayed on the admin download as "footnote" |
||
| 67 | * @var array specialities |
||
| 68 | */ |
||
| 69 | public $specialities; |
||
| 70 | |||
| 71 | /** |
||
| 72 | * list of supported EAP methods |
||
| 73 | * @var array EAP methods |
||
| 74 | */ |
||
| 75 | public $supportedEapMethods; |
||
| 76 | |||
| 77 | /** |
||
| 78 | * sets the supported EAP methods for a device |
||
| 79 | * |
||
| 80 | * @param array $eapArray the list of EAP methods the device supports |
||
| 81 | * @return void |
||
| 82 | */ |
||
| 83 | protected function setSupportedEapMethods($eapArray) { |
||
| 87 | } |
||
| 88 | |||
| 89 | /** |
||
| 90 | * device module constructor should be defined by each module. |
||
| 91 | * The one important thing to do is to call setSupportedEapMethods with an |
||
| 92 | * array of EAP methods the device supports |
||
| 93 | */ |
||
| 94 | public function __construct() { |
||
| 95 | parent::__construct(); |
||
| 96 | } |
||
| 97 | |||
| 98 | /** |
||
| 99 | * Set up working environment for a device module |
||
| 100 | * |
||
| 101 | * Sets up the device module environment taking into account the actual profile |
||
| 102 | * selected by the user in the GUI. The selected profile is passed as the |
||
| 103 | * Profile $profile argumant. |
||
| 104 | * |
||
| 105 | * This method needs to be called after the device instance has been created (the GUI class does that) |
||
| 106 | * |
||
| 107 | * setup performs the following tasks: |
||
| 108 | * - collect profile attributes and pass them as the attributes property; |
||
| 109 | * - create the temporary working directory |
||
| 110 | * - process CA certificates and store them as 'internal:CAs' attribute |
||
| 111 | * - process and save optional info files and store references to them in |
||
| 112 | * 'internal:info_file' attribute |
||
| 113 | * @param AbstractProfile $profile the profile object which will be passed by the caller |
||
| 114 | * @param string $token the invitation token for silverbullet requests |
||
| 115 | * @param string $importPassword the PIN for the installer for silverbullet requests |
||
| 116 | * @return void |
||
| 117 | * @final not to be redefined |
||
| 118 | */ |
||
|
|
|||
| 119 | final public function setup(AbstractProfile $profile, $token = NULL, $importPassword = NULL) { |
||
| 120 | $this->loggerInstance->debug(4, "module setup start\n"); |
||
| 121 | common\Entity::intoThePotatoes(); |
||
| 122 | $purpose = 'installer'; |
||
| 123 | $eaps = $profile->getEapMethodsinOrderOfPreference(1); |
||
| 124 | $this->calculatePreferredEapType($eaps); |
||
| 125 | if (count($this->selectedEap) == 0) { |
||
| 126 | throw new Exception("No EAP type available."); |
||
| 127 | } |
||
| 128 | $this->attributes = $this->getProfileAttributes($profile); |
||
| 129 | $this->deviceUUID = common\Entity::uuid('', 'CAT' . $profile->institution . "-" . $profile->identifier . "-" . $this->device_id); |
||
| 130 | |||
| 131 | |||
| 132 | // if we are instantiating a Silverbullet profile AND have been given |
||
| 133 | // a token, attempt to create the client certificate NOW |
||
| 134 | // then, this is the only instance of the device ever which knows the |
||
| 135 | // cert and private key. It's not saved anywhere, so it's gone forever |
||
| 136 | // after code execution! |
||
| 137 | |||
| 138 | $this->loggerInstance->debug(5, "DeviceConfig->setup() - preliminaries done.\n"); |
||
| 139 | if ($profile instanceof ProfileSilverbullet && $token !== NULL && $importPassword !== NULL) { |
||
| 140 | $this->clientCert = SilverbulletCertificate::issueCertificate($token, $importPassword, $this->options['clientcert']); |
||
| 141 | // we need to drag this along; ChromeOS needs it outside the P12 container to encrypt the entire *config* with it. |
||
| 142 | // Because encrypted private keys are not supported as per spec! |
||
| 143 | $purpose = 'silverbullet'; |
||
| 144 | // let's keep a record for which device type this token was consumed |
||
| 145 | $dbInstance = DBConnection::handle("INST"); |
||
| 146 | $certId = $this->clientCert['certObject']->dbId; |
||
| 147 | $dbInstance->exec("UPDATE `silverbullet_certificate` SET `device` = ? WHERE `id` = ?", "si", $this->device_id, $certId); |
||
| 148 | } |
||
| 149 | $this->loggerInstance->debug(5, "DeviceConfig->setup() - silverbullet checks done.\n"); |
||
| 150 | // create temporary directory, its full path will be saved in $this->FPATH; |
||
| 151 | $tempDir = $this->createTemporaryDirectory($purpose); |
||
| 152 | $this->FPATH = $tempDir['dir']; |
||
| 153 | mkdir($tempDir['dir'] . '/tmp'); |
||
| 154 | chdir($tempDir['dir'] . '/tmp'); |
||
| 155 | $caList = []; |
||
| 156 | $x509 = new \core\common\X509(); |
||
| 157 | if (isset($this->attributes['eap:ca_file'])) { |
||
| 158 | foreach ($this->attributes['eap:ca_file'] as $ca) { |
||
| 159 | $processedCert = $x509->processCertificate($ca); |
||
| 160 | if (is_array($processedCert)) { |
||
| 161 | // add a UUID for convenience (some devices refer to their CAs by a UUID value) |
||
| 162 | $processedCert['uuid'] = common\Entity::uuid("", $processedCert['pem']); |
||
| 163 | $caList[] = $processedCert; |
||
| 164 | } |
||
| 165 | } |
||
| 166 | $this->attributes['internal:CAs'][0] = $caList; |
||
| 167 | } |
||
| 168 | |||
| 169 | if (isset($this->attributes['support:info_file'])) { |
||
| 170 | $this->attributes['internal:info_file'][0] = $this->saveInfoFile($this->attributes['support:info_file'][0]); |
||
| 171 | } |
||
| 172 | if (isset($this->attributes['general:logo_file'])) { |
||
| 173 | $this->loggerInstance->debug(5, "saving IDP logo\n"); |
||
| 174 | $this->attributes['internal:logo_file'] = $this->saveLogoFile($this->attributes['general:logo_file'],'idp'); |
||
| 175 | } |
||
| 176 | if (isset($this->attributes['fed:logo_file'])) { |
||
| 177 | $this->loggerInstance->debug(5, "saving FED logo\n"); |
||
| 178 | $this->attributes['fed:logo_file'] = $this->saveLogoFile($this->attributes['fed:logo_file'], 'fed'); |
||
| 179 | } |
||
| 180 | $this->attributes['internal:SSID'] = $this->getSSIDs()['add']; |
||
| 181 | |||
| 182 | $this->attributes['internal:remove_SSID'] = $this->getSSIDs()['del']; |
||
| 183 | |||
| 184 | $this->attributes['internal:consortia'] = $this->getConsortia(); |
||
| 185 | |||
| 186 | $this->support_email_substitute = sprintf(_("your local %s support"), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name']); |
||
| 187 | $this->support_url_substitute = sprintf(_("your local %s support page"), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name']); |
||
| 188 | |||
| 189 | if ($this->signer && $this->options['sign']) { |
||
| 190 | $this->sign = ROOT . '/signer/' . $this->signer; |
||
| 191 | } |
||
| 192 | $this->installerBasename = $this->getInstallerBasename(); |
||
| 193 | common\Entity::outOfThePotatoes(); |
||
| 194 | } |
||
| 195 | |||
| 196 | /** |
||
| 197 | * Selects the preferred eap method based on profile EAP configuration and device EAP capabilities |
||
| 198 | * |
||
| 199 | * @param array $eapArrayofObjects an array of eap methods supported by a given device |
||
| 200 | * @return void |
||
| 201 | */ |
||
| 202 | public function calculatePreferredEapType($eapArrayofObjects) { |
||
| 203 | $this->selectedEap = []; |
||
| 204 | foreach ($eapArrayofObjects as $eap) { |
||
| 205 | if (in_array($eap->getArrayRep(), $this->supportedEapMethods)) { |
||
| 206 | $this->selectedEap = $eap->getArrayRep(); |
||
| 207 | break; |
||
| 208 | } |
||
| 209 | } |
||
| 210 | if ($this->selectedEap != []) { |
||
| 211 | $this->selectedEapObject = new common\EAP($this->selectedEap); |
||
| 212 | } |
||
| 213 | } |
||
| 214 | |||
| 215 | /** |
||
| 216 | * prepare usage information for the installer |
||
| 217 | * every device module should override this method |
||
| 218 | * |
||
| 219 | * @return string HTML text to be displayed |
||
| 220 | */ |
||
| 221 | public function writeDeviceInfo() { |
||
| 222 | common\Entity::intoThePotatoes(); |
||
| 223 | $retval = _("Sorry, this should not happen - no additional information is available"); |
||
| 224 | common\Entity::outOfThePotatoes(); |
||
| 225 | return $retval; |
||
| 226 | } |
||
| 227 | |||
| 228 | /** |
||
| 229 | * function to return exactly one attribute type |
||
| 230 | * |
||
| 231 | * @param string $attrName the attribute to retrieve |
||
| 232 | * @return array|NULL the attributes |
||
| 233 | */ |
||
| 234 | public function getAttribute($attrName) { |
||
| 236 | } |
||
| 237 | |||
| 238 | /** |
||
| 239 | * some modules have a complex directory structure. This helper finds resources |
||
| 240 | * in that structure. Mostly used in the Windows modules. |
||
| 241 | * |
||
| 242 | * @param string $file the filename to search for (without path) |
||
| 243 | * @return string|boolean the filename as found, with path, or FALSE if it does not exist |
||
| 244 | */ |
||
| 245 | protected function findSourceFile($file) { |
||
| 246 | if (is_file($this->module_path . '/Files/' . $this->device_id . '/' . $file)) { |
||
| 247 | return $this->module_path . '/Files/' . $this->device_id . '/' . $file; |
||
| 248 | } elseif (is_file($this->module_path . '/Files/' . $file)) { |
||
| 249 | return $this->module_path . '/Files/' . $file; |
||
| 250 | } else { |
||
| 251 | $this->loggerInstance->debug(2, "requested file $file does not exist\n"); |
||
| 252 | return FALSE; |
||
| 253 | } |
||
| 254 | } |
||
| 255 | |||
| 256 | /** |
||
| 257 | * Copy a file from the module location to the temporary directory. |
||
| 258 | * |
||
| 259 | * If the second argument is provided then the file will be saved under the name |
||
| 260 | * taken form this argument. If only one parameter is given, source and destination |
||
| 261 | * filenames are the same |
||
| 262 | * Source file can be located either in the Files subdirectory or in the sibdirectory of Files |
||
| 263 | * named the same as device_id. The second option takes precedence. |
||
| 264 | * |
||
| 265 | * @param string $source_name The source file name |
||
| 266 | * @param string $output_name The destination file name |
||
| 267 | * |
||
| 268 | * @return boolean result of the copy operation |
||
| 269 | * @final not to be redefined |
||
| 270 | */ |
||
| 271 | final protected function copyFile($source_name, $output_name = NULL) { |
||
| 286 | } |
||
| 287 | |||
| 288 | /** |
||
| 289 | * Save certificate files in either DER or PEM format |
||
| 290 | * |
||
| 291 | * Certificate files will be saved in the module working directory. |
||
| 292 | * |
||
| 293 | * saved certificate file names are avalable under the 'file' index |
||
| 294 | * additional array entries are indexed as 'sha1', 'md5', and 'root'. |
||
| 295 | * sha1 and md5 are correcponding certificate hashes |
||
| 296 | * root is set to 1 for the CA roor certicicate and 0 otherwise |
||
| 297 | * |
||
| 298 | * @param string $format only "der" and "pem" are currently allowed |
||
| 299 | * @return array an array of arrays or empty array on error |
||
| 300 | |||
| 301 | */ |
||
| 302 | final protected function saveCertificateFiles($format) { |
||
| 303 | switch ($format) { |
||
| 304 | case "der": // fall-thorugh, same treatment |
||
| 305 | case "pem": |
||
| 306 | $iterator = 0; |
||
| 307 | $caFiles = []; |
||
| 308 | $caArray = $this->attributes['internal:CAs'][0]; |
||
| 309 | if (!$caArray) { |
||
| 310 | return([]); |
||
| 311 | } |
||
| 312 | foreach ($caArray as $certAuthority) { |
||
| 313 | $fileHandle = fopen("cert-$iterator.crt", "w"); |
||
| 314 | if (!$fileHandle) { |
||
| 315 | throw new Exception("problem opening the file"); |
||
| 316 | } |
||
| 317 | if ($format === "pem") { |
||
| 318 | fwrite($fileHandle, $certAuthority['pem']); |
||
| 319 | } else { |
||
| 320 | fwrite($fileHandle, $certAuthority['der']); |
||
| 321 | } |
||
| 322 | fclose($fileHandle); |
||
| 323 | $certAuthorityProps = []; |
||
| 324 | $certAuthorityProps['file'] = "cert-$iterator.crt"; |
||
| 325 | $certAuthorityProps['sha1'] = $certAuthority['sha1']; |
||
| 326 | $certAuthorityProps['md5'] = $certAuthority['md5']; |
||
| 327 | $certAuthorityProps['root'] = $certAuthority['root']; |
||
| 328 | $caFiles[] = $certAuthorityProps; |
||
| 329 | $iterator++; |
||
| 330 | } |
||
| 331 | return($caFiles); |
||
| 332 | default: |
||
| 333 | $this->loggerInstance->debug(2, 'incorrect format value specified'); |
||
| 334 | return([]); |
||
| 335 | } |
||
| 336 | } |
||
| 337 | |||
| 338 | /** |
||
| 339 | * set of characters to remove from filename strings |
||
| 340 | */ |
||
| 341 | private const TRANSLIT_SCRUB = '/[ ()\/\'"]+/'; |
||
| 342 | |||
| 343 | /** |
||
| 344 | * Does a transliteration from UTF-8 to ASCII to get a sane filename |
||
| 345 | * Takes special characters into account, and always uses English CTYPE |
||
| 346 | * to avoid introduction of funny characters due to "flying accents" |
||
| 347 | * |
||
| 348 | * @param string $input the input string that is to be transliterated |
||
| 349 | * @return string the transliterated string |
||
| 350 | */ |
||
| 351 | private function customTranslit($input) { |
||
| 357 | } |
||
| 358 | |||
| 359 | /** |
||
| 360 | * Generate installer filename base. |
||
| 361 | * Device module should use this name adding an extension. |
||
| 362 | * Normally the device identifier follows the Consortium name. |
||
| 363 | * The sting taken for the device identifier equals (by default) to the index in the listDevices array, |
||
| 364 | * but can be overriden with the 'device_id' device option. |
||
| 365 | * |
||
| 366 | * @return string |
||
| 367 | */ |
||
| 368 | private function getInstallerBasename() { |
||
| 369 | |||
| 370 | $baseName = $this->customTranslit(CONFIG_CONFASSISTANT['CONSORTIUM']['name']) . "-" . $this->getDeviceId(); |
||
| 371 | if (isset($this->attributes['profile:customsuffix'][1])) { |
||
| 372 | // this string will end up as a filename on a filesystem, so always |
||
| 373 | // take a latin-based language variant if available |
||
| 374 | // and then scrub non-ASCII just in case |
||
| 375 | return $baseName . $this->customTranslit($this->attributes['profile:customsuffix'][1]); |
||
| 376 | } |
||
| 377 | // Okay, no custom suffix. |
||
| 378 | // Use the configured inst name and apply shortening heuristics |
||
| 379 | $lang_pointer = CONFIG['LANGUAGES'][$this->languageInstance->getLang()]['latin_based'] == TRUE ? 0 : 1; |
||
| 380 | $this->loggerInstance->debug(5, "getInstallerBasename1:" . $this->attributes['general:instname'][$lang_pointer] . "\n"); |
||
| 381 | $inst = $this->customTranslit($this->attributes['general:instname'][$lang_pointer]); |
||
| 382 | $this->loggerInstance->debug(4, "getInstallerBasename2:$inst\n"); |
||
| 383 | $Inst_a = explode('_', $inst); |
||
| 384 | if (count($Inst_a) > 2) { |
||
| 385 | $inst = ''; |
||
| 386 | foreach ($Inst_a as $i) { |
||
| 387 | $inst .= $i[0]; |
||
| 388 | } |
||
| 389 | } |
||
| 390 | // and if the inst has multiple profiles, add the profile name behin |
||
| 391 | if ($this->attributes['internal:profile_count'][0] > 1) { |
||
| 392 | if (!empty($this->attributes['profile:name']) && !empty($this->attributes['profile:name'][$lang_pointer])) { |
||
| 393 | $profTemp = $this->customTranslit($this->attributes['profile:name'][$lang_pointer]); |
||
| 394 | $prof = preg_replace('/_+$/', '', $profTemp); |
||
| 395 | return $baseName . $inst . '-' . $prof; |
||
| 396 | } |
||
| 397 | } |
||
| 398 | return $baseName . $inst; |
||
| 399 | } |
||
| 400 | |||
| 401 | /** |
||
| 402 | * returns the device_id of the current device |
||
| 403 | * |
||
| 404 | * @return string |
||
| 405 | */ |
||
| 406 | private function getDeviceId() { |
||
| 415 | } |
||
| 416 | |||
| 417 | /** |
||
| 418 | * returns the list of SSIDs that installers should treat. |
||
| 419 | * |
||
| 420 | * Includes both SSIDs to be set up (and whether it's a TKIP-mixed or AES-only SSID) and SSIDs to be deleted |
||
| 421 | * |
||
| 422 | * @return array |
||
| 423 | */ |
||
| 424 | private function getSSIDs() { |
||
| 425 | $ssidList = []; |
||
| 426 | $ssidList['add'] = []; |
||
| 427 | $ssidList['del'] = []; |
||
| 428 | if (isset(CONFIG_CONFASSISTANT['CONSORTIUM']['ssid'])) { |
||
| 429 | foreach (CONFIG_CONFASSISTANT['CONSORTIUM']['ssid'] as $ssid) { |
||
| 430 | if (\core\common\Entity::getAttributeValue(CONFIG_CONFASSISTANT, 'CONSORTIUM', 'tkipsupport') == TRUE) { |
||
| 431 | $ssidList['add'][$ssid] = 'TKIP'; |
||
| 432 | } else { |
||
| 433 | $ssidList['add'][$ssid] = 'AES'; |
||
| 434 | $ssidList['del'][$ssid] = 'TKIP'; |
||
| 435 | } |
||
| 436 | } |
||
| 437 | } |
||
| 438 | if (isset($this->attributes['media:SSID'])) { |
||
| 439 | $ssidWpa2 = $this->attributes['media:SSID']; |
||
| 440 | |||
| 441 | foreach ($ssidWpa2 as $ssid) { |
||
| 442 | $ssidList['add'][$ssid] = 'AES'; |
||
| 443 | } |
||
| 444 | } |
||
| 445 | if (isset($this->attributes['media:SSID_with_legacy'])) { |
||
| 446 | $ssidTkip = $this->attributes['media:SSID_with_legacy']; |
||
| 447 | foreach ($ssidTkip as $ssid) { |
||
| 448 | $ssidList['add'][$ssid] = 'TKIP'; |
||
| 449 | } |
||
| 450 | } |
||
| 451 | if (isset($this->attributes['media:remove_SSID'])) { |
||
| 452 | $ssidRemove = $this->attributes['media:remove_SSID']; |
||
| 453 | foreach ($ssidRemove as $ssid) { |
||
| 454 | $ssidList['del'][$ssid] = 'DEL'; |
||
| 455 | } |
||
| 456 | } |
||
| 457 | return $ssidList; |
||
| 458 | } |
||
| 459 | |||
| 460 | /** |
||
| 461 | * returns the list of Hotspot 2.0 / Passpoint roaming consortia to set up |
||
| 462 | * |
||
| 463 | * @return array |
||
| 464 | */ |
||
| 465 | private function getConsortia() { |
||
| 478 | } |
||
| 479 | |||
| 480 | /** |
||
| 481 | * An array with shorthand definitions for MIME types |
||
| 482 | * @var array |
||
| 483 | */ |
||
| 484 | private $mime_extensions = [ |
||
| 485 | 'text/plain' => 'txt', |
||
| 486 | 'text/rtf' => 'rtf', |
||
| 487 | 'application/pdf' => 'pdf', |
||
| 488 | ]; |
||
| 489 | |||
| 490 | /** |
||
| 491 | * saves a number of logos to a cache directory on disk. |
||
| 492 | * |
||
| 493 | * @param array $logos list of logos (binary strings each) |
||
| 494 | * @param string $type a qualifier what type of logo this is |
||
| 495 | * @return array list of filenames and the mime types |
||
| 496 | * @throws Exception |
||
| 497 | */ |
||
| 498 | private function saveLogoFile($logos,$type) { |
||
| 523 | } |
||
| 524 | |||
| 525 | /** |
||
| 526 | * saves the Terms of Use file onto disk |
||
| 527 | * |
||
| 528 | * @param string $blob the Terms of Use |
||
| 529 | * @return array with one entry, containging the filename and mime type |
||
| 530 | * @throws Exception |
||
| 531 | */ |
||
| 532 | private function saveInfoFile($blob) { |
||
| 533 | $finfo = new \finfo(FILEINFO_MIME_TYPE); |
||
| 534 | $mime = $finfo->buffer($blob); |
||
| 535 | $ext = isset($this->mime_extensions[$mime]) ? $this->mime_extensions[$mime] : 'usupported'; |
||
| 536 | $this->loggerInstance->debug(5, "saveInfoFile: $mime : $ext\n"); |
||
| 537 | $fileHandle = fopen('local-info.' . $ext, "w"); |
||
| 538 | if ($fileHandle === FALSE) { |
||
| 539 | throw new Exception("problem opening the file"); |
||
| 540 | } |
||
| 541 | fwrite($fileHandle, $blob); |
||
| 542 | fclose($fileHandle); |
||
| 543 | return(['name' => 'local-info.' . $ext, 'mime' => $ext]); |
||
| 544 | } |
||
| 545 | |||
| 546 | /** |
||
| 547 | * returns the attributes of the profile for which to generate an installer |
||
| 548 | * |
||
| 549 | * In condensed notion, and most specific level only (i.e. ignores overriden attributes from a higher level) |
||
| 550 | * @param \core\AbstractProfile $profile the Profile in question |
||
| 551 | * @return array |
||
| 552 | */ |
||
| 553 | private function getProfileAttributes(AbstractProfile $profile) { |
||
| 554 | $bestMatchEap = $this->selectedEap; |
||
| 555 | if (count($bestMatchEap) > 0) { |
||
| 556 | $a = $profile->getCollapsedAttributes($bestMatchEap); |
||
| 557 | $a['eap'] = $bestMatchEap; |
||
| 558 | $a['all_eaps'] = $profile->getEapMethodsinOrderOfPreference(1); |
||
| 559 | return($a); |
||
| 560 | } |
||
| 561 | print("No supported eap types found for this profile.\n"); |
||
| 562 | return []; |
||
| 563 | } |
||
| 564 | |||
| 565 | /** |
||
| 566 | * dumps attributes for debugging purposes |
||
| 567 | * |
||
| 568 | * dumpAttibutes method is supplied for debuging purposes, it simply dumps the attribute array |
||
| 569 | * to a file with name passed in the attribute. |
||
| 570 | * @param string $file the output file name |
||
| 571 | * @return void |
||
| 572 | */ |
||
| 573 | protected function dumpAttibutes($file) { |
||
| 574 | ob_start(); |
||
| 575 | print_r($this->attributes); |
||
| 576 | $output = ob_get_clean(); |
||
| 577 | file_put_contents($file, $output); |
||
| 578 | } |
||
| 579 | |||
| 580 | /** |
||
| 581 | * placeholder for the main device method |
||
| 582 | * @return string |
||
| 583 | */ |
||
| 584 | abstract public function writeInstaller(); |
||
| 585 | |||
| 586 | /** |
||
| 587 | * collates the string to use as EAP outer ID |
||
| 588 | * |
||
| 589 | * @return string|NULL |
||
| 590 | */ |
||
| 591 | protected function determineOuterIdString() { |
||
| 600 | } |
||
| 601 | |||
| 602 | /** |
||
| 603 | * Array passing all options to the device module. |
||
| 604 | * |
||
| 605 | * $attrbutes array contains option values defined for the institution and a particular |
||
| 606 | * profile (possibly overriding one another) ready for the device module to consume. |
||
| 607 | * |
||
| 608 | * For each of the options the value is another array of vales (even if only one value is present). |
||
| 609 | * Some attributes may be missing if they have not been configured for a viven institution or profile. |
||
| 610 | * |
||
| 611 | * The following attributes are meant to be used by device modules: |
||
| 612 | * - <b>general:geo_coordinates</b> - geographical coordinates of the institution or a campus |
||
| 613 | * - <b>support:info_file</b> - consent file displayed to the users |
||
| 614 | * - <b>general:logo_file</b> - file data containing institution logo |
||
| 615 | * - <b>support:eap_types</b> - URL to a local support page for a specific eap methiod, not to be confused with general:url |
||
| 616 | * - <b>support:email</b> - email for users to contact for local instructions |
||
| 617 | * - <b>support:phone</b> - telephone number for users to contact for local instructions |
||
| 618 | * - <b>support:url</b> - URL where the user will find local instructions |
||
| 619 | * - <b>internal:info_file</b> - the pathname of the info_file saved in the working directory |
||
| 620 | * - <b>internal:logo_file</b> - array of pathnames of logo_files saved in the working directory |
||
| 621 | * - <b>internal:CAs</b> - the value is an array produced by X509::processCertificate() with the following filds |
||
| 622 | * - <b>internal:SSID</b> - an array indexed by SSID strings with values either TKIP or AES; if TKIP is set the both WPA/TKIP and WPA2/AES should be set if AES is set the this is a WPA2/AES only SSID; the consortium's defined SSIDs are always set as the first array elements. |
||
| 623 | * - <b>internal:consortia</b> an array of consortion IO as declared in the config-confassistant |
||
| 624 | * - <b>internal:profile_count</b> - the number of profiles for the associated IdP |
||
| 625 | * |
||
| 626 | * |
||
| 627 | * these attributes are available and can be used, but the "internal" attributes are better suited for modules |
||
| 628 | * - eap:ca_file - certificate of the CA signing the RADIUS server key |
||
| 629 | * - <b>media:SSID</b> - additional SSID to configure, WPA2/AES only (device modules should use internal:SSID) |
||
| 630 | * - <b>media:SSID_with_legacy</b> - additional SSID to configure, WPA2/AES and WPA/TKIP (device modules should use internal:SSID) |
||
| 631 | * |
||
| 632 | * @see \core\common\X509::processCertificate() |
||
| 633 | * @var array $attributes |
||
| 634 | */ |
||
| 635 | public $attributes; |
||
| 636 | |||
| 637 | /** |
||
| 638 | * stores the path to the module source location and is used |
||
| 639 | * by copyFile and translateFile |
||
| 640 | * the only reason for it to be a public variable ies that it is set by the DeviceFactory class |
||
| 641 | * module_path should not be used by module drivers. |
||
| 642 | * @var string |
||
| 643 | */ |
||
| 644 | public $module_path; |
||
| 645 | |||
| 646 | /** |
||
| 647 | * * The optimal EAP type selected given profile and device |
||
| 648 | * @var array |
||
| 649 | */ |
||
| 650 | public $selectedEap; |
||
| 651 | public $selectedEapObject; |
||
| 652 | |||
| 653 | /** |
||
| 654 | * the path to the profile signing program |
||
| 655 | * device modules which require signing should use this property to exec the signer |
||
| 656 | * the signer program must accept two arguments - input and output file names |
||
| 657 | * the signer program mus operate in the local directory and filenames are relative to this |
||
| 658 | * directory |
||
| 659 | * |
||
| 660 | * @var string |
||
| 661 | */ |
||
| 662 | public $sign; |
||
| 663 | public $signer; |
||
| 664 | |||
| 665 | /** |
||
| 666 | * The string identifier of the device (don't show this to users) |
||
| 667 | * @var string |
||
| 668 | */ |
||
| 669 | public $device_id; |
||
| 670 | |||
| 671 | /** |
||
| 672 | * See devices-template.php for a list of available options |
||
| 673 | * @var array |
||
| 674 | */ |
||
| 675 | public $options; |
||
| 676 | |||
| 677 | /** |
||
| 678 | * This string will be shown if no support email was configured by the admin |
||
| 679 | * |
||
| 680 | * @var string |
||
| 681 | */ |
||
| 682 | public $support_email_substitute; |
||
| 683 | |||
| 684 | /** |
||
| 685 | * This string will be shown if no support URL was configured by the admin |
||
| 686 | * |
||
| 687 | * @var string |
||
| 688 | */ |
||
| 689 | public $support_url_substitute; |
||
| 690 | |||
| 691 | /** |
||
| 692 | * This string should be used by all installer modules to set the |
||
| 693 | * installer file basename. |
||
| 694 | * |
||
| 695 | * @var string |
||
| 696 | */ |
||
| 697 | public $installerBasename; |
||
| 698 | |||
| 699 | /** |
||
| 700 | * stores the PKCS#12 DER representation of a client certificate for SilverBullet |
||
| 701 | */ |
||
| 702 | protected $clientCert; |
||
| 703 | |||
| 704 | /** |
||
| 705 | * stores identifier used by GEANTLink profiles |
||
| 706 | */ |
||
| 707 | public $deviceUUID; |
||
| 708 | |||
| 710 |