@@ -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 |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function __construct($blueprint) { |
48 | 48 | |
49 | - $Dev = Devices::listDevices(); |
|
49 | + $Dev = Devices::listDevices(); |
|
50 | 50 | if(isset($Dev[$blueprint])) { |
51 | 51 | if($Dev[$blueprint]['directory'] && $Dev[$blueprint]['module']) |
52 | 52 | require_once("devices/".$Dev[$blueprint]['directory']."/".$Dev[$blueprint]['module'].".php"); |
@@ -60,15 +60,15 @@ discard block |
||
60 | 60 | } else { |
61 | 61 | error("unknown devicename:$blueprint"); |
62 | 62 | } |
63 | - $this->device->module_path = CAT::$root.'/devices/'.$Dev[$blueprint]['directory']; |
|
64 | - $this->device->signer = isset($Dev[$blueprint]['signer']) ? $Dev[$blueprint]['signer'] : 0; |
|
65 | - $this->device->device_id = $blueprint; |
|
66 | - $options = Devices::$Options; |
|
67 | - if(isset($Dev[$blueprint]['options'])) { |
|
68 | - $Opt = $Dev[$blueprint]['options']; |
|
69 | - foreach ($Opt as $option => $value) |
|
63 | + $this->device->module_path = CAT::$root.'/devices/'.$Dev[$blueprint]['directory']; |
|
64 | + $this->device->signer = isset($Dev[$blueprint]['signer']) ? $Dev[$blueprint]['signer'] : 0; |
|
65 | + $this->device->device_id = $blueprint; |
|
66 | + $options = Devices::$Options; |
|
67 | + if(isset($Dev[$blueprint]['options'])) { |
|
68 | + $Opt = $Dev[$blueprint]['options']; |
|
69 | + foreach ($Opt as $option => $value) |
|
70 | 70 | $options[$option] = $value; |
71 | - } |
|
72 | - $this->device->options = $options; |
|
71 | + } |
|
72 | + $this->device->options = $options; |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | \ No newline at end of file |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * link - the path name of the resulting installer |
53 | 53 | * mime - the mimetype of the installer |
54 | 54 | */ |
55 | - public function generateInstaller($device,$prof_id, $generated_for = "user") { |
|
55 | + public function generateInstaller($device,$prof_id, $generated_for = "user") { |
|
56 | 56 | $this->set_locale("devices"); |
57 | 57 | $Dev = Devices::listDevices(); |
58 | 58 | $Config = $Dev[$device]; |
@@ -61,93 +61,93 @@ discard block |
||
61 | 61 | $attribs = $profile->getCollapsedAttributes(); |
62 | 62 | // test if the profile is production-ready and if not if the authenticated user is an owner |
63 | 63 | if (!isset($attribs['profile:production']) || (isset($attribs['profile:production']) && $attribs['profile:production'][0] != "on")) { |
64 | - debug(4,"Attempt to download a non-production ready installer fir profile: $prof_id\n"); |
|
65 | - require_once(Config::$AUTHENTICATION['ssp-path-to-autoloader']); |
|
66 | - $as = new SimpleSAML_Auth_Simple(Config::$AUTHENTICATION['ssp-authsource']); |
|
67 | - if($as->isAuthenticated()) { |
|
68 | - $user_object = new User($_SESSION['user']); |
|
69 | - if($user_object->isIdPOwner($profile->institution)) { |
|
70 | - debug(4, "User is the owner - allowing access\n"); |
|
71 | - } else { |
|
72 | - debug(2, "User not an owner of a non-production profile - access forbidden\n"); |
|
73 | - header("HTTP/1.0 403 Not Authorized"); |
|
74 | - return; |
|
75 | - } |
|
76 | - } else { |
|
77 | - debug(2, "User NOT authenticated, rejecting request for a non-production installer\n"); |
|
78 | - header("HTTP/1.0 403 Not Authorized"); |
|
79 | - return; |
|
80 | - } |
|
64 | + debug(4,"Attempt to download a non-production ready installer fir profile: $prof_id\n"); |
|
65 | + require_once(Config::$AUTHENTICATION['ssp-path-to-autoloader']); |
|
66 | + $as = new SimpleSAML_Auth_Simple(Config::$AUTHENTICATION['ssp-authsource']); |
|
67 | + if($as->isAuthenticated()) { |
|
68 | + $user_object = new User($_SESSION['user']); |
|
69 | + if($user_object->isIdPOwner($profile->institution)) { |
|
70 | + debug(4, "User is the owner - allowing access\n"); |
|
71 | + } else { |
|
72 | + debug(2, "User not an owner of a non-production profile - access forbidden\n"); |
|
73 | + header("HTTP/1.0 403 Not Authorized"); |
|
74 | + return; |
|
75 | + } |
|
76 | + } else { |
|
77 | + debug(2, "User NOT authenticated, rejecting request for a non-production installer\n"); |
|
78 | + header("HTTP/1.0 403 Not Authorized"); |
|
79 | + return; |
|
80 | + } |
|
81 | 81 | } |
82 | 82 | $a = []; |
83 | 83 | $a['profile'] = $prof_id; |
84 | 84 | $a['device'] = $device; |
85 | 85 | if( (isset(Devices::$Options['no_cache']) && Devices::$Options['no_cache'] ) || ( isset($Config['options']['no_cache']) && $Config['options']['no_cache'] )) |
86 | - $this->i_path = FALSE; |
|
86 | + $this->i_path = FALSE; |
|
87 | 87 | else { |
88 | - $cache = $profile->testCache($device); |
|
89 | - $this->i_path = $cache['cache']; |
|
88 | + $cache = $profile->testCache($device); |
|
89 | + $this->i_path = $cache['cache']; |
|
90 | 90 | } |
91 | 91 | if($this->i_path && is_file($this->i_path)) { |
92 | - debug(4,"Using cached installer for: $device\n"); |
|
93 | - $a['link'] = "API.php?api_version=$version&action=downloadInstaller&lang=".CAT::get_lang()."&profile=$prof_id&device=$device&generatedfor=$generated_for"; |
|
94 | - $a['mime'] = $cache['mime']; |
|
92 | + debug(4,"Using cached installer for: $device\n"); |
|
93 | + $a['link'] = "API.php?api_version=$version&action=downloadInstaller&lang=".CAT::get_lang()."&profile=$prof_id&device=$device&generatedfor=$generated_for"; |
|
94 | + $a['mime'] = $cache['mime']; |
|
95 | 95 | } else { |
96 | - $factory = new DeviceFactory($device); |
|
97 | - $dev = $factory->device; |
|
98 | - if(isset($dev)) { |
|
99 | - $dev->setup($profile); |
|
100 | - $installer = $dev->writeInstaller(); |
|
101 | - $i_path = $dev->FPATH.'/tmp/'.$installer; |
|
102 | - if($i_path && is_file($i_path)) { |
|
103 | - if(isset($dev->options['mime'])) |
|
104 | - $a['mime'] = $dev->options['mime']; |
|
105 | - else { |
|
106 | - $info = new finfo(); |
|
107 | - $a['mime'] = $info->file($i_path, FILEINFO_MIME_TYPE); |
|
108 | - } |
|
109 | - $this->i_path = $dev->FPATH.'/'.$installer; |
|
110 | - rename($i_path, $this->i_path); |
|
111 | - $profile->updateCache($device,$this->i_path,$a['mime']); |
|
96 | + $factory = new DeviceFactory($device); |
|
97 | + $dev = $factory->device; |
|
98 | + if(isset($dev)) { |
|
99 | + $dev->setup($profile); |
|
100 | + $installer = $dev->writeInstaller(); |
|
101 | + $i_path = $dev->FPATH.'/tmp/'.$installer; |
|
102 | + if($i_path && is_file($i_path)) { |
|
103 | + if(isset($dev->options['mime'])) |
|
104 | + $a['mime'] = $dev->options['mime']; |
|
105 | + else { |
|
106 | + $info = new finfo(); |
|
107 | + $a['mime'] = $info->file($i_path, FILEINFO_MIME_TYPE); |
|
108 | + } |
|
109 | + $this->i_path = $dev->FPATH.'/'.$installer; |
|
110 | + rename($i_path, $this->i_path); |
|
111 | + $profile->updateCache($device,$this->i_path,$a['mime']); |
|
112 | 112 | // rrmdir($dev->FPATH.'/tmp'); |
113 | - debug(4,"Generated installer: ".$this->i_path.": for: $device\n"); |
|
114 | - $a['link'] = "API.php?api_version=$version&action=downloadInstaller&lang=".CAT::get_lang()."&profile=$prof_id&device=$device&generatedfor=$generated_for"; |
|
115 | - } else { |
|
116 | - debug(2,"Installer generation failed for: $prof_id:$device:".CAT::get_lang()."\n"); |
|
117 | - $a['link'] = 0; |
|
118 | - } |
|
119 | - } |
|
113 | + debug(4,"Generated installer: ".$this->i_path.": for: $device\n"); |
|
114 | + $a['link'] = "API.php?api_version=$version&action=downloadInstaller&lang=".CAT::get_lang()."&profile=$prof_id&device=$device&generatedfor=$generated_for"; |
|
115 | + } else { |
|
116 | + debug(2,"Installer generation failed for: $prof_id:$device:".CAT::get_lang()."\n"); |
|
117 | + $a['link'] = 0; |
|
118 | + } |
|
119 | + } |
|
120 | 120 | } |
121 | 121 | $this->set_locale("web_user"); |
122 | 122 | return($a); |
123 | - } |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * interface to Devices::listDevices() |
|
127 | - */ |
|
128 | - public function listDevices($show_hidden = 0) { |
|
125 | + /** |
|
126 | + * interface to Devices::listDevices() |
|
127 | + */ |
|
128 | + public function listDevices($show_hidden = 0) { |
|
129 | 129 | $Dev = Devices::listDevices(); |
130 | 130 | $R = []; |
131 | 131 | $ct = 0; |
132 | 132 | if($show_hidden !== 0 && $show_hidden != 1) |
133 | - return; |
|
133 | + return; |
|
134 | 134 | foreach ($Dev as $device => $D) { |
135 | - if(isset($D['options']['hidden']) && $D['options']['hidden'] && $show_hidden == 0) |
|
136 | - continue; |
|
137 | - $ct ++; |
|
138 | - if($this->version == 1) |
|
139 | - $D['device'] = $device; |
|
140 | - else |
|
141 | - $D['device'] = $device; |
|
142 | - $group = isset($D['group']) ? $D['group'] : 'other'; |
|
143 | - if (! isset($R[$group])) |
|
144 | - $R[$group] = []; |
|
145 | - $R[$group][$device] = $D; |
|
146 | - } |
|
147 | - return $R; |
|
148 | - } |
|
149 | - |
|
150 | - public function deviceInfo($device,$prof_id) { |
|
135 | + if(isset($D['options']['hidden']) && $D['options']['hidden'] && $show_hidden == 0) |
|
136 | + continue; |
|
137 | + $ct ++; |
|
138 | + if($this->version == 1) |
|
139 | + $D['device'] = $device; |
|
140 | + else |
|
141 | + $D['device'] = $device; |
|
142 | + $group = isset($D['group']) ? $D['group'] : 'other'; |
|
143 | + if (! isset($R[$group])) |
|
144 | + $R[$group] = []; |
|
145 | + $R[$group][$device] = $D; |
|
146 | + } |
|
147 | + return $R; |
|
148 | + } |
|
149 | + |
|
150 | + public function deviceInfo($device,$prof_id) { |
|
151 | 151 | $this->set_locale("devices"); |
152 | 152 | $out = 0; |
153 | 153 | $profile = new Profile($prof_id); |
@@ -155,11 +155,11 @@ discard block |
||
155 | 155 | $dev = $factory->device; |
156 | 156 | if(isset($dev)) { |
157 | 157 | // $dev->setup($profile); |
158 | - $out = $dev->writeDeviceInfo(); |
|
159 | - } |
|
158 | + $out = $dev->writeDeviceInfo(); |
|
159 | + } |
|
160 | 160 | $this->set_locale("web_user"); |
161 | 161 | echo $out; |
162 | - } |
|
162 | + } |
|
163 | 163 | |
164 | 164 | /** |
165 | 165 | * Prepare the support data for a given profile |
@@ -173,23 +173,23 @@ discard block |
||
173 | 173 | * - description |
174 | 174 | * - devices - an array of device names and their statuses (for a given profile) |
175 | 175 | */ |
176 | - public function profileAttributes($prof_id) { |
|
176 | + public function profileAttributes($prof_id) { |
|
177 | 177 | $this->set_locale("devices"); |
178 | - $profile = new Profile($prof_id); |
|
179 | - $attr = $profile->getCollapsedAttributes(); |
|
180 | - $a = []; |
|
181 | - if(isset($attr['support:email'])) |
|
182 | - $a['local_email'] = $attr['support:email'][0]; |
|
183 | - if(isset($attr['support:phone'])) |
|
184 | - $a['local_phone'] = $attr['support:phone'][0]; |
|
185 | - if(isset($attr['support:url'])) |
|
186 | - $a['local_url'] = $attr['support:url'][0]; |
|
187 | - if(isset($attr['profile:description'])) |
|
188 | - $a['description'] = $attr['profile:description'][0]; |
|
189 | - $a['devices'] = $profile->listDevices(); |
|
190 | - $this->set_locale("web_user"); |
|
191 | - return($a); |
|
192 | - } |
|
178 | + $profile = new Profile($prof_id); |
|
179 | + $attr = $profile->getCollapsedAttributes(); |
|
180 | + $a = []; |
|
181 | + if(isset($attr['support:email'])) |
|
182 | + $a['local_email'] = $attr['support:email'][0]; |
|
183 | + if(isset($attr['support:phone'])) |
|
184 | + $a['local_phone'] = $attr['support:phone'][0]; |
|
185 | + if(isset($attr['support:url'])) |
|
186 | + $a['local_url'] = $attr['support:url'][0]; |
|
187 | + if(isset($attr['profile:description'])) |
|
188 | + $a['description'] = $attr['profile:description'][0]; |
|
189 | + $a['devices'] = $profile->listDevices(); |
|
190 | + $this->set_locale("web_user"); |
|
191 | + return($a); |
|
192 | + } |
|
193 | 193 | |
194 | 194 | /* |
195 | 195 | this method needs to be used with care, it could give wrong results in some |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | $file= $F['file']; |
202 | 202 | $file = substr($file,strlen(dirname(__DIR__))); |
203 | 203 | while(substr($file,0,1) == '/') |
204 | - $file = substr($file,1); |
|
204 | + $file = substr($file,1); |
|
205 | 205 | $n = count(explode('/',$file)); |
206 | 206 | $out = $_SERVER['SCRIPT_NAME']; |
207 | 207 | for ($i= 0; $i < $n; $i++) |
208 | - $out = dirname($out); |
|
208 | + $out = dirname($out); |
|
209 | 209 | if ($out == '/') |
210 | - $out = ''; |
|
210 | + $out = ''; |
|
211 | 211 | $s = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'https' : 'http'; |
212 | 212 | $s .= '://'.$_SERVER['HTTP_HOST'] . $out; |
213 | 213 | return $s; |
@@ -215,29 +215,29 @@ discard block |
||
215 | 215 | |
216 | 216 | /* JSON functions */ |
217 | 217 | |
218 | - public function return_json($data,$status=1) { |
|
219 | - $return_array = []; |
|
220 | - $return_array['status'] = $status; |
|
221 | - $return_array['data'] = $data; |
|
222 | - $return_array['tou'] = "Please consult Terms of Use at: ".$this->GetRootURL()."/tou.php"; |
|
223 | - return(json_encode($return_array)); |
|
224 | - } |
|
218 | + public function return_json($data,$status=1) { |
|
219 | + $return_array = []; |
|
220 | + $return_array['status'] = $status; |
|
221 | + $return_array['data'] = $data; |
|
222 | + $return_array['tou'] = "Please consult Terms of Use at: ".$this->GetRootURL()."/tou.php"; |
|
223 | + return(json_encode($return_array)); |
|
224 | + } |
|
225 | 225 | |
226 | 226 | /** |
227 | - * Return the list of supported languages. |
|
228 | - * |
|
229 | - * |
|
230 | - */ |
|
231 | - public function JSON_listLanguages() { |
|
232 | - $return_array = []; |
|
233 | - foreach(Config::$LANGUAGES as $id => $val){ |
|
234 | - if($this->version == 1) |
|
235 | - $return_array[] = ['id'=>$id,'display'=>$val['display'],'locale'=>$val['locale']]; |
|
236 | - else |
|
237 | - $return_array[] = ['lang'=>$id,'display'=>$val['display'],'locale'=>$val['locale']]; |
|
238 | - } |
|
239 | - echo $this->return_json($return_array); |
|
240 | - } |
|
227 | + * Return the list of supported languages. |
|
228 | + * |
|
229 | + * |
|
230 | + */ |
|
231 | + public function JSON_listLanguages() { |
|
232 | + $return_array = []; |
|
233 | + foreach(Config::$LANGUAGES as $id => $val){ |
|
234 | + if($this->version == 1) |
|
235 | + $return_array[] = ['id'=>$id,'display'=>$val['display'],'locale'=>$val['locale']]; |
|
236 | + else |
|
237 | + $return_array[] = ['lang'=>$id,'display'=>$val['display'],'locale'=>$val['locale']]; |
|
238 | + } |
|
239 | + echo $this->return_json($return_array); |
|
240 | + } |
|
241 | 241 | |
242 | 242 | /** |
243 | 243 | * Return the list of countiers with configured IdPs |
@@ -245,17 +245,17 @@ discard block |
||
245 | 245 | * @return string JSON encoded data |
246 | 246 | */ |
247 | 247 | |
248 | - public function JSON_listCountries() { |
|
249 | - $FED = $this->printCountryList(1); |
|
250 | - $return_array = []; |
|
251 | - foreach ($FED as $id => $val) { |
|
252 | - if($this->version == 1) |
|
253 | - $return_array[] = ['id'=>$id,'display'=>$val]; |
|
254 | - else |
|
255 | - $return_array[] = ['federation'=>$id,'display'=>$val]; |
|
256 | - } |
|
257 | - echo $this->return_json($return_array); |
|
258 | - } |
|
248 | + public function JSON_listCountries() { |
|
249 | + $FED = $this->printCountryList(1); |
|
250 | + $return_array = []; |
|
251 | + foreach ($FED as $id => $val) { |
|
252 | + if($this->version == 1) |
|
253 | + $return_array[] = ['id'=>$id,'display'=>$val]; |
|
254 | + else |
|
255 | + $return_array[] = ['federation'=>$id,'display'=>$val]; |
|
256 | + } |
|
257 | + echo $this->return_json($return_array); |
|
258 | + } |
|
259 | 259 | |
260 | 260 | /** |
261 | 261 | * Return the list of IdPs in a given country |
@@ -264,17 +264,17 @@ discard block |
||
264 | 264 | * @return string JSON encoded data |
265 | 265 | */ |
266 | 266 | |
267 | - public function JSON_listIdentityProviders($country) { |
|
268 | - $idps = Federation::listAllIdentityProviders(1,$country); |
|
269 | - $return_array = []; |
|
270 | - foreach ($idps as $idp) { |
|
267 | + public function JSON_listIdentityProviders($country) { |
|
268 | + $idps = Federation::listAllIdentityProviders(1,$country); |
|
269 | + $return_array = []; |
|
270 | + foreach ($idps as $idp) { |
|
271 | 271 | if($this->version == 1) |
272 | - $return_array[] = ['id'=>$idp['entityID'],'display'=>$idp['title']]; |
|
272 | + $return_array[] = ['id'=>$idp['entityID'],'display'=>$idp['title']]; |
|
273 | 273 | else |
274 | - $return_array[] = ['idp'=>$idp['entityID'],'display'=>$idp['title']]; |
|
275 | - } |
|
276 | - echo $this->return_json($return_array); |
|
277 | - } |
|
274 | + $return_array[] = ['idp'=>$idp['entityID'],'display'=>$idp['title']]; |
|
275 | + } |
|
276 | + echo $this->return_json($return_array); |
|
277 | + } |
|
278 | 278 | |
279 | 279 | /** |
280 | 280 | * return the list of all active IdPs |
@@ -283,18 +283,18 @@ discard block |
||
283 | 283 | * @return string JSON encoded data |
284 | 284 | */ |
285 | 285 | |
286 | - public function JSON_listIdentityProvidersForDisco() { |
|
287 | - $idps = Federation::listAllIdentityProviders(1); |
|
288 | - $return_array = []; |
|
289 | - foreach ($idps as $idp) { |
|
286 | + public function JSON_listIdentityProvidersForDisco() { |
|
287 | + $idps = Federation::listAllIdentityProviders(1); |
|
288 | + $return_array = []; |
|
289 | + foreach ($idps as $idp) { |
|
290 | 290 | if($this->version == 1) |
291 | - $idp['id'] = $idp['entityID']; |
|
292 | - else |
|
293 | - $idp['idp'] = $idp['entityID']; |
|
291 | + $idp['id'] = $idp['entityID']; |
|
292 | + else |
|
293 | + $idp['idp'] = $idp['entityID']; |
|
294 | 294 | $return_array[] = $idp; |
295 | - } |
|
296 | - echo json_encode($return_array); |
|
297 | - } |
|
295 | + } |
|
296 | + echo json_encode($return_array); |
|
297 | + } |
|
298 | 298 | |
299 | 299 | |
300 | 300 | |
@@ -306,17 +306,17 @@ discard block |
||
306 | 306 | */ |
307 | 307 | |
308 | 308 | |
309 | - public function JSON_orderIdentityProviders($country,$L=NULL) { |
|
310 | - $idps = $this->orderIdentityProviders($country,$L); |
|
311 | - $return_array = []; |
|
312 | - foreach ($idps as $idp) { |
|
309 | + public function JSON_orderIdentityProviders($country,$L=NULL) { |
|
310 | + $idps = $this->orderIdentityProviders($country,$L); |
|
311 | + $return_array = []; |
|
312 | + foreach ($idps as $idp) { |
|
313 | 313 | if($this->version == 1) |
314 | - $return_array[] = ['id'=>$idp['id'],'display'=>$idp['title']]; |
|
314 | + $return_array[] = ['id'=>$idp['id'],'display'=>$idp['title']]; |
|
315 | 315 | else |
316 | - $return_array[] = ['idp'=>$idp['id'],'display'=>$idp['title']]; |
|
317 | - } |
|
318 | - echo $this->return_json($return_array); |
|
319 | - } |
|
316 | + $return_array[] = ['idp'=>$idp['id'],'display'=>$idp['title']]; |
|
317 | + } |
|
318 | + echo $this->return_json($return_array); |
|
319 | + } |
|
320 | 320 | |
321 | 321 | /** |
322 | 322 | * Produce a list of profiles available for a given IdP |
@@ -324,31 +324,31 @@ discard block |
||
324 | 324 | * @param int $idp_id the IdP identifier |
325 | 325 | * @return string JSON encoded data |
326 | 326 | */ |
327 | - public function JSON_listProfiles($idp_id,$sort = 0) { |
|
328 | - $this->set_locale("web_user"); |
|
329 | - $return_array = []; |
|
330 | - try { |
|
331 | - $idp = new IdP($idp_id); |
|
332 | - } |
|
333 | - catch (Exception $fail) { |
|
327 | + public function JSON_listProfiles($idp_id,$sort = 0) { |
|
328 | + $this->set_locale("web_user"); |
|
329 | + $return_array = []; |
|
330 | + try { |
|
331 | + $idp = new IdP($idp_id); |
|
332 | + } |
|
333 | + catch (Exception $fail) { |
|
334 | 334 | echo $this->return_json($return_array,0); |
335 | 335 | return; |
336 | - } |
|
337 | - $l = 0; |
|
338 | - $logo = $idp->getAttributes('general:logo_file'); |
|
339 | - if($logo) |
|
340 | - $l = 1; |
|
341 | - $profiles = $idp->listProfiles(1); |
|
342 | - if($sort == 1) |
|
336 | + } |
|
337 | + $l = 0; |
|
338 | + $logo = $idp->getAttributes('general:logo_file'); |
|
339 | + if($logo) |
|
340 | + $l = 1; |
|
341 | + $profiles = $idp->listProfiles(1); |
|
342 | + if($sort == 1) |
|
343 | 343 | usort($profiles,"profile_sort"); |
344 | - foreach ($profiles as $P) { |
|
345 | - if($this->version == 1) |
|
346 | - $return_array[] = ['id'=>$P->identifier,'display'=>$P->name, 'idp_name'=>$P->inst_name,'logo'=>$l]; |
|
347 | - else |
|
348 | - $return_array[] = ['profile'=>$P->identifier,'display'=>$P->name, 'idp_name'=>$P->inst_name,'logo'=>$l]; |
|
349 | - } |
|
350 | - echo $this->return_json($return_array); |
|
351 | - } |
|
344 | + foreach ($profiles as $P) { |
|
345 | + if($this->version == 1) |
|
346 | + $return_array[] = ['id'=>$P->identifier,'display'=>$P->name, 'idp_name'=>$P->inst_name,'logo'=>$l]; |
|
347 | + else |
|
348 | + $return_array[] = ['profile'=>$P->identifier,'display'=>$P->name, 'idp_name'=>$P->inst_name,'logo'=>$l]; |
|
349 | + } |
|
350 | + echo $this->return_json($return_array); |
|
351 | + } |
|
352 | 352 | |
353 | 353 | /** |
354 | 354 | * Return the list of devices available for the given profile |
@@ -356,34 +356,34 @@ discard block |
||
356 | 356 | * @param int $profile_id the Profile identifier |
357 | 357 | * @return string JSON encoded data |
358 | 358 | */ |
359 | - public function JSON_listDevices($profile_id) { |
|
360 | - $this->set_locale("web_user"); |
|
361 | - $return_array = []; |
|
362 | - $a = $this->profileAttributes($profile_id); |
|
363 | - $thedevices = $a['devices']; |
|
364 | - if(!isset($profile_redirect) || ! $profile_redirect) { |
|
365 | - $profile_redirect = 0; |
|
366 | - foreach ($thedevices as $D) { |
|
367 | - if(isset($D['options']) && isset($D['options']['hidden']) && $D['options']['hidden']) |
|
368 | - continue; |
|
369 | - $disp = $D['display']; |
|
370 | - if($this->version == 1) { |
|
371 | - if($D['id'] === '0') { |
|
372 | - $profile_redirect = 1; |
|
373 | - $disp = $c; |
|
374 | - } |
|
359 | + public function JSON_listDevices($profile_id) { |
|
360 | + $this->set_locale("web_user"); |
|
361 | + $return_array = []; |
|
362 | + $a = $this->profileAttributes($profile_id); |
|
363 | + $thedevices = $a['devices']; |
|
364 | + if(!isset($profile_redirect) || ! $profile_redirect) { |
|
365 | + $profile_redirect = 0; |
|
366 | + foreach ($thedevices as $D) { |
|
367 | + if(isset($D['options']) && isset($D['options']['hidden']) && $D['options']['hidden']) |
|
368 | + continue; |
|
369 | + $disp = $D['display']; |
|
370 | + if($this->version == 1) { |
|
371 | + if($D['id'] === '0') { |
|
372 | + $profile_redirect = 1; |
|
373 | + $disp = $c; |
|
374 | + } |
|
375 | 375 | $return_array[] = ['id'=>$D['id'], 'display'=>$disp, 'status'=>$D['status'], 'redirect'=>$D['redirect']]; |
376 | - } else { |
|
377 | - if($D['device'] === '0') { |
|
378 | - $profile_redirect = 1; |
|
379 | - $disp = $c; |
|
380 | - } |
|
376 | + } else { |
|
377 | + if($D['device'] === '0') { |
|
378 | + $profile_redirect = 1; |
|
379 | + $disp = $c; |
|
380 | + } |
|
381 | 381 | $return_array[] = ['device'=>$D['id'], 'display'=>$disp, 'status'=>$D['status'], 'redirect'=>$D['redirect']]; |
382 | - } |
|
383 | - } |
|
382 | + } |
|
383 | + } |
|
384 | 384 | |
385 | - } |
|
386 | - echo $this->return_json($return_array); |
|
385 | + } |
|
386 | + echo $this->return_json($return_array); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | /** |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | * @param int $prof_id profile identifier |
394 | 394 | * @return string JSON encoded data |
395 | 395 | */ |
396 | - public function JSON_generateInstaller($device,$prof_id) { |
|
396 | + public function JSON_generateInstaller($device,$prof_id) { |
|
397 | 397 | debug(4,"JSON::generateInstaller arguments: $device,$prof_id\n"); |
398 | 398 | $o = $this->generateInstaller($device,$prof_id); |
399 | 399 | debug(4,"output from GUI::generateInstaller:"); |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | debug(4,json_encode($o)); |
402 | 402 | // header('Content-type: application/json; utf-8'); |
403 | 403 | echo $this->return_json($o); |
404 | - } |
|
404 | + } |
|
405 | 405 | |
406 | 406 | /** |
407 | 407 | * Generate and send the installer |
@@ -411,14 +411,14 @@ discard block |
||
411 | 411 | * @return binary installerFile |
412 | 412 | */ |
413 | 413 | |
414 | - public function downloadInstaller($device,$prof_id,$generated_for='user') { |
|
414 | + public function downloadInstaller($device,$prof_id,$generated_for='user') { |
|
415 | 415 | debug(4,"downloadInstaller arguments: $device,$prof_id,$generated_for\n"); |
416 | 416 | $o = $this->generateInstaller($device,$prof_id); |
417 | 417 | debug(4,"output from GUI::generateInstaller:"); |
418 | 418 | debug(4,$o); |
419 | 419 | if(! $o['link']) { |
420 | - header("HTTP/1.0 404 Not Found"); |
|
421 | - return; |
|
420 | + header("HTTP/1.0 404 Not Found"); |
|
421 | + return; |
|
422 | 422 | } |
423 | 423 | $profile = new Profile($prof_id); |
424 | 424 | $profile->incrementDownloadStats($device, $generated_for); |
@@ -431,242 +431,242 @@ discard block |
||
431 | 431 | ob_clean(); |
432 | 432 | flush(); |
433 | 433 | readfile($file); |
434 | - } |
|
434 | + } |
|
435 | 435 | /** |
436 | - * Get and prepare logo file |
|
437 | - * |
|
438 | - * When called for DiscoJuice, first check if file cache exists |
|
439 | - * If not then generate the file and save it in the cache |
|
440 | - * @param int $idp_id IdP identifier |
|
441 | - * @param int $disco flag turning on image generation for DiscoJuice |
|
442 | - * @param int $width, $height maximum width and height of the generated image |
|
443 | - * if one of these is 0 then it is treated as no upper bound |
|
444 | - * |
|
445 | - */ |
|
436 | + * Get and prepare logo file |
|
437 | + * |
|
438 | + * When called for DiscoJuice, first check if file cache exists |
|
439 | + * If not then generate the file and save it in the cache |
|
440 | + * @param int $idp_id IdP identifier |
|
441 | + * @param int $disco flag turning on image generation for DiscoJuice |
|
442 | + * @param int $width, $height maximum width and height of the generated image |
|
443 | + * if one of these is 0 then it is treated as no upper bound |
|
444 | + * |
|
445 | + */ |
|
446 | + |
|
447 | + public function sendLogo($idp_id, $disco=FALSE, $width=0, $height=0) { |
|
448 | + $ExpStr = ''; |
|
449 | + $resize = 0; |
|
450 | + if(($width || $height) && is_numeric($width) && is_numeric($height)) { |
|
451 | + $resize = 1; |
|
452 | + if($height == 0) |
|
453 | + $height = 10000; |
|
454 | + if($width == 0) |
|
455 | + $width = 10000; |
|
456 | + $logo_file = CAT::$root.'/web/downloads/logos/'.$idp_id.'_'.$width.'_'.$height.'.png'; |
|
457 | + } elseif($disco == 1) { |
|
458 | + $width = 120; |
|
459 | + $height = 40; |
|
460 | + $resize = 1; |
|
461 | + $logo_file = CAT::$root.'/web/downloads/logos/'.$idp_id.'_'.$width.'_'.$height.'.png'; |
|
462 | + } |
|
446 | 463 | |
447 | - public function sendLogo($idp_id, $disco=FALSE, $width=0, $height=0) { |
|
448 | - $ExpStr = ''; |
|
449 | - $resize = 0; |
|
450 | - if(($width || $height) && is_numeric($width) && is_numeric($height)) { |
|
451 | - $resize = 1; |
|
452 | - if($height == 0) |
|
453 | - $height = 10000; |
|
454 | - if($width == 0) |
|
455 | - $width = 10000; |
|
456 | - $logo_file = CAT::$root.'/web/downloads/logos/'.$idp_id.'_'.$width.'_'.$height.'.png'; |
|
457 | - } elseif($disco == 1) { |
|
458 | - $width = 120; |
|
459 | - $height = 40; |
|
460 | - $resize = 1; |
|
461 | - $logo_file = CAT::$root.'/web/downloads/logos/'.$idp_id.'_'.$width.'_'.$height.'.png'; |
|
462 | - } |
|
463 | - |
|
464 | - if($resize && is_file($logo_file)){ |
|
465 | - debug(4,"Using cached logo $logo_file for: $idp_id\n"); |
|
466 | - $blob = file_get_contents($logo_file); |
|
467 | - $filetype = 'image/png'; |
|
468 | - } |
|
469 | - else { |
|
470 | - $idp = new IdP($idp_id); |
|
471 | - $at = $idp->getAttributes('general:logo_file'); |
|
472 | - $blob = $at[0]['value']; |
|
473 | - $info = new finfo(); |
|
474 | - $filetype = $info->buffer($blob, FILEINFO_MIME_TYPE); |
|
475 | - $offset = 60 * 60 * 24 * 30; |
|
476 | - $ExpStr = "Expires: " . gmdate( "D, d M Y H:i:s", time() + $offset ) . " GMT"; |
|
477 | - if($resize) { |
|
478 | - $filetype = 'image/png'; |
|
479 | - $image = new Imagick(); |
|
480 | - $image->readImageBlob($blob); |
|
481 | - if( $image->setImageFormat('PNG')) { |
|
482 | - $image->thumbnailImage($width,$height,1); |
|
483 | - $blob = $image->getImageBlob(); |
|
484 | - debug(4,"Writing cached logo $logo_file for: $idp_id\n"); |
|
485 | - file_put_contents($logo_file,$blob); |
|
486 | - } |
|
487 | - else |
|
488 | - $blob = "XXXXXX"; |
|
489 | - } |
|
490 | - } |
|
491 | - header( "Content-type: ".$filetype ); |
|
492 | - header( "Cache-Control:max-age=36000, must-revalidate" ); |
|
493 | - header( $ExpStr ); |
|
494 | - echo $blob; |
|
495 | - } |
|
496 | - |
|
497 | - public function locateUser() { |
|
498 | - $host = $_SERVER['REMOTE_ADDR']; |
|
499 | - $record = geoip_record_by_name($host); |
|
500 | - if($record) { |
|
501 | - $result = ['status' => 'ok']; |
|
502 | - $result['country'] = $record['country_code']; |
|
464 | + if($resize && is_file($logo_file)){ |
|
465 | + debug(4,"Using cached logo $logo_file for: $idp_id\n"); |
|
466 | + $blob = file_get_contents($logo_file); |
|
467 | + $filetype = 'image/png'; |
|
468 | + } |
|
469 | + else { |
|
470 | + $idp = new IdP($idp_id); |
|
471 | + $at = $idp->getAttributes('general:logo_file'); |
|
472 | + $blob = $at[0]['value']; |
|
473 | + $info = new finfo(); |
|
474 | + $filetype = $info->buffer($blob, FILEINFO_MIME_TYPE); |
|
475 | + $offset = 60 * 60 * 24 * 30; |
|
476 | + $ExpStr = "Expires: " . gmdate( "D, d M Y H:i:s", time() + $offset ) . " GMT"; |
|
477 | + if($resize) { |
|
478 | + $filetype = 'image/png'; |
|
479 | + $image = new Imagick(); |
|
480 | + $image->readImageBlob($blob); |
|
481 | + if( $image->setImageFormat('PNG')) { |
|
482 | + $image->thumbnailImage($width,$height,1); |
|
483 | + $blob = $image->getImageBlob(); |
|
484 | + debug(4,"Writing cached logo $logo_file for: $idp_id\n"); |
|
485 | + file_put_contents($logo_file,$blob); |
|
486 | + } |
|
487 | + else |
|
488 | + $blob = "XXXXXX"; |
|
489 | + } |
|
490 | + } |
|
491 | + header( "Content-type: ".$filetype ); |
|
492 | + header( "Cache-Control:max-age=36000, must-revalidate" ); |
|
493 | + header( $ExpStr ); |
|
494 | + echo $blob; |
|
495 | + } |
|
496 | + |
|
497 | + public function locateUser() { |
|
498 | + $host = $_SERVER['REMOTE_ADDR']; |
|
499 | + $record = geoip_record_by_name($host); |
|
500 | + if($record) { |
|
501 | + $result = ['status' => 'ok']; |
|
502 | + $result['country'] = $record['country_code']; |
|
503 | 503 | // the two lines below are a dirty hack to take of the error in naming the UK federation |
504 | - if($result['country'] == 'GB') |
|
505 | - $result['country'] = 'UK'; |
|
506 | - $result['region'] = $record['region']; |
|
507 | - $result['geo'] = ['lat' => (float)$record['latitude'] , 'lon' => (float)$record['longitude']]; |
|
508 | - } else { |
|
509 | - $result = ['status' => 'error', 'error' =>'Problem listing countries']; |
|
510 | - } |
|
511 | - return($result); |
|
512 | - } |
|
513 | - |
|
514 | - |
|
515 | - public function locateUser2() { |
|
516 | - require_once Config::$GEOIP['geoip2-path-to-autoloader']; |
|
517 | - $reader = new Reader(Config::$GEOIP['geoip2-path-to-db']); |
|
518 | - $host = $_SERVER['REMOTE_ADDR']; |
|
519 | - try { |
|
520 | - $record = $reader->city($host); |
|
521 | - } catch (Exception $e) { |
|
522 | - $result = ['status' => 'error', 'error' =>'Problem listing countries']; |
|
523 | - return($result); |
|
524 | - } |
|
525 | - $result = ['status' => 'ok']; |
|
526 | - $result['country'] = $record->country->isoCode; |
|
504 | + if($result['country'] == 'GB') |
|
505 | + $result['country'] = 'UK'; |
|
506 | + $result['region'] = $record['region']; |
|
507 | + $result['geo'] = ['lat' => (float)$record['latitude'] , 'lon' => (float)$record['longitude']]; |
|
508 | + } else { |
|
509 | + $result = ['status' => 'error', 'error' =>'Problem listing countries']; |
|
510 | + } |
|
511 | + return($result); |
|
512 | + } |
|
513 | + |
|
514 | + |
|
515 | + public function locateUser2() { |
|
516 | + require_once Config::$GEOIP['geoip2-path-to-autoloader']; |
|
517 | + $reader = new Reader(Config::$GEOIP['geoip2-path-to-db']); |
|
518 | + $host = $_SERVER['REMOTE_ADDR']; |
|
519 | + try { |
|
520 | + $record = $reader->city($host); |
|
521 | + } catch (Exception $e) { |
|
522 | + $result = ['status' => 'error', 'error' =>'Problem listing countries']; |
|
523 | + return($result); |
|
524 | + } |
|
525 | + $result = ['status' => 'ok']; |
|
526 | + $result['country'] = $record->country->isoCode; |
|
527 | 527 | // the two lines below are a dirty hack to take of the error in naming the UK federation |
528 | - if($result['country'] == 'GB') |
|
529 | - $result['country'] = 'UK'; |
|
530 | - $result['region'] = $record->continent->name; |
|
528 | + if($result['country'] == 'GB') |
|
529 | + $result['country'] = 'UK'; |
|
530 | + $result['region'] = $record->continent->name; |
|
531 | 531 | |
532 | - $result['geo'] = ['lat' => (float)$record->location->latitude , 'lon' => (float)$record->location->longitude]; |
|
533 | - return($result); |
|
534 | - } |
|
532 | + $result['geo'] = ['lat' => (float)$record->location->latitude , 'lon' => (float)$record->location->longitude]; |
|
533 | + return($result); |
|
534 | + } |
|
535 | 535 | |
536 | 536 | public function JSON_locateUser() { |
537 | 537 | header('Content-type: application/json; utf-8'); |
538 | 538 | |
539 | 539 | if(empty(Config::$GEOIP['version']) || Config::$GEOIP['version'] == 0) |
540 | - echo json_encode(['status' => 'error', 'error' =>'Geolocation not supported']); |
|
540 | + echo json_encode(['status' => 'error', 'error' =>'Geolocation not supported']); |
|
541 | 541 | if(Config::$GEOIP['version'] == 1) |
542 | - echo json_encode($this->locateUser()); |
|
542 | + echo json_encode($this->locateUser()); |
|
543 | 543 | if(Config::$GEOIP['version'] == 2) |
544 | - echo json_encode($this->locateUser2()); |
|
544 | + echo json_encode($this->locateUser2()); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | /** |
548 | 548 | * Produce support data prepared within {@link GUI::profileAttributes()} |
549 | 549 | * @return string JSON encoded data |
550 | 550 | */ |
551 | - public function JSON_profileAttributes($prof_id) { |
|
551 | + public function JSON_profileAttributes($prof_id) { |
|
552 | 552 | // header('Content-type: application/json; utf-8'); |
553 | 553 | echo $this->return_json($this->profileAttributes($prof_id)); |
554 | - } |
|
554 | + } |
|
555 | 555 | |
556 | 556 | /** |
557 | - * Calculate the distence in km between two points given their |
|
558 | - * geo coordinates. |
|
559 | - * @param array $P1 - first point as an 'lat', 'lon' array |
|
560 | - * @param array $P2 - second point as an 'lat', 'lon' array |
|
561 | - * @return float distance in km |
|
562 | - */ |
|
557 | + * Calculate the distence in km between two points given their |
|
558 | + * geo coordinates. |
|
559 | + * @param array $P1 - first point as an 'lat', 'lon' array |
|
560 | + * @param array $P2 - second point as an 'lat', 'lon' array |
|
561 | + * @return float distance in km |
|
562 | + */ |
|
563 | 563 | private function geoDistance($P1,$P2) { |
564 | 564 | |
565 | - $dist = sin(deg2rad($P1['lat'])) * sin(deg2rad($P2['lat'])) + |
|
565 | + $dist = sin(deg2rad($P1['lat'])) * sin(deg2rad($P2['lat'])) + |
|
566 | 566 | cos(deg2rad($P1['lat'])) * cos(deg2rad($P2['lat'])) * cos(deg2rad($P1['lon'] - $P2['lon'])); |
567 | - $dist = rad2deg(acos($dist)) * 60 * 1.1852 ; |
|
568 | - return(round($dist)); |
|
567 | + $dist = rad2deg(acos($dist)) * 60 * 1.1852 ; |
|
568 | + return(round($dist)); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | /** |
572 | - * Order active identity providers according to their distance and name |
|
573 | - * @param array $L - current location |
|
574 | - * @return array $IdPs - list of arrays ('id', 'name'); |
|
575 | - */ |
|
572 | + * Order active identity providers according to their distance and name |
|
573 | + * @param array $L - current location |
|
574 | + * @return array $IdPs - list of arrays ('id', 'name'); |
|
575 | + */ |
|
576 | 576 | |
577 | 577 | public function orderIdentityProviders($country,$L=NULL) { |
578 | - $idps = Federation::listAllIdentityProviders(1,$country); |
|
579 | - |
|
580 | - if(is_null($L)) { |
|
581 | - $U = $this->locateUser(); |
|
582 | - if($U['status'] == 'ok') { |
|
583 | - $L = $U['geo']; |
|
584 | - } else { |
|
585 | - $L = ['lat'=>"90",'lon'=>"0"]; |
|
586 | - } |
|
587 | - } |
|
588 | - $T=[]; |
|
589 | - $R=[]; |
|
590 | - foreach ($idps as $idp) { |
|
578 | + $idps = Federation::listAllIdentityProviders(1,$country); |
|
579 | + |
|
580 | + if(is_null($L)) { |
|
581 | + $U = $this->locateUser(); |
|
582 | + if($U['status'] == 'ok') { |
|
583 | + $L = $U['geo']; |
|
584 | + } else { |
|
585 | + $L = ['lat'=>"90",'lon'=>"0"]; |
|
586 | + } |
|
587 | + } |
|
588 | + $T=[]; |
|
589 | + $R=[]; |
|
590 | + foreach ($idps as $idp) { |
|
591 | 591 | $T[$idp['entityID']] = $idp['title']; |
592 | 592 | $dist = 10000; |
593 | 593 | if(isset($idp['geo'])) { |
594 | - $G=$idp['geo']; |
|
595 | - if(isset($G['lon'])) { |
|
596 | - $d1 = $this->geoDistance($L,$G); |
|
597 | - if( $d1 < $dist) |
|
594 | + $G=$idp['geo']; |
|
595 | + if(isset($G['lon'])) { |
|
596 | + $d1 = $this->geoDistance($L,$G); |
|
597 | + if( $d1 < $dist) |
|
598 | 598 | $dist = $d1; |
599 | - } else { |
|
599 | + } else { |
|
600 | 600 | foreach ($G as $g) { |
601 | - $d1 = $this->geoDistance($L,$g); |
|
602 | - if( $d1 < $dist) |
|
601 | + $d1 = $this->geoDistance($L,$g); |
|
602 | + if( $d1 < $dist) |
|
603 | 603 | $dist = $d1; |
604 | 604 | } |
605 | - } |
|
605 | + } |
|
606 | 606 | } |
607 | - if($dist > 100) |
|
608 | - $dist=10000; |
|
609 | - $d = sprintf("%06d",$dist); |
|
610 | - $R[$idp['entityID']] = $d." ".$idp['title']; |
|
611 | - } |
|
612 | - asort($R); |
|
613 | - foreach (array_keys($R) as $r) { |
|
614 | - if($this->version == 1) |
|
615 | - $outarray[] = ['id'=>$r, 'title'=>$T[$r]]; |
|
616 | - else |
|
617 | - $outarray[] = ['idp'=>$r, 'title'=>$T[$r]]; |
|
618 | - } |
|
619 | - return($outarray); |
|
607 | + if($dist > 100) |
|
608 | + $dist=10000; |
|
609 | + $d = sprintf("%06d",$dist); |
|
610 | + $R[$idp['entityID']] = $d." ".$idp['title']; |
|
611 | + } |
|
612 | + asort($R); |
|
613 | + foreach (array_keys($R) as $r) { |
|
614 | + if($this->version == 1) |
|
615 | + $outarray[] = ['id'=>$r, 'title'=>$T[$r]]; |
|
616 | + else |
|
617 | + $outarray[] = ['idp'=>$r, 'title'=>$T[$r]]; |
|
618 | + } |
|
619 | + return($outarray); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | /** |
623 | - * Detect the best device driver form the browser |
|
624 | - * |
|
625 | - * Detects the operating system and returns its id |
|
626 | - * display name and group membership (as in devices.php) |
|
627 | - * @return array indexed by 'id', 'display', 'group' |
|
628 | - */ |
|
623 | + * Detect the best device driver form the browser |
|
624 | + * |
|
625 | + * Detects the operating system and returns its id |
|
626 | + * display name and group membership (as in devices.php) |
|
627 | + * @return array indexed by 'id', 'display', 'group' |
|
628 | + */ |
|
629 | 629 | |
630 | 630 | public function detectOS() { |
631 | - $Dev = Devices::listDevices(); |
|
632 | - if( isset($_REQUEST['device']) && isset($Dev[$_REQUEST['device']]) && (!isset($device['options']['hidden']) || $device['options']['hidden'] == 0)) { |
|
633 | - $dev_id = $_REQUEST['device']; |
|
634 | - $device = $Dev[$dev_id]; |
|
635 | - if($this->version == 1) |
|
636 | - return(['id'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
637 | - else |
|
638 | - return(['device'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
639 | - } |
|
640 | - $browser = $_SERVER['HTTP_USER_AGENT']; |
|
641 | - debug(4,"HTTP_USER_AGENT=$browser\n"); |
|
642 | - foreach ($Dev as $dev_id => $device) { |
|
643 | - if(!isset($device['match'])) |
|
631 | + $Dev = Devices::listDevices(); |
|
632 | + if( isset($_REQUEST['device']) && isset($Dev[$_REQUEST['device']]) && (!isset($device['options']['hidden']) || $device['options']['hidden'] == 0)) { |
|
633 | + $dev_id = $_REQUEST['device']; |
|
634 | + $device = $Dev[$dev_id]; |
|
635 | + if($this->version == 1) |
|
636 | + return(['id'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
637 | + else |
|
638 | + return(['device'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
639 | + } |
|
640 | + $browser = $_SERVER['HTTP_USER_AGENT']; |
|
641 | + debug(4,"HTTP_USER_AGENT=$browser\n"); |
|
642 | + foreach ($Dev as $dev_id => $device) { |
|
643 | + if(!isset($device['match'])) |
|
644 | 644 | continue; |
645 | - if(preg_match('/'.$device['match'].'/',$browser)) { |
|
646 | - if(!isset($device['options']['hidden']) || $device['options']['hidden'] == 0) { |
|
647 | - debug(4,"Browser_id: $dev_id\n"); |
|
648 | - if($this->version == 1) |
|
649 | - return(['id'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
650 | - else |
|
651 | - return(['device'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
652 | - } |
|
653 | - else { |
|
654 | - debug(2, "Unrecognised system: ".$_SERVER['HTTP_USER_AGENT']."\n"); |
|
655 | - return(false); |
|
656 | - } |
|
657 | - } |
|
658 | - } |
|
659 | - debug(2, "Unrecognised system: ".$_SERVER['HTTP_USER_AGENT']."\n"); |
|
660 | - return(false); |
|
645 | + if(preg_match('/'.$device['match'].'/',$browser)) { |
|
646 | + if(!isset($device['options']['hidden']) || $device['options']['hidden'] == 0) { |
|
647 | + debug(4,"Browser_id: $dev_id\n"); |
|
648 | + if($this->version == 1) |
|
649 | + return(['id'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
650 | + else |
|
651 | + return(['device'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
652 | + } |
|
653 | + else { |
|
654 | + debug(2, "Unrecognised system: ".$_SERVER['HTTP_USER_AGENT']."\n"); |
|
655 | + return(false); |
|
656 | + } |
|
657 | + } |
|
658 | + } |
|
659 | + debug(2, "Unrecognised system: ".$_SERVER['HTTP_USER_AGENT']."\n"); |
|
660 | + return(false); |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | public function JSON_detectOS() { |
664 | - $return_array=$this->detectOS(); |
|
665 | - if($return_array) |
|
664 | + $return_array=$this->detectOS(); |
|
665 | + if($return_array) |
|
666 | 666 | $status = 1; |
667 | - else |
|
667 | + else |
|
668 | 668 | $status = 0; |
669 | - echo $this->return_json($return_array,$status); |
|
669 | + echo $this->return_json($return_array,$status); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | |
@@ -676,5 +676,5 @@ discard block |
||
676 | 676 | |
677 | 677 | } |
678 | 678 | function profile_sort($P1,$P2) { |
679 | - return strcasecmp($P1->name, $P2->name); |
|
679 | + return strcasecmp($P1->name, $P2->name); |
|
680 | 680 | } |
681 | 681 | \ No newline at end of file |
@@ -26,66 +26,66 @@ discard block |
||
26 | 26 | */ |
27 | 27 | class Device_Vista7 extends WindowsCommon { |
28 | 28 | final public function __construct() { |
29 | - $this->supportedEapMethods = [EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$PWD]; |
|
30 | - debug(4,"This device supports the following EAP methods: "); |
|
31 | - debug(4,$this->supportedEapMethods); |
|
32 | - $this->specialities['anon_id'][serialize(EAP::$PEAP_MSCHAP2)] = _("Anonymous identities do not use the realm as specified in the profile - it is derived from the suffix of the user's username input instead."); |
|
29 | + $this->supportedEapMethods = [EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$PWD]; |
|
30 | + debug(4,"This device supports the following EAP methods: "); |
|
31 | + debug(4,$this->supportedEapMethods); |
|
32 | + $this->specialities['anon_id'][serialize(EAP::$PEAP_MSCHAP2)] = _("Anonymous identities do not use the realm as specified in the profile - it is derived from the suffix of the user's username input instead."); |
|
33 | 33 | } |
34 | 34 | |
35 | - public function writeInstaller() { |
|
36 | - $dom = textdomain(NULL); |
|
37 | - textdomain("devices"); |
|
38 | - // create certificate files and save their names in $CA_files arrary |
|
39 | - $CA_files = $this->saveCertificateFiles('der'); |
|
35 | + public function writeInstaller() { |
|
36 | + $dom = textdomain(NULL); |
|
37 | + textdomain("devices"); |
|
38 | + // create certificate files and save their names in $CA_files arrary |
|
39 | + $CA_files = $this->saveCertificateFiles('der'); |
|
40 | 40 | |
41 | - $SSIDs = $this->attributes['internal:SSID']; |
|
42 | - $delSSIDs = $this->attributes['internal:remove_SSID']; |
|
43 | - $this->prepareInstallerLang(); |
|
44 | - $set_wired = isset($this->attributes['media:wired'][0]) && $this->attributes['media:wired'][0] == 'on' ? 1 : 0; |
|
41 | + $SSIDs = $this->attributes['internal:SSID']; |
|
42 | + $delSSIDs = $this->attributes['internal:remove_SSID']; |
|
43 | + $this->prepareInstallerLang(); |
|
44 | + $set_wired = isset($this->attributes['media:wired'][0]) && $this->attributes['media:wired'][0] == 'on' ? 1 : 0; |
|
45 | 45 | // create a list of profiles to be deleted after installation |
46 | - $delProfiles = []; |
|
47 | - foreach ($delSSIDs as $ssid => $cipher) { |
|
48 | - if($cipher == 'DEL') |
|
49 | - $delProfiles[] = $ssid; |
|
50 | - if($cipher == 'TKIP') |
|
51 | - $delProfiles[] = $ssid.' (TKIP)'; |
|
52 | - } |
|
53 | - |
|
54 | - if ($this->selected_eap == EAP::$TLS || $this->selected_eap == EAP::$PEAP_MSCHAP2 || $this->selected_eap == EAP::$PWD || $this->selected_eap == EAP::$TTLS_PAP) { |
|
55 | - $WindowsProfile = []; |
|
56 | - $eap_config = $this->prepareEapConfig($this->attributes); |
|
57 | - $i = 0; |
|
58 | - foreach ($SSIDs as $ssid => $cipher) { |
|
59 | - if($cipher == 'TKIP') { |
|
60 | - $WindowsProfile[$i] = $this->writeWLANprofile ($ssid.' (TKIP)',$ssid,'WPA','TKIP',$eap_config,$i); |
|
61 | - $i++; |
|
62 | - } |
|
63 | - $WindowsProfile[$i] = $this->writeWLANprofile ($ssid,$ssid,'WPA2','AES',$eap_config,$i); |
|
64 | - $i++; |
|
65 | - } |
|
66 | - if($set_wired) { |
|
67 | - $this->writeLANprofile($eap_config); |
|
68 | - } |
|
69 | - } else { |
|
70 | - error(" this EAP type is not handled yet"); |
|
71 | - return; |
|
72 | - } |
|
46 | + $delProfiles = []; |
|
47 | + foreach ($delSSIDs as $ssid => $cipher) { |
|
48 | + if($cipher == 'DEL') |
|
49 | + $delProfiles[] = $ssid; |
|
50 | + if($cipher == 'TKIP') |
|
51 | + $delProfiles[] = $ssid.' (TKIP)'; |
|
52 | + } |
|
53 | + |
|
54 | + if ($this->selected_eap == EAP::$TLS || $this->selected_eap == EAP::$PEAP_MSCHAP2 || $this->selected_eap == EAP::$PWD || $this->selected_eap == EAP::$TTLS_PAP) { |
|
55 | + $WindowsProfile = []; |
|
56 | + $eap_config = $this->prepareEapConfig($this->attributes); |
|
57 | + $i = 0; |
|
58 | + foreach ($SSIDs as $ssid => $cipher) { |
|
59 | + if($cipher == 'TKIP') { |
|
60 | + $WindowsProfile[$i] = $this->writeWLANprofile ($ssid.' (TKIP)',$ssid,'WPA','TKIP',$eap_config,$i); |
|
61 | + $i++; |
|
62 | + } |
|
63 | + $WindowsProfile[$i] = $this->writeWLANprofile ($ssid,$ssid,'WPA2','AES',$eap_config,$i); |
|
64 | + $i++; |
|
65 | + } |
|
66 | + if($set_wired) { |
|
67 | + $this->writeLANprofile($eap_config); |
|
68 | + } |
|
69 | + } else { |
|
70 | + error(" this EAP type is not handled yet"); |
|
71 | + return; |
|
72 | + } |
|
73 | 73 | debug(4,"WindowsProfile"); debug(4,$WindowsProfile); |
74 | 74 | |
75 | 75 | $this->writeProfilesNSH($WindowsProfile, $CA_files,$set_wired); |
76 | 76 | $this->writeAdditionalDeletes($delProfiles); |
77 | 77 | $this->copyFiles($this->selected_eap); |
78 | 78 | if(isset($this->attributes['internal:logo_file'])) |
79 | - $this->combineLogo($this->attributes['internal:logo_file']); |
|
79 | + $this->combineLogo($this->attributes['internal:logo_file']); |
|
80 | 80 | $this->writeMainNSH($this->selected_eap,$this->attributes); |
81 | 81 | $this->compileNSIS(); |
82 | 82 | $installer_path = $this->signInstaller($this->attributes); |
83 | 83 | |
84 | 84 | textdomain($dom); |
85 | 85 | return($installer_path); |
86 | - } |
|
86 | + } |
|
87 | 87 | |
88 | - public function writeDeviceInfo() { |
|
88 | + public function writeDeviceInfo() { |
|
89 | 89 | $ssid_ct=count($this->attributes['internal:SSID']); |
90 | 90 | $out = "<p>"; |
91 | 91 | $out .= sprintf(_("%s installer will be in the form of an EXE file. It will configure %s on your device, by creating wireless network profiles.<p>When you click the download button, the installer will be saved by your browser. Copy it to the machine you want to configure and execute."),Config::$CONSORTIUM['name'],Config::$CONSORTIUM['name']); |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to:"),implode(', ',Config::$CONSORTIUM['ssid']))." "; |
98 | 98 | $i = 0; |
99 | 99 | foreach ($this->attributes['internal:SSID'] as $ssid=>$v) { |
100 | - if(! in_array($ssid, Config::$CONSORTIUM['ssid'])) { |
|
101 | - if($i > 0) |
|
102 | - $out .= ", "; |
|
103 | - $i++; |
|
104 | - $out .= "<strong>$ssid</strong>"; |
|
105 | - } |
|
100 | + if(! in_array($ssid, Config::$CONSORTIUM['ssid'])) { |
|
101 | + if($i > 0) |
|
102 | + $out .= ", "; |
|
103 | + $i++; |
|
104 | + $out .= "<strong>$ssid</strong>"; |
|
105 | + } |
|
106 | 106 | } |
107 | 107 | $out .= "<p>"; |
108 | 108 | } |
@@ -115,21 +115,21 @@ discard block |
||
115 | 115 | $out .= "<p>"; |
116 | 116 | $out .= _("When you are connecting to the network for the first time, Windows will pop up a login box, where you should enter your user name and password. This information will be saved so that you will reconnect to the network automatically each time you are in the range."); |
117 | 117 | if($ssid_ct > 1) { |
118 | - $out .= "<p>"; |
|
119 | - $out .= _("You will be required to enter the same credentials for each of the configured notworks:")." "; |
|
120 | - $i = 0; |
|
118 | + $out .= "<p>"; |
|
119 | + $out .= _("You will be required to enter the same credentials for each of the configured notworks:")." "; |
|
120 | + $i = 0; |
|
121 | 121 | foreach ($this->attributes['internal:SSID'] as $ssid=>$v) { |
122 | - if($i > 0) |
|
123 | - $out .= ", "; |
|
124 | - $i++; |
|
125 | - $out .= "<strong>$ssid</strong>"; |
|
122 | + if($i > 0) |
|
123 | + $out .= ", "; |
|
124 | + $i++; |
|
125 | + $out .= "<strong>$ssid</strong>"; |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | - } |
|
129 | + } |
|
130 | 130 | |
131 | - } |
|
132 | - return($out); |
|
131 | + } |
|
132 | + return($out); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | private function prepareEapConfig($attr) { |
@@ -137,25 +137,25 @@ discard block |
||
137 | 137 | $w7_ext = ''; |
138 | 138 | $eap = $this->selected_eap; |
139 | 139 | if ($eap != EAP::$TLS && $eap != EAP::$PEAP_MSCHAP2 && $eap != EAP::$PWD && $eap != EAP::$TTLS_PAP) { |
140 | - debug(2,"this method only allows TLS, PEAP, TTLS-PAP or EAP-pwd"); |
|
141 | - error("this method only allows TLS, PEAP, TTLS-PAP or EAP-pwd"); |
|
142 | - return; |
|
140 | + debug(2,"this method only allows TLS, PEAP, TTLS-PAP or EAP-pwd"); |
|
141 | + error("this method only allows TLS, PEAP, TTLS-PAP or EAP-pwd"); |
|
142 | + return; |
|
143 | + } |
|
144 | + $use_anon = $attr['internal:use_anon_outer'] [0]; |
|
145 | + $realm = $attr['internal:realm'] [0]; |
|
146 | + if ($use_anon) { |
|
147 | + $outer_user = $attr['internal:anon_local_value'][0]; |
|
143 | 148 | } |
144 | - $use_anon = $attr['internal:use_anon_outer'] [0]; |
|
145 | - $realm = $attr['internal:realm'] [0]; |
|
146 | - if ($use_anon) { |
|
147 | - $outer_user = $attr['internal:anon_local_value'][0]; |
|
148 | - } |
|
149 | 149 | // $servers = preg_quote(implode(';',$attr['eap:server_name'])); |
150 | - $servers = implode(';',$attr['eap:server_name']); |
|
151 | - $ca_array = $attr['internal:CAs'][0]; |
|
152 | - $author_id = "0"; |
|
153 | - if( $eap == EAP::$TTLS_PAP) { |
|
154 | - $author_id = "17236"; |
|
155 | - $servers = implode('</ServerName><ServerName>',$attr['eap:server_name']); |
|
156 | - } |
|
157 | - |
|
158 | - $profile_file_contents = '<EAPConfig><EapHostConfig xmlns="http://www.microsoft.com/provisioning/EapHostConfig"> |
|
150 | + $servers = implode(';',$attr['eap:server_name']); |
|
151 | + $ca_array = $attr['internal:CAs'][0]; |
|
152 | + $author_id = "0"; |
|
153 | + if( $eap == EAP::$TTLS_PAP) { |
|
154 | + $author_id = "17236"; |
|
155 | + $servers = implode('</ServerName><ServerName>',$attr['eap:server_name']); |
|
156 | + } |
|
157 | + |
|
158 | + $profile_file_contents = '<EAPConfig><EapHostConfig xmlns="http://www.microsoft.com/provisioning/EapHostConfig"> |
|
159 | 159 | <EapMethod> |
160 | 160 | <Type xmlns="http://www.microsoft.com/provisioning/EapCommon">'. |
161 | 161 | $this->selected_eap["OUTER"] .'</Type> |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | '; |
167 | 167 | |
168 | 168 | |
169 | - if( $eap == EAP::$TTLS_PAP) { |
|
169 | + if( $eap == EAP::$TTLS_PAP) { |
|
170 | 170 | $profile_file_contents .= ' |
171 | 171 | <Config xmlns="http://www.microsoft.com/provisioning/EapHostConfig"> |
172 | 172 | <EAPIdentityProviderList xmlns="urn:ietf:params:xml:ns:yang:ietf-eap-metadata"> |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | $profile_file_contents .= '<ServerSideCredential> |
202 | 202 | '; |
203 | 203 | |
204 | - foreach ($ca_array as $ca) { |
|
204 | + foreach ($ca_array as $ca) { |
|
205 | 205 | |
206 | - $profile_file_contents .= '<CA><format>PEM</format><cert-data>'; |
|
207 | - $profile_file_contents .= base64_encode($ca['der']); |
|
208 | - $profile_file_contents .= '</cert-data></CA> |
|
206 | + $profile_file_contents .= '<CA><format>PEM</format><cert-data>'; |
|
207 | + $profile_file_contents .= base64_encode($ca['der']); |
|
208 | + $profile_file_contents .= '</cert-data></CA> |
|
209 | 209 | '; |
210 | - } |
|
211 | - $profile_file_contents .= "<ServerName>$servers</ServerName>\n"; |
|
210 | + } |
|
211 | + $profile_file_contents .= "<ServerName>$servers</ServerName>\n"; |
|
212 | 212 | |
213 | 213 | $profile_file_contents .= ' |
214 | 214 | </ServerSideCredential> |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | } |
229 | 229 | |
230 | 230 | elseif( $eap == EAP::$TLS) { |
231 | - $profile_file_contents .= ' |
|
231 | + $profile_file_contents .= ' |
|
232 | 232 | |
233 | 233 | <Config xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1" |
234 | 234 | xmlns:eapTls="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV1"> |
@@ -244,14 +244,14 @@ discard block |
||
244 | 244 | if($ca_array) { |
245 | 245 | foreach ($ca_array as $CA) |
246 | 246 | if($CA['root']) |
247 | - $profile_file_contents .= "<eapTls:TrustedRootCA>".$CA['sha1']."</eapTls:TrustedRootCA>\n"; |
|
247 | + $profile_file_contents .= "<eapTls:TrustedRootCA>".$CA['sha1']."</eapTls:TrustedRootCA>\n"; |
|
248 | 248 | } |
249 | 249 | $profile_file_contents .= '</eapTls:ServerValidation> |
250 | 250 | '; |
251 | 251 | if(isset($attr['eap-specific:tls_use_other_id']) && $attr['eap-specific:tls_use_other_id'][0] == 'on') |
252 | - $profile_file_contents .= '<eapTls:DifferentUsername>true</eapTls:DifferentUsername>'; |
|
252 | + $profile_file_contents .= '<eapTls:DifferentUsername>true</eapTls:DifferentUsername>'; |
|
253 | 253 | else |
254 | - $profile_file_contents .= '<eapTls:DifferentUsername>false</eapTls:DifferentUsername>'; |
|
254 | + $profile_file_contents .= '<eapTls:DifferentUsername>false</eapTls:DifferentUsername>'; |
|
255 | 255 | $profile_file_contents .= ' |
256 | 256 | </eapTls:EapType> |
257 | 257 | </baseEap:Eap> |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | '; |
260 | 260 | } elseif ( $eap == EAP::$PEAP_MSCHAP2) { |
261 | 261 | if(isset($attr['eap:enable_nea']) && $attr['eap:enable_nea'][0] == 'on') |
262 | - $nea = 'true'; |
|
262 | + $nea = 'true'; |
|
263 | 263 | else |
264 | - $nea = 'false'; |
|
264 | + $nea = 'false'; |
|
265 | 265 | $vista_ext = '<Config xmlns:eapUser="http://www.microsoft.com/provisioning/EapUserPropertiesV1" |
266 | 266 | xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1" |
267 | 267 | xmlns:msPeap="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV1" |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | if($ca_array) { |
276 | 276 | foreach ($ca_array as $CA) |
277 | 277 | if($CA['root']) |
278 | - $vista_ext .= "<msPeap:TrustedRootCA>".$CA['sha1']."</msPeap:TrustedRootCA>\n"; |
|
278 | + $vista_ext .= "<msPeap:TrustedRootCA>".$CA['sha1']."</msPeap:TrustedRootCA>\n"; |
|
279 | 279 | } |
280 | 280 | $vista_ext .= '</msPeap:ServerValidation> |
281 | 281 | <msPeap:FastReconnect>true</msPeap:FastReconnect> |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | </Config> |
330 | 330 | '; |
331 | 331 | } elseif ( $eap == EAP::$PWD) { |
332 | - $profile_file_contents .= '<ConfigBlob></ConfigBlob>'; |
|
332 | + $profile_file_contents .= '<ConfigBlob></ConfigBlob>'; |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | /** |
352 | 352 | * produce PEAP and TLS configuration files for Vista and Windows 7 |
353 | 353 | */ |
354 | - private function writeWLANprofile($wlan_profile_name,$ssid,$auth,$encryption,$eap_config,$i) { |
|
354 | + private function writeWLANprofile($wlan_profile_name,$ssid,$auth,$encryption,$eap_config,$i) { |
|
355 | 355 | $profile_file_contents = '<?xml version="1.0"?> |
356 | 356 | <WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1"> |
357 | 357 | <name>'.$wlan_profile_name.'</name> |
@@ -391,9 +391,9 @@ discard block |
||
391 | 391 | '; |
392 | 392 | |
393 | 393 | if(! is_dir('w7')) |
394 | - mkdir('w7'); |
|
394 | + mkdir('w7'); |
|
395 | 395 | if(! is_dir('vista')) |
396 | - mkdir('vista'); |
|
396 | + mkdir('vista'); |
|
397 | 397 | $xml_f_name = "vista/wlan_prof-$i.xml"; |
398 | 398 | $xml_f = fopen($xml_f_name,'w'); |
399 | 399 | fwrite($xml_f,$profile_file_contents. $eap_config['vista']. $closing) ; |
@@ -423,9 +423,9 @@ discard block |
||
423 | 423 | </LANProfile> |
424 | 424 | '; |
425 | 425 | if(! is_dir('w7')) |
426 | - mkdir('w7'); |
|
426 | + mkdir('w7'); |
|
427 | 427 | if(! is_dir('vista')) |
428 | - mkdir('vista'); |
|
428 | + mkdir('vista'); |
|
429 | 429 | $xml_f_name = "vista/lan_prof.xml"; |
430 | 430 | $xml_f = fopen($xml_f_name,'w'); |
431 | 431 | fwrite($xml_f,$profile_file_contents. $eap_config['vista']. $closing) ; |
@@ -438,16 +438,16 @@ discard block |
||
438 | 438 | |
439 | 439 | private function glueServerNames($server_list) { |
440 | 440 | //print_r($server_list); |
441 | - $A0 = array_reverse(explode('.',array_shift($server_list))); |
|
442 | - $B = $A0; |
|
443 | - if($server_list) { |
|
444 | - foreach($server_list as $a) { |
|
445 | - $A= array_reverse(explode('.',$a)); |
|
446 | - $B = array_intersect_assoc($A0,$A); |
|
447 | - $A0 = $B; |
|
448 | - } |
|
449 | - } |
|
450 | - return(implode('.',array_reverse($B))); |
|
441 | + $A0 = array_reverse(explode('.',array_shift($server_list))); |
|
442 | + $B = $A0; |
|
443 | + if($server_list) { |
|
444 | + foreach($server_list as $a) { |
|
445 | + $A= array_reverse(explode('.',$a)); |
|
446 | + $B = array_intersect_assoc($A0,$A); |
|
447 | + $A0 = $B; |
|
448 | + } |
|
449 | + } |
|
450 | + return(implode('.',array_reverse($B))); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | '; |
503 | 503 | |
504 | 504 | if(isset($this->attributes['media:wired'][0]) && $attr['media:wired'][0] == 'on') |
505 | - $fcontents .= '!define WIRED |
|
505 | + $fcontents .= '!define WIRED |
|
506 | 506 | '; |
507 | 507 | |
508 | 508 | $f = fopen('main.nsh','w'); |
@@ -514,8 +514,8 @@ discard block |
||
514 | 514 | private function writeProfilesNSH($P,$ca_array,$wired=0) { |
515 | 515 | debug(4,"writeProfilesNSH"); |
516 | 516 | debug(4,$P); |
517 | - $fcontents = ''; |
|
518 | - foreach($P as $p) |
|
517 | + $fcontents = ''; |
|
518 | + foreach($P as $p) |
|
519 | 519 | $fcontents .= "!insertmacro define_wlan_profile $p\n"; |
520 | 520 | |
521 | 521 | $f = fopen('profiles.nsh','w'); |
@@ -526,8 +526,8 @@ discard block |
||
526 | 526 | $f = fopen('certs.nsh','w'); |
527 | 527 | if($ca_array) { |
528 | 528 | foreach ($ca_array as $CA) { |
529 | - $store = $CA['root'] ? "root" : "ca"; |
|
530 | - $fcontents .= '!insertmacro install_ca_cert "'.$CA['file'].'" "'.$CA['sha1'].'" "'.$store."\"\n"; |
|
529 | + $store = $CA['root'] ? "root" : "ca"; |
|
530 | + $fcontents .= '!insertmacro install_ca_cert "'.$CA['file'].'" "'.$CA['sha1'].'" "'.$store."\"\n"; |
|
531 | 531 | } |
532 | 532 | fwrite($f, $fcontents); |
533 | 533 | } |
@@ -537,33 +537,33 @@ discard block |
||
537 | 537 | private function copyFiles ($eap) { |
538 | 538 | debug(4,"copyFiles start\n"); |
539 | 539 | debug(4,"code_page=".$this->code_page."\n"); |
540 | - $result; |
|
541 | - $result = $this->copyFile('wlan_test.exe'); |
|
542 | - $result = $this->copyFile('check_wired.cmd'); |
|
543 | - $result = $this->copyFile('install_wired.cmd'); |
|
544 | - $result = $this->copyFile('setEAPCred.exe'); |
|
545 | - $result = $this->copyFile('base64.nsh'); |
|
546 | - $result = $this->copyFile('cat_bg.bmp'); |
|
547 | - $result = $result && $this->copyFile('cat32.ico'); |
|
548 | - $result = $result && $this->copyFile('cat_150.bmp'); |
|
549 | - $this->translateFile('common.inc','common.nsh',$this->code_page); |
|
550 | - if( $eap["OUTER"] == TTLS) { |
|
551 | - $result = $this->copyFile('GPL3.rtf'); |
|
552 | - $result = $result && $this->copyFile('ArnesLinkEn32.msi'); |
|
553 | - $result = $result && $this->copyFile('ArnesLinkEn64.msi'); |
|
554 | - $result = $result && $this->copyFile('dump_arneslink_profile.cmd'); |
|
555 | - $result = $result && $this->copyFile('install_arneslink_profile.cmd'); |
|
556 | - $this->translateFile('arnes_link.inc','cat.NSI',$this->code_page); |
|
557 | - } elseif($eap["OUTER"] == PWD) { |
|
558 | - $this->translateFile('pwd.inc','cat.NSI',$this->code_page); |
|
559 | - $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x32.msi'); |
|
560 | - $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x64.msi'); |
|
540 | + $result; |
|
541 | + $result = $this->copyFile('wlan_test.exe'); |
|
542 | + $result = $this->copyFile('check_wired.cmd'); |
|
543 | + $result = $this->copyFile('install_wired.cmd'); |
|
544 | + $result = $this->copyFile('setEAPCred.exe'); |
|
545 | + $result = $this->copyFile('base64.nsh'); |
|
546 | + $result = $this->copyFile('cat_bg.bmp'); |
|
547 | + $result = $result && $this->copyFile('cat32.ico'); |
|
548 | + $result = $result && $this->copyFile('cat_150.bmp'); |
|
549 | + $this->translateFile('common.inc','common.nsh',$this->code_page); |
|
550 | + if( $eap["OUTER"] == TTLS) { |
|
551 | + $result = $this->copyFile('GPL3.rtf'); |
|
552 | + $result = $result && $this->copyFile('ArnesLinkEn32.msi'); |
|
553 | + $result = $result && $this->copyFile('ArnesLinkEn64.msi'); |
|
554 | + $result = $result && $this->copyFile('dump_arneslink_profile.cmd'); |
|
555 | + $result = $result && $this->copyFile('install_arneslink_profile.cmd'); |
|
556 | + $this->translateFile('arnes_link.inc','cat.NSI',$this->code_page); |
|
557 | + } elseif($eap["OUTER"] == PWD) { |
|
558 | + $this->translateFile('pwd.inc','cat.NSI',$this->code_page); |
|
559 | + $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x32.msi'); |
|
560 | + $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x64.msi'); |
|
561 | 561 | } else { |
562 | - $this->translateFile('peap_tls.inc','cat.NSI',$this->code_page); |
|
563 | - $result = 1; |
|
562 | + $this->translateFile('peap_tls.inc','cat.NSI',$this->code_page); |
|
563 | + $result = 1; |
|
564 | 564 | } |
565 | 565 | debug(4,"copyFiles end\n"); |
566 | - return($result); |
|
566 | + return($result); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | } |
570 | 570 | \ No newline at end of file |
@@ -26,74 +26,74 @@ discard block |
||
26 | 26 | */ |
27 | 27 | class Device_W8 extends WindowsCommon { |
28 | 28 | final public function __construct() { |
29 | - $this->supportedEapMethods = [EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP, EAP::$TTLS_MSCHAP2, EAP::$PWD]; |
|
29 | + $this->supportedEapMethods = [EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP, EAP::$TTLS_MSCHAP2, EAP::$PWD]; |
|
30 | 30 | # $this->supportedEapMethods = array(EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP, EAP::$PWD); |
31 | - debug(4,"This device supports the following EAP methods: "); |
|
32 | - debug(4,$this->supportedEapMethods); |
|
33 | - $this->specialities['anon_id'][serialize(EAP::$PEAP_MSCHAP2)] = _("Anonymous identities do not use the realm as specified in the profile - it is derived from the suffix of the user's username input instead."); |
|
31 | + debug(4,"This device supports the following EAP methods: "); |
|
32 | + debug(4,$this->supportedEapMethods); |
|
33 | + $this->specialities['anon_id'][serialize(EAP::$PEAP_MSCHAP2)] = _("Anonymous identities do not use the realm as specified in the profile - it is derived from the suffix of the user's username input instead."); |
|
34 | 34 | } |
35 | 35 | |
36 | - public function writeInstaller() { |
|
37 | - $dom = textdomain(NULL); |
|
38 | - textdomain("devices"); |
|
39 | - // create certificate files and save their names in $CA_files arrary |
|
40 | - $CA_files = $this->saveCertificateFiles('der'); |
|
36 | + public function writeInstaller() { |
|
37 | + $dom = textdomain(NULL); |
|
38 | + textdomain("devices"); |
|
39 | + // create certificate files and save their names in $CA_files arrary |
|
40 | + $CA_files = $this->saveCertificateFiles('der'); |
|
41 | 41 | |
42 | - $SSIDs = $this->attributes['internal:SSID']; |
|
43 | - $delSSIDs = $this->attributes['internal:remove_SSID']; |
|
44 | - $this->prepareInstallerLang(); |
|
45 | - $set_wired = isset($this->attributes['media:wired'][0]) && $this->attributes['media:wired'][0] == 'on' ? 1 : 0; |
|
42 | + $SSIDs = $this->attributes['internal:SSID']; |
|
43 | + $delSSIDs = $this->attributes['internal:remove_SSID']; |
|
44 | + $this->prepareInstallerLang(); |
|
45 | + $set_wired = isset($this->attributes['media:wired'][0]) && $this->attributes['media:wired'][0] == 'on' ? 1 : 0; |
|
46 | 46 | // create a list of profiles to be deleted after installation |
47 | - $delProfiles = []; |
|
48 | - foreach ($delSSIDs as $ssid => $cipher) { |
|
49 | - if($cipher == 'DEL') |
|
50 | - $delProfiles[] = $ssid; |
|
51 | - if($cipher == 'TKIP') |
|
52 | - $delProfiles[] = $ssid.' (TKIP)'; |
|
53 | - } |
|
54 | - |
|
55 | - |
|
56 | - if ($this->selected_eap == EAP::$TLS || $this->selected_eap == EAP::$PEAP_MSCHAP2 || $this->selected_eap == EAP::$TTLS_PAP || $this->selected_eap == EAP::$TTLS_MSCHAP2 || $this->selected_eap == EAP::$PWD) { |
|
57 | - $WindowsProfile = []; |
|
58 | - $eap_config = $this->prepareEapConfig($this->attributes); |
|
59 | - $i = 0; |
|
60 | - foreach ($SSIDs as $ssid => $cipher) { |
|
61 | - if($cipher == 'TKIP') { |
|
62 | - $WindowsProfile[$i] = $this->writeWLANprofile ($ssid.' (TKIP)',$ssid,'WPA','TKIP',$eap_config,$i); |
|
63 | - $i++; |
|
64 | - } |
|
65 | - $WindowsProfile[$i] = $this->writeWLANprofile ($ssid,$ssid,'WPA2','AES',$eap_config,$i); |
|
66 | - $i++; |
|
67 | - } |
|
68 | - if($set_wired) { |
|
69 | - $this->writeLANprofile($eap_config); |
|
70 | - } |
|
71 | - } else { |
|
72 | - error(" this EAP type is not handled yet"); |
|
73 | - return; |
|
74 | - } |
|
47 | + $delProfiles = []; |
|
48 | + foreach ($delSSIDs as $ssid => $cipher) { |
|
49 | + if($cipher == 'DEL') |
|
50 | + $delProfiles[] = $ssid; |
|
51 | + if($cipher == 'TKIP') |
|
52 | + $delProfiles[] = $ssid.' (TKIP)'; |
|
53 | + } |
|
54 | + |
|
55 | + |
|
56 | + if ($this->selected_eap == EAP::$TLS || $this->selected_eap == EAP::$PEAP_MSCHAP2 || $this->selected_eap == EAP::$TTLS_PAP || $this->selected_eap == EAP::$TTLS_MSCHAP2 || $this->selected_eap == EAP::$PWD) { |
|
57 | + $WindowsProfile = []; |
|
58 | + $eap_config = $this->prepareEapConfig($this->attributes); |
|
59 | + $i = 0; |
|
60 | + foreach ($SSIDs as $ssid => $cipher) { |
|
61 | + if($cipher == 'TKIP') { |
|
62 | + $WindowsProfile[$i] = $this->writeWLANprofile ($ssid.' (TKIP)',$ssid,'WPA','TKIP',$eap_config,$i); |
|
63 | + $i++; |
|
64 | + } |
|
65 | + $WindowsProfile[$i] = $this->writeWLANprofile ($ssid,$ssid,'WPA2','AES',$eap_config,$i); |
|
66 | + $i++; |
|
67 | + } |
|
68 | + if($set_wired) { |
|
69 | + $this->writeLANprofile($eap_config); |
|
70 | + } |
|
71 | + } else { |
|
72 | + error(" this EAP type is not handled yet"); |
|
73 | + return; |
|
74 | + } |
|
75 | 75 | debug(4,"WindowsProfile"); debug(4,$WindowsProfile); |
76 | 76 | |
77 | 77 | $this->writeProfilesNSH($WindowsProfile, $CA_files,$set_wired); |
78 | 78 | $this->writeAdditionalDeletes($delProfiles); |
79 | 79 | if(isset($additional_deletes) && count($additional_deletes)) |
80 | - $this->writeAdditionalDeletes($additional_deletes); |
|
80 | + $this->writeAdditionalDeletes($additional_deletes); |
|
81 | 81 | $this->copyFiles($this->selected_eap); |
82 | 82 | if(isset($this->attributes['internal:logo_file'])) |
83 | - $this->combineLogo($this->attributes['internal:logo_file']); |
|
83 | + $this->combineLogo($this->attributes['internal:logo_file']); |
|
84 | 84 | $this->writeMainNSH($this->selected_eap,$this->attributes); |
85 | 85 | $this->compileNSIS(); |
86 | 86 | $installer_path = $this->signInstaller($this->attributes); |
87 | 87 | |
88 | 88 | textdomain($dom); |
89 | 89 | return($installer_path); |
90 | - } |
|
90 | + } |
|
91 | 91 | |
92 | - public function writeDeviceInfo() { |
|
92 | + public function writeDeviceInfo() { |
|
93 | 93 | $ssid_ct=count($this->attributes['internal:SSID']); |
94 | - $out = "<p>"; |
|
95 | - $out .= sprintf(_("%s installer will be in the form of an EXE file. It will configure %s on your device, by creating wireless network profiles.<p>When you click the download button, the installer will be saved by your browser. Copy it to the machine you want to configure and execute."),Config::$CONSORTIUM['name'],Config::$CONSORTIUM['name']); |
|
96 | - $out .= "<p>"; |
|
94 | + $out = "<p>"; |
|
95 | + $out .= sprintf(_("%s installer will be in the form of an EXE file. It will configure %s on your device, by creating wireless network profiles.<p>When you click the download button, the installer will be saved by your browser. Copy it to the machine you want to configure and execute."),Config::$CONSORTIUM['name'],Config::$CONSORTIUM['name']); |
|
96 | + $out .= "<p>"; |
|
97 | 97 | if($ssid_ct > 1) { |
98 | 98 | if($ssid_ct > 2) { |
99 | 99 | $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to the following networks:"),implode(', ',Config::$CONSORTIUM['ssid']))." "; |
@@ -101,52 +101,52 @@ discard block |
||
101 | 101 | $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to:"),implode(', ',Config::$CONSORTIUM['ssid']))." "; |
102 | 102 | $i = 0; |
103 | 103 | foreach ($this->attributes['internal:SSID'] as $ssid=>$v) { |
104 | - if(! in_array($ssid, Config::$CONSORTIUM['ssid'])) { |
|
105 | - if($i > 0) |
|
106 | - $out .= ", "; |
|
107 | - $i++; |
|
108 | - $out .= "<strong>$ssid</strong>"; |
|
109 | - } |
|
104 | + if(! in_array($ssid, Config::$CONSORTIUM['ssid'])) { |
|
105 | + if($i > 0) |
|
106 | + $out .= ", "; |
|
107 | + $i++; |
|
108 | + $out .= "<strong>$ssid</strong>"; |
|
109 | + } |
|
110 | 110 | } |
111 | 111 | $out .= "<p>"; |
112 | 112 | } |
113 | 113 | |
114 | 114 | if($this->eap == EAP::$TLS) |
115 | - $out .= _("In order to connect to the network you will need an a personal certificate in the form of a p12 file. You should obtain this certificate from your home institution. Consult the support page to find out how this certificate can be obtained. Such certificate files are password protected. You should have both the file and the password available during the installation process."); |
|
115 | + $out .= _("In order to connect to the network you will need an a personal certificate in the form of a p12 file. You should obtain this certificate from your home institution. Consult the support page to find out how this certificate can be obtained. Such certificate files are password protected. You should have both the file and the password available during the installation process."); |
|
116 | 116 | else { |
117 | - $out .= _("In order to connect to the network you will need an account from your home institution. You should consult the support page to find out how this account can be obtained. It is very likely that your account is already activated."); |
|
118 | - $out .= "<p>"; |
|
119 | - $out .= _("When you are connecting to the network for the first time, Windows will pop up a login box, where you should enter your user name and password. This information will be saved so that you will reconnect to the network automatically each time you are in the range."); |
|
117 | + $out .= _("In order to connect to the network you will need an account from your home institution. You should consult the support page to find out how this account can be obtained. It is very likely that your account is already activated."); |
|
118 | + $out .= "<p>"; |
|
119 | + $out .= _("When you are connecting to the network for the first time, Windows will pop up a login box, where you should enter your user name and password. This information will be saved so that you will reconnect to the network automatically each time you are in the range."); |
|
120 | 120 | if($ssid_ct > 1) { |
121 | - $out .= "<p>"; |
|
122 | - $out .= _("You will be required to enter the same credentials for each of the configured notworks:")." "; |
|
123 | - $i = 0; |
|
121 | + $out .= "<p>"; |
|
122 | + $out .= _("You will be required to enter the same credentials for each of the configured notworks:")." "; |
|
123 | + $i = 0; |
|
124 | 124 | foreach ($this->attributes['internal:SSID'] as $ssid=>$v) { |
125 | - if($i > 0) |
|
126 | - $out .= ", "; |
|
127 | - $i++; |
|
128 | - $out .= "<strong>$ssid</strong>"; |
|
125 | + if($i > 0) |
|
126 | + $out .= ", "; |
|
127 | + $i++; |
|
128 | + $out .= "<strong>$ssid</strong>"; |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | |
132 | 132 | |
133 | 133 | } |
134 | 134 | return $out; |
135 | - } |
|
135 | + } |
|
136 | 136 | |
137 | 137 | |
138 | 138 | private function prepareEapConfig($attr) { |
139 | - $eap = $this->selected_eap; |
|
140 | - $w8_ext = ''; |
|
141 | - $use_anon = $attr['internal:use_anon_outer'] [0]; |
|
142 | - if ($use_anon) { |
|
143 | - $outer_user = $attr['internal:anon_local_value'][0]; |
|
144 | - $outer_id = $outer_user.'@'.$attr['internal:realm'][0]; |
|
145 | - } |
|
139 | + $eap = $this->selected_eap; |
|
140 | + $w8_ext = ''; |
|
141 | + $use_anon = $attr['internal:use_anon_outer'] [0]; |
|
142 | + if ($use_anon) { |
|
143 | + $outer_user = $attr['internal:anon_local_value'][0]; |
|
144 | + $outer_id = $outer_user.'@'.$attr['internal:realm'][0]; |
|
145 | + } |
|
146 | 146 | // $servers = preg_quote(implode(';',$attr['eap:server_name'])); |
147 | - $servers = implode(';',$attr['eap:server_name']); |
|
147 | + $servers = implode(';',$attr['eap:server_name']); |
|
148 | 148 | |
149 | - $ca_array = $attr['internal:CAs'][0]; |
|
149 | + $ca_array = $attr['internal:CAs'][0]; |
|
150 | 150 | |
151 | 151 | |
152 | 152 | $profile_file_contents = '<EAPConfig><EapHostConfig xmlns="http://www.microsoft.com/provisioning/EapHostConfig"> |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $profile_file_contents .= '<AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</AuthorId> |
163 | 163 | </EapMethod> |
164 | 164 | '; |
165 | - $profile_file_contents .= ' |
|
165 | + $profile_file_contents .= ' |
|
166 | 166 | |
167 | 167 | <Config xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1" |
168 | 168 | xmlns:eapTls="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV1"> |
@@ -178,14 +178,14 @@ discard block |
||
178 | 178 | if($ca_array) { |
179 | 179 | foreach ($ca_array as $CA) |
180 | 180 | if($CA['root']) |
181 | - $profile_file_contents .= "<eapTls:TrustedRootCA>".$CA['sha1']."</eapTls:TrustedRootCA>\n"; |
|
181 | + $profile_file_contents .= "<eapTls:TrustedRootCA>".$CA['sha1']."</eapTls:TrustedRootCA>\n"; |
|
182 | 182 | } |
183 | 183 | $profile_file_contents .= '</eapTls:ServerValidation> |
184 | 184 | '; |
185 | 185 | if(isset($attr['eap-specific:tls_use_other_id']) && $attr['eap-specific:tls_use_other_id'][0] == 'on') |
186 | - $profile_file_contents .= '<eapTls:DifferentUsername>true</eapTls:DifferentUsername>'; |
|
186 | + $profile_file_contents .= '<eapTls:DifferentUsername>true</eapTls:DifferentUsername>'; |
|
187 | 187 | else |
188 | - $profile_file_contents .= '<eapTls:DifferentUsername>false</eapTls:DifferentUsername>'; |
|
188 | + $profile_file_contents .= '<eapTls:DifferentUsername>false</eapTls:DifferentUsername>'; |
|
189 | 189 | $profile_file_contents .= ' |
190 | 190 | </eapTls:EapType> |
191 | 191 | </baseEap:Eap> |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | '; |
194 | 194 | } elseif ( $eap == EAP::$PEAP_MSCHAP2) { |
195 | 195 | if(isset($attr['eap:enable_nea']) && $attr['eap:enable_nea'][0] == 'on') |
196 | - $nea = 'true'; |
|
196 | + $nea = 'true'; |
|
197 | 197 | else |
198 | - $nea = 'false'; |
|
198 | + $nea = 'false'; |
|
199 | 199 | $profile_file_contents .= '<AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</AuthorId> |
200 | 200 | </EapMethod> |
201 | 201 | '; |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | <Phase2Authentication> |
261 | 261 | '; |
262 | 262 | if ( $eap == EAP::$TTLS_PAP) { |
263 | - $w8_ext .='<PAPAuthentication /> '; |
|
263 | + $w8_ext .='<PAPAuthentication /> '; |
|
264 | 264 | } |
265 | 265 | if ( $eap == EAP::$TTLS_MSCHAP2) { |
266 | - $w8_ext .='<MSCHAPv2Authentication> |
|
266 | + $w8_ext .='<MSCHAPv2Authentication> |
|
267 | 267 | <UseWinlogonCredentials>false</UseWinlogonCredentials> |
268 | 268 | </MSCHAPv2Authentication> |
269 | 269 | '; |
@@ -272,16 +272,16 @@ discard block |
||
272 | 272 | <Phase1Identity> |
273 | 273 | '; |
274 | 274 | if($use_anon == 1) { |
275 | - $w8_ext .= '<IdentityPrivacy>true</IdentityPrivacy> |
|
275 | + $w8_ext .= '<IdentityPrivacy>true</IdentityPrivacy> |
|
276 | 276 | '; |
277 | - if(isset($outer_id) && $outer_id) |
|
277 | + if(isset($outer_id) && $outer_id) |
|
278 | 278 | $w8_ext .='<AnonymousIdentity>'.$outer_id.'</AnonymousIdentity> |
279 | 279 | '; |
280 | - else |
|
280 | + else |
|
281 | 281 | $w8_ext .='<AnonymousIdentity/> |
282 | 282 | '; |
283 | 283 | } else { |
284 | - $w8_ext .= '<IdentityPrivacy>false</IdentityPrivacy> |
|
284 | + $w8_ext .= '<IdentityPrivacy>false</IdentityPrivacy> |
|
285 | 285 | '; |
286 | 286 | } |
287 | 287 | $w8_ext .='</Phase1Identity> |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | $profile_file_contents .= '<AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</AuthorId> |
293 | 293 | </EapMethod> |
294 | 294 | '; |
295 | - $profile_file_contents .= '<ConfigBlob></ConfigBlob>'; |
|
295 | + $profile_file_contents .= '<ConfigBlob></ConfigBlob>'; |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | $profile_file_contents_end = '</EapHostConfig></EAPConfig>'; |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | /** |
310 | 310 | * produce PEAP, TLS and TTLS configuration files for Windows 8 |
311 | 311 | */ |
312 | - private function writeWLANprofile($wlan_profile_name,$ssid,$auth,$encryption,$eap_config,$i) { |
|
312 | + private function writeWLANprofile($wlan_profile_name,$ssid,$auth,$encryption,$eap_config,$i) { |
|
313 | 313 | $profile_file_contents = '<?xml version="1.0"?> |
314 | 314 | <WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1"> |
315 | 315 | <name>'.$wlan_profile_name.'</name> |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | '; |
350 | 350 | |
351 | 351 | if(! is_dir('w8')) |
352 | - mkdir('w8'); |
|
352 | + mkdir('w8'); |
|
353 | 353 | $xml_f_name = "w8/wlan_prof-$i.xml"; |
354 | 354 | $xml_f = fopen($xml_f_name,'w'); |
355 | 355 | fwrite($xml_f,$profile_file_contents. $eap_config['w8']. $closing) ; |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | '; |
377 | 377 | |
378 | 378 | if(! is_dir('w8')) |
379 | - mkdir('w8'); |
|
379 | + mkdir('w8'); |
|
380 | 380 | $xml_f_name = "w8/lan_prof.xml"; |
381 | 381 | $xml_f = fopen($xml_f_name,'w'); |
382 | 382 | fwrite($xml_f,$profile_file_contents. $eap_config['w8']. $closing) ; |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | '; |
436 | 436 | |
437 | 437 | if(isset($this->attributes['media:wired'][0]) && $attr['media:wired'][0] == 'on') |
438 | - $fcontents .= '!define WIRED |
|
438 | + $fcontents .= '!define WIRED |
|
439 | 439 | '; |
440 | 440 | |
441 | 441 | $f = fopen('main.nsh','w'); |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | debug(4,"writeProfilesNSH"); |
449 | 449 | debug(4,$P); |
450 | 450 | $fcontents = ''; |
451 | - foreach($P as $p) |
|
451 | + foreach($P as $p) |
|
452 | 452 | $fcontents .= "!insertmacro define_wlan_profile $p\n"; |
453 | 453 | |
454 | 454 | $f = fopen('profiles.nsh','w'); |
@@ -459,8 +459,8 @@ discard block |
||
459 | 459 | $f = fopen('certs.nsh','w'); |
460 | 460 | if($ca_array) { |
461 | 461 | foreach ($ca_array as $CA) { |
462 | - $store = $CA['root'] ? "root" : "ca"; |
|
463 | - $fcontents .= '!insertmacro install_ca_cert "'.$CA['file'].'" "'.$CA['sha1'].'" "'.$store."\"\n"; |
|
462 | + $store = $CA['root'] ? "root" : "ca"; |
|
463 | + $fcontents .= '!insertmacro install_ca_cert "'.$CA['file'].'" "'.$CA['sha1'].'" "'.$store."\"\n"; |
|
464 | 464 | } |
465 | 465 | fwrite($f, $fcontents); |
466 | 466 | } |
@@ -471,26 +471,26 @@ discard block |
||
471 | 471 | |
472 | 472 | private function copyFiles ($eap) { |
473 | 473 | debug(4,"copyFiles start\n"); |
474 | - $result; |
|
475 | - $result = $this->copyFile('wlan_test.exe'); |
|
476 | - $result = $this->copyFile('check_wired.cmd'); |
|
477 | - $result = $this->copyFile('install_wired.cmd'); |
|
478 | - $result = $this->copyFile('setEAPCred.exe'); |
|
479 | - $result = $this->copyFile('cat_bg.bmp'); |
|
480 | - $result = $this->copyFile('base64.nsh'); |
|
481 | - $result = $result && $this->copyFile('cat32.ico'); |
|
482 | - $result = $result && $this->copyFile('cat_150.bmp'); |
|
483 | - $this->translateFile('common.inc','common.nsh',$this->code_page); |
|
484 | - if($eap["OUTER"] == PWD) { |
|
485 | - $this->translateFile('pwd.inc','cat.NSI',$this->code_page); |
|
486 | - $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x32.msi'); |
|
487 | - $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x64.msi'); |
|
488 | - } else { |
|
489 | - $this->translateFile('eap_w8.inc','cat.NSI',$this->code_page); |
|
490 | - $result = 1; |
|
491 | - } |
|
474 | + $result; |
|
475 | + $result = $this->copyFile('wlan_test.exe'); |
|
476 | + $result = $this->copyFile('check_wired.cmd'); |
|
477 | + $result = $this->copyFile('install_wired.cmd'); |
|
478 | + $result = $this->copyFile('setEAPCred.exe'); |
|
479 | + $result = $this->copyFile('cat_bg.bmp'); |
|
480 | + $result = $this->copyFile('base64.nsh'); |
|
481 | + $result = $result && $this->copyFile('cat32.ico'); |
|
482 | + $result = $result && $this->copyFile('cat_150.bmp'); |
|
483 | + $this->translateFile('common.inc','common.nsh',$this->code_page); |
|
484 | + if($eap["OUTER"] == PWD) { |
|
485 | + $this->translateFile('pwd.inc','cat.NSI',$this->code_page); |
|
486 | + $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x32.msi'); |
|
487 | + $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x64.msi'); |
|
488 | + } else { |
|
489 | + $this->translateFile('eap_w8.inc','cat.NSI',$this->code_page); |
|
490 | + $result = 1; |
|
491 | + } |
|
492 | 492 | debug(4,"copyFiles end\n"); |
493 | - return($result); |
|
493 | + return($result); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | } |
497 | 497 | \ No newline at end of file |