You are here

function _openid_xri_discovery in Drupal 7

OpenID discovery method: perform an XRI discovery.

Return value

An array of discovered services and claimed identifier or NULL. See openid_discovery() for more specific information.

See also

http://openid.net/specs/openid-authentication-2_0.html#discovery

hook_openid_discovery_method_info()

openid_discovery()

1 string reference to '_openid_xri_discovery'
openid_openid_discovery_method_info in modules/openid/openid.module
Implements hook_openid_discovery_method_info().

File

modules/openid/openid.module, line 463
Implement OpenID Relying Party support for Drupal

Code

function _openid_xri_discovery($claimed_id) {
  if (_openid_is_xri($claimed_id)) {

    // Resolve XRI using a proxy resolver (Extensible Resource Identifier (XRI)
    // Resolution Version 2.0, section 11.2 and 14.3).
    $xrds_url = variable_get('xri_proxy_resolver', 'http://xri.net/') . rawurlencode($claimed_id) . '?_xrd_r=application/xrds+xml';
    $discovery = _openid_xrds_discovery($xrds_url);
    if (!empty($discovery['services']) && is_array($discovery['services'])) {
      foreach ($discovery['services'] as $i => &$service) {
        $status = $service['xrd']
          ->children(OPENID_NS_XRD)->Status;
        if ($status && $status
          ->attributes()->cid == 'verified') {
          $service['claimed_id'] = openid_normalize((string) $service['xrd']
            ->children(OPENID_NS_XRD)->CanonicalID);
        }
        else {

          // Ignore service if the Canonical ID could not be verified.
          unset($discovery['services'][$i]);
        }
      }
      if (!empty($discovery['services'])) {
        return $discovery;
      }
    }
  }
}