Passed
Push — master ( 1f009a...96d9a7 )
by Stefan
17:52 queued 01:08
created

Devices   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 459
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 459
rs 10
wmc 1
lcom 0
cbo 0
1
<?php
2
/* 
3
 *******************************************************************************
4
 * Copyright 2011-2017 DANTE Ltd. and GÉANT on behalf of the GN3, GN3+, GN4-1 
5
 * and GN4-2 consortia
6
 *
7
 * License: see the web/copyright.php file in the file structure
8
 *******************************************************************************
9
 */
10
11
/**
12
 * This file contains the Devices class.
13
 *
14
 * @package ModuleWriting
15
 */
16
namespace devices;
17
/**
18
 * The Devices class holds a list of all devices the CAT knows about
19
 * 
20
 * @author Tomasz Wolniewicz <[email protected]>
21
 * 
22
 * @license see LICENSE file in root directory
23
 * 
24
 * @package ModuleWriting
25
 */
26
class Devices{
27
28
/**
29
 * This array lists available configuration options for local device management.
30
 * Values from this array will be taken as defaults.
31
 * Do not modify this array unless you really konw what you are doing.
32
 * Default values will be overriden by the settings of options inside
33
 * each device definition
34
 *
35
 * - 'sign' - if set to nonzero will cause installer signing if the module
36
 *         supports this. The default settings for Microsoft and Apple systems
37
 *         is 1, since without signing, installation makes liitle sense. Be aware
38
 *         that you need to set up signers and have proper certificates, if
39
 *         you do not want to do that and you are just testing CAT, then you can
40
 *         switch sign to 0, of course.
41
 * - 'no_cache' if defined and equal to 1 will block installer caching - useful
42
 *         for device development, should not be used in production
43
 * - 'hidden' if defined and equal to 1 will hide the device form listing - 
44
 *         useful for device development 
45
 * - 'redirect if defined and equal to 1 will only show the device on the listing
46
 *         if device redirect has been defined by the admin
47
 * - 'message' if defined will cause a display of the contents of this option as
48
 *         an additional warning
49
 *
50
 * - 'device_id' - used in building the installer filename; when this option
51
 *         is not defined, the filename will use the index from 
52
 *         the listDevices array; when defined and not empty, it will be 
53
 *         used in place of this index; when defined as empty will cause
54
 *         the omission of the device part the filename.
55
 *         The default is unset, so it is not listed in the Options array.
56
 * - 'mime' - used to set the MIME type of the installer file;
57
 *         if not set will default to the value provided by PHP finfo.
58
 *         The default is unset, so it is not listed in the Options array.
59
 */
60
61
public static $Options=[
62
  'sign'=>0,
63
  'no_cache'=>0,
64
  'hidden'=>0,
65
  'redirect'=>0,
66
];
67
68
/**
69
 * Each device is defined as a sub-array within this array
70
 *
71
 * Except for changing/adding things inside the options arrays, do not modify
72
 * this array unless you really know what you are doing.
73
 *
74
 * Beware that the entrance page of CAT contains a rolling ad which 
75
 * lists some devices, and also states that certain device modules are signed,
76
 * you should keep this information in sync with your settings in this file
77
 * See web/user/roll.php for settings and more information.
78
 *
79
 * Settings
80
 * - 'group' - caused device grouping used by the entrance screen
81
 * - 'display' is the name shown on the GUI button
82
 * - 'match' - a regular expression which will be matched against HTTP_USER_AGENT
83
 *             to discover the operating system of the user
84
 * - 'directory' is the subdirectory of devices directory, where
85
 *       the device module resides
86
 * - 'module' is the name of the module class, the same name with .php
87
 *       added will be used as the name of the main include file for the module
88
 * - 'signer' if defined points to a script which will sign a file. 
89
 *       The script must be located in the signer subdirectory of CAT.
90
 *       The first argument of this script must be the input file name, 
91
 *       the second - the signed file filename. Signer will not be used
92
 *       unless the sign option is set to nonzero.
93
 * - 'options' - the array of options overriding the default settings.
94
 *       See the descripption of options above.
95
 *
96
 * @example devices/devices-template.php file listing
97
 * @return array the device modules
98
 */
99
100
101
public static function listDevices() {
102
    return [
103
 'w10'=>[
104
   'group' => "microsoft",
105
   'display'=>_("MS Windows 10"),
106
   'match'=>'Windows NT 10',
107
   'directory'=>'ms',
108
   'module'=>'W10',
109
   'signer'=>'ms_windows_sign',
110
    'options'=>[
111
       'sign'=>1,
112
       'device_id'=>'W10',
113
       'mime'=>'application/x-dosexec',
114
      ],
115
   ],
116
	
117
 'w8'=>[
118
   'group' => "microsoft",
119
   'display'=>_("MS Windows 8, 8.1"),
120
   'match'=>'Windows NT 6[._][23]',
121
   'directory'=>'ms',
122
   'module'=>'W8',
123
   'signer'=>'ms_windows_sign',
124
    'options'=>[
125
       'sign'=>1,
126
       'device_id'=>'W8',
127
       'mime'=>'application/x-dosexec',
128
      ],
129
   ],
130
	
131
 'w7'=>[
132
   'group' => "microsoft",
133
   'display'=>_("MS Windows 7"),
134
   'match'=>'Windows NT 6[._]1',
135
   'directory'=>'ms',
136
   'module'=>'Vista7',
137
   'signer'=>'ms_windows_sign',
138
    'options'=>[
139
       'sign'=>1,
140
       'device_id'=>'W7',
141
       'mime'=>'application/x-dosexec',
142
      ],
143
   ],
144
	
145
 'vista'=>[
146
   'group' => "microsoft",
147
   'display'=>_("MS Windows Vista"),
148
   'match'=>'Windows NT 6[._]0',
149
   'directory'=>'ms',
150
   'module'=>'Vista7',
151
   'signer'=>'ms_windows_sign',
152
    'options'=>[
153
       'sign'=>1,
154
       'device_id'=>'Vista',
155
       'mime'=>'application/x-dosexec',
156
      ],
157
   ],
158
	
159
 'win-rt'=>[
160
    'group' => "microsoft",
161
    'display'=>_("Windows RT"),
162
    'directory'=>'redirect_dev',
163
    'module'=>'RedirectDev',
164
    'options'=>[
165
      'hidden'=>0,
166
      'redirect'=>1,
167
      ],
168
   ],
169
    
170
     
171
 'apple_hi_sierra'=>array(
172
    'group' => "apple",
173
    'display'=>_("Apple macOS High Sierra"),
174
    'match'=>'Mac OS X 10[._]13',
175
    'directory'=>'apple_mobileconfig',
176
    'module'=>'mobileconfig_os_x',
177
    'signer'=>'mobileconfig_sign',
178
    'options'=>array(
179
       'sign'=>1,
180
       'device_id'=>'OS_X',
181
       'mime'=>'application/x-apple-aspen-config',
182
      ),
183
    ),
184
	
185
   
186
 'apple_sierra'=>array(
187
    'group' => "apple",
188
    'display'=>_("Apple macOS Sierra"),
189
    'match'=>'Mac OS X 10[._]12',
190
    'directory'=>'apple_mobileconfig',
191
    'module'=>'mobileconfig_os_x',
192
    'signer'=>'mobileconfig_sign',
193
    'options'=>array(
194
       'sign'=>1,
195
       'device_id'=>'OS_X',
196
       'mime'=>'application/x-apple-aspen-config',
197
      ),
198
    ),
199
	
200
201
 'apple_el_cap'=>[
202
    'group' => "apple",
203
    'display'=>_("Apple OS X El Capitan"),
204
    'match'=>'Mac OS X 10[._]11',
205
    'directory'=>'apple_mobileconfig',
206
    'module'=>'mobileconfig_os_x',
207
    'signer'=>'mobileconfig_sign',
208
    'options'=>array(
209
       'sign'=>1,
210
       'device_id'=>'OS_X',
211
       'mime'=>'application/x-apple-aspen-config',
212
      ),
213
    ],
214
215
 'apple_yos'=>[
216
    'group' => "apple",
217
    'display'=>_("Apple OS X Yosemite"),
218
    'match'=>'Mac OS X 10[._]10',
219
    'directory'=>'apple_mobileconfig',
220
    'module'=>'mobileconfig_os_x',
221
    'signer'=>'mobileconfig_sign',
222
    'options'=>[
223
       'sign'=>1,
224
       'device_id'=>'OS_X',
225
       'mime'=>'application/x-apple-aspen-config',
226
      ],
227
    ],
228
229
 'apple_mav'=>[
230
    'group' => "apple",
231
    'display'=>_("Apple OS X Mavericks"),
232
    'match'=>'Mac OS X 10[._]9',
233
    'directory'=>'apple_mobileconfig',
234
    'module'=>'mobileconfig_os_x',
235
    'signer'=>'mobileconfig_sign',
236
    'options'=>[
237
       'sign'=>1,
238
       'device_id'=>'OS_X',
239
       'mime'=>'application/x-apple-aspen-config',
240
      ],
241
    ],
242
243
 'apple_m_lion'=>[
244
    'group' => "apple",
245
    'display'=>_("Apple OS X Mountain Lion"),
246
    'match'=>'Mac OS X 10[._]8',
247
    'directory'=>'apple_mobileconfig',
248
    'module'=>'mobileconfig_os_x',
249
    'signer'=>'mobileconfig_sign',
250
    'options'=>[
251
       'sign'=>1,
252
       'device_id'=>'OS_X',
253
       'mime'=>'application/x-apple-aspen-config',
254
      ],
255
    ],
256
	
257
 'apple_lion'=>[
258
    'group' => "apple",
259
    'display'=>_("Apple OS X Lion"),
260
    'match'=>'Mac OS X 10[._]7',
261
    'directory'=>'apple_mobileconfig',
262
    'module'=>'mobileconfig_os_x',
263
    'signer'=>'mobileconfig_sign',
264
    'options'=>[
265
       'sign'=>1,
266
       'device_id'=>'OS_X',
267
       'mime'=>'application/x-apple-aspen-config',
268
      ],
269
    ],
270
        
271
 'mobileconfig'=>[
272
    'group' => "apple",     
273
    'display'=>_("Apple iOS mobile devices"),
274
    'match'=>'(iPad|iPhone|iPod);.*OS ([7-9]|1[0-5])_',
275
    'directory'=>'apple_mobileconfig',
276
    'module'=>'mobileconfig_ios',
277
    'signer'=>'mobileconfig_sign',
278
    'options'=>[
279
       'sign'=>1,
280
       'device_id'=>'iOS',
281
       'mime'=>'application/x-apple-aspen-config',
282
      ],
283
    ],
284
285
 'mobileconfig-56'=>[
286
    'group' => "apple",
287
    'display'=>_("Apple iOS mobile devices (iOS 5 and 6)"),
288
    'match'=>'(iPad|iPhone|iPod);.*OS [56]_',
289
    'directory'=>'apple_mobileconfig',
290
    'module'=>'mobileconfig_ios_56',
291
    'signer'=>'mobileconfig_sign',
292
    'options'=>[
293
       'sign'=>1,
294
       'device_id'=>'iOS',
295
       'mime'=>'application/x-apple-aspen-config',
296
      ],
297
    ],
298
299
        
300
 'linux'=>[
301
     'group' => "linux",
302
     'display'=>_("Linux"),
303
     'match'=>'Linux(?!.*Android)',
304
     'directory'=>'linux',
305
     'module' => 'Linux',
306
     'options'=>[
307
       'mime'=>'application/x-sh',
308
      ],
309
   ],
310
311
 'chromeos'=>[
312
    'group' => "chrome",
313
    'display'=>_("Chrome OS"),
314
    'match'=>'CrOS',
315
    'directory'=>'chromebook',
316
    'module'=>'chromebook',
317
    'options'=>[
318
       'mime'=>'application/x-onc',
319
       'message'=>sprintf(_("After downloading the file, open the Chrome browser and browse to this URL: <a href='chrome://net-internals/#chromeos'>chrome://net-internals/#chromeos</a>. Then, use the 'Import ONC file' button. The import is silent; the new network definitions will be added to the preferred networks.")),
320
      ],
321
   ],
322
        
323
 'android_marshmallow'=>[
324
    'group' => "android",
325
    'display'=>_("Android 6.0 Marshmallow"),
326
     'match'=>'Android 6\.[0-9]',
327
    'directory'=>'xml',
328
    'module'=>'Lollipop',
329
    'options'=>[
330
       'mime'=>'application/eap-config',
331
       'message'=>sprintf(_("Before you proceed with installation on Android systems, please make sure that you have installed the %s application. This application is available from %s, %s and %s, and will use the configuration file downloaded from CAT to create all necessary settings."),
332
                            "eduroamCAT",
333
                            "<a target='_blank' href='https://play.google.com/store/apps/details?id=uk.ac.swansea.eduroamcat'>Google Play</a>",
334
                            "<a target='_blank' href='unbeknownst'>Amazon Appstore</a>",
335
                            "<a target='_blank' href='eduroamCAT-stable.apk'>"._("as local download")."</a>"),
336
      ],
337
   ],
338
339
 'android_lollipop'=>[
340
    'group' => "android",
341
    'display'=>_("Android 5.0 Lollipop"),
342
     'match'=>'Android 5\.[0-9]',
343
    'directory'=>'xml',
344
    'module'=>'Lollipop',
345
    'options'=>[
346
       'mime'=>'application/eap-config',
347
       'message'=>sprintf(_("Before you proceed with installation on Android systems, please make sure that you have installed the %s application. This application is available from %s, %s and %s, and will use the configuration file downloaded from CAT to create all necessary settings."),
348
                            "eduroamCAT",
349
                            "<a target='_blank' href='https://play.google.com/store/apps/details?id=uk.ac.swansea.eduroamcat'>Google Play</a>",
350
                            "<a target='_blank' href='unbeknownst'>Amazon Appstore</a>",
351
                            "<a target='_blank' href='eduroamCAT-stable.apk'>"._("as local download")."</a>"),
352
      ],
353
   ],
354
355
 'android_kitkat'=>[
356
    'group' => "android",
357
    'display'=>_("Android 4.4 KitKat"),
358
     'match'=>'Android 4\.[4-9]',
359
    'directory'=>'xml',
360
    'module'=>'KitKat',
361
    'options'=>[
362
       'mime'=>'application/eap-config',
363
       'message'=>sprintf(_("Before you proceed with installation on Android systems, please make sure that you have installed the %s application. This application is available from %s, %s and %s, and will use the configuration file downloaded from CAT to create all necessary settings."),
364
                            "eduroamCAT",
365
                            "<a target='_blank' href='https://play.google.com/store/apps/details?id=uk.ac.swansea.eduroamcat'>Google Play</a>",
366
                            "<a target='_blank' href='unbeknownst'>Amazon Appstore</a>",
367
                            "<a target='_blank' href='eduroamCAT-stable.apk'>"._("as local download")."</a>"),
368
      ],
369
   ],
370
371
372
 'android_43'=>[
373
    'group' => "android",
374
    'display'=>_("Android 4.3"),
375
     'match'=>'Android 4\.3',
376
    'directory'=>'xml',
377
    'module'=>'KitKat',
378
    'options'=>[
379
       'mime'=>'application/eap-config',
380
       'message'=>sprintf(_("Before you proceed with installation on Android systems, please make sure that you have installed the %s application. This application is available from %s, %s and %s, and will use the configuration file downloaded from CAT to create all necessary settings."),
381
                            "eduroamCAT",
382
                            "<a target='_blank' href='https://play.google.com/store/apps/details?id=uk.ac.swansea.eduroamcat'>Google Play</a>",
383
                            "<a target='_blank' href='unbeknownst'>Amazon Appstore</a>",
384
                            "<a target='_blank' href='eduroamCAT-stable.apk'>"._("as local download")."</a>"),
385
      ],
386
   ],
387
388
 'android_legacy'=>[
389
     'group' => "android",
390
     'display'=>_("Android"),
391
     'match'=>'Android',
392
     'directory'=>'redirect_dev',
393
     'module'=>'RedirectDev',
394
     'options'=>[
395
       'redirect'=>1,
396
      ],
397
   ],
398
399
 'eap-config'=>[
400
    'group' => "eap-config",
401
    'display'=>_("EAP config"),
402
    'directory'=>'xml',
403
    'module'=>'XML_ALL',
404
    'options'=>[
405
       'mime'=>'application/eap-config',
406
       'message'=>sprintf(_("This option provides a generic EAP config XML file, which can be consumed by dedicated applications like eduroamCAT for Android and Linux platforms. This is still an experimental feature.")),
407
      ],
408
    ],
409
410
 'test'=>[
411
    'group' => "other",
412
    'display'=>_("Test"),
413
    'directory'=>'test_module',
414
    'module'=>'TestModule',
415
    'options'=>[
416
       'hidden'=>1,
417
      ],
418
   ],
419
420
421
/*    
422
    
423
 'xml-ttls-pap'=>array(
424
    'group' => "generic",
425
    'display'=>_("Generic profile TTLS-PAP"),
426
    'directory'=>'xml',
427
    'module'=>'XML_TTLS_PAP',
428
    'options'=>array(
429
       'mime'=>'application/eap-config',
430
      ),
431
   ),
432
    
433
 'xml-ttls-mschap2'=>array(
434
    'group' => "generic",
435
    'display'=>_("Generic profile TTLS-MSCHAPv2"),
436
    'directory'=>'xml',
437
    'module'=>'XML_TTLS_MSCHAP2',
438
    'options'=>array(
439
       'mime'=>'application/eap-config',
440
      ),
441
   ),
442
    
443
 'xml-peap'=>array(
444
    'group' => "generic",
445
    'display'=>_("Generic profile PEAP"),
446
    'directory'=>'xml',
447
    'module'=>'XML_PEAP',
448
    'options'=>array(
449
       'mime'=>'application/eap-config',
450
      ),
451
   ),
452
    
453
 'xml-tls'=>array(
454
    'group' => "generic",
455
    'display'=>_("Generic profile TLS"),
456
    'directory'=>'xml',
457
    'module'=>'XML_TLS',
458
    'options'=>array(
459
       'mime'=>'application/eap-config',
460
      ),
461
   ),
462
    
463
 'xml-pwd'=>array(
464
    'group' => "generic",
465
    'display'=>_("Generic profile PWD"),
466
    'directory'=>'xml',
467
    'module'=>'XML_PWD',
468
    'options'=>array(
469
       'mime'=>'application/eap-config',
470
      ),
471
   ),
472
 'xml-all'=>array(
473
    'group' => "generic",
474
    'display'=>_("Generic profile ALL EAPs"),
475
    'directory'=>'xml',
476
    'module'=>'XML_ALL',
477
    'options'=>array(
478
       'mime'=>'application/eap-config',
479
      ),
480
   ),
481
*/
482
];
483
}
484
}
485