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

Class: Device_TestModule

Source Location: /devices/test_module/TestModule.php

Class Device_TestModule

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/test_module/TestModule.php [line 72]

DeviceConfig
   |
   --Device_TestModule
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_TestModule   __construct()   Constructs a Device object.
string   writeDeviceInfo()   prepare module desctiption and usage information
string   writeInstaller()   prepare a zip archive containing files and settings which normally would be used inside the module to produce an installer

[ Top ]
Methods
Constructor __construct  [line 84]

  Device_TestModule __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  EAP::listKnownEAPTypes();
  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 118]

  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 96]

  string writeInstaller( )

prepare a zip archive containing files and settings which normally would be used inside the module to produce an installer

  1. function writeInstaller({
  2. debug(4,"Test Module Installer start\n");
  3.    // create certificate files and save their names in $CA_files arrary
  4.      $CA_files $this->saveCertificateFiles('der');
  5.   
  6.     // copy a fixed file from the module Files directory
  7.        if($this->copyFile('Module.howto'))
  8.           debug(2"copying of Module.howto failed\n");
  9.  
  10.     // copy a fixed file from the module Files directory and saveunde a different name
  11.        if$this->copyFile('test_file','copied_test_file'))
  12.           debug(2"copying of Module.howto to copied_test_file failed\n");
  13.        $this->dumpAttibutes('profile_attributes');
  14.        $installer_path =  $this->zipInstaller($this->attributes);
  15.        return($installer_path);
  16.    }


API Tags:
Return:  installer path name
Access:  public


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

[ Top ]

Documentation generated on Thu, 16 Apr 2015 10:26:08 +0000 by phpDocumentor 1.4.4