phpDocumentor ModuleWriting
[ class tree: ModuleWriting ] [ index: ModuleWriting ] [ all elements ]

Class: Device_Chromebook

Source Location: /devices/chromebook/chromebook.php

Class Device_Chromebook

Class Overview

This is the main implementation class of the module

The name of the class must the the 'Device_' followed by the name of the module file (without the '.php' extension), so in this case the file is "TestModule.php" and the class is Device_TestModule.

The class MUST define the constructor method and one additional public method: writeInstaller().

All other methods and properties should be private. This example sets zipInstaller method to protected, so that it can be seen in the documentation.

It is important to understand how the device module fits into the whole picture, so here is s short descrption. An external caller (for instance GUI::generateInstaller()) creates the module device instance and prepares its environment for a given user profile by calling DeviceConfig::setup() method. this will:

  • create the temporary directory and save its path as $this->FPATH
  • process the CA certificates and store results in $this->attributes['internal:CAs'][0] $this->attributes['internal:CAs'][0] is an array of processed CA certificates a processed certifincate is an array 'pem' points to pem feromat certificate 'der' points to der format certificate 'md5' points to md5 fingerprint 'sha1' points to sha1 fingerprint 'name' points to the certificate subject 'root' can be 1 for self-signed certificate or 0 otherwise
  • save the info_file (if exists) and put the name in $this->attributes['internal:info_file_name'][0]
Finally, the module DeviceConfig::writeInstaller is called and the returned path name is used for user download.

Located in /devices/chromebook/chromebook.php [line 73]

DeviceConfig
   |
   --Device_Chromebook
Author(s): Information Tags:

Methods

[ Top ]
Inherited Properties, Constants, and Methods
Inherited Properties Inherited Methods Inherited Constants

Inherited From DeviceConfig

DeviceConfig::$attributes
DeviceConfig::$device_id
DeviceConfig::$FPATH
DeviceConfig::$installerBasename
DeviceConfig::$lang_index
DeviceConfig::$module_path
DeviceConfig::$options
DeviceConfig::$selected_eap
DeviceConfig::$sign
DeviceConfig::$signer
DeviceConfig::$specialities
DeviceConfig::$support_email_substitute
DeviceConfig::$support_url_substitute

Inherited From DeviceConfig

DeviceConfig::__construct()
device module constructor should be defined by each module, but if it is not, then here is a default one
DeviceConfig::copyFile()
Copy a file from the module location to the temporary directory.
DeviceConfig::dumpAttibutes()
dumps attributes for debugging purposes
DeviceConfig::getPreferredEapType()
Selects the preferred eap method based on profile EAP configuration and device EAP capabilities
DeviceConfig::saveCertificateFiles()
Save certificate files in either DER or PEM format
DeviceConfig::setup()
Set up working environment for a device module
DeviceConfig::translateFile()
Copy a file from the module location to the temporary directory aplying translation.
DeviceConfig::translateString()
DeviceConfig::writeDeviceInfo()
prepare usage information for the installer every device module should override this method
DeviceConfig::writeInstaller()
placeholder for the main device method

[ Top ]
Method Summary
Device_Chromebook   __construct()   Constructs a Device object.
string   writeDeviceInfo()   prepare module desctiption and usage information
string   writeInstaller()   prepare a ONC file

[ Top ]
Methods
Constructor __construct  [line 86]

  Device_Chromebook __construct( string $device  )

Constructs a Device object.

