diff options
author | tailor <cygnus@janrain.com> | 2007-03-12 19:13:55 +0000 |
---|---|---|
committer | tailor <cygnus@janrain.com> | 2007-03-12 19:13:55 +0000 |
commit | 42ef9952383e5517fef269b3efd669325c59ad44 (patch) | |
tree | 4747359a14d59068761a3cea325df613811d0c87 | |
parent | 57ae1417c4a06d713370adee98e49df52bd2a67d (diff) | |
download | php-openid-42ef9952383e5517fef269b3efd669325c59ad44.zip php-openid-42ef9952383e5517fef269b3efd669325c59ad44.tar.gz php-openid-42ef9952383e5517fef269b3efd669325c59ad44.tar.bz2 |
[project @ [2/2] Change Services_Yadis_ and Services/Yadis/]
29 files changed, 339 insertions, 333 deletions
diff --git a/Auth/OpenID.php b/Auth/OpenID.php index 3acf070..ae35880 100644 --- a/Auth/OpenID.php +++ b/Auth/OpenID.php @@ -20,8 +20,8 @@ /** * Require the fetcher code. */ -require_once "Services/Yadis/PlainHTTPFetcher.php"; -require_once "Services/Yadis/ParanoidHTTPFetcher.php"; +require_once "Auth/Yadis/PlainHTTPFetcher.php"; +require_once "Auth/Yadis/ParanoidHTTPFetcher.php"; require_once "Auth/OpenID/BigMath.php"; /** diff --git a/Auth/OpenID/Consumer.php b/Auth/OpenID/Consumer.php index 23fae48..9b852eb 100644 --- a/Auth/OpenID/Consumer.php +++ b/Auth/OpenID/Consumer.php @@ -173,8 +173,8 @@ require_once "Auth/OpenID/DiffieHellman.php"; require_once "Auth/OpenID/KVForm.php"; require_once "Auth/OpenID/Nonce.php"; require_once "Auth/OpenID/Discover.php"; -require_once "Services/Yadis/Manager.php"; -require_once "Services/Yadis/XRI.php"; +require_once "Auth/Yadis/Manager.php"; +require_once "Auth/Yadis/XRI.php"; /** * This is the status code returned when the complete method returns @@ -250,7 +250,7 @@ class Auth_OpenID_Consumer { * Auth_OpenID_DumbStore} can be used. * * @param mixed session An object which implements the interface - * of the Services_Yadis_Session class. Particularly, this object + * of the Auth_Yadis_Session class. Particularly, this object * is expected to have these methods: get($key), set($key, * $value), and del($key). This defaults to a session object * which wraps PHP's native session machinery. You should only @@ -261,7 +261,7 @@ class Auth_OpenID_Consumer { $consumer_cls = null) { if ($session === null) { - $session = new Services_Yadis_PHPSession(); + $session = new Auth_Yadis_PHPSession(); } $this->session =& $session; @@ -278,7 +278,7 @@ class Auth_OpenID_Consumer { function getDiscoveryObject(&$session, $openid_url, $session_key_prefix) { - return new Services_Yadis_Discovery($session, $openid_url, + return new Auth_Yadis_Discovery($session, $openid_url, $session_key_prefix); } @@ -312,7 +312,7 @@ class Auth_OpenID_Consumer { // to be cleaned up next time discovery is attempted. $m = $disco->getManager(); - $loader = new Services_Yadis_ManagerLoader(); + $loader = new Auth_Yadis_ManagerLoader(); if ($m) { if ($m->stale) { @@ -558,7 +558,7 @@ class Auth_OpenID_GenericConsumer { $this->negotiator =& Auth_OpenID_getDefaultNegotiator(); $this->_use_assocs = ($this->store ? true : false); - $this->fetcher = Services_Yadis_Yadis::getHTTPFetcher(); + $this->fetcher = Auth_Yadis_Yadis::getHTTPFetcher(); $this->session_types = Auth_OpenID_getAvailableSessionTypes(); } diff --git a/Auth/OpenID/Discover.php b/Auth/OpenID/Discover.php index 4f21e7a..caf805f 100644 --- a/Auth/OpenID/Discover.php +++ b/Auth/OpenID/Discover.php @@ -7,8 +7,8 @@ require_once "Auth/OpenID.php"; require_once "Auth/OpenID/Parse.php"; require_once "Auth/OpenID/Message.php"; -require_once "Services/Yadis/XRIRes.php"; -require_once "Services/Yadis/Yadis.php"; +require_once "Auth/Yadis/XRIRes.php"; +require_once "Auth/Yadis/Yadis.php"; // XML namespace value define('Auth_OpenID_XMLNS_1_0', 'http://openid.net/xmlns/1.0'); @@ -184,7 +184,7 @@ function Auth_OpenID_findOPLocalIdentifier($service, $type_uris) Auth_OpenID_XMLNS_1_0); $service->parser->registerNamespace('xrd', - Services_Yadis_XMLNS_XRD_2_0); + Auth_Yadis_XMLNS_XRD_2_0); $parser =& $service->parser; @@ -338,7 +338,7 @@ function Auth_OpenID_discoverWithYadis($uri, &$fetcher) // OpenID 1.0 discovery on the same URL will help, so don't bother // to catch it. $openid_services = array(); - $response = Services_Yadis_Yadis::discover($uri, $fetcher); + $response = Auth_Yadis_Yadis::discover($uri, $fetcher); $yadis_url = $response->normalized_uri; $yadis_services = array(); @@ -346,7 +346,7 @@ function Auth_OpenID_discoverWithYadis($uri, &$fetcher) return array($uri, array()); } - $xrds =& Services_Yadis_XRDS::parseXRDS($response->response_text); + $xrds =& Auth_Yadis_XRDS::parseXRDS($response->response_text); if ($xrds) { $yadis_services = @@ -412,7 +412,7 @@ function Auth_OpenID_discoverWithoutYadis($uri, &$fetcher) function Auth_OpenID_discoverXRI($iname, &$fetcher) { - $resolver = new Services_Yadis_ProxyResolver($fetcher); + $resolver = new Auth_Yadis_ProxyResolver($fetcher); list($canonicalID, $yadis_services) = $resolver->query($iname, Auth_OpenID_getOpenIDTypeURIs(), @@ -434,7 +434,7 @@ function Auth_OpenID_discoverXRI($iname, &$fetcher) function Auth_OpenID_discover($uri, &$fetcher) { - if (Services_Yadis_identifierScheme($uri) == 'XRI') { + if (Auth_Yadis_identifierScheme($uri) == 'XRI') { return Auth_OpenID_discoverXRI($uri, $fetcher); } else { return Auth_OpenID_discoverURI($uri, $fetcher); diff --git a/Auth/OpenID/Message.php b/Auth/OpenID/Message.php index 520f6d4..b8fd8d8 100644 --- a/Auth/OpenID/Message.php +++ b/Auth/OpenID/Message.php @@ -8,7 +8,7 @@ require_once 'Auth/OpenID.php'; require_once 'Auth/OpenID/KVForm.php'; -require_once 'Services/Yadis/XML.php'; +require_once 'Auth/Yadis/XML.php'; // This doesn't REALLY belong here, but where is better? define('Auth_OpenID_IDENTIFIER_SELECT', diff --git a/Auth/OpenID/URINorm.php b/Auth/OpenID/URINorm.php index d1c653e..60e900a 100644 --- a/Auth/OpenID/URINorm.php +++ b/Auth/OpenID/URINorm.php @@ -9,7 +9,7 @@ * @license http://www.gnu.org/copyleft/lesser.html LGPL */ -require_once 'Services/Yadis/Misc.php'; +require_once 'Auth/Yadis/Misc.php'; // from appendix B of rfc 3986 (http://www.ietf.org/rfc/rfc3986.txt) function Auth_OpenID_getURIPattern() @@ -57,8 +57,8 @@ function Auth_OpenID_getUnreserved() function Auth_OpenID_getEscapeRE() { $parts = array(); - foreach (array_merge(Services_Yadis_getUCSChars(), - Services_Yadis_getIPrivateChars()) as $pair) { + foreach (array_merge(Auth_Yadis_getUCSChars(), + Auth_Yadis_getIPrivateChars()) as $pair) { list($m, $n) = $pair; $parts[] = sprintf("%s-%s", chr($m), chr($n)); } @@ -90,15 +90,15 @@ function Auth_OpenID_remove_dot_segments($path) $result_segments = array(); while ($path) { - if (Services_Yadis_startswith($path, '../')) { + if (Auth_Yadis_startswith($path, '../')) { $path = substr($path, 3); - } else if (Services_Yadis_startswith($path, './')) { + } else if (Auth_Yadis_startswith($path, './')) { $path = substr($path, 2); - } else if (Services_Yadis_startswith($path, '/./')) { + } else if (Auth_Yadis_startswith($path, '/./')) { $path = substr($path, 2); } else if ($path == '/.') { $path = '/'; - } else if (Services_Yadis_startswith($path, '/../')) { + } else if (Auth_Yadis_startswith($path, '/../')) { $path = substr($path, 3); if ($result_segments) { array_pop($result_segments); diff --git a/Auth/Yadis/HTTPFetcher.php b/Auth/Yadis/HTTPFetcher.php index 97940a4..7d8cc76 100644 --- a/Auth/Yadis/HTTPFetcher.php +++ b/Auth/Yadis/HTTPFetcher.php @@ -13,8 +13,8 @@ * @license http://www.gnu.org/copyleft/lesser.html LGPL */ -class Services_Yadis_HTTPResponse { - function Services_Yadis_HTTPResponse($final_url = null, $status = null, +class Auth_Yadis_HTTPResponse { + function Auth_Yadis_HTTPResponse($final_url = null, $status = null, $headers = null, $body = null) { $this->final_url = $final_url; @@ -32,7 +32,7 @@ class Services_Yadis_HTTPResponse { * @access private * @package Yadis */ -class Services_Yadis_HTTPFetcher { +class Auth_Yadis_HTTPFetcher { var $timeout = 20; // timeout in seconds. diff --git a/Auth/Yadis/Manager.php b/Auth/Yadis/Manager.php index d6e3e37..60a4cf3 100644 --- a/Auth/Yadis/Manager.php +++ b/Auth/Yadis/Manager.php @@ -8,13 +8,13 @@ */ /** - * The base session class used by the Services_Yadis_Manager. This + * The base session class used by the Auth_Yadis_Manager. This * class wraps the default PHP session machinery and should be * subclassed if your application doesn't use PHP sessioning. * * @package Yadis */ -class Services_Yadis_PHPSession { +class Auth_Yadis_PHPSession { /** * Set a session key/value pair. * @@ -71,7 +71,7 @@ class Services_Yadis_PHPSession { * is that you'll subclass this and override $this->check($data) -> * bool to implement your own session data validation. */ -class Services_Yadis_SessionLoader { +class Auth_Yadis_SessionLoader { /** * Override this. */ @@ -174,7 +174,7 @@ class Services_Yadis_SessionLoader { } } -class Auth_OpenID_ServiceEndpointLoader extends Services_Yadis_SessionLoader { +class Auth_OpenID_ServiceEndpointLoader extends Auth_Yadis_SessionLoader { function newObject($data) { return new Auth_OpenID_ServiceEndpoint(); @@ -196,7 +196,7 @@ class Auth_OpenID_ServiceEndpointLoader extends Services_Yadis_SessionLoader { } } -class Services_Yadis_ManagerLoader extends Services_Yadis_SessionLoader { +class Auth_Yadis_ManagerLoader extends Auth_Yadis_SessionLoader { function requiredKeys() { return array('starting_url', @@ -209,7 +209,7 @@ class Services_Yadis_ManagerLoader extends Services_Yadis_SessionLoader { function newObject($data) { - return new Services_Yadis_Manager($data['starting_url'], + return new Auth_Yadis_Manager($data['starting_url'], $data['yadis_url'], $data['services'], $data['session_key']); @@ -249,14 +249,14 @@ class Services_Yadis_ManagerLoader extends Services_Yadis_SessionLoader { * * @package Yadis */ -class Services_Yadis_Manager { +class Auth_Yadis_Manager { /** * Intialize a new yadis service manager. * * @access private */ - function Services_Yadis_Manager($starting_url, $yadis_url, + function Auth_Yadis_Manager($starting_url, $yadis_url, $services, $session_key) { // The URL that was used to initiate the Yadis protocol @@ -342,7 +342,7 @@ class Services_Yadis_Manager { * * @package Yadis */ -class Services_Yadis_Discovery { +class Auth_Yadis_Discovery { /** * @access private @@ -357,13 +357,13 @@ class Services_Yadis_Discovery { /** * Initialize a discovery object. * - * @param Services_Yadis_PHPSession $session An object which - * implements the Services_Yadis_PHPSession API. + * @param Auth_Yadis_PHPSession $session An object which + * implements the Auth_Yadis_PHPSession API. * @param string $url The URL on which to attempt discovery. * @param string $session_key_suffix The optional session key * suffix override. */ - function Services_Yadis_Discovery(&$session, $url, + function Auth_Yadis_Discovery(&$session, $url, $session_key_suffix = null) { /// Initialize a discovery object @@ -396,7 +396,7 @@ class Services_Yadis_Discovery { } if ($manager) { - $loader = new Services_Yadis_ManagerLoader(); + $loader = new Auth_Yadis_ManagerLoader(); $service = $manager->nextService(); $this->session->set($this->session_key, serialize($loader->toSession($manager))); @@ -446,7 +446,7 @@ class Services_Yadis_Discovery { $manager = null; if ($manager_str !== null) { - $loader = new Services_Yadis_ManagerLoader(); + $loader = new Auth_Yadis_ManagerLoader(); $manager = $loader->fromSession(unserialize($manager_str)); } @@ -469,8 +469,8 @@ class Services_Yadis_Discovery { } if ($services) { - $loader = new Services_Yadis_ManagerLoader(); - $manager = new Services_Yadis_Manager($this->url, $yadis_url, + $loader = new Auth_Yadis_ManagerLoader(); + $manager = new Auth_Yadis_Manager($this->url, $yadis_url, $services, $key); $this->session->set($this->session_key, serialize($loader->toSession($manager))); diff --git a/Auth/Yadis/Misc.php b/Auth/Yadis/Misc.php index 794b62e..a29ce4a 100644 --- a/Auth/Yadis/Misc.php +++ b/Auth/Yadis/Misc.php @@ -9,7 +9,7 @@ * @license http://www.gnu.org/copyleft/lesser.html LGPL */ -function Services_Yadis_getUCSChars() +function Auth_Yadis_getUCSChars() { return array( array(0xA0, 0xD7FF), @@ -32,7 +32,7 @@ function Services_Yadis_getUCSChars() ); } -function Services_Yadis_getIPrivateChars() +function Auth_Yadis_getIPrivateChars() { return array( array(0xE000, 0xF8FF), @@ -41,7 +41,7 @@ function Services_Yadis_getIPrivateChars() ); } -function Services_Yadis_pct_escape_unicode($char_match) +function Auth_Yadis_pct_escape_unicode($char_match) { $c = $char_match[0]; $result = ""; @@ -51,7 +51,7 @@ function Services_Yadis_pct_escape_unicode($char_match) return $result; } -function Services_Yadis_startswith($s, $stuff) +function Auth_Yadis_startswith($s, $stuff) { return strpos($s, $stuff) === 0; } diff --git a/Auth/Yadis/ParanoidHTTPFetcher.php b/Auth/Yadis/ParanoidHTTPFetcher.php index e14799f..607afd2 100644 --- a/Auth/Yadis/ParanoidHTTPFetcher.php +++ b/Auth/Yadis/ParanoidHTTPFetcher.php @@ -16,16 +16,16 @@ /** * Interface import */ -require_once "Services/Yadis/HTTPFetcher.php"; +require_once "Auth/Yadis/HTTPFetcher.php"; /** - * A paranoid {@link Services_Yadis_HTTPFetcher} class which uses CURL + * A paranoid {@link Auth_Yadis_HTTPFetcher} class which uses CURL * for fetching. * * @package Yadis */ -class Services_Yadis_ParanoidHTTPFetcher extends Services_Yadis_HTTPFetcher { - function Services_Yadis_ParanoidHTTPFetcher() +class Auth_Yadis_ParanoidHTTPFetcher extends Auth_Yadis_HTTPFetcher { + function Auth_Yadis_ParanoidHTTPFetcher() { $this->reset(); } @@ -113,7 +113,7 @@ class Services_Yadis_ParanoidHTTPFetcher extends Services_Yadis_HTTPFetcher { } } - return new Services_Yadis_HTTPResponse($url, $code, + return new Auth_Yadis_HTTPResponse($url, $code, $new_headers, $body); } @@ -169,7 +169,7 @@ class Services_Yadis_ParanoidHTTPFetcher extends Services_Yadis_HTTPFetcher { } - return new Services_Yadis_HTTPResponse($url, $code, + return new Auth_Yadis_HTTPResponse($url, $code, $new_headers, $body); } } diff --git a/Auth/Yadis/ParseHTML.php b/Auth/Yadis/ParseHTML.php index 2906645..75e0bc9 100644 --- a/Auth/Yadis/ParseHTML.php +++ b/Auth/Yadis/ParseHTML.php @@ -20,7 +20,7 @@ * * @package Yadis */ -class Services_Yadis_ParseHTML { +class Auth_Yadis_ParseHTML { /** * @access private @@ -37,7 +37,7 @@ class Services_Yadis_ParseHTML { */ var $_attr_find = '\b([-\w]+)=(".*?"|\'.*?\'|.+?)[\s>]'; - function Services_Yadis_ParseHTML() + function Auth_Yadis_ParseHTML() { $this->_attr_find = sprintf("/%s/%s", $this->_attr_find, @@ -185,7 +185,8 @@ class Services_Yadis_ParseHTML { if (!is_null($key_tags_pos[0]) && $key_tags_pos[1] < $key_tags_pos[0]) { return array(); } - $html_string = substr($html_string, $key_tags_pos[1], ($key_tags_pos[2]-$key_tags_pos[1])); + $html_string = substr($html_string, $key_tags_pos[1], + ($key_tags_pos[2]-$key_tags_pos[1])); $link_data = array(); $link_matches = array(); diff --git a/Auth/Yadis/PlainHTTPFetcher.php b/Auth/Yadis/PlainHTTPFetcher.php index 6b4b143..548afb2 100644 --- a/Auth/Yadis/PlainHTTPFetcher.php +++ b/Auth/Yadis/PlainHTTPFetcher.php @@ -17,7 +17,7 @@ /** * Interface import */ -require_once "Services/Yadis/HTTPFetcher.php"; +require_once "Auth/Yadis/HTTPFetcher.php"; /** * This class implements a plain, hand-built socket-based fetcher @@ -25,7 +25,7 @@ require_once "Services/Yadis/HTTPFetcher.php"; * * @package Yadis */ -class Services_Yadis_PlainHTTPFetcher extends Services_Yadis_HTTPFetcher { +class Auth_Yadis_PlainHTTPFetcher extends Auth_Yadis_HTTPFetcher { function get($url, $extra_headers = null) { if (!$this->allowedURL($url)) { @@ -132,7 +132,7 @@ class Services_Yadis_PlainHTTPFetcher extends Services_Yadis_HTTPFetcher { } - return new Services_Yadis_HTTPResponse($url, $code, $new_headers, $body); + return new Auth_Yadis_HTTPResponse($url, $code, $new_headers, $body); } function post($url, $body, $extra_headers = null) @@ -237,7 +237,7 @@ class Services_Yadis_PlainHTTPFetcher extends Services_Yadis_HTTPFetcher { } - return new Services_Yadis_HTTPResponse($url, $code, + return new Auth_Yadis_HTTPResponse($url, $code, $headers, $response_body); } } diff --git a/Auth/Yadis/XML.php b/Auth/Yadis/XML.php index aef94c6..8f177e6 100644 --- a/Auth/Yadis/XML.php +++ b/Auth/Yadis/XML.php @@ -11,16 +11,16 @@ * The base class for wrappers for available PHP XML-parsing * extensions. To work with this Yadis library, subclasses of this * class MUST implement the API as defined in the remarks for this - * class. Subclasses of Services_Yadis_XMLParser are used to wrap + * class. Subclasses of Auth_Yadis_XMLParser are used to wrap * particular PHP XML extensions such as 'domxml'. These are used * internally by the library depending on the availability of * supported PHP XML extensions. * * @package Yadis */ -class Services_Yadis_XMLParser { +class Auth_Yadis_XMLParser { /** - * Initialize an instance of Services_Yadis_XMLParser with some + * Initialize an instance of Auth_Yadis_XMLParser with some * XML and namespaces. This SHOULD NOT be overridden by * subclasses. * @@ -125,16 +125,16 @@ class Services_Yadis_XMLParser { } /** - * This concrete implementation of Services_Yadis_XMLParser implements + * This concrete implementation of Auth_Yadis_XMLParser implements * the appropriate API for the 'domxml' extension which is typically * packaged with PHP 4. This class will be used whenever the 'domxml' - * extension is detected. See the Services_Yadis_XMLParser class for + * extension is detected. See the Auth_Yadis_XMLParser class for * details on this class's methods. * * @package Yadis */ -class Services_Yadis_domxml extends Services_Yadis_XMLParser { - function Services_Yadis_domxml() +class Auth_Yadis_domxml extends Auth_Yadis_XMLParser { + function Auth_Yadis_domxml() { $this->xml = null; $this->doc = null; @@ -208,16 +208,16 @@ class Services_Yadis_domxml extends Services_Yadis_XMLParser { } /** - * This concrete implementation of Services_Yadis_XMLParser implements + * This concrete implementation of Auth_Yadis_XMLParser implements * the appropriate API for the 'dom' extension which is typically * packaged with PHP 5. This class will be used whenever the 'dom' - * extension is detected. See the Services_Yadis_XMLParser class for + * extension is detected. See the Auth_Yadis_XMLParser class for * details on this class's methods. * * @package Yadis */ -class Services_Yadis_dom extends Services_Yadis_XMLParser { - function Services_Yadis_dom() +class Auth_Yadis_dom extends Auth_Yadis_XMLParser { + function Auth_Yadis_dom() { $this->xml = null; $this->doc = null; @@ -306,43 +306,43 @@ $__Services_Yadis_defaultParser = null; * one in which multiple parsers can be used but one is more * desirable. * - * @param Services_Yadis_XMLParser $parser An instance of a - * Services_Yadis_XMLParser subclass. + * @param Auth_Yadis_XMLParser $parser An instance of a + * Auth_Yadis_XMLParser subclass. */ -function Services_Yadis_setDefaultParser(&$parser) +function Auth_Yadis_setDefaultParser(&$parser) { - global $__Services_Yadis_defaultParser; - $__Services_Yadis_defaultParser =& $parser; + global $__Auth_Yadis_defaultParser; + $__Auth_Yadis_defaultParser =& $parser; } -function Services_Yadis_getSupportedExtensions() +function Auth_Yadis_getSupportedExtensions() { return array( - 'dom' => array('classname' => 'Services_Yadis_dom', - 'libname' => array('dom.so', 'dom.dll')), - 'domxml' => array('classname' => 'Services_Yadis_domxml', - 'libname' => array('domxml.so', 'php_domxml.dll')), + 'dom' => array('classname' => 'Auth_Yadis_dom', + 'libname' => array('dom.so', 'dom.dll')), + 'domxml' => array('classname' => 'Auth_Yadis_domxml', + 'libname' => array('domxml.so', 'php_domxml.dll')), ); } /** - * Returns an instance of a Services_Yadis_XMLParser subclass based on + * Returns an instance of a Auth_Yadis_XMLParser subclass based on * the availability of PHP extensions for XML parsing. If - * Services_Yadis_setDefaultParser has been called, the parser used in + * Auth_Yadis_setDefaultParser has been called, the parser used in * that call will be returned instead. */ -function &Services_Yadis_getXMLParser() +function &Auth_Yadis_getXMLParser() { - global $__Services_Yadis_defaultParser; + global $__Auth_Yadis_defaultParser; - if (isset($__Services_Yadis_defaultParser)) { - return $__Services_Yadis_defaultParser; + if (isset($__Auth_Yadis_defaultParser)) { + return $__Auth_Yadis_defaultParser; } $p = null; $classname = null; - $extensions = Services_Yadis_getSupportedExtensions(); + $extensions = Auth_Yadis_getSupportedExtensions(); // Return a wrapper for the resident implementation, if any. foreach ($extensions as $name => $params) { @@ -364,7 +364,7 @@ function &Services_Yadis_getXMLParser() if (!isset($p)) { trigger_error('No XML parser was found', E_USER_ERROR); } else { - Services_Yadis_setDefaultParser($p); + Auth_Yadis_setDefaultParser($p); } return $p; diff --git a/Auth/Yadis/XRDS.php b/Auth/Yadis/XRDS.php index 0dbcfcd..03f142d 100644 --- a/Auth/Yadis/XRDS.php +++ b/Auth/Yadis/XRDS.php @@ -16,17 +16,17 @@ /** * Require the XPath implementation. */ -require_once 'Services/Yadis/XML.php'; +require_once 'Auth/Yadis/XML.php'; /** * This match mode means a given service must match ALL filters passed - * to the Services_Yadis_XRDS::services() call. + * to the Auth_Yadis_XRDS::services() call. */ define('SERVICES_YADIS_MATCH_ALL', 101); /** * This match mode means a given service must match ANY filters (at - * least one) passed to the Services_Yadis_XRDS::services() call. + * least one) passed to the Auth_Yadis_XRDS::services() call. */ define('SERVICES_YADIS_MATCH_ANY', 102); @@ -39,23 +39,23 @@ define('SERVICES_YADIS_MAX_PRIORITY', pow(2, 30)); /** * XRD XML namespace */ -define('Services_Yadis_XMLNS_XRD_2_0', 'xri://$xrd*($v*2.0)'); +define('Auth_Yadis_XMLNS_XRD_2_0', 'xri://$xrd*($v*2.0)'); /** * XRDS XML namespace */ -define('Services_Yadis_XMLNS_XRDS', 'xri://$xrds'); +define('Auth_Yadis_XMLNS_XRDS', 'xri://$xrds'); -function Services_Yadis_getNSMap() +function Auth_Yadis_getNSMap() { - return array('xrds' => Services_Yadis_XMLNS_XRDS, - 'xrd' => Services_Yadis_XMLNS_XRD_2_0); + return array('xrds' => Auth_Yadis_XMLNS_XRDS, + 'xrd' => Auth_Yadis_XMLNS_XRD_2_0); } /** * @access private */ -function Services_Yadis_array_scramble($arr) +function Auth_Yadis_array_scramble($arr) { $result = array(); @@ -71,21 +71,21 @@ function Services_Yadis_array_scramble($arr) /** * This class represents a <Service> element in an XRDS document. * Objects of this type are returned by - * Services_Yadis_XRDS::services() and - * Services_Yadis_Yadis::services(). Each object corresponds directly + * Auth_Yadis_XRDS::services() and + * Auth_Yadis_Yadis::services(). Each object corresponds directly * to a <Service> element in the XRDS and supplies a * getElements($name) method which you should use to inspect the - * element's contents. See {@link Services_Yadis_Yadis} for more + * element's contents. See {@link Auth_Yadis_Yadis} for more * information on the role this class plays in Yadis discovery. * * @package Yadis */ -class Services_Yadis_Service { +class Auth_Yadis_Service { /** * Creates an empty service object. */ - function Services_Yadis_Service() + function Auth_Yadis_Service() { $this->element = null; $this->parser = null; @@ -155,12 +155,12 @@ class Services_Yadis_Service { // Rebuild array of URIs. $result = array(); foreach ($keys as $k) { - $new_uris = Services_Yadis_array_scramble($uris[$k]); + $new_uris = Auth_Yadis_array_scramble($uris[$k]); $result = array_merge($result, $new_uris); } $result = array_merge($result, - Services_Yadis_array_scramble($last)); + Auth_Yadis_array_scramble($last)); return $result; } @@ -196,7 +196,7 @@ class Services_Yadis_Service { * @return array $list An array of elements with the specified * name which are direct children of the <Service> element. The * nodes returned by this function can be passed to $this->parser - * methods (see {@link Services_Yadis_XMLParser}). + * methods (see {@link Auth_Yadis_XMLParser}). */ function getElements($name) { @@ -210,22 +210,22 @@ class Services_Yadis_Service { * You should not instantiate this class directly; rather, call * parseXRDS statically: * - * <pre> $xrds = Services_Yadis_XRDS::parseXRDS($xml_string);</pre> + * <pre> $xrds = Auth_Yadis_XRDS::parseXRDS($xml_string);</pre> * * If the XRDS can be parsed and is valid, an instance of - * Services_Yadis_XRDS will be returned. Otherwise, null will be - * returned. This class is used by the Services_Yadis_Yadis::discover + * Auth_Yadis_XRDS will be returned. Otherwise, null will be + * returned. This class is used by the Auth_Yadis_Yadis::discover * method. * * @package Yadis */ -class Services_Yadis_XRDS { +class Auth_Yadis_XRDS { /** - * Instantiate a Services_Yadis_XRDS object. Requires an XPath + * Instantiate a Auth_Yadis_XRDS object. Requires an XPath * instance which has been used to parse a valid XRDS document. */ - function Services_Yadis_XRDS(&$xmlParser, &$xrdNodes) + function Auth_Yadis_XRDS(&$xmlParser, &$xrdNodes) { $this->parser =& $xmlParser; $this->xrdNode = $xrdNodes[count($xrdNodes) - 1]; @@ -236,11 +236,11 @@ class Services_Yadis_XRDS { /** * Parse an XML string (XRDS document) and return either a - * Services_Yadis_XRDS object or null, depending on whether the + * Auth_Yadis_XRDS object or null, depending on whether the * XRDS XML is valid. * * @param string $xml_string An XRDS XML string. - * @return mixed $xrds An instance of Services_Yadis_XRDS or null, + * @return mixed $xrds An instance of Auth_Yadis_XRDS or null, * depending on the validity of $xml_string */ function &parseXRDS($xml_string, $extra_ns_map = null) @@ -251,9 +251,9 @@ class Services_Yadis_XRDS { return $_null; } - $parser = Services_Yadis_getXMLParser(); + $parser = Auth_Yadis_getXMLParser(); - $ns_map = Services_Yadis_getNSMap(); + $ns_map = Auth_Yadis_getNSMap(); if ($extra_ns_map && is_array($extra_ns_map)) { $ns_map = array_merge($ns_map, $extra_ns_map); @@ -276,11 +276,11 @@ class Services_Yadis_XRDS { $attrs = $parser->attributes($root); if (array_key_exists('xmlns:xrd', $attrs) && - $attrs['xmlns:xrd'] != Services_Yadis_XMLNS_XRDS) { + $attrs['xmlns:xrd'] != Auth_Yadis_XMLNS_XRDS) { return $_null; } else if (array_key_exists('xmlns', $attrs) && preg_match('/xri/', $attrs['xmlns']) && - $attrs['xmlns'] != Services_Yadis_XMLNS_XRD_2_0) { + $attrs['xmlns'] != Auth_Yadis_XMLNS_XRD_2_0) { return $_null; } @@ -291,7 +291,7 @@ class Services_Yadis_XRDS { return $_null; } - $xrds = new Services_Yadis_XRDS($parser, $xrd_nodes); + $xrds = new Auth_Yadis_XRDS($parser, $xrd_nodes); return $xrds; } @@ -322,7 +322,7 @@ class Services_Yadis_XRDS { $services = $this->parser->evalXPath('xrd:Service', $this->xrdNode); foreach ($services as $node) { - $s =& new Services_Yadis_Service(); + $s =& new Auth_Yadis_Service(); $s->element = $node; $s->parser =& $this->parser; @@ -346,7 +346,7 @@ class Services_Yadis_XRDS { * specified filters, but $filter_mode may be * SERVICES_YADIS_MATCH_ALL if you want to be sure that the * returned services match all the given filters. See {@link - * Services_Yadis_Yadis} for detailed usage information on filter + * Auth_Yadis_Yadis} for detailed usage information on filter * functions. * * @param mixed $filters An array of callbacks to filter the @@ -356,7 +356,7 @@ class Services_Yadis_XRDS { * services should match ALL or ANY of the specified filters, * respectively. * @return mixed $services An array of {@link - * Services_Yadis_Service} objects if $filter_mode is a valid + * Auth_Yadis_Service} objects if $filter_mode is a valid * mode; null if $filter_mode is an invalid mode (i.e., not * SERVICES_YADIS_MATCH_ANY or SERVICES_YADIS_MATCH_ALL). */ diff --git a/Auth/Yadis/XRI.php b/Auth/Yadis/XRI.php index 91d385e..cfc6af9 100644 --- a/Auth/Yadis/XRI.php +++ b/Auth/Yadis/XRI.php @@ -9,25 +9,25 @@ * @license http://www.gnu.org/copyleft/lesser.html LGPL */ -require_once 'Services/Yadis/Misc.php'; -require_once 'Services/Yadis/Yadis.php'; +require_once 'Auth/Yadis/Misc.php'; +require_once 'Auth/Yadis/Yadis.php'; require_once 'Auth/OpenID.php'; -function Services_Yadis_getDefaultProxy() +function Auth_Yadis_getDefaultProxy() { return 'http://proxy.xri.net/'; } -function Services_Yadis_getXRIAuthorities() +function Auth_Yadis_getXRIAuthorities() { return array('!', '=', '@', '+', '$', '('); } -function Services_Yadis_getEscapeRE() +function Auth_Yadis_getEscapeRE() { $parts = array(); - foreach (array_merge(Services_Yadis_getUCSChars(), - Services_Yadis_getIPrivateChars()) as $pair) { + foreach (array_merge(Auth_Yadis_getUCSChars(), + Auth_Yadis_getIPrivateChars()) as $pair) { list($m, $n) = $pair; $parts[] = sprintf("%s-%s", chr($m), chr($n)); } @@ -35,28 +35,28 @@ function Services_Yadis_getEscapeRE() return sprintf('/[%s]/', implode('', $parts)); } -function Services_Yadis_getXrefRE() +function Auth_Yadis_getXrefRE() { return '/\((.*?)\)/'; } -function Services_Yadis_identifierScheme($identifier) +function Auth_Yadis_identifierScheme($identifier) { - if (Services_Yadis_startswith($identifier, 'xri://') || - (in_array($identifier[0], Services_Yadis_getXRIAuthorities()))) { + if (Auth_Yadis_startswith($identifier, 'xri://') || + (in_array($identifier[0], Auth_Yadis_getXRIAuthorities()))) { return "XRI"; } else { return "URI"; } } -function Services_Yadis_toIRINormal($xri) +function Auth_Yadis_toIRINormal($xri) { - if (!Services_Yadis_startswith($xri, 'xri://')) { + if (!Auth_Yadis_startswith($xri, 'xri://')) { $xri = 'xri://' . $xri; } - return Services_Yadis_escapeForIRI($xri); + return Auth_Yadis_escapeForIRI($xri); } function _escape_xref($xref_match) @@ -68,32 +68,32 @@ function _escape_xref($xref_match) return $xref; } -function Services_Yadis_escapeForIRI($xri) +function Auth_Yadis_escapeForIRI($xri) { $xri = str_replace('%', '%25', $xri); - $xri = preg_replace_callback(Services_Yadis_getXrefRE(), + $xri = preg_replace_callback(Auth_Yadis_getXrefRE(), '_escape_xref', $xri); return $xri; } -function Services_Yadis_toURINormal($xri) +function Auth_Yadis_toURINormal($xri) { - return Services_Yadis_iriToURI(Services_Yadis_toIRINormal($xri)); + return Auth_Yadis_iriToURI(Auth_Yadis_toIRINormal($xri)); } -function Services_Yadis_iriToURI($iri) +function Auth_Yadis_iriToURI($iri) { if (1) { return $iri; } else { // According to RFC 3987, section 3.1, "Mapping of IRIs to URIs" - return preg_replace_callback(Services_Yadis_getEscapeRE(), - 'Services_Yadis_pct_escape_unicode', $iri); + return preg_replace_callback(Auth_Yadis_getEscapeRE(), + 'Auth_Yadis_pct_escape_unicode', $iri); } } -function Services_Yadis_XRIAppendArgs($url, $args) +function Auth_Yadis_XRIAppendArgs($url, $args) { // Append some arguments to an HTTP query. Yes, this is just like // OpenID's appendArgs, but with special seasoning for XRI @@ -133,20 +133,20 @@ function Services_Yadis_XRIAppendArgs($url, $args) return $url . $sep . Auth_OpenID::httpBuildQuery($args); } -function Services_Yadis_providerIsAuthoritative($providerID, $canonicalID) +function Auth_Yadis_providerIsAuthoritative($providerID, $canonicalID) { $lastbang = strrpos($canonicalID, '!'); $p = substr($canonicalID, 0, $lastbang); return $p == $providerID; } -function Services_Yadis_rootAuthority($xri) +function Auth_Yadis_rootAuthority($xri) { // Return the root authority for an XRI. $root = null; - if (Services_Yadis_startswith($xri, 'xri://')) { + if (Auth_Yadis_startswith($xri, 'xri://')) { $xri = substr($xri, 6); } @@ -159,7 +159,7 @@ function Services_Yadis_rootAuthority($xri) // does that before we have a real xriparse function. // Hopefully nobody does that *ever*. $root = substr($authority, 0, strpos($authority, ')') + 1); - } else if (in_array($authority[0], Services_Yadis_getXRIAuthorities())) { + } else if (in_array($authority[0], Auth_Yadis_getXRIAuthorities())) { // Other XRI reference. $root = $authority[0]; } else { @@ -172,20 +172,20 @@ function Services_Yadis_rootAuthority($xri) $root = $segments[0]; } - return Services_Yadis_XRI($root); + return Auth_Yadis_XRI($root); } -function Services_Yadis_XRI($xri) +function Auth_Yadis_XRI($xri) { - if (!Services_Yadis_startswith($xri, 'xri://')) { + if (!Auth_Yadis_startswith($xri, 'xri://')) { $xri = 'xri://' . $xri; } return $xri; } -function Services_Yadis_getCanonicalID($iname, $xrds) +function Auth_Yadis_getCanonicalID($iname, $xrds) { - // Returns FALSE or a canonical ID value. + // Returns false or a canonical ID value. // Now nodes are in reverse order. $xrd_list = array_reverse($xrds->allXrdNodes); @@ -199,7 +199,7 @@ function Services_Yadis_getCanonicalID($iname, $xrds) } $canonicalID = $canonicalID_nodes[count($canonicalID_nodes) - 1]; - $canonicalID = Services_Yadis_XRI($parser->content($canonicalID)); + $canonicalID = Auth_Yadis_XRI($parser->content($canonicalID)); $childID = $canonicalID; @@ -210,7 +210,7 @@ function Services_Yadis_getCanonicalID($iname, $xrds) $parent_list = array(); foreach ($parser->evalXPath('xrd:CanonicalID', $xrd) as $c) { - $parent_list[] = Services_Yadis_XRI($parser->content($c)); + $parent_list[] = Auth_Yadis_XRI($parser->content($c)); } if (!in_array($parent_sought, $parent_list)) { @@ -221,8 +221,8 @@ function Services_Yadis_getCanonicalID($iname, $xrds) $childID = $parent_sought; } - $root = Services_Yadis_rootAuthority($iname); - if (!Services_Yadis_providerIsAuthoritative($root, $childID)) { + $root = Auth_Yadis_rootAuthority($iname); + if (!Auth_Yadis_providerIsAuthoritative($root, $childID)) { // raise XRDSFraud. return false; } diff --git a/Auth/Yadis/XRIRes.php b/Auth/Yadis/XRIRes.php index b87cf04..b90591f 100644 --- a/Auth/Yadis/XRIRes.php +++ b/Auth/Yadis/XRIRes.php @@ -1,22 +1,26 @@ <?php -require_once 'Services/Yadis/XRDS.php'; -require_once 'Services/Yadis/XRI.php'; +/** + * Code for using a proxy XRI resolver. + */ -class Services_Yadis_ProxyResolver { - function Services_Yadis_ProxyResolver(&$fetcher, $proxy_url = null) +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 = Services_Yadis_getDefaultProxy(); + $this->proxy_url = Auth_Yadis_getDefaultProxy(); } } function queryURL($xri, $service_type = null) { // trim off the xri:// prefix - $qxri = substr(Services_Yadis_toURINormal($xri), 6); + $qxri = substr(Auth_Yadis_toURINormal($xri), 6); $hxri = $this->proxy_url . $qxri; $args = array( '_xrd_r' => 'application/xrds+xml' @@ -29,7 +33,7 @@ class Services_Yadis_ProxyResolver { $args['_xrd_r'] .= ';sep=false'; } - $query = Services_Yadis_XRIAppendArgs($hxri, $args); + $query = Auth_Yadis_XRIAppendArgs($hxri, $args); return $query; } @@ -43,11 +47,11 @@ class Services_Yadis_ProxyResolver { if ($response->status != 200) { continue; } - $xrds = Services_Yadis_XRDS::parseXRDS($response->body); + $xrds = Auth_Yadis_XRDS::parseXRDS($response->body); if (!$xrds) { continue; } - $canonicalID = Services_Yadis_getCanonicalID($xri, + $canonicalID = Auth_Yadis_getCanonicalID($xri, $xrds); if ($canonicalID === false) { diff --git a/Auth/Yadis/Yadis.php b/Auth/Yadis/Yadis.php index 4bb73fd..b6dad09 100644 --- a/Auth/Yadis/Yadis.php +++ b/Auth/Yadis/Yadis.php @@ -17,31 +17,31 @@ * Need both fetcher types so we can use the right one based on the * presence or absence of CURL. */ -require_once "Services/Yadis/PlainHTTPFetcher.php"; -require_once "Services/Yadis/ParanoidHTTPFetcher.php"; +require_once "Auth/Yadis/PlainHTTPFetcher.php"; +require_once "Auth/Yadis/ParanoidHTTPFetcher.php"; /** * Need this for parsing HTML (looking for META tags). */ -require_once "Services/Yadis/ParseHTML.php"; +require_once "Auth/Yadis/ParseHTML.php"; /** * Need this to parse the XRDS document during Yadis discovery. */ -require_once "Services/Yadis/XRDS.php"; +require_once "Auth/Yadis/XRDS.php"; /** * XRDS (yadis) content type */ -define('Services_Yadis_CONTENT_TYPE', 'application/xrds+xml'); +define('Auth_Yadis_CONTENT_TYPE', 'application/xrds+xml'); /** * Yadis header */ -define('Services_Yadis_HEADER_NAME', 'X-XRDS-Location'); +define('Auth_Yadis_HEADER_NAME', 'X-XRDS-Location'); // Contains the result of performing Yadis discovery on a URI -class Services_Yadis_DiscoveryResult { +class Auth_Yadis_DiscoveryResult { // The URI that was passed to the fetcher var $request_uri = null; @@ -64,7 +64,7 @@ class Services_Yadis_DiscoveryResult { // Did the discovery fail miserably? var $failed = false; - function Services_Yadis_DiscoveryResult($request_uri) + function Auth_Yadis_DiscoveryResult($request_uri) { // Initialize the state of the object // sets all attributes to None except the request_uri @@ -86,7 +86,7 @@ class Services_Yadis_DiscoveryResult { * document, if this yadis object represents a successful Yadis * discovery. * - * @return array $services An array of {@link Services_Yadis_Service} + * @return array $services An array of {@link Auth_Yadis_Service} * objects */ function services() @@ -108,7 +108,7 @@ class Services_Yadis_DiscoveryResult { { // Is the response text supposed to be an XRDS document? return ($this->usedYadisLocation() || - $this->content_type == Services_Yadis_CONTENT_TYPE); + $this->content_type == Auth_Yadis_CONTENT_TYPE); } } @@ -119,25 +119,25 @@ class Services_Yadis_DiscoveryResult { * * First, require this library into your program source: * - * <pre> require_once "Services/Yadis/Yadis.php";</pre> + * <pre> require_once "Auth/Yadis/Yadis.php";</pre> * * To perform Yadis discovery, first call the "discover" method * statically with a URI parameter: * * <pre> $http_response = array(); - * $fetcher = Services_Yadis_Yadis::getHTTPFetcher(); - * $yadis_object = Services_Yadis_Yadis::discover($uri, + * $fetcher = Auth_Yadis_Yadis::getHTTPFetcher(); + * $yadis_object = Auth_Yadis_Yadis::discover($uri, * $http_response, $fetcher);</pre> * * If the discovery succeeds, $yadis_object will be an instance of - * {@link Services_Yadis_Yadis}. If not, it will be null. The XRDS + * {@link Auth_Yadis_Yadis}. If not, it will be null. The XRDS * document found during discovery should have service descriptions, * which can be accessed by calling * * <pre> $service_list = $yadis_object->services();</pre> * * which returns an array of objects which describe each service. - * These objects are instances of Services_Yadis_Service. Each object + * These objects are instances of Auth_Yadis_Service. Each object * describes exactly one whole Service element, complete with all of * its Types and URIs (no expansion is performed). The common use * case for using the service objects returned by services() is to @@ -156,7 +156,7 @@ class Services_Yadis_DiscoveryResult { * }</pre> * * This is an example of a filter which uses a regular expression to - * match the content of URI tags (note that the Services_Yadis_Service + * match the content of URI tags (note that the Auth_Yadis_Service * class provides a getURIs() method which you should use instead of * this contrived example): * @@ -189,24 +189,24 @@ class Services_Yadis_DiscoveryResult { * probably be using. Those libraries are responsible for defining * filters that can be used with the "services()" call. If you need * to write your own filter, see the documentation for {@link - * Services_Yadis_Service}. + * Auth_Yadis_Service}. * * @package Yadis */ -class Services_Yadis_Yadis { +class Auth_Yadis_Yadis { /** * Returns an HTTP fetcher object. If the CURL extension is - * present, an instance of {@link Services_Yadis_ParanoidHTTPFetcher} + * present, an instance of {@link Auth_Yadis_ParanoidHTTPFetcher} * is returned. If not, an instance of - * {@link Services_Yadis_PlainHTTPFetcher} is returned. + * {@link Auth_Yadis_PlainHTTPFetcher} is returned. */ function getHTTPFetcher($timeout = 20) { - if (Services_Yadis_Yadis::curlPresent()) { - $fetcher = new Services_Yadis_ParanoidHTTPFetcher($timeout); + if (Auth_Yadis_Yadis::curlPresent()) { + $fetcher = new Auth_Yadis_ParanoidHTTPFetcher($timeout); } else { - $fetcher = new Services_Yadis_PlainHTTPFetcher($timeout); + $fetcher = new Auth_Yadis_PlainHTTPFetcher($timeout); } return $fetcher; } @@ -252,10 +252,10 @@ class Services_Yadis_Yadis { * * @param array $http_response An array reference where the HTTP * response object will be stored (see {@link - * Services_Yadis_HTTPResponse}. + * Auth_Yadis_HTTPResponse}. * - * @param Services_Yadis_HTTPFetcher $fetcher An instance of a - * Services_Yadis_HTTPFetcher subclass. + * @param Auth_Yadis_HTTPFetcher $fetcher An instance of a + * Auth_Yadis_HTTPFetcher subclass. * * @param array $extra_ns_map An array which maps namespace names * to namespace URIs to be used when parsing the Yadis XRDS @@ -264,19 +264,19 @@ class Services_Yadis_Yadis { * @param integer $timeout An optional fetcher timeout, in seconds. * * @return mixed $obj Either null or an instance of - * Services_Yadis_Yadis, depending on whether the discovery + * Auth_Yadis_Yadis, depending on whether the discovery * succeeded. */ function discover($uri, &$fetcher, $extra_ns_map = null, $timeout = 20) { - $result = new Services_Yadis_DiscoveryResult($uri); + $result = new Auth_Yadis_DiscoveryResult($uri); $request_uri = $uri; - $headers = array("Accept: " . Services_Yadis_CONTENT_TYPE); + $headers = array("Accept: " . Auth_Yadis_CONTENT_TYPE); if (!$fetcher) { - $fetcher = Services_Yadis_Yadis::getHTTPFetcher($timeout); + $fetcher = Auth_Yadis_Yadis::getHTTPFetcher($timeout); } $response = $fetcher->get($uri, $headers); @@ -287,20 +287,21 @@ class Services_Yadis_Yadis { } $result->normalized_uri = $response->final_url; - $result->content_type = Services_Yadis_Yadis::_getHeader($response->headers, - array('content-type')); + $result->content_type = Auth_Yadis_Yadis::_getHeader( + $response->headers, + array('content-type')); if ($result->content_type && - (Services_Yadis_Yadis::_getContentType($result->content_type) == - Services_Yadis_CONTENT_TYPE)) { + (Auth_Yadis_Yadis::_getContentType($result->content_type) == + Auth_Yadis_CONTENT_TYPE)) { $result->xrds_uri = $result->normalized_uri; } else { - $yadis_location = Services_Yadis_Yadis::_getHeader( - $response->headers, - array(Services_Yadis_HEADER_NAME)); + $yadis_location = Auth_Yadis_Yadis::_getHeader( + $response->headers, + array(Auth_Yadis_HEADER_NAME)); if (!$yadis_location) { - $parser = new Services_Yadis_ParseHTML(); + $parser = new Auth_Yadis_ParseHTML(); $yadis_location = $parser->getHTTPEquiv($response->body); } @@ -314,7 +315,7 @@ class Services_Yadis_Yadis { return $result; } - $result->content_type = Services_Yadis_Yadis::_getHeader( + $result->content_type = Auth_Yadis_Yadis::_getHeader( $response->headers, array('content-type')); } diff --git a/Tests/Auth/OpenID/Consumer.php b/Tests/Auth/OpenID/Consumer.php index 853e47b..67e6d4f 100644 --- a/Tests/Auth/OpenID/Consumer.php +++ b/Tests/Auth/OpenID/Consumer.php @@ -16,7 +16,7 @@ session_start(); require_once 'Auth/OpenID/CryptUtil.php'; -require_once 'Services/Yadis/HTTPFetcher.php'; +require_once 'Auth/Yadis/HTTPFetcher.php'; require_once 'Auth/OpenID/DiffieHellman.php'; require_once 'Auth/OpenID/FileStore.php'; require_once 'Auth/OpenID/KVForm.php'; @@ -90,12 +90,12 @@ function Auth_OpenID_associate($qs, $assoc_secret, $assoc_handle) return Auth_OpenID_KVForm::fromArray($reply_dict); } -class Auth_OpenID_TestFetcher extends Services_Yadis_HTTPFetcher { +class Auth_OpenID_TestFetcher extends Auth_Yadis_HTTPFetcher { function Auth_OpenID_TestFetcher($user_url, $user_page, $assoc_secret, $assoc_handle) { $this->get_responses = array($user_url => - new Services_Yadis_HTTPResponse($user_url, + new Auth_Yadis_HTTPResponse($user_url, 200, array(), $user_page)); @@ -107,9 +107,9 @@ class Auth_OpenID_TestFetcher extends Services_Yadis_HTTPFetcher { function response($url, $body) { if ($body === null) { - return new Services_Yadis_HTTPResponse($url, 404, array(), 'Not found'); + return new Auth_Yadis_HTTPResponse($url, 404, array(), 'Not found'); } else { - return new Services_Yadis_HTTPResponse($url, 200, array(), $body); + return new Auth_Yadis_HTTPResponse($url, 200, array(), $body); } } @@ -133,9 +133,9 @@ class Auth_OpenID_TestFetcher extends Services_Yadis_HTTPFetcher { ); if ($query_data == $expected) { - return new Services_Yadis_HTTPResponse($url, 200, array(), "is_valid:true\n"); + return new Auth_Yadis_HTTPResponse($url, 200, array(), "is_valid:true\n"); } else { - return new Services_Yadis_HTTPResponse($url, 400, array(), + return new Auth_Yadis_HTTPResponse($url, 400, array(), "error:bad check_authentication query\n"); } } @@ -1279,7 +1279,7 @@ class _ExceptionRaisingMockFetcher { { __raiseError(E_MOCK_FETCHER_EXCEPTION); - return new Services_Yadis_HTTPResponse($url, 400, + return new Auth_Yadis_HTTPResponse($url, 400, array(), ''); } } @@ -1310,7 +1310,7 @@ class Tests_Auth_OpenID_Consumer_TestCheckAuth extends _TestIdRes { function test_checkauth_error() { global $_Auth_OpenID_server_url; - $this->fetcher->response = new Services_Yadis_HTTPResponse("http://some_url", + $this->fetcher->response = new Auth_Yadis_HTTPResponse("http://some_url", 404, array(), "blah:blah\n"); @@ -1369,7 +1369,7 @@ class Tests_Auth_OpenID_Consumer_TestFetchAssoc extends PHPUnit_TestCase { function test_kvpost_error() { - $this->fetcher->response = new Services_Yadis_HTTPResponse("http://some_url", + $this->fetcher->response = new Auth_Yadis_HTTPResponse("http://some_url", 404, array(), "blah:blah\n"); @@ -1386,7 +1386,7 @@ class Tests_Auth_OpenID_Consumer_TestFetchAssoc extends PHPUnit_TestCase { function test_error_404() { // 404 from a kv post raises HTTPFetchingError - $this->fetcher->response = new Services_Yadis_HTTPResponse( + $this->fetcher->response = new Auth_Yadis_HTTPResponse( "http://some_url", 404, array('Hea'=> 'der'), 'blah:blah\n'); $result = $this->consumer->_makeKVPost( @@ -1543,11 +1543,11 @@ class Tests_Auth_OpenID_DiscoFailure extends PHPUnit_TestCase { $this->claimed_id = 'http://identity.url/'; $this->endpoint->claimed_id = $this->claimed_id; $this->store = null; - $this->session = new Services_Yadis_PHPSession(); + $this->session = new Auth_Yadis_PHPSession(); $cls = $this->consumerClass; $this->consumer =& new $cls($this->store, &$this->session); $this->consumer->consumer =& new _StubConsumer(); - $this->discovery =& new Services_Yadis_Discovery(&$this->session, + $this->discovery =& new Auth_Yadis_Discovery(&$this->session, $this->claimed_id, $this->consumer->session_key_prefix); } @@ -1564,10 +1564,10 @@ class Tests_Auth_OpenID_ConsumerTest2 extends PHPUnit_TestCase { $this->claimed_id = 'http://identity.url/'; $this->endpoint->claimed_id = $this->claimed_id; $this->store = null; - $this->session = new Services_Yadis_PHPSession(); + $this->session = new Auth_Yadis_PHPSession(); $this->consumer =& new Auth_OpenID_Consumer($this->store, $this->session); $this->consumer->consumer =& new _StubConsumer(); - $this->discovery =& new Services_Yadis_Discovery(&$this->session, + $this->discovery =& new Auth_Yadis_Discovery(&$this->session, $this->claimed_id, $this->consumer->session_key_prefix); } diff --git a/Tests/Auth/OpenID/Discover_OpenID.php b/Tests/Auth/OpenID/Discover_OpenID.php index 43ab1a1..4fa0743 100644 --- a/Tests/Auth/OpenID/Discover_OpenID.php +++ b/Tests/Auth/OpenID/Discover_OpenID.php @@ -5,9 +5,9 @@ require_once 'TestUtil.php'; require_once 'Auth/OpenID.php'; require_once 'Auth/OpenID/Discover.php'; -require_once 'Services/Yadis/Manager.php'; -require_once 'Services/Yadis/Misc.php'; -require_once 'Services/Yadis/XRI.php'; +require_once 'Auth/Yadis/Manager.php'; +require_once 'Auth/Yadis/Misc.php'; +require_once 'Auth/Yadis/XRI.php'; /** * Tests for the core of the PHP Yadis library discovery logic. @@ -151,7 +151,7 @@ class _DiscoveryMockFetcher { $body = ''; } - return new Services_Yadis_HTTPResponse($final_url, $status, + return new Auth_Yadis_HTTPResponse($final_url, $status, array('content-type' => $ctype), $body); } } @@ -481,7 +481,7 @@ class _MockFetcherForXRIProxy { trigger_error('Error in mock XRI fetcher: no headers or query'); } - if (Services_Yadis_startswith($xri, '/')) { + if (Auth_Yadis_startswith($xri, '/')) { $xri = substr($xri, 1); } @@ -494,7 +494,7 @@ class _MockFetcherForXRIProxy { $body = ''; } - return new Services_Yadis_HTTPResponse($url, $status, + return new Auth_Yadis_HTTPResponse($url, $status, array('content-type' => $ctype), $body); } diff --git a/Tests/Auth/OpenID/Message.php b/Tests/Auth/OpenID/Message.php index 9c4e637..d95f17e 100644 --- a/Tests/Auth/OpenID/Message.php +++ b/Tests/Auth/OpenID/Message.php @@ -915,7 +915,7 @@ class Tests_Auth_OpenID_GeneralMessageTest extends PHPUnit_TestCase { function _checkForm($html, $message_, $action_url, $form_tag_attrs, $submit_text) { - $parser =& Services_Yadis_getXMLParser(); + $parser =& Auth_Yadis_getXMLParser(); // Parse HTML source $this->assertTrue($parser->init($html, array())); diff --git a/Tests/Auth/OpenID/OpenID_Yadis.php b/Tests/Auth/OpenID/OpenID_Yadis.php index 7ce85d7..02981c0 100644 --- a/Tests/Auth/OpenID/OpenID_Yadis.php +++ b/Tests/Auth/OpenID/OpenID_Yadis.php @@ -6,7 +6,7 @@ */ require_once "PHPUnit.php"; -require_once "Services/Yadis/XRDS.php"; +require_once "Auth/Yadis/XRDS.php"; require_once "Auth/OpenID/Discover.php"; global $__XRDS_BOILERPLATE; @@ -164,7 +164,7 @@ class Tests_Auth_OpenID_Tester extends PHPUnit_TestCase { function runTest() { // Parse into endpoint objects that we will check - $xrds_object = Services_Yadis_XRDS::parseXRDS($this->xrds); + $xrds_object = Auth_Yadis_XRDS::parseXRDS($this->xrds); $endpoints = array(); diff --git a/Tests/Auth/Yadis/DiscoverData.php b/Tests/Auth/Yadis/DiscoverData.php index 60aa5e2..816a06b 100644 --- a/Tests/Auth/Yadis/DiscoverData.php +++ b/Tests/Auth/Yadis/DiscoverData.php @@ -1,7 +1,7 @@ <?php -require_once "Services/Yadis/Yadis.php"; -require_once "Tests/Services/Yadis/TestUtil.php"; +require_once "Auth/Yadis/Yadis.php"; +require_once "Tests/Auth/Yadis/TestUtil.php"; global $testlist; $testlist = array( @@ -27,7 +27,7 @@ $testlist = array( function getExampleXRDS() { - return Tests_Services_Yadis_readdata('example-xrds.xml'); + return Tests_Auth_Yadis_readdata('example-xrds.xml'); } global $example_xrds; @@ -41,7 +41,7 @@ $discover_tests = array(); function readTests($filename) { - $data = Tests_Services_Yadis_readdata($filename); + $data = Tests_Auth_Yadis_readdata($filename); if ($data === null) { return null; @@ -138,7 +138,7 @@ function generateResult($base_url, $input_name, $id_name, $result_name, $success $id_url = $base_url . $id_name; - $result = new Services_Yadis_Yadis(); + $result = new Auth_Yadis_Yadis(); $result->uri = $id_url; if ($success) { $result->xrds_uri = $base_url . $result_name; diff --git a/Tests/Auth/Yadis/Discover_Yadis.php b/Tests/Auth/Yadis/Discover_Yadis.php index 7ec9d7d..c5f67a7 100644 --- a/Tests/Auth/Yadis/Discover_Yadis.php +++ b/Tests/Auth/Yadis/Discover_Yadis.php @@ -1,9 +1,9 @@ <?php require_once "PHPUnit.php"; -require_once "Tests/Services/Yadis/DiscoverData.php"; -require_once "Services/Yadis/Yadis.php"; -require_once "Services/Yadis/HTTPFetcher.php"; +require_once "Tests/Auth/Yadis/DiscoverData.php"; +require_once "Auth/Yadis/Yadis.php"; +require_once "Auth/Yadis/HTTPFetcher.php"; global $__status_header_re; $__status_header_re = '/Status: (\d+) .*?$/m'; @@ -23,7 +23,7 @@ function mkResponse($data) $headers[$k] = $v; } $status = intval($matches[1]); - $r = new Services_Yadis_HTTPResponse(null, $status, $headers, $body); + $r = new Auth_Yadis_HTTPResponse(null, $status, $headers, $body); return $r; } class TestFetcher { @@ -41,7 +41,7 @@ class TestFetcher { $data = generateSample($path, $this->base_url); if ($data === null) { - return new Services_Yadis_HTTPResponse($current_url, + return new Auth_Yadis_HTTPResponse($current_url, 404, array(), ''); @@ -68,9 +68,9 @@ class MockFetcher { $this->count++; if ($this->count == 1) { $headers = array(strtolower('X-XRDS-Location') . ': http://unittest/404'); - return new Services_Yadis_HTTPResponse($uri, 200, $headers, ''); + return new Auth_Yadis_HTTPResponse($uri, 200, $headers, ''); } else { - return new Services_Yadis_HTTPResponse($uri, 404); + return new Auth_Yadis_HTTPResponse($uri, 404); } } } @@ -82,7 +82,7 @@ class TestSecondGet extends PHPUnit_TestCase { $response = null; $fetcher = new MockFetcher(); $this->assertTrue( - Services_Yadis_Yadis::discover($uri, $response, $fetcher) === null); + Auth_Yadis_Yadis::discover($uri, $response, $fetcher) === null); } } @@ -111,11 +111,11 @@ class _TestCase extends PHPUnit_TestCase { function runTest() { if ($this->expected === null) { - $result = Services_Yadis_Yadis::discover($this->input_url, + $result = Auth_Yadis_Yadis::discover($this->input_url, $this->fetcher); $this->assertTrue($result->isFailure()); } else { - $result = Services_Yadis_Yadis::discover($this->input_url, + $result = Auth_Yadis_Yadis::discover($this->input_url, $this->fetcher); if ($result === null) { @@ -148,14 +148,14 @@ class _TestCase extends PHPUnit_TestCase { } } -class Tests_Services_Yadis_Discover_Yadis extends PHPUnit_TestSuite { +class Tests_Auth_Yadis_Discover_Yadis extends PHPUnit_TestSuite { function getName() { - return "Tests_Services_Yadis_Discover_Yadis"; + return "Tests_Auth_Yadis_Discover_Yadis"; } - function Tests_Services_Yadis_Discover_Yadis() + function Tests_Auth_Yadis_Discover_Yadis() { global $testlist; diff --git a/Tests/Auth/Yadis/ParseHTML.php b/Tests/Auth/Yadis/ParseHTML.php index 744af45..a3f4891 100644 --- a/Tests/Auth/Yadis/ParseHTML.php +++ b/Tests/Auth/Yadis/ParseHTML.php @@ -13,19 +13,19 @@ * @license http://www.gnu.org/copyleft/lesser.html LGPL */ -require_once 'Tests/Services/Yadis/TestUtil.php'; -require_once 'Services/Yadis/ParseHTML.php'; +require_once 'Tests/Auth/Yadis/TestUtil.php'; +require_once 'Auth/Yadis/ParseHTML.php'; require_once 'PHPUnit.php'; -class Tests_Services_Yadis_ParseTest extends PHPUnit_TestCase { - function Tests_Services_Yadis_ParseTest($case) +class Tests_Auth_Yadis_ParseTest extends PHPUnit_TestCase { + function Tests_Auth_Yadis_ParseTest($case) { list($result, $comment, $html) = $case; $this->result = $result; $this->comment = $comment; $this->html_string = $html; - $this->parser = new Services_Yadis_ParseHTML(); + $this->parser = new Auth_Yadis_ParseHTML(); } function getName() @@ -47,11 +47,11 @@ class Tests_Services_Yadis_ParseTest extends PHPUnit_TestCase { } } -class Tests_Services_Yadis_ParseHTML extends PHPUnit_TestSuite { +class Tests_Auth_Yadis_ParseHTML extends PHPUnit_TestSuite { function getName() { - return "Tests_Services_Yadis_Parse"; + return "Tests_Auth_Yadis_Parse"; } function parseTests($s) @@ -73,14 +73,14 @@ class Tests_Services_Yadis_ParseHTML extends PHPUnit_TestSuite { return $tests; } - function Tests_Services_Yadis_ParseHTML() + function Tests_Auth_Yadis_ParseHTML() { - $test_data = Tests_Services_Yadis_readdata('test1-parsehtml.txt'); + $test_data = Tests_Auth_Yadis_readdata('test1-parsehtml.txt'); $test_cases = $this->parseTests($test_data); foreach ($test_cases as $case) { - $this->addTest(new Tests_Services_Yadis_ParseTest($case)); + $this->addTest(new Tests_Auth_Yadis_ParseTest($case)); } } } diff --git a/Tests/Auth/Yadis/TestUtil.php b/Tests/Auth/Yadis/TestUtil.php index e6d7a57..66fb0e0 100644 --- a/Tests/Auth/Yadis/TestUtil.php +++ b/Tests/Auth/Yadis/TestUtil.php @@ -4,7 +4,7 @@ * Utilites for test functions */ -function Tests_Services_Yadis_datafile($name, $reader) +function Tests_Auth_Yadis_datafile($name, $reader) { $path = dirname(realpath(__FILE__)); $sep = DIRECTORY_SEPARATOR; @@ -17,12 +17,12 @@ function Tests_Services_Yadis_datafile($name, $reader) return $data; } -function Tests_Services_Yadis_readdata($name) +function Tests_Auth_Yadis_readdata($name) { - return Tests_Services_Yadis_datafile($name, 'file_get_contents'); + return Tests_Auth_Yadis_datafile($name, 'file_get_contents'); } -function Tests_Services_Yadis_readlines($name) +function Tests_Auth_Yadis_readlines($name) { - return Tests_Services_Yadis_datafile($name, 'file'); + return Tests_Auth_Yadis_datafile($name, 'file'); } diff --git a/Tests/Auth/Yadis/XRDS.php b/Tests/Auth/Yadis/XRDS.php index 102a3b9..4aa639c 100644 --- a/Tests/Auth/Yadis/XRDS.php +++ b/Tests/Auth/Yadis/XRDS.php @@ -5,12 +5,12 @@ */ require_once 'PHPUnit.php'; -require_once 'Services/Yadis/XRDS.php'; -require_once 'Services/Yadis/XRIRes.php'; -require_once 'Services/Yadis/XRI.php'; -require_once 'Tests/Services/Yadis/TestUtil.php'; +require_once 'Auth/Yadis/XRDS.php'; +require_once 'Auth/Yadis/XRIRes.php'; +require_once 'Auth/Yadis/XRI.php'; +require_once 'Tests/Auth/Yadis/TestUtil.php'; -class Tests_Services_Yadis_XRDS extends PHPUnit_TestCase { +class Tests_Auth_Yadis_XRDS extends PHPUnit_TestCase { function test_good() { @@ -20,8 +20,8 @@ class Tests_Services_Yadis_XRDS extends PHPUnit_TestCase { ); foreach ($files as $filename => $service_count) { - $xml = Tests_Services_Yadis_readdata($filename); - $xrds = Services_Yadis_XRDS::parseXRDS($xml); + $xml = Tests_Auth_Yadis_readdata($filename); + $xrds = Auth_Yadis_XRDS::parseXRDS($xml); $this->assertTrue($xrds !== null); @@ -36,8 +36,8 @@ class Tests_Services_Yadis_XRDS extends PHPUnit_TestCase { function test_good_multi() { - $xml = Tests_Services_Yadis_readdata("brian.multi.xrds"); - $xrds = Services_Yadis_XRDS::parseXRDS($xml); + $xml = Tests_Auth_Yadis_readdata("brian.multi.xrds"); + $xrds = Auth_Yadis_XRDS::parseXRDS($xml); $this->assertTrue($xrds !== null); $this->assertEquals(count($xrds->services()), 1); $s = $xrds->services(); @@ -52,16 +52,16 @@ class Tests_Services_Yadis_XRDS extends PHPUnit_TestCase { function test_good_uri_multi() { - $xml = Tests_Services_Yadis_readdata("brian.multi_uri.xrds"); - $xrds = Services_Yadis_XRDS::parseXRDS($xml); + $xml = Tests_Auth_Yadis_readdata("brian.multi_uri.xrds"); + $xrds = Auth_Yadis_XRDS::parseXRDS($xml); $this->assertTrue($xrds !== null); $this->assertEquals(1, count($xrds->services())); } function test_uri_sorting() { - $xml = Tests_Services_Yadis_readdata("uri_priority.xrds"); - $xrds = Services_Yadis_XRDS::parseXRDS($xml); + $xml = Tests_Auth_Yadis_readdata("uri_priority.xrds"); + $xrds = Auth_Yadis_XRDS::parseXRDS($xml); $services = $xrds->services(); $uris = $services[0]->getURIs(); @@ -76,12 +76,12 @@ class Tests_Services_Yadis_XRDS extends PHPUnit_TestCase { function test_bad() { - $this->assertTrue(Services_Yadis_XRDS::parseXRDS(null) === null); - $this->assertTrue(Services_Yadis_XRDS::parseXRDS(5) === null); - $this->assertTrue(Services_Yadis_XRDS::parseXRDS('') === null); - $this->assertTrue(Services_Yadis_XRDS::parseXRDS('<html></html>') === + $this->assertTrue(Auth_Yadis_XRDS::parseXRDS(null) === null); + $this->assertTrue(Auth_Yadis_XRDS::parseXRDS(5) === null); + $this->assertTrue(Auth_Yadis_XRDS::parseXRDS('') === null); + $this->assertTrue(Auth_Yadis_XRDS::parseXRDS('<html></html>') === null); - $this->assertTrue(Services_Yadis_XRDS::parseXRDS("\x00") === null); + $this->assertTrue(Auth_Yadis_XRDS::parseXRDS("\x00") === null); } function test_getCanonicalID() @@ -109,8 +109,8 @@ class Tests_Services_Yadis_XRDS extends PHPUnit_TestCase { foreach ($canonicalIDtests as $tupl) { list($iname, $filename, $expectedID) = $tupl; - $xml = Tests_Services_Yadis_readdata($filename); - $xrds = Services_Yadis_XRDS::parseXRDS($xml); + $xml = Tests_Auth_Yadis_readdata($filename); + $xrds = Auth_Yadis_XRDS::parseXRDS($xml); $this->_getCanonicalID($iname, $xrds, $expectedID); } } @@ -118,13 +118,13 @@ class Tests_Services_Yadis_XRDS extends PHPUnit_TestCase { function _getCanonicalID($iname, $xrds, $expectedID) { if ($expectedID === null) { - $result = Services_Yadis_getCanonicalID($iname, $xrds); + $result = Auth_Yadis_getCanonicalID($iname, $xrds); if ($result !== false) { $this->fail($iname.' (got '.$result.')'); } } else { - $cid = Services_Yadis_getCanonicalID($iname, $xrds); - $this->assertEquals(Services_Yadis_XRI($expectedID), $cid); + $cid = Auth_Yadis_getCanonicalID($iname, $xrds); + $this->assertEquals(Auth_Yadis_XRI($expectedID), $cid); } } @@ -132,8 +132,8 @@ class Tests_Services_Yadis_XRDS extends PHPUnit_TestCase { { // First, just be sure that service objects do the right // thing. - $xml = Tests_Services_Yadis_readdata("brian_priority.xrds"); - $xrds = Services_Yadis_XRDS::parseXRDS($xml, + $xml = Tests_Auth_Yadis_readdata("brian_priority.xrds"); + $xrds = Auth_Yadis_XRDS::parseXRDS($xml, array('openid' => 'http://openid.net/xmlns/1.0')); $this->assertTrue($xrds !== null); diff --git a/Tests/Auth/Yadis/XRI.php b/Tests/Auth/Yadis/XRI.php index f00fef1..29fd367 100644 --- a/Tests/Auth/Yadis/XRI.php +++ b/Tests/Auth/Yadis/XRI.php @@ -10,31 +10,31 @@ */ require_once "PHPUnit.php"; -require_once "Services/Yadis/XRIRes.php"; -require_once "Services/Yadis/XRI.php"; -require_once "Services/Yadis/Yadis.php"; +require_once "Auth/Yadis/XRIRes.php"; +require_once "Auth/Yadis/XRI.php"; +require_once "Auth/Yadis/Yadis.php"; -class Tests_Services_Yadis_XriDiscoveryTestCase extends PHPUnit_TestCase { +class Tests_Auth_Yadis_XriDiscoveryTestCase extends PHPUnit_TestCase { function runTest() { $this->assertEquals( - Services_Yadis_identifierScheme('=john.smith'), 'XRI'); + Auth_Yadis_identifierScheme('=john.smith'), 'XRI'); $this->assertEquals( - Services_Yadis_identifierScheme('@smiths/john'), 'XRI'); + Auth_Yadis_identifierScheme('@smiths/john'), 'XRI'); $this->assertEquals( - Services_Yadis_identifierScheme('smoker.myopenid.com'), 'URI'); + Auth_Yadis_identifierScheme('smoker.myopenid.com'), 'URI'); $this->assertEquals( - Services_Yadis_identifierScheme('xri://=john'), 'XRI'); + Auth_Yadis_identifierScheme('xri://=john'), 'XRI'); } } -class Tests_Services_Yadis_XriEscapingTestCase extends PHPUnit_TestCase { +class Tests_Auth_Yadis_XriEscapingTestCase extends PHPUnit_TestCase { function test_escaping_percents() { - $this->assertEquals(Services_Yadis_escapeForIRI('@example/abc%2Fd/ef'), + $this->assertEquals(Auth_Yadis_escapeForIRI('@example/abc%2Fd/ef'), '@example/abc%252Fd/ef'); } @@ -42,27 +42,27 @@ class Tests_Services_Yadis_XriEscapingTestCase extends PHPUnit_TestCase { { // no escapes $this->assertEquals('@example/foo/(@bar)', - Services_Yadis_escapeForIRI('@example/foo/(@bar)')); + Auth_Yadis_escapeForIRI('@example/foo/(@bar)')); // escape slashes $this->assertEquals('@example/foo/(@bar%2Fbaz)', - Services_Yadis_escapeForIRI('@example/foo/(@bar/baz)')); + Auth_Yadis_escapeForIRI('@example/foo/(@bar/baz)')); $this->assertEquals('@example/foo/(@bar%2Fbaz)/(+a%2Fb)', - Services_Yadis_escapeForIRI('@example/foo/(@bar/baz)/(+a/b)')); + Auth_Yadis_escapeForIRI('@example/foo/(@bar/baz)/(+a/b)')); // escape query ? and fragment $this->assertEquals('@example/foo/(@baz%3Fp=q%23r)?i=j#k', - Services_Yadis_escapeForIRI('@example/foo/(@baz?p=q#r)?i=j#k')); + Auth_Yadis_escapeForIRI('@example/foo/(@baz?p=q#r)?i=j#k')); } } -class Tests_Services_Yadis_ProxyQueryTestCase extends PHPUnit_TestCase { +class Tests_Auth_Yadis_ProxyQueryTestCase extends PHPUnit_TestCase { function setUp() { $this->proxy_url = 'http://xri.example.com/'; - $this->fetcher = Services_Yadis_Yadis::getHTTPFetcher(); - $this->proxy = new Services_Yadis_ProxyResolver($fetcher, + $this->fetcher = Auth_Yadis_Yadis::getHTTPFetcher(); + $this->proxy = new Auth_Yadis_ProxyResolver($fetcher, $this->proxy_url); $this->servicetype = 'xri://+i-service*(+forwarding)*($v*1.0)'; $this->servicetype_enc = 'xri%3A%2F%2F%2Bi-service%2A%28%2Bforwarding%29%2A%28%24v%2A1.0%29'; @@ -92,7 +92,7 @@ class Tests_Services_Yadis_ProxyQueryTestCase extends PHPUnit_TestCase { } } -class Tests_Services_Yadis_TestGetRootAuthority extends PHPUnit_TestCase { +class Tests_Auth_Yadis_TestGetRootAuthority extends PHPUnit_TestCase { function runTest() { $xris = array( @@ -116,25 +116,25 @@ class Tests_Services_Yadis_TestGetRootAuthority extends PHPUnit_TestCase { foreach ($xris as $tupl) { list($thexri, $expected_root) = $tupl; - $this->assertEquals(Services_Yadis_XRI($expected_root), - Services_Yadis_rootAuthority($thexri), + $this->assertEquals(Auth_Yadis_XRI($expected_root), + Auth_Yadis_rootAuthority($thexri), 'rootAuthority test ('.$thexri.')'); } } } -class Tests_Services_Yadis_XRI extends PHPUnit_TestSuite { +class Tests_Auth_Yadis_XRI extends PHPUnit_TestSuite { function getName() { - return "Tests_Services_Yadis_XRI"; + return "Tests_Auth_Yadis_XRI"; } - function Tests_Services_Yadis_XRI() + function Tests_Auth_Yadis_XRI() { - $this->addTest(new Tests_Services_Yadis_ProxyQueryTestCase()); - $this->addTest(new Tests_Services_Yadis_XriEscapingTestCase()); - $this->addTest(new Tests_Services_Yadis_XriDiscoveryTestCase()); - $this->addTest(new Tests_Services_Yadis_TestGetRootAuthority()); + $this->addTest(new Tests_Auth_Yadis_ProxyQueryTestCase()); + $this->addTest(new Tests_Auth_Yadis_XriEscapingTestCase()); + $this->addTest(new Tests_Auth_Yadis_XriDiscoveryTestCase()); + $this->addTest(new Tests_Auth_Yadis_TestGetRootAuthority()); } } diff --git a/Tests/Auth/Yadis/Yadis.php b/Tests/Auth/Yadis/Yadis.php index 8cf50f9..4e45b07 100644 --- a/Tests/Auth/Yadis/Yadis.php +++ b/Tests/Auth/Yadis/Yadis.php @@ -5,12 +5,12 @@ */ require_once 'PHPUnit.php'; -require_once 'Services/Yadis/Yadis.php'; -require_once 'Tests/Services/Yadis/TestUtil.php'; +require_once 'Auth/Yadis/Yadis.php'; +require_once 'Tests/Auth/Yadis/TestUtil.php'; -class Tests_Services_Yadis_DiscoveryTest extends PHPUnit_TestCase { +class Tests_Auth_Yadis_DiscoveryTest extends PHPUnit_TestCase { - function Tests_Services_Yadis_DiscoveryTest($input_url, $redir_uri, + function Tests_Auth_Yadis_DiscoveryTest($input_url, $redir_uri, $xrds_uri, $num) { $this->input_url = $input_url; @@ -26,8 +26,8 @@ class Tests_Services_Yadis_DiscoveryTest extends PHPUnit_TestCase { function runTest() { - $fetcher = Services_Yadis_Yadis::getHTTPFetcher(); - $y = Services_Yadis_Yadis::discover( + $fetcher = Auth_Yadis_Yadis::getHTTPFetcher(); + $y = Auth_Yadis_Yadis::discover( $this->input_url, $fetcher); $this->assertTrue($y !== null); @@ -38,7 +38,7 @@ class Tests_Services_Yadis_DiscoveryTest extends PHPUnit_TestCase { $this->assertEquals($this->xrds_uri, $y->xrds_uri); // Compare contents of actual HTTP GET with that of Yadis // response. - $f = Services_Yadis_Yadis::getHTTPFetcher(); + $f = Auth_Yadis_Yadis::getHTTPFetcher(); $http_response = $f->get($this->xrds_uri); $this->assertEquals($http_response->body, $y->response_text); @@ -48,11 +48,11 @@ class Tests_Services_Yadis_DiscoveryTest extends PHPUnit_TestCase { } } -class Tests_Services_Yadis_Yadis extends PHPUnit_TestSuite { +class Tests_Auth_Yadis_Yadis extends PHPUnit_TestSuite { function getName() { - return "Tests_Services_Yadis_Yadis"; + return "Tests_Auth_Yadis_Yadis"; } function parseTests($data) @@ -69,9 +69,9 @@ class Tests_Services_Yadis_Yadis extends PHPUnit_TestSuite { return $tests; } - function Tests_Services_Yadis_Yadis() + function Tests_Auth_Yadis_Yadis() { - $test_data = Tests_Services_Yadis_readdata('manifest.txt'); + $test_data = Tests_Auth_Yadis_readdata('manifest.txt'); $test_cases = $this->parseTests($test_data); @@ -79,7 +79,7 @@ class Tests_Services_Yadis_Yadis extends PHPUnit_TestSuite { foreach ($test_cases as $case) { $i++; list($input, $redir, $xrds) = $case; - $this->addTest(new Tests_Services_Yadis_DiscoveryTest($input, + $this->addTest(new Tests_Auth_Yadis_DiscoveryTest($input, $redir, $xrds, $i)); } diff --git a/Tests/TestDriver.php b/Tests/TestDriver.php index cd413aa..c88d525 100644 --- a/Tests/TestDriver.php +++ b/Tests/TestDriver.php @@ -137,7 +137,7 @@ $_tests = array( 'VerifyDisco'), ), array( - 'dir' => 'Tests/Services/Yadis/', + 'dir' => 'Tests/Auth/Yadis/', 'files' => array( 'ParseHTML', 'XRDS', diff --git a/examples/detect.php b/examples/detect.php index 29593f2..ed9ef4f 100644 --- a/examples/detect.php +++ b/examples/detect.php @@ -362,12 +362,12 @@ function detect_stores($r, &$out) function detect_xml($r, &$out) { - global $__Services_Yadis_xml_extensions; + global $__Auth_Yadis_xml_extensions; $out .= $r->h2('XML Support'); // Try to get an XML extension. - $ext = Services_Yadis_getXMLParser(); + $ext = Auth_Yadis_getXMLParser(); if ($ext !== null) { $out .= $r->p('XML parsing support is present using the '. @@ -376,7 +376,7 @@ function detect_xml($r, &$out) } else { $out .= $r->p('XML parsing support is absent; please install one '. 'of the following PHP extensions:'); - foreach ($__Services_Yadis_xml_extensions as $name => $cls) { + foreach ($__Auth_Yadis_xml_extensions as $name => $cls) { $out .= "<li>" . $r->b($name) . "</li>"; } return false; @@ -387,14 +387,14 @@ function detect_fetcher($r, &$out) { $out .= $r->h2('HTTP Fetching'); - $result = @include 'Services/Yadis/Yadis.php'; + $result = @include 'Auth/Yadis/Yadis.php'; if (!$result) { $out .= $r->p('Yadis code unavailable; could not test fetcher support.'); return false; } - if (Services_Yadis_Yadis::curlPresent()) { + if (Auth_Yadis_Yadis::curlPresent()) { $out .= $r->p('This PHP installation has support for libcurl. Good.'); } else { $out .= $r->p('This PHP installation does not have support for ' . @@ -407,7 +407,7 @@ function detect_fetcher($r, &$out) } $ok = true; - $fetcher = Services_Yadis_Yadis::getHTTPFetcher(); + $fetcher = Auth_Yadis_Yadis::getHTTPFetcher(); $fetch_url = 'http://www.openidenabled.com/resources/php-fetch-test'; $expected_url = $fetch_url . '.txt'; $result = $fetcher->get($fetch_url); |