@@ -5,16 +5,16 @@ |
||
5 | 5 | |
6 | 6 | class Device_XML_ALL extends Device_XML{ |
7 | 7 | final public function __construct() { |
8 | - $this->supportedEapMethods = |
|
8 | + $this->supportedEapMethods = |
|
9 | 9 | [ |
10 | - EAP::$PEAP_MSCHAP2, |
|
11 | - EAP::$TTLS_PAP, |
|
12 | - EAP::$TTLS_MSCHAP2, |
|
13 | - EAP::$TLS, |
|
14 | - EAP::$PWD, |
|
15 | - ]; |
|
16 | - $this->lang_scope = 'single'; |
|
17 | - $this->all_eaps = TRUE; |
|
10 | + EAP::$PEAP_MSCHAP2, |
|
11 | + EAP::$TTLS_PAP, |
|
12 | + EAP::$TTLS_MSCHAP2, |
|
13 | + EAP::$TLS, |
|
14 | + EAP::$PWD, |
|
15 | + ]; |
|
16 | + $this->lang_scope = 'single'; |
|
17 | + $this->all_eaps = TRUE; |
|
18 | 18 | } |
19 | 19 | } |
20 | 20 |
@@ -5,14 +5,14 @@ |
||
5 | 5 | |
6 | 6 | class Device_KitKat extends Device_XML{ |
7 | 7 | final public function __construct() { |
8 | - $this->supportedEapMethods = |
|
8 | + $this->supportedEapMethods = |
|
9 | 9 | [ |
10 | - EAP::$PEAP_MSCHAP2, |
|
11 | - EAP::$TTLS_PAP, |
|
12 | - EAP::$TTLS_MSCHAP2, |
|
13 | - ]; |
|
14 | - $this->lang_scope = 'single'; |
|
15 | - $this->all_eaps = TRUE; |
|
10 | + EAP::$PEAP_MSCHAP2, |
|
11 | + EAP::$TTLS_PAP, |
|
12 | + EAP::$TTLS_MSCHAP2, |
|
13 | + ]; |
|
14 | + $this->lang_scope = 'single'; |
|
15 | + $this->all_eaps = TRUE; |
|
16 | 16 | } |
17 | 17 | } |
18 | 18 |
@@ -5,11 +5,11 @@ |
||
5 | 5 | |
6 | 6 | class Device_XML_TLS extends Device_XML { |
7 | 7 | final public function __construct() { |
8 | - $this->supportedEapMethods = |
|
8 | + $this->supportedEapMethods = |
|
9 | 9 | [ |
10 | - EAP::$TLS, |
|
11 | - ]; |
|
12 | - $this->lang_scope = 'single'; |
|
10 | + EAP::$TLS, |
|
11 | + ]; |
|
12 | + $this->lang_scope = 'single'; |
|
13 | 13 | } |
14 | 14 | } |
15 | 15 |
@@ -20,100 +20,100 @@ discard block |
||
20 | 20 | * base class extended by every element |
21 | 21 | */ |
22 | 22 | class XMLElement { |
23 | - private $attributes; |
|
24 | - private $value; |
|
23 | + private $attributes; |
|
24 | + private $value; |
|
25 | 25 | |
26 | - protected function getObjectVars($obj) { |
|
27 | - return get_object_vars($obj); |
|
28 | - } |
|
26 | + protected function getObjectVars($obj) { |
|
27 | + return get_object_vars($obj); |
|
28 | + } |
|
29 | 29 | /** |
30 | - * @var array $AuthMethodElements is used to limit |
|
31 | - * XML elements present within ServerSideCredentials and |
|
32 | - * ClientSideCredentials to ones which are relevant |
|
33 | - * for a given EAP method. |
|
34 | - * @var array of XLM element names which are allowed |
|
35 | - * EAP method names are defined in core/EAP.php |
|
36 | - */ |
|
37 | - public static $AuthMethodElements = [ |
|
38 | - 'server' => [ |
|
30 | + * @var array $AuthMethodElements is used to limit |
|
31 | + * XML elements present within ServerSideCredentials and |
|
32 | + * ClientSideCredentials to ones which are relevant |
|
33 | + * for a given EAP method. |
|
34 | + * @var array of XLM element names which are allowed |
|
35 | + * EAP method names are defined in core/EAP.php |
|
36 | + */ |
|
37 | + public static $AuthMethodElements = [ |
|
38 | + 'server' => [ |
|
39 | 39 | TLS => ['CA', 'ServerID'], |
40 | 40 | FAST => ['CA','ServerID'], |
41 | 41 | PEAP => ['CA','ServerID'], |
42 | 42 | TTLS => ['CA','ServerID'], |
43 | 43 | PWD => [], |
44 | - ], |
|
45 | - 'client' => [ |
|
46 | - TLS => ['UserName','Password','ClientCertificate'], |
|
47 | - MSCHAP2 => ['UserName','Password','OuterIdentity'], |
|
48 | - GTC => ['UserName','OneTimeToken'], |
|
49 | - NE_PAP => ['UserName','Password','OuterIdentity'], |
|
50 | - ] |
|
51 | - ]; |
|
44 | + ], |
|
45 | + 'client' => [ |
|
46 | + TLS => ['UserName','Password','ClientCertificate'], |
|
47 | + MSCHAP2 => ['UserName','Password','OuterIdentity'], |
|
48 | + GTC => ['UserName','OneTimeToken'], |
|
49 | + NE_PAP => ['UserName','Password','OuterIdentity'], |
|
50 | + ] |
|
51 | + ]; |
|
52 | 52 | |
53 | - public function __construct() { |
|
53 | + public function __construct() { |
|
54 | 54 | $this->attributes = []; |
55 | 55 | $this->value = []; |
56 | - } |
|
57 | - public function setAttributes($attributes) { |
|
56 | + } |
|
57 | + public function setAttributes($attributes) { |
|
58 | 58 | $this->attributes = $attributes; |
59 | - } |
|
60 | - public function getAttributes() { |
|
59 | + } |
|
60 | + public function getAttributes() { |
|
61 | 61 | return $this->attributes; |
62 | - } |
|
63 | - public function setValue($value) { |
|
62 | + } |
|
63 | + public function setValue($value) { |
|
64 | 64 | $this->value = $value; |
65 | - } |
|
66 | - public function getValue() { |
|
65 | + } |
|
66 | + public function getValue() { |
|
67 | 67 | return $this->value; |
68 | - } |
|
69 | - public function areAttributes() { |
|
68 | + } |
|
69 | + public function areAttributes() { |
|
70 | 70 | return empty($this->attributes)?0:1; |
71 | - } |
|
72 | - public function setAttribute($attribute,$value) { |
|
71 | + } |
|
72 | + public function setAttribute($attribute,$value) { |
|
73 | 73 | if( ! isset($this->attributes)) |
74 | - $this->attributes = []; |
|
74 | + $this->attributes = []; |
|
75 | 75 | $this->attributes[$attribute] = $value; |
76 | - } |
|
77 | - public function setProperty($property,$value) { |
|
76 | + } |
|
77 | + public function setProperty($property,$value) { |
|
78 | 78 | $this->$property = $value; |
79 | - } |
|
80 | - public function getAll() { |
|
79 | + } |
|
80 | + public function getAll() { |
|
81 | 81 | $elems = get_object_vars($this); |
82 | 82 | $objvars = []; |
83 | 83 | foreach ($elems as $key=>$val) |
84 | - if ( ($key!='attributes') && ($key!='value') ) |
|
84 | + if ( ($key!='attributes') && ($key!='value') ) |
|
85 | 85 | $objvars[$key] = $val; |
86 | 86 | return $objvars; |
87 | - } |
|
87 | + } |
|
88 | 88 | } |
89 | 89 | class EAPIdentityProvider extends XMLElement { |
90 | - protected $ValidUntil; |
|
91 | - protected $AuthenticationMethods; |
|
92 | - protected $ProviderInfo; |
|
93 | - protected $VendorSpecific; |
|
90 | + protected $ValidUntil; |
|
91 | + protected $AuthenticationMethods; |
|
92 | + protected $ProviderInfo; |
|
93 | + protected $VendorSpecific; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | class AuthenticationMethods extends XMLElement { |
97 | - protected $AuthenticationMethod; |
|
97 | + protected $AuthenticationMethod; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | class AuthenticationMethod extends XMLElement { |
101 | - protected $EAPMethod; |
|
102 | - protected $ServerSideCredential; |
|
103 | - protected $ClientSideCredential; |
|
104 | - protected $InnerAuthenticationMethod; |
|
101 | + protected $EAPMethod; |
|
102 | + protected $ServerSideCredential; |
|
103 | + protected $ClientSideCredential; |
|
104 | + protected $InnerAuthenticationMethod; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | class EAPMethod extends XMLElement { |
108 | - protected $Type; |
|
109 | - protected $TypeSpecific; |
|
110 | - protected $VendorSpecific; |
|
108 | + protected $Type; |
|
109 | + protected $TypeSpecific; |
|
110 | + protected $VendorSpecific; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | class NonEAPAuthMethod extends XMLElement { |
114 | - protected $Type; |
|
115 | - protected $TypeSpecific; |
|
116 | - protected $VendorSpecific; |
|
114 | + protected $Type; |
|
115 | + protected $TypeSpecific; |
|
116 | + protected $VendorSpecific; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | class Type extends XMLElement { |
@@ -126,34 +126,34 @@ discard block |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | class ServerSideCredential extends XMLElement { |
129 | - protected $CA; // multi |
|
130 | - protected $ServerID; //multi |
|
131 | - public function getAll() { |
|
129 | + protected $CA; // multi |
|
130 | + protected $ServerID; //multi |
|
131 | + public function getAll() { |
|
132 | 132 | if(isset(XMLElement::$AuthMethodElements['server'][$this->EAPType]) && XMLElement::$AuthMethodElements['server'][$this->EAPType]) { |
133 | 133 | $E = XMLElement::$AuthMethodElements['server'][$this->EAPType]; |
134 | 134 | $out = get_object_vars($this); |
135 | 135 | $OUT = []; |
136 | 136 | foreach ($out as $o => $v) { |
137 | - if(in_array($o, $E)) |
|
138 | - $OUT[$o] = $v; |
|
137 | + if(in_array($o, $E)) |
|
138 | + $OUT[$o] = $v; |
|
139 | 139 | } |
140 | 140 | return($OUT); |
141 | - } |
|
142 | - } |
|
141 | + } |
|
142 | + } |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | class ServerID extends XMLElement { |
146 | 146 | } |
147 | 147 | |
148 | 148 | class ClientSideCredential extends XMLElement { |
149 | - protected $OuterIdentity; |
|
150 | - protected $UserName; |
|
151 | - protected $Password; |
|
152 | - protected $ClientCertificate; |
|
153 | - protected $Passphrase; |
|
154 | - protected $PAC; |
|
155 | - protected $ProvisionPAC; |
|
156 | - public function getAll() { |
|
149 | + protected $OuterIdentity; |
|
150 | + protected $UserName; |
|
151 | + protected $Password; |
|
152 | + protected $ClientCertificate; |
|
153 | + protected $Passphrase; |
|
154 | + protected $PAC; |
|
155 | + protected $ProvisionPAC; |
|
156 | + public function getAll() { |
|
157 | 157 | if(isset(XMLElement::$AuthMethodElements['client'][$this->EAPType]) && XMLElement::$AuthMethodElements['client'][$this->EAPType]) { |
158 | 158 | $E = XMLElement::$AuthMethodElements['client'][$this->EAPType]; |
159 | 159 | $out = get_object_vars($this); |
@@ -161,31 +161,31 @@ discard block |
||
161 | 161 | debug(4,"EEE:".$this->EAPType.":\n"); |
162 | 162 | debug(4,$E); |
163 | 163 | foreach ($out as $o => $v) { |
164 | - if(in_array($o, $E)) |
|
165 | - $OUT[$o] = $v; |
|
164 | + if(in_array($o, $E)) |
|
165 | + $OUT[$o] = $v; |
|
166 | 166 | } |
167 | 167 | return($OUT); |
168 | 168 | } |
169 | - } |
|
169 | + } |
|
170 | 170 | } |
171 | 171 | class ClientCertificate extends XMLElement { |
172 | 172 | } |
173 | 173 | class CA extends XMLElement { |
174 | 174 | } |
175 | 175 | class InnerAuthenticationMethod extends XMLElement { |
176 | - protected $EAPMethod; |
|
177 | - protected $NonEAPAuthMethod; |
|
178 | - protected $ServerSideCredential; |
|
179 | - protected $ClientSideCredential; |
|
176 | + protected $EAPMethod; |
|
177 | + protected $NonEAPAuthMethod; |
|
178 | + protected $ServerSideCredential; |
|
179 | + protected $ClientSideCredential; |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | class ProviderInfo extends XMLElement { |
183 | - protected $DisplayName; |
|
184 | - protected $Description; |
|
185 | - protected $ProviderLocation; |
|
186 | - protected $ProviderLogo; |
|
187 | - protected $TermsOfUse; |
|
188 | - protected $Helpdesk; |
|
183 | + protected $DisplayName; |
|
184 | + protected $Description; |
|
185 | + protected $ProviderLocation; |
|
186 | + protected $ProviderLogo; |
|
187 | + protected $TermsOfUse; |
|
188 | + protected $Helpdesk; |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | class DisplayName extends XMLElement { |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | } |
196 | 196 | |
197 | 197 | class ProviderLocation extends XMLElement { |
198 | - protected $Longitude; |
|
199 | - protected $Latitude; |
|
198 | + protected $Longitude; |
|
199 | + protected $Latitude; |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | class ProviderLogo extends XMLElement { |
@@ -206,9 +206,9 @@ discard block |
||
206 | 206 | } |
207 | 207 | |
208 | 208 | class Helpdesk extends XMLElement { |
209 | - protected $EmailAddress; |
|
210 | - protected $WebAddress; |
|
211 | - protected $Phone; |
|
209 | + protected $EmailAddress; |
|
210 | + protected $WebAddress; |
|
211 | + protected $Phone; |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | class EmailAddress extends XMLElement { |
@@ -242,61 +242,61 @@ discard block |
||
242 | 242 | |
243 | 243 | */ |
244 | 244 | function SimpleXMLElement_append($key, $value) { |
245 | - if (trim((string) $value) == '') { |
|
245 | + if (trim((string) $value) == '') { |
|
246 | 246 | $element = $key->addChild($value->getName()); |
247 | 247 | foreach ($value->attributes() as $attKey => $attValue) { |
248 | - $element->addAttribute($attKey, $attValue); |
|
248 | + $element->addAttribute($attKey, $attValue); |
|
249 | 249 | } |
250 | 250 | foreach ($value->children() as $child) { |
251 | - SimpleXMLElement_append($element, $child); |
|
251 | + SimpleXMLElement_append($element, $child); |
|
252 | 252 | } |
253 | - } else { |
|
253 | + } else { |
|
254 | 254 | $element = $key->addChild($value->getName(), trim((string) $value)); |
255 | - } |
|
255 | + } |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | function marshalObject($node, $object) { |
259 | 259 | |
260 | - $name = get_class($object); |
|
261 | - $name = preg_replace("/_/", "-", $name); |
|
262 | - if ($object->getValue()) $val = $object->getValue(); |
|
263 | - else $val = ''; |
|
264 | - $simplexmlelement = ''; |
|
265 | - if ($val instanceof SimpleXMLElement) { |
|
260 | + $name = get_class($object); |
|
261 | + $name = preg_replace("/_/", "-", $name); |
|
262 | + if ($object->getValue()) $val = $object->getValue(); |
|
263 | + else $val = ''; |
|
264 | + $simplexmlelement = ''; |
|
265 | + if ($val instanceof SimpleXMLElement) { |
|
266 | 266 | $simplexmlelement = $val; |
267 | 267 | $val = ''; |
268 | - } |
|
269 | - if ($val) { |
|
268 | + } |
|
269 | + if ($val) { |
|
270 | 270 | if(getType($val) == 'string') |
271 | - $val = preg_replace('/&/','&',$val); |
|
271 | + $val = preg_replace('/&/','&',$val); |
|
272 | 272 | $node = $node->addChild($name, $val); |
273 | - } |
|
274 | - else |
|
273 | + } |
|
274 | + else |
|
275 | 275 | $node = $node->addChild($name); |
276 | - if ($object->areAttributes()) { |
|
276 | + if ($object->areAttributes()) { |
|
277 | 277 | $attrs = $object->getAttributes(); |
278 | 278 | foreach ($attrs as $attrt=>$attrv) |
279 | - $node->addAttribute($attrt, $attrv); |
|
280 | - } |
|
281 | - if ($simplexmlelement == '') { |
|
279 | + $node->addAttribute($attrt, $attrv); |
|
280 | + } |
|
281 | + if ($simplexmlelement == '') { |
|
282 | 282 | $fields = $object->getAll(); |
283 | 283 | if (!empty($fields)) { |
284 | - foreach ($fields as $name=>$value) { |
|
284 | + foreach ($fields as $name=>$value) { |
|
285 | 285 | if (getType($value)=='string' || getType($value)=='integer' || getType($value)=='double') { |
286 | - $node->addChild($name, $value); |
|
286 | + $node->addChild($name, $value); |
|
287 | 287 | } else { |
288 | - if (getType($value)=='array') { |
|
288 | + if (getType($value)=='array') { |
|
289 | 289 | foreach ($value as $v) |
290 | - if (is_object($v)) |
|
290 | + if (is_object($v)) |
|
291 | 291 | marshalObject($node, $v); |
292 | - } else if (getType($value)=='object') { |
|
292 | + } else if (getType($value)=='object') { |
|
293 | 293 | marshalObject($node, $value); |
294 | - } |
|
294 | + } |
|
295 | + } |
|
295 | 296 | } |
296 | - } |
|
297 | 297 | } |
298 | - } else { |
|
298 | + } else { |
|
299 | 299 | SimpleXMLElement_append($node, $simplexmlelement); |
300 | - } |
|
300 | + } |
|
301 | 301 | } |
302 | 302 |
@@ -5,11 +5,11 @@ |
||
5 | 5 | |
6 | 6 | class Device_XML_PEAP extends Device_XML { |
7 | 7 | final public function __construct() { |
8 | - $this->supportedEapMethods = |
|
8 | + $this->supportedEapMethods = |
|
9 | 9 | [ |
10 | - EAP::$PEAP_MSCHAP2, |
|
11 | - ]; |
|
12 | - $this->lang_scope = 'single'; |
|
10 | + EAP::$PEAP_MSCHAP2, |
|
11 | + ]; |
|
12 | + $this->lang_scope = 'single'; |
|
13 | 13 | } |
14 | 14 | } |
15 | 15 |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | require_once('XML.inc.php'); |
23 | 23 | |
24 | 24 | /** |
25 | - * This class implements full functionality of the generic XML device |
|
26 | - * the only fuction of the extenstions of this class is to specify |
|
27 | - * supported EAP methods. |
|
28 | - * Instead of specifying supported EAPS an extension can set $all_eaps to true |
|
29 | - * this will cause the installer to configure all EAP methods supported by |
|
30 | - * the current profile and declared by the given device. |
|
31 | - */ |
|
25 | + * This class implements full functionality of the generic XML device |
|
26 | + * the only fuction of the extenstions of this class is to specify |
|
27 | + * supported EAP methods. |
|
28 | + * Instead of specifying supported EAPS an extension can set $all_eaps to true |
|
29 | + * this will cause the installer to configure all EAP methods supported by |
|
30 | + * the current profile and declared by the given device. |
|
31 | + */ |
|
32 | 32 | abstract class Device_XML extends DeviceConfig { |
33 | 33 | |
34 | 34 | /** |
@@ -62,29 +62,29 @@ discard block |
||
62 | 62 | //lang attribute |
63 | 63 | $authmethods = []; |
64 | 64 | if($this->all_eaps) { |
65 | - $EAPs = []; |
|
66 | - foreach ($attr['all_eaps'] as $eap) { |
|
67 | - if(in_array($eap, $this->supportedEapMethods)) |
|
65 | + $EAPs = []; |
|
66 | + foreach ($attr['all_eaps'] as $eap) { |
|
67 | + if(in_array($eap, $this->supportedEapMethods)) |
|
68 | 68 | $EAPs[] = $eap; |
69 | - } |
|
69 | + } |
|
70 | 70 | } else |
71 | - $EAPs = [ $this->selected_eap]; |
|
71 | + $EAPs = [ $this->selected_eap]; |
|
72 | 72 | |
73 | 73 | foreach ($EAPs as $eap) { |
74 | - $authmethods[] = $this->getAuthMethod($eap); |
|
74 | + $authmethods[] = $this->getAuthMethod($eap); |
|
75 | 75 | } |
76 | 76 | $authenticationmethods = new AuthenticationMethods(); |
77 | 77 | $authenticationmethods->setProperty('AuthenticationMethods',$authmethods); |
78 | 78 | $eap_idp->setProperty('AuthenticationMethods',$authenticationmethods); |
79 | 79 | if(empty($attr['internal:realm'][0])) { |
80 | - $eap_idp->setAttribute('ID','undefined'); |
|
81 | - $eap_idp->setAttribute('namespace','urn:undefined'); |
|
80 | + $eap_idp->setAttribute('ID','undefined'); |
|
81 | + $eap_idp->setAttribute('namespace','urn:undefined'); |
|
82 | 82 | } else { |
83 | - $eap_idp->setAttribute('ID',$attr['internal:realm'][0]); |
|
84 | - $eap_idp->setAttribute('namespace',$NAMESPACE); |
|
83 | + $eap_idp->setAttribute('ID',$attr['internal:realm'][0]); |
|
84 | + $eap_idp->setAttribute('namespace',$NAMESPACE); |
|
85 | 85 | } |
86 | 86 | if($this->lang_scope === 'single') |
87 | - $eap_idp->setAttribute('lang',$this->lang_index); |
|
87 | + $eap_idp->setAttribute('lang',$this->lang_index); |
|
88 | 88 | $eap_idp->setAttribute('version','1'); |
89 | 89 | |
90 | 90 | |
@@ -105,235 +105,235 @@ discard block |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | private $AttributeNames = [ |
108 | - 'support:email' => 'EmailAddress', |
|
109 | - 'support:url' => 'WebAddress', |
|
110 | - 'support:phone' => 'Phone', |
|
111 | - 'profile:description' => 'Description', |
|
112 | - 'support:info_file' => 'TermsOfUse', |
|
113 | - 'general:logo_file' => 'ProviderLogo', |
|
108 | + 'support:email' => 'EmailAddress', |
|
109 | + 'support:url' => 'WebAddress', |
|
110 | + 'support:phone' => 'Phone', |
|
111 | + 'profile:description' => 'Description', |
|
112 | + 'support:info_file' => 'TermsOfUse', |
|
113 | + 'general:logo_file' => 'ProviderLogo', |
|
114 | 114 | ]; |
115 | 115 | |
116 | 116 | private function getSimpleAttribute($attr_name) { |
117 | - if(isset($this->attributes[$attr_name][0]) && $this->attributes[$attr_name][0]) { |
|
118 | - $a = $this->attributes[$attr_name]; |
|
119 | - if(! isset($this->AttributeNames[$attr_name])) { |
|
120 | - debug(4,"Missing class definition for $attr_name\n"); |
|
121 | - return; |
|
122 | - } |
|
123 | - $class_name = $this->AttributeNames[$attr_name]; |
|
124 | - $obj = new $class_name(); |
|
125 | - $obj->setValue($a[0]); |
|
126 | - return($obj); |
|
127 | - } else |
|
128 | - return ''; |
|
117 | + if(isset($this->attributes[$attr_name][0]) && $this->attributes[$attr_name][0]) { |
|
118 | + $a = $this->attributes[$attr_name]; |
|
119 | + if(! isset($this->AttributeNames[$attr_name])) { |
|
120 | + debug(4,"Missing class definition for $attr_name\n"); |
|
121 | + return; |
|
122 | + } |
|
123 | + $class_name = $this->AttributeNames[$attr_name]; |
|
124 | + $obj = new $class_name(); |
|
125 | + $obj->setValue($a[0]); |
|
126 | + return($obj); |
|
127 | + } else |
|
128 | + return ''; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
132 | 132 | private function getSimpleMLAttribute($attr_name) { |
133 | - if(isset($this->attributes[$attr_name][0]) && $this->attributes[$attr_name][0]) { |
|
134 | - $a = $this->attributes[$attr_name]; |
|
135 | - if(! isset($this->AttributeNames[$attr_name])) { |
|
136 | - debug(4,"Missing class definition for $attr_name\n"); |
|
137 | - return; |
|
138 | - } |
|
139 | - $class_name = $this->AttributeNames[$attr_name]; |
|
140 | - $objs = []; |
|
141 | - if($this->lang_scope === 'global') { |
|
142 | - foreach( $a['langs'] as $l => $v ) { |
|
133 | + if(isset($this->attributes[$attr_name][0]) && $this->attributes[$attr_name][0]) { |
|
134 | + $a = $this->attributes[$attr_name]; |
|
135 | + if(! isset($this->AttributeNames[$attr_name])) { |
|
136 | + debug(4,"Missing class definition for $attr_name\n"); |
|
137 | + return; |
|
138 | + } |
|
139 | + $class_name = $this->AttributeNames[$attr_name]; |
|
140 | + $objs = []; |
|
141 | + if($this->lang_scope === 'global') { |
|
142 | + foreach( $a['langs'] as $l => $v ) { |
|
143 | 143 | $l = ( $l === 'C' ? 'any' : $l ); |
144 | 144 | $obj = new $class_name(); |
145 | 145 | $obj->setValue($v); |
146 | 146 | $obj->setAttributes(['lang' => $l]); |
147 | 147 | $objs[] = $obj; |
148 | - } |
|
149 | - } else { |
|
150 | - $obj = new $class_name(); |
|
151 | - $obj->setValue($a[0]); |
|
152 | - $objs[] = $obj; |
|
153 | - } |
|
154 | - |
|
155 | - return($objs); |
|
156 | - } else |
|
157 | - return ''; |
|
148 | + } |
|
149 | + } else { |
|
150 | + $obj = new $class_name(); |
|
151 | + $obj->setValue($a[0]); |
|
152 | + $objs[] = $obj; |
|
153 | + } |
|
154 | + |
|
155 | + return($objs); |
|
156 | + } else |
|
157 | + return ''; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | private function getDisplayName() { |
161 | - $attr = $this->attributes; |
|
162 | - $objs = []; |
|
163 | - if($this->lang_scope === 'global') { |
|
164 | - $I = $attr['general:instname']['langs']; |
|
165 | - if($attr['internal:profile_count'][0] > 1) |
|
161 | + $attr = $this->attributes; |
|
162 | + $objs = []; |
|
163 | + if($this->lang_scope === 'global') { |
|
164 | + $I = $attr['general:instname']['langs']; |
|
165 | + if($attr['internal:profile_count'][0] > 1) |
|
166 | 166 | $P = $attr['profile:name']['langs']; |
167 | - foreach( $I as $l => $v ) { |
|
167 | + foreach( $I as $l => $v ) { |
|
168 | 168 | $l = ( $l === 'C' ? 'any' : $l ); |
169 | 169 | $displayname = new DisplayName(); |
170 | 170 | if(isset($P)) { |
171 | - $p = isset($P[$l]) ? $P[$l] : $P['C']; |
|
172 | - $v .= ' - '. $p; |
|
171 | + $p = isset($P[$l]) ? $P[$l] : $P['C']; |
|
172 | + $v .= ' - '. $p; |
|
173 | 173 | } |
174 | 174 | $displayname->setValue($v); |
175 | 175 | $displayname->setAttributes(['lang' => $l]); |
176 | 176 | $objs[] = $displayname; |
177 | - } |
|
178 | - } else { |
|
179 | - $displayname = new DisplayName(); |
|
180 | - $v = $attr['general:instname'][0]; |
|
181 | - if($attr['internal:profile_count'][0] > 1) |
|
182 | - $v .= ' - '.$attr['profile:name'][0]; |
|
183 | - $displayname->setValue($v); |
|
184 | - $objs[] = $displayname; |
|
185 | - } |
|
186 | - return $objs; |
|
177 | + } |
|
178 | + } else { |
|
179 | + $displayname = new DisplayName(); |
|
180 | + $v = $attr['general:instname'][0]; |
|
181 | + if($attr['internal:profile_count'][0] > 1) |
|
182 | + $v .= ' - '.$attr['profile:name'][0]; |
|
183 | + $displayname->setValue($v); |
|
184 | + $objs[] = $displayname; |
|
185 | + } |
|
186 | + return $objs; |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | private function getProviderLogo() { |
190 | - $attr = $this->attributes; |
|
191 | - if(isset($attr['general:logo_file'][0])){ |
|
192 | - $logo_string = base64_encode($attr['general:logo_file'][0]); |
|
193 | - $logo_mime = 'image/'.$attr['internal:logo_file'][0]['mime']; |
|
194 | - $providerlogo = new ProviderLogo(); |
|
195 | - $providerlogo->setAttributes(['mime'=>$logo_mime, 'encoding'=>'base64']); |
|
196 | - $providerlogo->setValue($logo_string); |
|
197 | - return $providerlogo; |
|
198 | - } |
|
190 | + $attr = $this->attributes; |
|
191 | + if(isset($attr['general:logo_file'][0])){ |
|
192 | + $logo_string = base64_encode($attr['general:logo_file'][0]); |
|
193 | + $logo_mime = 'image/'.$attr['internal:logo_file'][0]['mime']; |
|
194 | + $providerlogo = new ProviderLogo(); |
|
195 | + $providerlogo->setAttributes(['mime'=>$logo_mime, 'encoding'=>'base64']); |
|
196 | + $providerlogo->setValue($logo_string); |
|
197 | + return $providerlogo; |
|
198 | + } |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | private function getProviderInfo() { |
202 | - $providerinfo = new ProviderInfo(); |
|
203 | - $providerinfo->setProperty('DisplayName',$this->getDisplayName()); |
|
204 | - $providerinfo->setProperty('Description',$this->getSimpleMLAttribute('profile:description')); |
|
205 | - $providerinfo->setProperty('ProviderLocation',$this->getProvideLocation()); |
|
206 | - $providerinfo->setProperty('ProviderLogo',$this->getProviderLogo()); |
|
207 | - $providerinfo->setProperty('TermsOfUse',$this->getSimpleMLAttribute('support:info_file')); |
|
208 | - $providerinfo->setProperty('Helpdesk',$this->getHelpdesk()); |
|
209 | - return $providerinfo; |
|
202 | + $providerinfo = new ProviderInfo(); |
|
203 | + $providerinfo->setProperty('DisplayName',$this->getDisplayName()); |
|
204 | + $providerinfo->setProperty('Description',$this->getSimpleMLAttribute('profile:description')); |
|
205 | + $providerinfo->setProperty('ProviderLocation',$this->getProvideLocation()); |
|
206 | + $providerinfo->setProperty('ProviderLogo',$this->getProviderLogo()); |
|
207 | + $providerinfo->setProperty('TermsOfUse',$this->getSimpleMLAttribute('support:info_file')); |
|
208 | + $providerinfo->setProperty('Helpdesk',$this->getHelpdesk()); |
|
209 | + return $providerinfo; |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | private function getProvideLocation() { |
213 | - $attr = $this->attributes; |
|
214 | - if(isset($attr['general:geo_coordinates'])){ |
|
215 | - $at = $attr['general:geo_coordinates']; |
|
216 | - if (count($at) > 1) { |
|
217 | - $at1 = []; |
|
218 | - foreach ($at as $a) { |
|
219 | - $providerlocation = new ProviderLocation(); |
|
220 | - $b = unserialize($a); |
|
221 | - $providerlocation->setProperty('Longitude',$b['lon']); |
|
222 | - $providerlocation->setProperty('Latitude',$b['lat']); |
|
223 | - $at1[] = $providerlocation; |
|
224 | - } |
|
225 | - } |
|
226 | - else { |
|
227 | - $providerlocation = new ProviderLocation(); |
|
228 | - $b = unserialize($at[0]); |
|
229 | - $providerlocation->setProperty('Longitude',$b['lon']); |
|
230 | - $providerlocation->setProperty('Latitude',$b['lat']); |
|
231 | - $at1 = $providerlocation; |
|
232 | - } |
|
233 | - return$at1; |
|
213 | + $attr = $this->attributes; |
|
214 | + if(isset($attr['general:geo_coordinates'])){ |
|
215 | + $at = $attr['general:geo_coordinates']; |
|
216 | + if (count($at) > 1) { |
|
217 | + $at1 = []; |
|
218 | + foreach ($at as $a) { |
|
219 | + $providerlocation = new ProviderLocation(); |
|
220 | + $b = unserialize($a); |
|
221 | + $providerlocation->setProperty('Longitude',$b['lon']); |
|
222 | + $providerlocation->setProperty('Latitude',$b['lat']); |
|
223 | + $at1[] = $providerlocation; |
|
224 | + } |
|
225 | + } |
|
226 | + else { |
|
227 | + $providerlocation = new ProviderLocation(); |
|
228 | + $b = unserialize($at[0]); |
|
229 | + $providerlocation->setProperty('Longitude',$b['lon']); |
|
230 | + $providerlocation->setProperty('Latitude',$b['lat']); |
|
231 | + $at1 = $providerlocation; |
|
232 | + } |
|
233 | + return$at1; |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
237 | 237 | private function getHelpdesk() { |
238 | - $helpdesk = new Helpdesk(); |
|
239 | - $helpdesk->setProperty('EmailAddress',$this->getSimpleMLAttribute('support:email')); |
|
240 | - $helpdesk->setProperty('WebAddress',$this->getSimpleMLAttribute('support:url')); |
|
241 | - $helpdesk->setProperty('Phone',$this->getSimpleMLAttribute('support:phone')); |
|
242 | - return $helpdesk; |
|
238 | + $helpdesk = new Helpdesk(); |
|
239 | + $helpdesk->setProperty('EmailAddress',$this->getSimpleMLAttribute('support:email')); |
|
240 | + $helpdesk->setProperty('WebAddress',$this->getSimpleMLAttribute('support:url')); |
|
241 | + $helpdesk->setProperty('Phone',$this->getSimpleMLAttribute('support:phone')); |
|
242 | + return $helpdesk; |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | private function getCompatibleUses() { |
246 | - $SSIDs = $this->attributes['internal:SSID']; |
|
247 | - $compatibleuses = new CompatibleUses(); |
|
248 | - $ieee80211s = []; |
|
249 | - foreach ($SSIDs as $ssid => $ciph) { |
|
250 | - $ieee80211 = new IEEE80211(); |
|
251 | - $ieee80211->setProperty('SSID',$ssid); |
|
252 | - $ieee80211->setProperty('MinRSNProto', $ciph == 'AES' ? 'CCMP' : 'TKIP'); |
|
253 | - $ieee80211s[] = $ieee80211; |
|
254 | - } |
|
255 | - $compatibleuses->setProperty('IEEE80211',$ieee80211s); |
|
246 | + $SSIDs = $this->attributes['internal:SSID']; |
|
247 | + $compatibleuses = new CompatibleUses(); |
|
248 | + $ieee80211s = []; |
|
249 | + foreach ($SSIDs as $ssid => $ciph) { |
|
250 | + $ieee80211 = new IEEE80211(); |
|
251 | + $ieee80211->setProperty('SSID',$ssid); |
|
252 | + $ieee80211->setProperty('MinRSNProto', $ciph == 'AES' ? 'CCMP' : 'TKIP'); |
|
253 | + $ieee80211s[] = $ieee80211; |
|
254 | + } |
|
255 | + $compatibleuses->setProperty('IEEE80211',$ieee80211s); |
|
256 | 256 | // TODO IEEE8023, ABFAB |
257 | - return($compatibleuses); |
|
257 | + return($compatibleuses); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | private function getAuthenticationMethodParams($eap) { |
261 | - $inner = EAP::innerAuth($eap); |
|
262 | - $outer_id = $eap["OUTER"]; |
|
263 | - |
|
264 | - if(isset($inner["METHOD"]) && $inner["METHOD"]) { |
|
265 | - $innerauthmethod = new InnerAuthenticationMethod(); |
|
266 | - $class_name = $inner["EAP"] ? 'EAPMethod' : 'NonEAPAuthMethod'; |
|
267 | - $eapmethod = new $class_name(); |
|
268 | - $eaptype = new Type(); |
|
269 | - $eaptype->setValue($inner['METHOD']); |
|
270 | - $eapmethod->setProperty('Type',$eaptype); |
|
271 | - $innerauthmethod->setProperty($class_name,$eapmethod); |
|
272 | - return ['inner_method'=>$innerauthmethod,'methodID'=> $outer_id, 'inner_methodID'=>$inner['METHOD']]; |
|
273 | - } else |
|
274 | - return ['inner_method'=>0,'methodID'=>$outer_id, 'inner_methodID'=>0]; |
|
261 | + $inner = EAP::innerAuth($eap); |
|
262 | + $outer_id = $eap["OUTER"]; |
|
263 | + |
|
264 | + if(isset($inner["METHOD"]) && $inner["METHOD"]) { |
|
265 | + $innerauthmethod = new InnerAuthenticationMethod(); |
|
266 | + $class_name = $inner["EAP"] ? 'EAPMethod' : 'NonEAPAuthMethod'; |
|
267 | + $eapmethod = new $class_name(); |
|
268 | + $eaptype = new Type(); |
|
269 | + $eaptype->setValue($inner['METHOD']); |
|
270 | + $eapmethod->setProperty('Type',$eaptype); |
|
271 | + $innerauthmethod->setProperty($class_name,$eapmethod); |
|
272 | + return ['inner_method'=>$innerauthmethod,'methodID'=> $outer_id, 'inner_methodID'=>$inner['METHOD']]; |
|
273 | + } else |
|
274 | + return ['inner_method'=>0,'methodID'=>$outer_id, 'inner_methodID'=>0]; |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | private function getAuthMethod($eap) { |
278 | - $attr = $this->attributes; |
|
279 | - $eapParams = $this->getAuthenticationMethodParams($eap); |
|
280 | - $authmethod = new AuthenticationMethod(); |
|
281 | - $eapmethod = new EAPMethod(); |
|
282 | - $eaptype = new Type(); |
|
283 | - $eaptype->setValue($eapParams['methodID']); |
|
284 | - $eapmethod->setProperty('Type',$eaptype); |
|
285 | - if(isset($this->VendorSpecific)) { |
|
286 | - $vendorspecifics = []; |
|
287 | - foreach($this->VendorSpecific as $vs) { |
|
278 | + $attr = $this->attributes; |
|
279 | + $eapParams = $this->getAuthenticationMethodParams($eap); |
|
280 | + $authmethod = new AuthenticationMethod(); |
|
281 | + $eapmethod = new EAPMethod(); |
|
282 | + $eaptype = new Type(); |
|
283 | + $eaptype->setValue($eapParams['methodID']); |
|
284 | + $eapmethod->setProperty('Type',$eaptype); |
|
285 | + if(isset($this->VendorSpecific)) { |
|
286 | + $vendorspecifics = []; |
|
287 | + foreach($this->VendorSpecific as $vs) { |
|
288 | 288 | $vendorspecific = new VendorSpecific(); |
289 | 289 | $vs['value']->addAttribute('xsi:noNamespaceSchemaLocation',"xxx.xsd"); |
290 | 290 | $vendorspecific->setValue($vs['value']); |
291 | 291 | $vendorspecific->setAttributes(['vendor'=>$vs['vendor']]); |
292 | 292 | $vendorspecifics[] = $vendorspecific; |
293 | - } |
|
294 | - $eapmethod->setProperty('VendorSpecific',$vendorspecifics); |
|
295 | - } |
|
296 | - $authmethod->setProperty('EAPMethod',$eapmethod); |
|
293 | + } |
|
294 | + $eapmethod->setProperty('VendorSpecific',$vendorspecifics); |
|
295 | + } |
|
296 | + $authmethod->setProperty('EAPMethod',$eapmethod); |
|
297 | 297 | |
298 | 298 | // ServerSideCredentials |
299 | - $serversidecredential = new ServerSideCredential(); |
|
299 | + $serversidecredential = new ServerSideCredential(); |
|
300 | 300 | |
301 | 301 | // Certificates and server names |
302 | 302 | |
303 | - $CAs = []; |
|
304 | - $cas = $attr['internal:CAs'][0]; |
|
305 | - foreach ($cas as $ca) { |
|
306 | - $CA = new CA(); |
|
307 | - $CA->setValue(base64_encode($ca['der'])); |
|
308 | - $CA->setAttributes(['format'=>'X.509', 'encoding'=>'base64']); |
|
309 | - $CAs[] = $CA; |
|
310 | - } |
|
311 | - |
|
312 | - $serverids = []; |
|
313 | - $servers = $attr['eap:server_name']; |
|
314 | - foreach ($servers as $server) { |
|
315 | - $serverid = new ServerID(); |
|
316 | - $serverid->setValue($server); |
|
317 | - $serverids[] = $serverid; |
|
318 | - } |
|
319 | - |
|
320 | - $serversidecredential->setProperty('EAPType',$eaptype->getValue()); |
|
321 | - $serversidecredential->setProperty('CA',$CAs); |
|
322 | - $serversidecredential->setProperty('ServerID',$serverids); |
|
323 | - $authmethod->setProperty('ServerSideCredential',$serversidecredential); |
|
303 | + $CAs = []; |
|
304 | + $cas = $attr['internal:CAs'][0]; |
|
305 | + foreach ($cas as $ca) { |
|
306 | + $CA = new CA(); |
|
307 | + $CA->setValue(base64_encode($ca['der'])); |
|
308 | + $CA->setAttributes(['format'=>'X.509', 'encoding'=>'base64']); |
|
309 | + $CAs[] = $CA; |
|
310 | + } |
|
311 | + |
|
312 | + $serverids = []; |
|
313 | + $servers = $attr['eap:server_name']; |
|
314 | + foreach ($servers as $server) { |
|
315 | + $serverid = new ServerID(); |
|
316 | + $serverid->setValue($server); |
|
317 | + $serverids[] = $serverid; |
|
318 | + } |
|
319 | + |
|
320 | + $serversidecredential->setProperty('EAPType',$eaptype->getValue()); |
|
321 | + $serversidecredential->setProperty('CA',$CAs); |
|
322 | + $serversidecredential->setProperty('ServerID',$serverids); |
|
323 | + $authmethod->setProperty('ServerSideCredential',$serversidecredential); |
|
324 | 324 | |
325 | 325 | // ClientSideCredentials |
326 | 326 | |
327 | - $clientsidecredential = new ClientSideCredential(); |
|
327 | + $clientsidecredential = new ClientSideCredential(); |
|
328 | 328 | |
329 | 329 | // OuterIdentity |
330 | - if($attr['internal:use_anon_outer'] [0]) |
|
331 | - $clientsidecredential->setProperty('OuterIdentity',$attr['internal:anon_local_value'][0].'@'.$attr['internal:realm'][0]); |
|
332 | - $clientsidecredential->setProperty('EAPType',$eapParams['inner_methodID'] ? $eapParams['inner_methodID'] : $eapParams['methodID']); |
|
333 | - $authmethod->setProperty('ClientSideCredential',$clientsidecredential); |
|
334 | - if($eapParams['inner_method']) |
|
335 | - $authmethod->setProperty('InnerAuthenticationMethod',$eapParams['inner_method']); |
|
336 | - return $authmethod; |
|
330 | + if($attr['internal:use_anon_outer'] [0]) |
|
331 | + $clientsidecredential->setProperty('OuterIdentity',$attr['internal:anon_local_value'][0].'@'.$attr['internal:realm'][0]); |
|
332 | + $clientsidecredential->setProperty('EAPType',$eapParams['inner_methodID'] ? $eapParams['inner_methodID'] : $eapParams['methodID']); |
|
333 | + $authmethod->setProperty('ClientSideCredential',$clientsidecredential); |
|
334 | + if($eapParams['inner_method']) |
|
335 | + $authmethod->setProperty('InnerAuthenticationMethod',$eapParams['inner_method']); |
|
336 | + return $authmethod; |
|
337 | 337 | } |
338 | 338 | |
339 | 339 |
@@ -5,11 +5,11 @@ |
||
5 | 5 | |
6 | 6 | class Device_XML_TTLS_MSCHAP2 extends Device_XML { |
7 | 7 | final public function __construct() { |
8 | - $this->supportedEapMethods = |
|
8 | + $this->supportedEapMethods = |
|
9 | 9 | [ |
10 | - EAP::$TTLS_MSCHAP2, |
|
11 | - ]; |
|
12 | - $this->lang_scope = 'single'; |
|
10 | + EAP::$TTLS_MSCHAP2, |
|
11 | + ]; |
|
12 | + $this->lang_scope = 'single'; |
|
13 | 13 | } |
14 | 14 | } |
15 | 15 |
@@ -5,11 +5,11 @@ |
||
5 | 5 | |
6 | 6 | class Device_XML_PWD extends Device_XML { |
7 | 7 | final public function __construct() { |
8 | - $this->supportedEapMethods = |
|
8 | + $this->supportedEapMethods = |
|
9 | 9 | [ |
10 | - EAP::$PWD, |
|
11 | - ]; |
|
12 | - $this->lang_scope = 'single'; |
|
10 | + EAP::$PWD, |
|
11 | + ]; |
|
12 | + $this->lang_scope = 'single'; |
|
13 | 13 | } |
14 | 14 | } |
15 | 15 |
@@ -5,15 +5,15 @@ |
||
5 | 5 | |
6 | 6 | class Device_Lollipop extends Device_XML{ |
7 | 7 | final public function __construct() { |
8 | - $this->supportedEapMethods = |
|
8 | + $this->supportedEapMethods = |
|
9 | 9 | [ |
10 | - EAP::$PEAP_MSCHAP2, |
|
11 | - EAP::$TTLS_PAP, |
|
12 | - EAP::$TTLS_MSCHAP2, |
|
13 | - EAP::$TLS, |
|
14 | - ]; |
|
15 | - $this->lang_scope = 'single'; |
|
16 | - $this->all_eaps = TRUE; |
|
10 | + EAP::$PEAP_MSCHAP2, |
|
11 | + EAP::$TTLS_PAP, |
|
12 | + EAP::$TTLS_MSCHAP2, |
|
13 | + EAP::$TLS, |
|
14 | + ]; |
|
15 | + $this->lang_scope = 'single'; |
|
16 | + $this->all_eaps = TRUE; |
|
17 | 17 | } |
18 | 18 | } |
19 | 19 |