Source code for file /openid/Auth/OpenID/Discover.php
Documentation is available at Discover.php
* The OpenID and Yadis discovery implementation for OpenID 1.2.
require_once "Auth/OpenID.php";
require_once "Auth/OpenID/Parse.php";
require_once "Services/Yadis/XRIRes.php";
require_once "Services/Yadis/Yadis.php";
define('_OPENID_1_0_NS', 'http://openid.net/xmlns/1.0');
define('_OPENID_1_2_TYPE', 'http://openid.net/signon/1.2');
define('_OPENID_1_1_TYPE', 'http://openid.net/signon/1.1');
define('_OPENID_1_0_TYPE', 'http://openid.net/signon/1.0');
* Object representing an OpenID service endpoint.
$this->identity_url =
null;
$this->server_url =
null;
$this->type_uris =
array();
$this->canonicalID =
null;
$this->used_yadis =
false; // whether this came from an XRDS
return in_array($extension_uri, $this->type_uris);
function parseService($yadis_url, $uri, $type_uris, $service_element)
// Set the state of this object based on the contents of the
$this->type_uris =
$type_uris;
$this->identity_url =
$yadis_url;
$this->server_url =
$uri;
$this->used_yadis =
true;
// Extract a openid:Delegate value from a Yadis Service
// element. If no delegate is found, returns null.
// Try to register new namespace.
$service->parser->registerNamespace('openid',
'http://openid.net/xmlns/1.0');
// XXX: should this die if there is more than one delegate
$delegates =
$service->getElements("openid:Delegate");
return $service->parser->content($delegates[0]);
// Return the identifier that should be sent as the
// openid.identity_url parameter to the server.
if ($this->delegate ===
null) {
if ($this->canonicalID) {
return $this->canonicalID;
return $this->identity_url;
// Parse the given document as HTML looking for an OpenID <link
$urls =
Auth_OpenID_legacy_discover($html);
list
($delegate_url, $server_url) =
$urls;
$service->identity_url =
$uri;
$service->delegate =
$delegate_url;
$service->server_url =
$server_url;
$uris =
$service->getTypes();
foreach ($uris as $uri) {
foreach ($endpoints as $service) {
$type_uris =
$service->getTypes();
$uris =
$service->getURIs();
// If any Type URIs match and there is an endpoint URI
// specified, then this is an OpenID endpoint
foreach ($uris as $service_uri) {
// Discover OpenID services for a URI. Tries Yadis and falls back
// on old-style <link rel='...'> discovery if Yadis fails.
// Might raise a yadis.discover.DiscoveryFailure if no document
// came back for that URI at all. I don't think falling back to
// OpenID 1.0 discovery on the same URL will help, so don't bother
$openid_services =
array();
$identity_url =
$response->uri;
$response->xrds->services(array('filter_MatchesAnyOpenIDType'));
// Try to parse the response as HTML to get OpenID 1.0/1.1
$openid_services =
array($service);
return array($identity_url, $openid_services, $http_response);
$http_resp =
@$fetcher->get($uri);
if ($http_resp->status !=
200) {
return array(null, array(), $http_resp);
$identity_url =
$http_resp->final_url;
// Try to parse the response as HTML to get OpenID 1.0/1.1 <link
$service =
$endpoint->fromHTML($identity_url, $http_resp->body);
$openid_services =
array();
$openid_services =
array($service);
return array($identity_url, $openid_services, $http_resp);
list
($canonicalID, $service_list) =
$services->query($iname,
array('filter_MatchesAnyOpenIDType'));
for ($i =
0; $i <
count($endpoints); $i++
) {
$endpoints[$i]->canonicalID =
$canonicalID;
// FIXME: returned xri should probably be in some normal form
return array($iname, $endpoints, null);