ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
XRIRes.php
Go to the documentation of this file.
1 <?php
2 
7 require_once 'Auth/Yadis/XRDS.php';
8 require_once 'Auth/Yadis/XRI.php';
9 
11  function Auth_Yadis_ProxyResolver($fetcher, $proxy_url = null)
12  {
13  $this->fetcher = $fetcher;
14  $this->proxy_url = $proxy_url;
15  if (!$this->proxy_url) {
16  $this->proxy_url = Auth_Yadis_getDefaultProxy();
17  }
18  }
19 
20  function queryURL($xri, $service_type = null)
21  {
22  // trim off the xri:// prefix
23  $qxri = substr(Auth_Yadis_toURINormal($xri), 6);
24  $hxri = $this->proxy_url . $qxri;
25  $args = array(
26  '_xrd_r' => 'application/xrds+xml'
27  );
28 
29  if ($service_type) {
30  $args['_xrd_t'] = $service_type;
31  } else {
32  // Don't perform service endpoint selection.
33  $args['_xrd_r'] .= ';sep=false';
34  }
35 
36  $query = Auth_Yadis_XRIAppendArgs($hxri, $args);
37  return $query;
38  }
39 
40  function query($xri, $service_types, $filters = array())
41  {
42  $services = array();
43  $canonicalID = null;
44  foreach ($service_types as $service_type) {
45  $url = $this->queryURL($xri, $service_type);
46  $response = $this->fetcher->get($url);
47  if ($response->status != 200 and $response->status != 206) {
48  continue;
49  }
50  $xrds = Auth_Yadis_XRDS::parseXRDS($response->body);
51  if (!$xrds) {
52  continue;
53  }
54  $canonicalID = Auth_Yadis_getCanonicalID($xri,
55  $xrds);
56 
57  if ($canonicalID === false) {
58  return null;
59  }
60 
61  $some_services = $xrds->services($filters);
62  $services = array_merge($services, $some_services);
63  // TODO:
64  // * If we do get hits for multiple service_types, we're
65  // almost certainly going to have duplicated service
66  // entries and broken priority ordering.
67  }
68  return array($canonicalID, $services);
69  }
70 }
71 
72