|
@@ -25,13 +25,14 @@
|
25
|
25
|
class Discoverer {
|
26
|
26
|
|
27
|
27
|
private $server = null;
|
|
28
|
+ private $servers = array();
|
28
|
29
|
private $delegate = '';
|
29
|
30
|
private $identity = '';
|
30
|
31
|
private $version = 1;
|
31
|
32
|
|
32
|
|
- public function __construct($uri) {
|
|
33
|
+ public function __construct($uri, $normalise = true) {
|
33
|
34
|
if ($uri !== null) {
|
34
|
|
- $this->discover($this->identity = $this->normalise($uri));
|
|
35
|
+ $this->discover($this->identity = ($normalise ? $this->normalise($uri) : $uri));
|
35
|
36
|
}
|
36
|
37
|
}
|
37
|
38
|
|
|
@@ -39,6 +40,10 @@ class Discoverer {
|
39
|
40
|
return $this->server;
|
40
|
41
|
}
|
41
|
42
|
|
|
43
|
+ public function hasServer($server) {
|
|
44
|
+ return array_search($server, $this->servers) !== false;
|
|
45
|
+ }
|
|
46
|
+
|
42
|
47
|
public function getDelegate() {
|
43
|
48
|
return $this->delegate;
|
44
|
49
|
}
|
|
@@ -155,15 +160,18 @@ class Discoverer {
|
155
|
160
|
}
|
156
|
161
|
|
157
|
162
|
// TODO: Better handling of namespaces
|
|
163
|
+ $found = false;
|
158
|
164
|
foreach ($sxml->XRD->Service as $service) {
|
159
|
165
|
if ((String) $service->Type == 'http://specs.openid.net/auth/2.0/server') {
|
160
|
166
|
$this->version = 2;
|
161
|
167
|
$this->server = (String) $service->URI;
|
162
|
168
|
$this->identity = $this->delegate = 'http://specs.openid.net/auth/2.0/identifier_select';
|
163
|
|
- return true;
|
|
169
|
+ $this->servers[] = $this->server;
|
|
170
|
+ $found = true;
|
164
|
171
|
} else if ((String) $service->Type == 'http://specs.openid.net/auth/2.0/signon') {
|
165
|
172
|
$this->version = 2;
|
166
|
173
|
$this->server = (String) $service->URI;
|
|
174
|
+ $this->servers[] = $this->server;
|
167
|
175
|
|
168
|
176
|
if (isset($service->LocalID)) {
|
169
|
177
|
$this->identity = (String) $service->LocalID;
|
|
@@ -172,11 +180,11 @@ class Discoverer {
|
172
|
180
|
}
|
173
|
181
|
$this->delegate = 'http://specs.openid.net/auth/2.0/identifier_select';
|
174
|
182
|
|
175
|
|
- return true;
|
|
183
|
+ $found = true;
|
176
|
184
|
}
|
177
|
185
|
}
|
178
|
186
|
|
179
|
|
- return false;
|
|
187
|
+ return $found;
|
180
|
188
|
}
|
181
|
189
|
|
182
|
190
|
private function parseYadisHTML($data) {
|
|
@@ -263,6 +271,7 @@ class Discoverer {
|
263
|
271
|
if (isset($links['openid2.provider'])) {
|
264
|
272
|
$this->version = 2;
|
265
|
273
|
$this->server = $links['openid2.provider'];
|
|
274
|
+ $this->servers[] = $this->server;
|
266
|
275
|
|
267
|
276
|
if (isset($links['openid2.local_id'])) {
|
268
|
277
|
$this->delegate = $links['openid2.local_id'];
|
|
@@ -270,6 +279,7 @@ class Discoverer {
|
270
|
279
|
} else if (isset($links['openid.server'])) {
|
271
|
280
|
$this->version = 1;
|
272
|
281
|
$this->server = $links['openid.server'];
|
|
282
|
+ $this->servers[] = $this->server;
|
273
|
283
|
|
274
|
284
|
if (isset($links['openid.delegate'])) {
|
275
|
285
|
$this->delegate = $links['openid.delegate'];
|