XRIRes.php

Go to the documentation of this file.
00001 <?php
00002 
00007 require_once 'Auth/Yadis/XRDS.php';
00008 require_once 'Auth/Yadis/XRI.php';
00009 
00010 class Auth_Yadis_ProxyResolver {
00011     function Auth_Yadis_ProxyResolver(&$fetcher, $proxy_url = null)
00012     {
00013         $this->fetcher =& $fetcher;
00014         $this->proxy_url = $proxy_url;
00015         if (!$this->proxy_url) {
00016             $this->proxy_url = Auth_Yadis_getDefaultProxy();
00017         }
00018     }
00019 
00020     function queryURL($xri, $service_type = null)
00021     {
00022         // trim off the xri:// prefix
00023         $qxri = substr(Auth_Yadis_toURINormal($xri), 6);
00024         $hxri = $this->proxy_url . $qxri;
00025         $args = array(
00026                       '_xrd_r' => 'application/xrds+xml'
00027                       );
00028 
00029         if ($service_type) {
00030             $args['_xrd_t'] = $service_type;
00031         } else {
00032             // Don't perform service endpoint selection.
00033             $args['_xrd_r'] .= ';sep=false';
00034         }
00035 
00036         $query = Auth_Yadis_XRIAppendArgs($hxri, $args);
00037         return $query;
00038     }
00039 
00040     function query($xri, $service_types, $filters = array())
00041     {
00042         $services = array();
00043         $canonicalID = null;
00044         foreach ($service_types as $service_type) {
00045             $url = $this->queryURL($xri, $service_type);
00046             $response = $this->fetcher->get($url);
00047             if ($response->status != 200 and $response->status != 206) {
00048                 continue;
00049             }
00050             $xrds = Auth_Yadis_XRDS::parseXRDS($response->body);
00051             if (!$xrds) {
00052                 continue;
00053             }
00054             $canonicalID = Auth_Yadis_getCanonicalID($xri,
00055                                                          $xrds);
00056 
00057             if ($canonicalID === false) {
00058                 return null;
00059             }
00060 
00061             $some_services = $xrds->services($filters);
00062             $services = array_merge($services, $some_services);
00063             // TODO:
00064             //  * If we do get hits for multiple service_types, we're
00065             //    almost certainly going to have duplicated service
00066             //    entries and broken priority ordering.
00067         }
00068         return array($canonicalID, $services);
00069     }
00070 }
00071 
00072 ?>

Generated on Thu Feb 19 15:02:21 2009 for OXID eShop CE by  doxygen 1.5.5