incubator-heraldry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ket...@apache.org
Subject svn commit: r463021 [1/12] - in /incubator/heraldry/libraries/php: ./ openid/ openid/trunk/ openid/trunk/Auth/ openid/trunk/Auth/OpenID/ openid/trunk/Services/ openid/trunk/Services/Yadis/ openid/trunk/Tests/ openid/trunk/Tests/Auth/ openid/trunk/Tests...
Date Wed, 11 Oct 2006 22:49:59 GMT
Author: keturn
Date: Wed Oct 11 15:49:50 2006
New Revision: 463021

URL: http://svn.apache.org/viewvc?view=rev&rev=463021
Log:
Initial import of PHP OpenID/Yadis libraries from JanRain.

Previous development history for this library may be found in the 
darcs repository at
http://www.openidenabled.com/resources/repos/php/openid/

Added:
    incubator/heraldry/libraries/php/
    incubator/heraldry/libraries/php/openid/
    incubator/heraldry/libraries/php/openid/trunk/   (with props)
    incubator/heraldry/libraries/php/openid/trunk/Auth/
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID.php
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/Association.php
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/BigMath.php
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/Consumer.php
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/CryptUtil.php
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/DatabaseConnection.php
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/DiffieHellman.php
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/Discover.php
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/DumbStore.php
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/FileStore.php
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/HMACSHA1.php
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/Interface.php
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/KVForm.php
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/Message.php
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/MySQLStore.php
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/Nonce.php
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/Parse.php
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/PostgreSQLStore.php
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/SQLStore.php
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/SQLiteStore.php
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/Server.php
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/ServerRequest.php
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/TrustRoot.php
    incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/URINorm.php
    incubator/heraldry/libraries/php/openid/trunk/COPYING
    incubator/heraldry/libraries/php/openid/trunk/NEWS
    incubator/heraldry/libraries/php/openid/trunk/README
    incubator/heraldry/libraries/php/openid/trunk/README.Debian
    incubator/heraldry/libraries/php/openid/trunk/Services/
    incubator/heraldry/libraries/php/openid/trunk/Services/Yadis/
    incubator/heraldry/libraries/php/openid/trunk/Services/Yadis/HTTPFetcher.php
    incubator/heraldry/libraries/php/openid/trunk/Services/Yadis/Manager.php
    incubator/heraldry/libraries/php/openid/trunk/Services/Yadis/Misc.php
    incubator/heraldry/libraries/php/openid/trunk/Services/Yadis/ParanoidHTTPFetcher.php
    incubator/heraldry/libraries/php/openid/trunk/Services/Yadis/ParseHTML.php
    incubator/heraldry/libraries/php/openid/trunk/Services/Yadis/PlainHTTPFetcher.php
    incubator/heraldry/libraries/php/openid/trunk/Services/Yadis/XML.php
    incubator/heraldry/libraries/php/openid/trunk/Services/Yadis/XRDS.php
    incubator/heraldry/libraries/php/openid/trunk/Services/Yadis/XRI.php
    incubator/heraldry/libraries/php/openid/trunk/Services/Yadis/XRIRes.php
    incubator/heraldry/libraries/php/openid/trunk/Services/Yadis/Yadis.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/Association.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/BigMath.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/Consumer.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/CryptUtil.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/DiffieHellman.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/Discover.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/HMACSHA1.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/KVForm.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/MemStore.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/Nonce.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/OpenID_Yadis.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/Parse.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/Server.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/StoreTest.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/TestUtil.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/TrustRoot.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/URINorm.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/Util.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/data/
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/data/dhexch
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/data/dhpriv
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/data/hmac.txt
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/data/linkparse.txt
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/data/n2b64
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/data/trustroot.txt
    incubator/heraldry/libraries/php/openid/trunk/Tests/Auth/OpenID/data/urinorm.txt
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/Discover.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/DiscoverData.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/ParseHTML.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/TestUtil.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/XRDS.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/XRI.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/Yadis.php
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/README
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/accept.txt
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/brian.multi.xrds
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/brian.multi_uri.xrds
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/brian.xrds
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/brian_priority.xrds
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/delegated-20060809-r1.xrds
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/delegated-20060809-r2.xrds
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/delegated-20060809.xrds
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/example-xrds.xml
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/manifest.txt
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/no-xrd.xml
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/not-xrds.xml
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/pip.xrds
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/prefixsometimes.xrds
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/ref.xrds
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/sometimesprefix.xrds
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/spoof1.xrds
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/spoof2.xrds
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/spoof3.xrds
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/test1-discover.txt
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/test1-parsehtml.txt
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/test1-xrd.xml
    incubator/heraldry/libraries/php/openid/trunk/Tests/Services/Yadis/data/uri_priority.xrds
    incubator/heraldry/libraries/php/openid/trunk/Tests/TestDriver.php
    incubator/heraldry/libraries/php/openid/trunk/admin/
    incubator/heraldry/libraries/php/openid/trunk/admin/adminutil.php
    incubator/heraldry/libraries/php/openid/trunk/admin/brace_style.pl   (with props)
    incubator/heraldry/libraries/php/openid/trunk/admin/checkimport   (with props)
    incubator/heraldry/libraries/php/openid/trunk/admin/checkimports   (with props)
    incubator/heraldry/libraries/php/openid/trunk/admin/darcs-ignore
    incubator/heraldry/libraries/php/openid/trunk/admin/docblocks   (with props)
    incubator/heraldry/libraries/php/openid/trunk/admin/docblocks.pl   (with props)
    incubator/heraldry/libraries/php/openid/trunk/admin/findglobals   (with props)
    incubator/heraldry/libraries/php/openid/trunk/admin/findphp   (with props)
    incubator/heraldry/libraries/php/openid/trunk/admin/fixperms   (with props)
    incubator/heraldry/libraries/php/openid/trunk/admin/library-name
    incubator/heraldry/libraries/php/openid/trunk/admin/longlines.pl   (with props)
    incubator/heraldry/libraries/php/openid/trunk/admin/makedoc.sh   (with props)
    incubator/heraldry/libraries/php/openid/trunk/admin/mathlib   (with props)
    incubator/heraldry/libraries/php/openid/trunk/admin/nobadbraces   (with props)
    incubator/heraldry/libraries/php/openid/trunk/admin/nobadcase   (with props)
    incubator/heraldry/libraries/php/openid/trunk/admin/nolonglines   (with props)
    incubator/heraldry/libraries/php/openid/trunk/admin/notabs   (with props)
    incubator/heraldry/libraries/php/openid/trunk/admin/open_tag   (with props)
    incubator/heraldry/libraries/php/openid/trunk/admin/otb_test.php
    incubator/heraldry/libraries/php/openid/trunk/admin/package.xml
    incubator/heraldry/libraries/php/openid/trunk/admin/package2.xml
    incubator/heraldry/libraries/php/openid/trunk/admin/packagexml.py   (with props)
    incubator/heraldry/libraries/php/openid/trunk/admin/phpaliases.py   (with props)
    incubator/heraldry/libraries/php/openid/trunk/admin/prepare-release   (with props)
    incubator/heraldry/libraries/php/openid/trunk/admin/runtests   (with props)
    incubator/heraldry/libraries/php/openid/trunk/admin/texttest.php
    incubator/heraldry/libraries/php/openid/trunk/admin/tutorials/
    incubator/heraldry/libraries/php/openid/trunk/admin/tutorials/OpenID/
    incubator/heraldry/libraries/php/openid/trunk/admin/tutorials/OpenID/OpenID.pkg
    incubator/heraldry/libraries/php/openid/trunk/admin/webtest.php
    incubator/heraldry/libraries/php/openid/trunk/admin/xmlconfig.py
    incubator/heraldry/libraries/php/openid/trunk/doc/
    incubator/heraldry/libraries/php/openid/trunk/examples/
    incubator/heraldry/libraries/php/openid/trunk/examples/README
    incubator/heraldry/libraries/php/openid/trunk/examples/consumer/
    incubator/heraldry/libraries/php/openid/trunk/examples/consumer/common.php
    incubator/heraldry/libraries/php/openid/trunk/examples/consumer/finish_auth.php
    incubator/heraldry/libraries/php/openid/trunk/examples/consumer/index.php
    incubator/heraldry/libraries/php/openid/trunk/examples/consumer/try_auth.php
    incubator/heraldry/libraries/php/openid/trunk/examples/detect.php
    incubator/heraldry/libraries/php/openid/trunk/examples/server/
    incubator/heraldry/libraries/php/openid/trunk/examples/server/index.php
    incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/
    incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/actions.php
    incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/common.php
    incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render/
    incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render.php
    incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render/about.php
    incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render/login.php
    incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render/sites.php
    incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render/trust.php
    incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/session.php
    incubator/heraldry/libraries/php/openid/trunk/examples/server/openid-server.css
    incubator/heraldry/libraries/php/openid/trunk/examples/server/server.php
    incubator/heraldry/libraries/php/openid/trunk/examples/server/setup.php

