diff options
author | Sem <sembrestels@riseup.net> | 2013-11-09 16:27:03 +0100 |
---|---|---|
committer | Sem <sembrestels@riseup.net> | 2013-11-09 16:27:03 +0100 |
commit | 911d0021c374602c31e5bfd71b1cd8074f2c2293 (patch) | |
tree | 7e1d529b705e24906d69b9056d7980f0ebabc772 /mod/openid_api/vendors/php-openid/Auth/Yadis/XRIRes.php | |
parent | 5cc7f96262509b2a5d43fa6fbb6cd083064385be (diff) | |
parent | 33c206552a0cfd1166b2d5e4fcceb26f5ff1d224 (diff) | |
download | elgg-911d0021c374602c31e5bfd71b1cd8074f2c2293.tar.gz elgg-911d0021c374602c31e5bfd71b1cd8074f2c2293.tar.bz2 |
Add 'mod/openid_api/' from commit '33c206552a0cfd1166b2d5e4fcceb26f5ff1d224'
git-subtree-dir: mod/openid_api
git-subtree-mainline: 5cc7f96262509b2a5d43fa6fbb6cd083064385be
git-subtree-split: 33c206552a0cfd1166b2d5e4fcceb26f5ff1d224
Diffstat (limited to 'mod/openid_api/vendors/php-openid/Auth/Yadis/XRIRes.php')
-rw-r--r-- | mod/openid_api/vendors/php-openid/Auth/Yadis/XRIRes.php | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/mod/openid_api/vendors/php-openid/Auth/Yadis/XRIRes.php b/mod/openid_api/vendors/php-openid/Auth/Yadis/XRIRes.php new file mode 100644 index 000000000..5e1158735 --- /dev/null +++ b/mod/openid_api/vendors/php-openid/Auth/Yadis/XRIRes.php @@ -0,0 +1,72 @@ +<?php + +/** + * Code for using a proxy XRI resolver. + */ + +require_once 'Auth/Yadis/XRDS.php'; +require_once 'Auth/Yadis/XRI.php'; + +class Auth_Yadis_ProxyResolver { + function Auth_Yadis_ProxyResolver($fetcher, $proxy_url = null) + { + $this->fetcher = $fetcher; + $this->proxy_url = $proxy_url; + if (!$this->proxy_url) { + $this->proxy_url = Auth_Yadis_getDefaultProxy(); + } + } + + function queryURL($xri, $service_type = null) + { + // trim off the xri:// prefix + $qxri = substr(Auth_Yadis_toURINormal($xri), 6); + $hxri = $this->proxy_url . $qxri; + $args = array( + '_xrd_r' => 'application/xrds+xml' + ); + + if ($service_type) { + $args['_xrd_t'] = $service_type; + } else { + // Don't perform service endpoint selection. + $args['_xrd_r'] .= ';sep=false'; + } + + $query = Auth_Yadis_XRIAppendArgs($hxri, $args); + return $query; + } + + function query($xri, $service_types, $filters = array()) + { + $services = array(); + $canonicalID = null; + foreach ($service_types as $service_type) { + $url = $this->queryURL($xri, $service_type); + $response = $this->fetcher->get($url); + if ($response->status != 200 and $response->status != 206) { + continue; + } + $xrds = Auth_Yadis_XRDS::parseXRDS($response->body); + if (!$xrds) { + continue; + } + $canonicalID = Auth_Yadis_getCanonicalID($xri, + $xrds); + + if ($canonicalID === false) { + return null; + } + + $some_services = $xrds->services($filters); + $services = array_merge($services, $some_services); + // TODO: + // * If we do get hits for multiple service_types, we're + // almost certainly going to have duplicated service + // entries and broken priority ordering. + } + return array($canonicalID, $services); + } +} + + |