It is CRUTCIAL that the constructor sets $this->supportedEapMethods to an array of methods available for the particular device.

  1. function __construct({
  2.         $this->supportedEapMethods array(EAP::$PEAP_MSCHAP2EAP::$TTLS_PAPEAP::$TTLS_MSCHAP2EAP::$TLS);
  3.         debug(4"This device supports the following EAP methods: ");
  4.         debug(4$this->supportedEapMethods);
  5.     }

Parameters:
string   $device:  a pointer to a device module, which must be an index of one of the devices defined in the Devices array in devices.php.

API Tags:
Access:  public

Information Tags:
Final:  not to be redefined

Redefinition of:
DeviceConfig::__construct()
device module constructor should be defined by each module, but if it is not, then here is a default one

[ Top ]
writeDeviceInfo  [line 201]

  string writeDeviceInfo( )

prepare module desctiption and usage information

  1. function writeDeviceInfo({
  2.         $ssid_ct count($this->attributes['internal:SSID']);
  3.         $out "<p>";
  4.         $out .= _("This installer is an example only. It produces a zip file containig the IdP certificates, info and logo files (if such have been defined by the IdP administrator) and a dump of all available attributes.");
  5.         return $out;
  6.     }


API Tags:
Return:  HTML text to be displayed in the information window
Access:  public


Redefinition of:
DeviceConfig::writeDeviceInfo()
prepare usage information for the installer every device module should override this method

[ Top ]
writeInstaller  [line 98]

  string writeInstaller( )

prepare a ONC file

  1. function writeInstaller({
  2.         debug(4"Chromebook Installer start\n");
  3.         // we don't do per-user encrypted containers
  4.         $json_array array();
  5.  
  6.         $json_array["Type""UnencryptedConfiguration";
  7.  
  8.         foreach ($this->attributes['internal:CAs'][0as $ca{
  9.             $ca_refs["{" $ca['uuid'"}";
  10.         }
  11.         // construct outer id, if anonymity is desired
  12.         if (isset($this->attributes['internal:use_anon_outer']&& $this->attributes['internal:use_anon_outer'][0== "1" && isset($this->attributes['internal:realm'])) {
  13.             $outer_id "@" $this->attributes['internal:realm'][0];
  14.             if (isset($this->attributes['internal:anon_local_value']))
  15.                 $outer_id $this->attributes['internal:anon_local_value'][0$outer_id;
  16.         }
  17.         else {
  18.             $outer_id 0;
  19.         }
  20.         // define networks
  21.         foreach ($this->attributes['internal:SSID'as $ssid => $cryptolevel{
  22.             $network_uuid uuid($prefix$ssid);
  23.             $eap_prettyprint EAP::eapDisplayName($this->selected_eap);
  24.             // ONC has its own enums, and guess what, they don't always match
  25.             if ($eap_prettyprint["OUTER"== "PEAP" && $eap_prettyprint["INNER"== "MSCHAPV2")
  26.                 $eap_prettyprint["INNER""EAP-MSCHAPv2";
  27.             if ($eap_prettyprint["OUTER"== "TTLS" && $eap_prettyprint["INNER"== "MSCHAPV2")
  28.                 $eap_prettyprint["INNER""MSCHAPv2";
  29.             if ($eap_prettyprint["OUTER"== "TLS")
  30.                 $eap_prettyprint["OUTER""EAP-TLS";
  31.             // define EAP properties
  32.             $eaparray array(
  33.                         "Outer" => $eap_prettyprint["OUTER"],
  34.                         "SaveCredentials" => true,
  35.                         "ServerCARefs" => $ca_refs// maybe takes just one CA?
  36.                         "UseSystemCAs" => false,
  37.                     );
  38. // according to the ONC spec, we should be allowed to set this, but it makes the import fail :-(
  39. //            if ($eap_prettyprint["OUTER"] != "EAP-TLS")
  40. //                $eaparray["Inner"] = $eap_prettyprint["INNER"];
  41.             if ($outer_id)
  42.                 $eaparray["AnonymousIdentity""$outer_id";
  43.             
  44.             $json_array["NetworkConfigurations"][array(
  45.                 "GUID" => $network_uuid,
  46.                 "Name" => "$ssid",
  47.                 "Type" => "WiFi",
  48.                 "WiFi" => array(
  49.                     "AutoConnect" => true,
  50.                     "EAP" => $eaparray,
  51.                     "HiddenSSID" => false,
  52.                     "SSID" => $ssid,
  53.                     "Security" => "WPA-EAP",
  54.                 ),
  55.                 "ProxySettings" => array("Type" => "WPAD"),
  56.             );
  57.         };
  58.         // are we also configuring wired?
  59.         if (isset($this->attributes['media:wired'])) {
  60.             $network_uuid "{" uuid($prefix"wired-dot1x-ethernet""}";
  61.             $json_array["NetworkConfigurations"][array(
  62.                 "GUID" => $network_uuid,
  63.                 "Name" => "eduroam configuration (wired network)",
  64.                 "Type" => "Ethernet",
  65.                 "Ethernet" => array(
  66.                     "Authentication" => "8021X",
  67.                     "EAP" => $eaparray,
  68.                 ),
  69.                 "ProxySettings" => array("Type" => "WPAD"),
  70.             );
  71.         };
  72.  
  73.         // define CA certificates
  74.         foreach ($this->attributes['internal:CAs'][0as $ca{
  75.             // strip -----BEGIN CERTIFICATE----- and -----END CERTIFICATE-----
  76.             $ca_sanitized substr($ca['pem']27strlen($ca['pem']27 25);
  77.             // remove \n
  78.             $ca_sanitized str_replace("\n"""$ca_sanitized);
  79.             $json_array["Certificates"][array("GUID" => "{" $ca['uuid'"}""Type" => "Authority""X509" => $ca_sanitized);
  80.         }
  81.                 
  82.         $output_json json_encode($json_arrayJSON_PRETTY_PRINT);
  83.         $xml_f fopen('installer_profile''w');
  84.         fwrite($xml_f$output_json);
  85.         fclose($xml_f);
  86.  
  87.         $e $this->installerBasename '.onc';
  88. //        if ($this->sign) {
  89. //            $o = system($this->sign . " installer_profile '$e' > /dev/null");
  90. //           if ($o === FALSE)
  91. //                debug(2, "Signing the mobileconfig installer $e FAILED!\n");
  92. //        } else
  93.         rename("installer_profile"$e);
  94.  
  95.         textdomain($dom);
  96.         return $e;
  97.     }


API Tags:
Return:  installer path name
Access:  public


Redefinition of:
DeviceConfig::writeInstaller()
placeholder for the main device method

[ Top ]

Documentation generated on Tue, 06 Oct 2015 06:11:16 +0000 by phpDocumentor 1.4.4