|
From: Greg M. <bli...@us...> - 2008-05-24 14:45:23
|
Update of /cvsroot/phpwebsite-comm/modules/openid/class/Auth/OpenID In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24754/Auth/OpenID Modified Files: AX.php Association.php Consumer.php DiffieHellman.php FileStore.php Nonce.php Parse.php SQLStore.php SReg.php TrustRoot.php Log Message: Update to 2.0.1 PHP OpenID library Index: Consumer.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/openid/class/Auth/OpenID/Consumer.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Consumer.php 4 Feb 2008 04:54:33 -0000 1.1.1.1 --- Consumer.php 24 May 2008 14:45:24 -0000 1.2 *************** *** 519,523 **** class Auth_OpenID_PlainTextConsumerSession { var $session_type = 'no-encryption'; ! var $allowed_assoc_types = array('HMAC-SHA1'); function getRequest() --- 519,523 ---- class Auth_OpenID_PlainTextConsumerSession { var $session_type = 'no-encryption'; ! var $allowed_assoc_types = array('HMAC-SHA1', 'HMAC-SHA256'); function getRequest() Index: SQLStore.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/openid/class/Auth/OpenID/SQLStore.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** SQLStore.php 4 Feb 2008 04:54:31 -0000 1.1.1.1 --- SQLStore.php 24 May 2008 14:45:25 -0000 1.2 *************** *** 482,486 **** global $Auth_OpenID_SKEW; ! if ( abs($timestamp - mktime()) > $Auth_OpenID_SKEW ) { return False; } --- 482,486 ---- global $Auth_OpenID_SKEW; ! if ( abs($timestamp - time()) > $Auth_OpenID_SKEW ) { return False; } Index: Nonce.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/openid/class/Auth/OpenID/Nonce.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Nonce.php 4 Feb 2008 04:54:32 -0000 1.1.1.1 --- Nonce.php 24 May 2008 14:45:25 -0000 1.2 *************** *** 75,79 **** if ($now === null) { ! $now = gmmktime(); } --- 75,79 ---- if ($now === null) { ! $now = time(); } *************** *** 97,105 **** 6, Auth_OpenID_Nonce_CHRS); if ($when === null) { ! // It's safe to call mktime() with no arguments; it returns a // GMT unix timestamp on PHP 4 and PHP 5. gmmktime() with no // args returns a local unix timestamp on PHP 4, so don't use // that. ! $when = mktime(); } $time_str = gmstrftime(Auth_OpenID_Nonce_TIME_FMT, $when); --- 97,105 ---- 6, Auth_OpenID_Nonce_CHRS); if ($when === null) { ! // It's safe to call time() with no arguments; it returns a // GMT unix timestamp on PHP 4 and PHP 5. gmmktime() with no // args returns a local unix timestamp on PHP 4, so don't use // that. ! $when = time(); } $time_str = gmstrftime(Auth_OpenID_Nonce_TIME_FMT, $when); Index: SReg.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/openid/class/Auth/OpenID/SReg.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** SReg.php 4 Feb 2008 04:54:32 -0000 1.1.1.1 --- SReg.php 24 May 2008 14:45:25 -0000 1.2 *************** *** 23,27 **** * * $sreg_req = Auth_OpenID_SRegRequest::fromOpenIDRequest( ! * $checkid_request->message); * // [ get the user's approval and data, informing the user that * // the fields in sreg_response were requested ] --- 23,27 ---- * * $sreg_req = Auth_OpenID_SRegRequest::fromOpenIDRequest( ! * $checkid_request); * // [ get the user's approval and data, informing the user that * // the fields in sreg_response were requested ] Index: FileStore.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/openid/class/Auth/OpenID/FileStore.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** FileStore.php 4 Feb 2008 04:54:32 -0000 1.1.1.1 --- FileStore.php 24 May 2008 14:45:24 -0000 1.2 *************** *** 367,371 **** } ! if ( abs($timestamp - mktime()) > $Auth_OpenID_SKEW ) { return False; } --- 367,371 ---- } ! if ( abs($timestamp - time()) > $Auth_OpenID_SKEW ) { return False; } Index: AX.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/openid/class/Auth/OpenID/AX.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** AX.php 4 Feb 2008 04:54:33 -0000 1.1.1.1 --- AX.php 24 May 2008 14:45:24 -0000 1.2 *************** *** 807,811 **** * Auth_OpenID_AX_Error on error. */ ! function getExtensionArgs(&$request) { $aliases = new Auth_OpenID_NamespaceMap(); --- 807,811 ---- * Auth_OpenID_AX_Error on error. */ ! function getExtensionArgs($request=null) { $aliases = new Auth_OpenID_NamespaceMap(); Index: TrustRoot.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/openid/class/Auth/OpenID/TrustRoot.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** TrustRoot.php 4 Feb 2008 04:54:32 -0000 1.1.1.1 --- TrustRoot.php 24 May 2008 14:45:25 -0000 1.2 *************** *** 357,361 **** list($rp_url_after_redirects, $endpoints) = Auth_OpenID_discoverWithYadis($relying_party_url, ! &$fetcher, 'Auth_OpenID_extractReturnURL', $discover_function); --- 357,361 ---- list($rp_url_after_redirects, $endpoints) = Auth_OpenID_discoverWithYadis($relying_party_url, ! $fetcher, 'Auth_OpenID_extractReturnURL', $discover_function); Index: Association.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/openid/class/Auth/OpenID/Association.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Association.php 4 Feb 2008 04:54:32 -0000 1.1.1.1 --- Association.php 24 May 2008 14:45:24 -0000 1.2 *************** *** 65,68 **** --- 65,73 ---- ); + var $_macs = array( + 'HMAC-SHA1' => 'Auth_OpenID_HMACSHA1', + 'HMAC-SHA256' => 'Auth_OpenID_HMACSHA256' + ); + /** * This is an alternate constructor (factory method) used by the *************** *** 83,89 **** * * @param assoc_type This is the type of association this ! * instance represents. The only valid value of this field at ! * this time is 'HMAC-SHA1', but new types may be defined in the ! * future. * * @return association An {@link Auth_OpenID_Association} --- 88,94 ---- * * @param assoc_type This is the type of association this ! * instance represents. The only valid values of this field at ! * this time is 'HMAC-SHA1' and 'HMAC-SHA256', but new types may ! * be defined in the future. * * @return association An {@link Auth_OpenID_Association} *************** *** 120,126 **** * * @param string $assoc_type This is the type of association this ! * instance represents. The only valid value of this field at ! * this time is 'HMAC-SHA1', but new types may be defined in the ! * future. */ function Auth_OpenID_Association( --- 125,131 ---- * * @param string $assoc_type This is the type of association this ! * instance represents. The only valid values of this field at ! * this time is 'HMAC-SHA1' and 'HMAC-SHA256', but new types may ! * be defined in the future. */ function Auth_OpenID_Association( *************** *** 259,263 **** { $kv = Auth_OpenID_KVForm::fromArray($pairs); ! return Auth_OpenID_HMACSHA1($this->secret, $kv); } --- 264,272 ---- { $kv = Auth_OpenID_KVForm::fromArray($pairs); ! ! /* Invalid association types should be caught at constructor */ ! $callback = $this->_macs[$this->assoc_type]; ! ! return call_user_func_array($callback, array($this->secret, $kv)); } Index: DiffieHellman.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/openid/class/Auth/OpenID/DiffieHellman.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** DiffieHellman.php 4 Feb 2008 04:54:32 -0000 1.1.1.1 --- DiffieHellman.php 24 May 2008 14:45:24 -0000 1.2 *************** *** 91,115 **** } - /** - * Generate the arguments for an OpenID Diffie-Hellman association - * request - */ - function getAssocArgs() - { - $cpub = $this->lib->longToBase64($this->getPublicKey()); - $args = array( - 'openid.dh_consumer_public' => $cpub, - 'openid.session_type' => 'DH-SHA1' - ); - - if ($this->lib->cmp($this->mod, Auth_OpenID_getDefaultMod()) || - $this->lib->cmp($this->gen, Auth_OpenID_getDefaultGen())) { - $args['openid.dh_modulus'] = $this->lib->longToBase64($this->mod); - $args['openid.dh_gen'] = $this->lib->longToBase64($this->gen); - } - - return $args; - } - function usingDefaultValues() { --- 91,94 ---- Index: Parse.php =================================================================== RCS file: /cvsroot/phpwebsite-comm/modules/openid/class/Auth/OpenID/Parse.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Parse.php 4 Feb 2008 04:54:32 -0000 1.1.1.1 --- Parse.php 24 May 2008 14:45:25 -0000 1.2 *************** *** 106,109 **** --- 106,112 ---- var $_attr_find = '\b(\w+)=("[^"]*"|\'[^\']*\'|[^\'"\s\/<>]+)'; + var $_open_tag_expr = "<%s\b"; + var $_close_tag_expr = "<((\/%s\b)|(%s[^>\/]*\/))>"; + function Auth_OpenID_Parse() { *************** *** 137,140 **** --- 140,145 ---- function tagMatcher($tag_name, $close_tags = null) { + $expr = $this->_tag_expr; + if ($close_tags) { $options = implode("|", array_merge(array($tag_name), $close_tags)); *************** *** 144,159 **** } ! $expr = sprintf($this->_tag_expr, $tag_name, $closer); return sprintf("/%s/%s", $expr, $this->_re_flags); } ! function htmlFind() { ! return $this->tagMatcher('html'); } function headFind() { ! return $this->tagMatcher('head', array('body')); } --- 149,195 ---- } ! $expr = sprintf($expr, $tag_name, $closer); return sprintf("/%s/%s", $expr, $this->_re_flags); } ! function openTag($tag_name) { ! $expr = sprintf($this->_open_tag_expr, $tag_name); ! return sprintf("/%s/%s", $expr, $this->_re_flags); ! } ! ! function closeTag($tag_name) ! { ! $expr = sprintf($this->_close_tag_expr, $tag_name, $tag_name); ! return sprintf("/%s/%s", $expr, $this->_re_flags); ! } ! ! function htmlBegin($s) ! { ! $matches = array(); ! $result = preg_match($this->openTag('html'), $s, ! $matches, PREG_OFFSET_CAPTURE); ! if ($result === false || !$matches) { ! return false; ! } ! // Return the offset of the first match. ! return $matches[0][1]; ! } ! ! function htmlEnd($s) ! { ! $matches = array(); ! $result = preg_match($this->closeTag('html'), $s, ! $matches, PREG_OFFSET_CAPTURE); ! if ($result === false || !$matches) { ! return false; ! } ! // Return the offset of the first match. ! return $matches[count($matches) - 1][1]; } function headFind() { ! return $this->tagMatcher('head', array('body', 'html')); } *************** *** 195,209 **** $html); ! // Try to find the <HTML> tag. ! $html_re = $this->htmlFind(); ! $html_matches = array(); ! if (!preg_match($html_re, $stripped, $html_matches)) { return array(); } // Try to find the <HEAD> tag. $head_re = $this->headFind(); $head_matches = array(); ! if (!preg_match($head_re, $html_matches[0], $head_matches)) { return array(); } --- 231,252 ---- $html); ! $html_begin = $this->htmlBegin($stripped); ! $html_end = $this->htmlEnd($stripped); ! ! if ($html_begin === false) { return array(); } + if ($html_end === false) { + $html_end = strlen($stripped); + } + + $stripped = substr($stripped, $html_begin, + $html_end - $html_begin); + // Try to find the <HEAD> tag. $head_re = $this->headFind(); $head_matches = array(); ! if (!preg_match($head_re, $stripped, $head_matches)) { return array(); } |