Propchange: incubator/heraldry/libraries/php/openid/trunk/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Oct 11 15:49:50 2006
@@ -0,0 +1 @@
+_darcs

Added: incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID.php
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID.php?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID.php (added)
+++ incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID.php Wed Oct 11 15:49:50 2006
@@ -0,0 +1,406 @@
+<?php
+
+/**
+ * This is the PHP OpenID library by JanRain, Inc.
+ *
+ * This module contains core utility functionality used by the
+ * library.  See Consumer.php and Server.php for the consumer and
+ * server implementations.
+ *
+ * PHP versions 4 and 5
+ *
+ * LICENSE: See the COPYING file included in this distribution.
+ *
+ * @package OpenID
+ * @author JanRain, Inc. <openid@janrain.com>
+ * @copyright 2005 Janrain, Inc.
+ * @license http://www.gnu.org/copyleft/lesser.html LGPL
+ */
+
+/**
+ * Require the fetcher code.
+ */
+require_once "Services/Yadis/PlainHTTPFetcher.php";
+require_once "Services/Yadis/ParanoidHTTPFetcher.php";
+
+/**
+ * Status code returned by the server when the only option is to show
+ * an error page, since we do not have enough information to redirect
+ * back to the consumer. The associated value is an error message that
+ * should be displayed on an HTML error page.
+ *
+ * @see Auth_OpenID_Server
+ */
+define('Auth_OpenID_LOCAL_ERROR', 'local_error');
+
+/**
+ * Status code returned when there is an error to return in key-value
+ * form to the consumer. The caller should return a 400 Bad Request
+ * response with content-type text/plain and the value as the body.
+ *
+ * @see Auth_OpenID_Server
+ */
+define('Auth_OpenID_REMOTE_ERROR', 'remote_error');
+
+/**
+ * Status code returned when there is a key-value form OK response to
+ * the consumer. The value associated with this code is the
+ * response. The caller should return a 200 OK response with
+ * content-type text/plain and the value as the body.
+ *
+ * @see Auth_OpenID_Server
+ */
+define('Auth_OpenID_REMOTE_OK', 'remote_ok');
+
+/**
+ * Status code returned when there is a redirect back to the
+ * consumer. The value is the URL to redirect back to. The caller
+ * should return a 302 Found redirect with a Location: header
+ * containing the URL.
+ *
+ * @see Auth_OpenID_Server
+ */
+define('Auth_OpenID_REDIRECT', 'redirect');
+
+/**
+ * Status code returned when the caller needs to authenticate the
+ * user. The associated value is a {@link Auth_OpenID_ServerRequest}
+ * object that can be used to complete the authentication. If the user
+ * has taken some authentication action, use the retry() method of the
+ * {@link Auth_OpenID_ServerRequest} object to complete the request.
+ *
+ * @see Auth_OpenID_Server
+ */
+define('Auth_OpenID_DO_AUTH', 'do_auth');
+
+/**
+ * Status code returned when there were no OpenID arguments
+ * passed. This code indicates that the caller should return a 200 OK
+ * response and display an HTML page that says that this is an OpenID
+ * server endpoint.
+ *
+ * @see Auth_OpenID_Server
+ */
+define('Auth_OpenID_DO_ABOUT', 'do_about');
+
+/**
+ * Defines for regexes and format checking.
+ */
+define('Auth_OpenID_letters',
+       "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
+
+define('Auth_OpenID_digits',
+       "0123456789");
+
+define('Auth_OpenID_punct',
+       "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~");
+
+/**
+ * These namespaces are automatically fixed in query arguments by
+ * Auth_OpenID::fixArgs.
+ */
+global $_Auth_OpenID_namespaces;
+$_Auth_OpenID_namespaces = array('openid',
+                                 'sreg');
+
+/**
+ * The OpenID utility function class.
+ *
+ * @package OpenID
+ * @access private
+ */
+class Auth_OpenID {
+
+    /**
+     * Rename query arguments back to 'openid.' from 'openid_'
+     *
+     * @access private
+     * @param array $args An associative array of URL query arguments
+     */
+    function fixArgs($args)
+    {
+        global $_Auth_OpenID_namespaces;
+        foreach (array_keys($args) as $key) {
+            $fixed = $key;
+            if (preg_match('/^openid/', $key)) {
+                foreach ($_Auth_OpenID_namespaces as $ns) {
+                    if (preg_match('/'.$ns.'_/', $key)) {
+                        $fixed = preg_replace('/'.$ns.'_/', $ns.'.', $fixed);
+                    }
+                }
+
+                if ($fixed != $key) {
+                    $val = $args[$key];
+                    unset($args[$key]);
+                    $args[$fixed] = $val;
+                }
+            }
+        }
+
+        return $args;
+    }
+
+    /**
+     * Create dir_name as a directory if it does not exist. If it
+     * exists, make sure that it is, in fact, a directory.  Returns
+     * true if the operation succeeded; false if not.
+     *
+     * @access private
+     */
+    function ensureDir($dir_name)
+    {
+        if (is_dir($dir_name) || @mkdir($dir_name)) {
+            return true;
+        } else {
+            if (Auth_OpenID::ensureDir(dirname($dir_name))) {
+                return is_dir($dir_name) || @mkdir($dir_name);
+            } else {
+                return false;
+            }
+        }
+    }
+
+    /**
+     * Convenience function for getting array values.
+     *
+     * @access private
+     */
+    function arrayGet($arr, $key, $fallback = null)
+    {
+        if (is_array($arr)) {
+            if (array_key_exists($key, $arr)) {
+                return $arr[$key];
+            } else {
+                return $fallback;
+            }
+        } else {
+            trigger_error("Auth_OpenID::arrayGet expected " .
+                          "array as first parameter", E_USER_WARNING);
+            return false;
+        }
+    }
+
+    /**
+     * Implements the PHP 5 'http_build_query' functionality.
+     *
+     * @access private
+     * @param array $data Either an array key/value pairs or an array
+     * of arrays, each of which holding two values: a key and a value,
+     * sequentially.
+     * @return string $result The result of url-encoding the key/value
+     * pairs from $data into a URL query string
+     * (e.g. "username=bob&id=56").
+     */
+    function httpBuildQuery($data)
+    {
+        $pairs = array();
+        foreach ($data as $key => $value) {
+            if (is_array($value)) {
+                $pairs[] = urlencode($value[0])."=".urlencode($value[1]);
+            } else {
+                $pairs[] = urlencode($key)."=".urlencode($value);
+            }
+        }
+        return implode("&", $pairs);
+    }
+
+    /**
+     * "Appends" query arguments onto a URL.  The URL may or may not
+     * already have arguments (following a question mark).
+     *
+     * @param string $url A URL, which may or may not already have
+     * arguments.
+     * @param array $args Either an array key/value pairs or an array of
+     * arrays, each of which holding two values: a key and a value,
+     * sequentially.  If $args is an ordinary key/value array, the
+     * parameters will be added to the URL in sorted alphabetical order;
+     * if $args is an array of arrays, their order will be preserved.
+     * @return string $url The original URL with the new parameters added.
+     *
+     */
+    function appendArgs($url, $args)
+    {
+        if (count($args) == 0) {
+            return $url;
+        }
+
+        // Non-empty array; if it is an array of arrays, use
+        // multisort; otherwise use sort.
+        if (array_key_exists(0, $args) &&
+            is_array($args[0])) {
+            // Do nothing here.
+        } else {
+            $keys = array_keys($args);
+            sort($keys);
+            $new_args = array();
+            foreach ($keys as $key) {
+                $new_args[] = array($key, $args[$key]);
+            }
+            $args = $new_args;
+        }
+
+        $sep = '?';
+        if (strpos($url, '?') !== false) {
+            $sep = '&';
+        }
+
+        return $url . $sep . Auth_OpenID::httpBuildQuery($args);
+    }
+
+    /**
+     * Turn a string into an ASCII string.
+     *
+     * Replace non-ascii characters with a %-encoded, UTF-8
+     * encoding. This function will fail if the input is a string and
+     * there are non-7-bit-safe characters. It is assumed that the
+     * caller will have already translated the input into a Unicode
+     * character sequence, according to the encoding of the HTTP POST
+     * or GET.
+     *
+     * Do not escape anything that is already 7-bit safe, so we do the
+     * minimal transform on the identity URL
+     *
+     * @access private
+     */
+    function quoteMinimal($s)
+    {
+        $res = array();
+        for ($i = 0; $i < strlen($s); $i++) {
+            $c = $s[$i];
+            if ($c >= "\x80") {
+                for ($j = 0; $j < count(utf8_encode($c)); $j++) {
+                    array_push($res, sprintf("%02X", ord($c[$j])));
+                }
+            } else {
+                array_push($res, $c);
+            }
+        }
+    
+        return implode('', $res);
+    }
+
+    /**
+     * Implements python's urlunparse, which is not available in PHP.
+     * Given the specified components of a URL, this function rebuilds
+     * and returns the URL.
+     *
+     * @access private
+     * @param string $scheme The scheme (e.g. 'http').  Defaults to 'http'.
+     * @param string $host The host.  Required.
+     * @param string $port The port.
+     * @param string $path The path.
+     * @param string $query The query.
+     * @param string $fragment The fragment.
+     * @return string $url The URL resulting from assembling the
+     * specified components.
+     */
+    function urlunparse($scheme, $host, $port = null, $path = '/',
+                                    $query = '', $fragment = '')
+    {
+
+        if (!$scheme) {
+            $scheme = 'http';
+        }
+
+        if (!$host) {
+            return false;
+        }
+
+        if (!$path) {
+            $path = '/';
+        }
+
+        $result = $scheme . "://" . $host;
+
+        if ($port) {
+            $result .= ":" . $port;
+        }
+
+        $result .= $path;
+
+        if ($query) {
+            $result .= "?" . $query;
+        }
+
+        if ($fragment) {
+            $result .= "#" . $fragment;
+        }
+
+        return $result;
+    }
+
+    /**
+     * Given a URL, this "normalizes" it by adding a trailing slash
+     * and / or a leading http:// scheme where necessary.  Returns
+     * null if the original URL is malformed and cannot be normalized.
+     *
+     * @access private
+     * @param string $url The URL to be normalized.
+     * @return mixed $new_url The URL after normalization, or null if
+     * $url was malformed.
+     */
+    function normalizeUrl($url)
+    {
+        if ($url === null) {
+            return null;
+        }
+
+        assert(is_string($url));
+
+        $old_url = $url;
+        $url = trim($url);
+
+        if (strpos($url, "://") === false) {
+            $url = "http://" . $url;
+        }
+
+        $parsed = @parse_url($url);
+
+        if ($parsed === false) {
+            return null;
+        }
+
+        $defaults = array(
+                          'scheme' => '',
+                          'host' => '',
+                          'path' => '',
+                          'query' => '',
+                          'fragment' => '',
+                          'port' => ''
+                          );
+
+        $parsed = array_merge($defaults, $parsed);
+
+        if (($parsed['scheme'] == '') ||
+            ($parsed['host'] == '')) {
+            if ($parsed['path'] == '' &&
+                $parsed['query'] == '' &&
+                $parsed['fragment'] == '') {
+                return null;
+            }
+
+            $url = 'http://' + $url;
+            $parsed = parse_url($url);
+
+            $parsed = array_merge($defaults, $parsed);
+        }
+
+        $tail = array_map(array('Auth_OpenID', 'quoteMinimal'),
+                          array($parsed['path'],
+                                $parsed['query'],
+                                $parsed['fragment']));
+        if ($tail[0] == '') {
+            $tail[0] = '/';
+        }
+
+        $url = Auth_OpenID::urlunparse($parsed['scheme'], $parsed['host'],
+                                       $parsed['port'], $tail[0], $tail[1],
+                                       $tail[2]);
+
+        assert(is_string($url));
+
+        return $url;
+    }
+}
+
+?>
\ No newline at end of file

Added: incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/Association.php
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/Association.php?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/Association.php (added)
+++ incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/Association.php Wed Oct 11 15:49:50
2006
@@ -0,0 +1,308 @@
+<?php
+
+/**
+ * This module contains code for dealing with associations between
+ * consumers and servers.
+ *
+ * PHP versions 4 and 5
+ *
+ * LICENSE: See the COPYING file included in this distribution.
+ *
+ * @package OpenID
+ * @author JanRain, Inc. <openid@janrain.com>
+ * @copyright 2005 Janrain, Inc.
+ * @license http://www.gnu.org/copyleft/lesser.html LGPL
+ */
+
+/**
+ * @access private
+ */
+require_once 'Auth/OpenID/CryptUtil.php';
+
+/**
+ * @access private
+ */
+require_once 'Auth/OpenID/KVForm.php';
+
+/**
+ * This class represents an association between a server and a
+ * consumer.  In general, users of this library will never see
+ * instances of this object.  The only exception is if you implement a
+ * custom {@link Auth_OpenID_OpenIDStore}.
+ *
+ * If you do implement such a store, it will need to store the values
+ * of the handle, secret, issued, lifetime, and assoc_type instance
+ * variables.
+ *
+ * @package OpenID
+ */
+class Auth_OpenID_Association {
+
+    /**
+     * This is a HMAC-SHA1 specific value.
+     *
+     * @access private
+     */
+    var $SIG_LENGTH = 20;
+
+    /**
+     * The ordering and name of keys as stored by serialize.
+     *
+     * @access private
+     */
+    var $assoc_keys = array(
+                            'version',
+                            'handle',
+                            'secret',
+                            'issued',
+                            'lifetime',
+                            'assoc_type'
+                            );
+
+    /**
+     * This is an alternate constructor (factory method) used by the
+     * OpenID consumer library to create associations.  OpenID store
+     * implementations shouldn't use this constructor.
+     *
+     * @access private
+     *
+     * @param integer $expires_in This is the amount of time this
+     * association is good for, measured in seconds since the
+     * association was issued.
+     *
+     * @param string $handle This is the handle the server gave this
+     * association.
+     *
+     * @param string secret This is the shared secret the server
+     * generated for this association.
+     *
+     * @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}
+     * instance.
+     */
+    function fromExpiresIn($expires_in, $handle, $secret, $assoc_type)
+    {
+        $issued = time();
+        $lifetime = $expires_in;
+        return new Auth_OpenID_Association($handle, $secret,
+                                           $issued, $lifetime, $assoc_type);
+    }
+
+    /**
+     * This is the standard constructor for creating an association.
+     * The library should create all of the necessary associations, so
+     * this constructor is not part of the external API.
+     *
+     * @access private
+     *
+     * @param string $handle This is the handle the server gave this
+     * association.
+     *
+     * @param string $secret This is the shared secret the server
+     * generated for this association.
+     *
+     * @param integer $issued This is the time this association was
+     * issued, in seconds since 00:00 GMT, January 1, 1970.  (ie, a
+     * unix timestamp)
+     *
+     * @param integer $lifetime This is the amount of time this
+     * association is good for, measured in seconds since the
+     * association was issued.
+     *
+     * @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(
+        $handle, $secret, $issued, $lifetime, $assoc_type)
+    {
+        if ($assoc_type != 'HMAC-SHA1') {
+            $fmt = 'HMAC-SHA1 is the only supported association type (got %s)';
+            trigger_error(sprintf($fmt, $assoc_type), E_USER_ERROR);
+        }
+
+        $this->handle = $handle;
+        $this->secret = $secret;
+        $this->issued = $issued;
+        $this->lifetime = $lifetime;
+        $this->assoc_type = $assoc_type;
+    }
+
+    /**
+     * This returns the number of seconds this association is still
+     * valid for, or 0 if the association is no longer valid.
+     *
+     * @return integer $seconds The number of seconds this association
+     * is still valid for, or 0 if the association is no longer valid.
+     */
+    function getExpiresIn($now = null)
+    {
+        if ($now == null) {
+            $now = time();
+        }
+
+        return max(0, $this->issued + $this->lifetime - $now);
+    }
+
+    /**
+     * This checks to see if two {@link Auth_OpenID_Association}
+     * instances represent the same association.
+     *
+     * @return bool $result true if the two instances represent the
+     * same association, false otherwise.
+     */
+    function equal($other)
+    {
+        return ((gettype($this) == gettype($other))
+                && ($this->handle == $other->handle)
+                && ($this->secret == $other->secret)
+                && ($this->issued == $other->issued)
+                && ($this->lifetime == $other->lifetime)
+                && ($this->assoc_type == $other->assoc_type));
+    }
+
+    /**
+     * Convert an association to KV form.
+     *
+     * @return string $result String in KV form suitable for
+     * deserialization by deserialize.
+     */
+    function serialize()
+    {
+        $data = array(
+                     'version' => '2',
+                     'handle' => $this->handle,
+                     'secret' => base64_encode($this->secret),
+                     'issued' => strval(intval($this->issued)),
+                     'lifetime' => strval(intval($this->lifetime)),
+                     'assoc_type' => $this->assoc_type
+                     );
+
+        assert(array_keys($data) == $this->assoc_keys);
+
+        return Auth_OpenID_KVForm::fromArray($data, $strict = true);
+    }
+
+    /**
+     * Parse an association as stored by serialize().  This is the
+     * inverse of serialize.
+     *
+     * @param string $assoc_s Association as serialized by serialize()
+     * @return Auth_OpenID_Association $result instance of this class
+     */
+    function deserialize($class_name, $assoc_s)
+    {
+        $pairs = Auth_OpenID_KVForm::toArray($assoc_s, $strict = true);
+        $keys = array();
+        $values = array();
+        foreach ($pairs as $key => $value) {
+            if (is_array($value)) {
+                list($key, $value) = $value;
+            }
+            $keys[] = $key;
+            $values[] = $value;
+        }
+
+        $class_vars = get_class_vars($class_name);
+        $class_assoc_keys = $class_vars['assoc_keys'];
+
+        sort($keys);
+        sort($class_assoc_keys);
+
+        if ($keys != $class_assoc_keys) {
+            trigger_error('Unexpected key values: ' . strval($keys),
+                          E_USER_WARNING);
+            return null;
+        }
+
+        $version = $pairs['version'];
+        $handle = $pairs['handle'];
+        $secret = $pairs['secret'];
+        $issued = $pairs['issued'];
+        $lifetime = $pairs['lifetime'];
+        $assoc_type = $pairs['assoc_type'];
+
+        if ($version != '2') {
+            trigger_error('Unknown version: ' . $version, E_USER_WARNING);
+            return null;
+        }
+
+        $issued = intval($issued);
+        $lifetime = intval($lifetime);
+        $secret = base64_decode($secret);
+
+        return new $class_name(
+            $handle, $secret, $issued, $lifetime, $assoc_type);
+    }
+
+    /**
+     * Generate a signature for a sequence of (key, value) pairs
+     *
+     * @access private
+     * @param array $pairs The pairs to sign, in order.  This is an
+     * array of two-tuples.
+     * @return string $signature The binary signature of this sequence
+     * of pairs
+     */
+    function sign($pairs)
+    {
+        $kv = Auth_OpenID_KVForm::fromArray($pairs);
+        return Auth_OpenID_HMACSHA1($this->secret, $kv);
+    }
+
+    /**
+     * Generate a signature for some fields in a dictionary
+     *
+     * @access private
+     * @param array $fields The fields to sign, in order; this is an
+     * array of strings.
+     * @param array $data Dictionary of values to sign (an array of
+     * string => string pairs).
+     * @return string $signature The signature, base64 encoded
+     */
+    function signDict($fields, $data, $prefix = 'openid.')
+    {
+        $pairs = array();
+        foreach ($fields as $field) {
+            $pairs[] = array($field, $data[$prefix . $field]);
+        }
+
+        return base64_encode($this->sign($pairs));
+    }
+
+    /**
+     * Add a signature to an array of fields
+     *
+     * @access private
+     */
+    function addSignature($fields, &$data, $prefix = 'openid.')
+    {
+        $sig = $this->signDict($fields, $data, $prefix);
+        $signed = implode(",", $fields);
+        $data[$prefix . 'sig'] = $sig;
+        $data[$prefix . 'signed'] = $signed;
+    }
+
+    /**
+     * Confirm that the signature of these fields matches the
+     * signature contained in the data
+     *
+     * @access private
+     */
+    function checkSignature($data, $prefix = 'openid.')
+    {
+        $signed = $data[$prefix . 'signed'];
+        $fields = explode(",", $signed);
+        $expected_sig = $this->signDict($fields, $data, $prefix);
+        $request_sig = $data[$prefix . 'sig'];
+
+        return ($request_sig == $expected_sig);
+    }
+}
+
+?>
\ No newline at end of file

Added: incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/BigMath.php
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/BigMath.php?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/BigMath.php (added)
+++ incubator/heraldry/libraries/php/openid/trunk/Auth/OpenID/BigMath.php Wed Oct 11 15:49:50
2006
@@ -0,0 +1,444 @@
+<?php
+
+/**
+ * BigMath: A math library wrapper that abstracts out the underlying
+ * long integer library.
+ *
+ * PHP versions 4 and 5
+ *
+ * LICENSE: See the COPYING file included in this distribution.
+ *
+ * @access private
+ * @package OpenID
+ * @author JanRain, Inc. <openid@janrain.com>
+ * @copyright 2005 Janrain, Inc.
+ * @license http://www.gnu.org/copyleft/lesser.html LGPL
+ */
+
+/**
+ * Needed for random number generation
+ */
+require_once 'Auth/OpenID/CryptUtil.php';
+
+/**
+ * The superclass of all big-integer math implementations
+ * @access private
+ * @package OpenID
+ */
+class Auth_OpenID_MathLibrary {
+    /**
+     * Given a long integer, returns the number converted to a binary
+     * string.  This function accepts long integer values of arbitrary
+     * magnitude and uses the local large-number math library when
+     * available.
+     *
+     * @param integer $long The long number (can be a normal PHP
+     * integer or a number created by one of the available long number
+     * libraries)
+     * @return string $binary The binary version of $long
+     */
+    function longToBinary($long)
+    {
+        $cmp = $this->cmp($long, 0);
+        if ($cmp < 0) {
+            $msg = __FUNCTION__ . " takes only positive integers.";
+            trigger_error($msg, E_USER_ERROR);
+            return null;
+        }
+
+        if ($cmp == 0) {
+            return "\x00";
+        }
+
+        $bytes = array();
+
+        while ($this->cmp($long, 0) > 0) {
+            array_unshift($bytes, $this->mod($long, 256));
+            $long = $this->div($long, pow(2, 8));
+        }
+
+        if ($bytes && ($bytes[0] > 127)) {
+            array_unshift($bytes, 0);
+        }
+
+        $string = '';
+        foreach ($bytes as $byte) {
+            $string .= pack('C', $byte);
+        }
+
+        return $string;
+    }
+
+    /**
+     * Given a binary string, returns the binary string converted to a
+     * long number.
+     *
+     * @param string $binary The binary version of a long number,
+     * probably as a result of calling longToBinary
+     * @return integer $long The long number equivalent of the binary
+     * string $str
+     */
+    function binaryToLong($str)
+    {
+        if ($str === null) {
+            return null;
+        }
+
+        // Use array_merge to return a zero-indexed array instead of a
+        // one-indexed array.
+        $bytes = array_merge(unpack('C*', $str));
+
+        $n = $this->init(0);
+
+        if ($bytes && ($bytes[0] > 127)) {
+            trigger_error("bytesToNum works only for positive integers.",
+                          E_USER_WARNING);
+            return null;
+        }
+
+        foreach ($bytes as $byte) {
+            $n = $this->mul($n, pow(2, 8));
+            $n = $this->add($n, $byte);
+        }
+
+        return $n;
+    }
+
+    function base64ToLong($str)
+    {
+        $b64 = base64_decode($str);
+
+        if ($b64 === false) {
+            return false;
+        }
+
+        return $this->binaryToLong($b64);
+    }
+
+    function longToBase64($str)
+    {
+        return base64_encode($this->longToBinary($str));
+    }
+
+    /**
+     * Returns a random number in the specified range.  This function
+     * accepts $start, $stop, and $step values of arbitrary magnitude
+     * and will utilize the local large-number math library when
+     * available.
+     *
+     * @param integer $start The start of the range, or the minimum
+     * random number to return
+     * @param integer $stop The end of the range, or the maximum
+     * random number to return
+     * @param integer $step The step size, such that $result - ($step
+     * * N) = $start for some N
+     * @return integer $result The resulting randomly-generated number
+     */
+    function rand($stop)
+    {
+        static $duplicate_cache = array();
+
+        // Used as the key for the duplicate cache
+        $rbytes = $this->longToBinary($stop);
+
+        if (array_key_exists($rbytes, $duplicate_cache)) {
+            list($duplicate, $nbytes) = $duplicate_cache[$rbytes];
+        } else {
+            if ($rbytes[0] == "\x00") {
+                $nbytes = strlen($rbytes) - 1;
+            } else {
+                $nbytes = strlen($rbytes);
+            }
+
+            $mxrand = $this->pow(256, $nbytes);
+
+            // If we get a number less than this, then it is in the
+            // duplicated range.
+            $duplicate = $this->mod($mxrand, $stop);
+
+            if (count($duplicate_cache) > 10) {
+                $duplicate_cache = array();
+            }
+
+            $duplicate_cache[$rbytes] = array($duplicate, $nbytes);
+        }
+
+        do {
+            $bytes = "\x00" . Auth_OpenID_CryptUtil::getBytes($nbytes);
+            $n = $this->binaryToLong($bytes);
+            // Keep looping if this value is in the low duplicated range
+        } while ($this->cmp($n, $duplicate) < 0);
+
+        return $this->mod($n, $stop);
+    }
+}
+
+/**
+ * Exposes BCmath math library functionality.
+ *
+ * {@link Auth_OpenID_BcMathWrapper} wraps the functionality provided
+ * by the BCMath extension.
+ *
+ * @access private
+ * @package OpenID
+ */
+class Auth_OpenID_BcMathWrapper extends Auth_OpenID_MathLibrary{
+    var $type = 'bcmath';
+
+    function add($x, $y)
+    {
+        return bcadd($x, $y);
+    }
+
+    function sub($x, $y)
+    {
+        return bcsub($x, $y);
+    }
+
+    function pow($base, $exponent)
+    {
+        return bcpow($base, $exponent);
+    }
+
+    function cmp($x, $y)
+    {
+        return bccomp($x, $y);
+    }
+
+    function init($number, $base = 10)
+    {
+        return $number;
+    }
+
+    function mod($base, $modulus)
+    {
+        return bcmod($base, $modulus);
+    }
+
+    function mul($x, $y)
+    {
+        return bcmul($x, $y);
+    }
+
+    function div($x, $y)
+    {
+        return bcdiv($x, $y);
+    }
+
+    /**
+     * Same as bcpowmod when bcpowmod is missing
+     *
+     * @access private
+     */
+    function _powmod($base, $exponent, $modulus)
+    {
+        $square = $this->mod($base, $modulus);
+        $result = 1;
+        while($this->cmp($exponent, 0) > 0) {
+            if ($this->mod($exponent, 2)) {
+                $result = $this->mod($this->mul($result, $square), $modulus);
+            }
+            $square = $this->mod($this->mul($square, $square), $modulus);
+            $exponent = $this->div($exponent, 2);
+        }
+        return $result;
+    }
+
+    function powmod($base, $exponent, $modulus)
+    {
+        if (function_exists('bcpowmod')) {
+            return bcpowmod($base, $exponent, $modulus);
+        } else {
+            return $this->_powmod($base, $exponent, $modulus);
+        }
+    }
+
+    function toString($num)
+    {
+        return $num;
+    }
+}
+
+/**
+ * Exposes GMP math library functionality.
+ *
+ * {@link Auth_OpenID_GmpMathWrapper} wraps the functionality provided
+ * by the GMP extension.
+ *
+ * @access private
+ * @package OpenID
+ */
+class Auth_OpenID_GmpMathWrapper extends Auth_OpenID_MathLibrary{
+    var $type = 'gmp';
+
+    function add($x, $y)
+    {
+        return gmp_add($x, $y);
+    }
+
+    function sub($x, $y)
+    {
+        return gmp_sub($x, $y);
+    }
+
+    function pow($base, $exponent)
+    {
+        return gmp_pow($base, $exponent);
+    }
+
+    function cmp($x, $y)
+    {
+        return gmp_cmp($x, $y);
+    }
+
+    function init($number, $base = 10)
+    {
+        return gmp_init($number, $base);
+    }
+
+    function mod($base, $modulus)
+    {
+        return gmp_mod($base, $modulus);
+    }
+
+    function mul($x, $y)
+    {
+        return gmp_mul($x, $y);
+    }
+
+    function div($x, $y)
+    {
+        return gmp_div_q($x, $y);
+    }
+
+    function powmod($base, $exponent, $modulus)
+    {
+        return gmp_powm($base, $exponent, $modulus);
+    }
+
+    function toString($num)
+    {
+        return gmp_strval($num);
+    }
+}
+
+/**
+ * Define the supported extensions.  An extension array has keys
+ * 'modules', 'extension', and 'class'.  'modules' is an array of PHP
+ * module names which the loading code will attempt to load.  These
+ * values will be suffixed with a library file extension (e.g. ".so").
+ * 'extension' is the name of a PHP extension which will be tested
+ * before 'modules' are loaded.  'class' is the string name of a
+ * {@link Auth_OpenID_MathWrapper} subclass which should be
+ * instantiated if a given extension is present.
+ *
+ * You can define new math library implementations and add them to
+ * this array.
+ */
+$_Auth_OpenID_math_extensions = array(
+    array('modules' => array('gmp', 'php_gmp'),
+          'extension' => 'gmp',
+          'class' => 'Auth_OpenID_GmpMathWrapper'),
+    array('modules' => array('bcmath', 'php_bcmath'),
+          'extension' => 'bcmath',
+          'class' => 'Auth_OpenID_BcMathWrapper')
+    );
+
+/**
+ * Detect which (if any) math library is available
+ */
+function Auth_OpenID_detectMathLibrary($exts)
+{
+    $loaded = false;
+
+    foreach ($exts as $extension) {
+        // See if the extension specified is already loaded.
+        if ($extension['extension'] &&
+            extension_loaded($extension['extension'])) {
+            $loaded = true;
+        }
+
+        // Try to load dynamic modules.
+        if (!$loaded) {
+            foreach ($extension['modules'] as $module) {
+                if (@dl($module . "." . PHP_SHLIB_SUFFIX)) {
+                    $loaded = true;
+                    break;
+                }
+            }
+        }
+
+        // If the load succeeded, supply an instance of
+        // Auth_OpenID_MathWrapper which wraps the specified
+        // module's functionality.
+        if ($loaded) {
+            return $extension;
+        }
+    }
+
+    return false;
+}
+
+/**
+ * {@link Auth_OpenID_getMathLib} checks for the presence of long
+ * number extension modules and returns an instance of
+ * {@link Auth_OpenID_MathWrapper} which exposes the module's
+ * functionality.
+ *
+ * Checks for the existence of an extension module described by the
+ * local {@link Auth_OpenID_math_extensions} array and returns an
+ * instance of a wrapper for that extension module.  If no extension
+ * module is found, an instance of {@link Auth_OpenID_MathWrapper} is
+ * returned, which wraps the native PHP integer implementation.  The
+ * proper calling convention for this method is $lib =&
+ * Auth_OpenID_getMathLib().
+ *
+ * This function checks for the existence of specific long number
+ * implementations in the following order: GMP followed by BCmath.
+ *
+ * @return Auth_OpenID_MathWrapper $instance An instance of
+ * {@link Auth_OpenID_MathWrapper} or one of its subclasses
+ *
+ * @package OpenID
+ */
+function &Auth_OpenID_getMathLib()
+{
+    // The instance of Auth_OpenID_MathWrapper that we choose to
+    // supply will be stored here, so that subseqent calls to this
+    // method will return a reference to the same object.
+    static $lib = null;
+
+    if (isset($lib)) {
+        return $lib;
+    }
+
+    if (defined('Auth_OpenID_NO_MATH_SUPPORT')) {
+        $null = null;
+        return $null;
+    }
+
+    // If this method has not been called before, look at
+    // $Auth_OpenID_math_extensions and try to find an extension that
+    // works.
+    global $_Auth_OpenID_math_extensions;
+    $ext = Auth_OpenID_detectMathLibrary($_Auth_OpenID_math_extensions);
+    if ($ext === false) {
+        $tried = array();
+        foreach ($_Auth_OpenID_math_extensions as $extinfo) {
+            $tried[] = $extinfo['extension'];
+        }
+        $triedstr = implode(", ", $tried);
+        $msg = 'This PHP installation has no big integer math ' .
+            'library. Define Auth_OpenID_NO_MATH_SUPPORT to use ' .
+            'this library in dumb mode. Tried: ' . $triedstr;
+        trigger_error($msg, E_USER_ERROR);
+    }
+
+    // Instantiate a new wrapper
+    $class = $ext['class'];
+    $lib = new $class();
+
+    return $lib;
+}
+
+?>
\ No newline at end of file



Mime
View raw message