code:
<?php

/**
 * XRDS-parsing tests for the Yadis library.
 */

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_Auth_Yadis_XRDS extends PHPUnit_Framework_TestCase {

    function test_good()
    {
        $files = array(
                       'brian.xrds' => 1,
                       'pip.xrds' => 2
                       );

        foreach ($files as $filename => $service_count) {
            $xml = Tests_Auth_Yadis_readdata($filename);
            $xrds = Auth_Yadis_XRDS::parseXRDS($xml);

            $this->assertTrue($xrds !== null);

            if ($xrds) {
                $this->assertEquals(count($xrds->services()), $service_count);
            } else {
                $this->fail("Could not test XRDS service list because the ".
                            "XRDS object is null");
            }
        }
    }

    function test_good_multi()
    {
        $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();
        $s = $s[0];

        $types = $s->getTypes();

        $this->assertTrue(count($types) == 1);
        $this->assertEquals('http://openid.net/signon/1.0',
                            $types[0]);
    }

    function test_good_uri_multi()
    {
        $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_Auth_Yadis_readdata("uri_priority.xrds");
        $xrds = Auth_Yadis_XRDS::parseXRDS($xml);
        $services = $xrds->services();
        $uris = $services[0]->getURIs();

        $expected_uris = array(
                               "http://zero.priority/",
                               "http://one.priority/",
                               "http://no.priority/"
                               );

        $this->assertEquals($uris, $expected_uris);
    }

    function test_bad()
    {
        $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(Auth_Yadis_XRDS::parseXRDS("\x00") === null);
    }

    function test_getCanonicalID()
    {
        $canonicalIDtests = array(
               array("@ootao*test1", "delegated-20060809.xrds",
                     "@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01"),
               array("@ootao*test1", "delegated-20060809-r1.xrds",
                     "@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01"),
               array("@ootao*test1", "delegated-20060809-r2.xrds",
                     "@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01"),
               array("@ootao*test1", "sometimesprefix.xrds",
                     "@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01"),
               array("@ootao*test1", "prefixsometimes.xrds",
                     "@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01"),
               array("=keturn*isDrummond", "spoof1.xrds", null),
               array("=keturn*isDrummond", "spoof2.xrds", null),
               array("@keturn*is*drummond", "spoof3.xrds", null),
               // Don't let IRI authorities be canonical for the GCS.
               array("phreak.example.com", "delegated-20060809-r2.xrds", null)
               // TODO: Refs
               // ("@ootao*test.ref", "ref.xrds", "@!BAE.A650.823B.2475")
               );

        foreach ($canonicalIDtests as $tupl) {
            list($iname, $filename, $expectedID) = $tupl;

            $xml = Tests_Auth_Yadis_readdata($filename);
            $xrds = Auth_Yadis_XRDS::parseXRDS($xml);
            $this->_getCanonicalID($iname, $xrds, $expectedID);
        }
    }

    function _getCanonicalID($iname, $xrds, $expectedID)
    {
        if ($expectedID === null) {
            $result = Auth_Yadis_getCanonicalID($iname, $xrds);
            if ($result !== false) {
                $this->fail($iname.' (got '.$result.')');
            }
        } else {
            $cid = Auth_Yadis_getCanonicalID($iname, $xrds);
            $this->assertEquals(Auth_Yadis_XRI($expectedID), $cid);
        }
    }

    function test_services_filters()
    {
        // First, just be sure that service objects do the right
        // thing.
        $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);

        // Get list of service objects.
        $services = $xrds->services();
        $this->assertEquals(count($services), 2, "first service count");

        // Query the two service objecs.
        $s1 = $services[0];
        $this->assertEquals($s1->getPriority(), 1, "first priority check");
        $types = $s1->getTypes();
        $this->assertEquals(count($types), 1, "first type check");

        $s2 = $services[1];
        $this->assertEquals($s2->getPriority(), 2, "second priority check");
        $types = $s2->getTypes();
        $this->assertEquals(count($types), 1, "second type check");

        function _DelegateFilter($service)
            {
                if ($service->getElements('openid:Delegate')) {
                    return true;
                }
                return false;
            }

        // Make sure that a filter which matches both DOES match both.
        $this->assertEquals(count(
                              $xrds->services(array("_DelegateFilter"))), 2,
                            "_DelegateFilter check");

        // This filter should match all services in the document.
        function _HasTypeAndURI($service)
            {
                if ($service->getTypes() &&
                    $service->getURIs()) {
                    return true;
                }
                return false;
            }

        // This filter should only match one.
        function _URIMatchesSchtuff($service)
            {
                $uris = $service->getURIs();

                foreach ($uris as $uri) {
                    if (preg_match("|schtuff|", $uri)) {
                        return true;
                    }
                }
                return false;
            }

        // This filter should only match one.
        function _URIMatchesMyOpenID($service)
            {
                $uris = $service->getURIs();

                foreach ($uris as $uri) {
                    if (preg_match("|myopenid|", $uri)) {
                        return true;
                    }
                }
                return false;
            }

        // Make sure a pair of filters in ALL mode only match one service.
        $this->assertEquals(count(
                              $xrds->services(array("_HasTypeAndURI",
                                                    "_URIMatchesSchtuff"),
                                              SERVICES_YADIS_MATCH_ALL)), 1,
                            "_HasTypeAndURI / _URIMatchesSchtuff check");

        // Make sure a pair of filters in ALL mode only match one service.
        $this->assertEquals(count(
                              $xrds->services(array("_HasTypeAndURI",
                                                    "_URIMatchesMyOpenID"),
                                              SERVICES_YADIS_MATCH_ALL)), 1,
                            "_HasTypeAndURI / _URIMatchesMyOpenID check");

        // Make sure a pair of filters in ANY mode matches both services.
        $this->assertEquals(count(
                              $xrds->services(array("_URIMatchesMyOpenID",
                                                    "_URIMatchesSchtuff"))), 2,
                            "_URIMatchesMyOpenID / _URIMatchesSchtuff check");

        // Make sure the order of the services returned (when using
        // filters) is correct.
        $s = $xrds->services(array("_URIMatchesMyOpenID",
                                   "_URIMatchesSchtuff"));

        $this->assertTrue($s[0]->getPriority() === 1, "s[0] priority check");
        $this->assertTrue($s[1]->getPriority() === 2, "s[1] priority check");

        // Make sure a bad filter mode gets us a null service list.
        $this->assertTrue($xrds->services(array("_URIMatchesMyOpenID",
                                                "_URIMatchesSchtuff"),
                                          "bogus") === null,
                          "bogus filter check");
    }

    function test_multisegment_xri()
    {
        $xml = Tests_Auth_Yadis_readdata('subsegments.xrds');
        $xmldoc = Auth_Yadis_XRDS::parseXRDS($xml);
        $result = Auth_Yadis_getCanonicalId('xri://=nishitani*masaki', $xmldoc);
        $this->assertEquals($result, "xri://=!E117.EF2F.454B.C707!0000.0000.3B9A.CA01");
    }
}


code:
<?php

/**
 * XRI resolution / handling tests.
 *
 * @package OpenID
 * @author JanRain, Inc. <openid@janrain.com>
 * @copyright 2005-2008 Janrain, Inc.
 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache
 */

require_once "Auth/Yadis/XRIRes.php";
require_once "Auth/Yadis/XRI.php";
require_once "Auth/Yadis/Yadis.php";

class Tests_Auth_Yadis_XriDiscoveryTestCase extends PHPUnit_Framework_TestCase {
    function runTest()
    {
        $this->assertEquals(
               Auth_Yadis_identifierScheme('=john.smith'), 'XRI');

        $this->assertEquals(
               Auth_Yadis_identifierScheme(''), 'URI');

        $this->assertEquals(
               Auth_Yadis_identifierScheme('@smiths/john'), 'XRI');

        $this->assertEquals(
               Auth_Yadis_identifierScheme('smoker.myopenid.com'), 'URI');

        $this->assertEquals(
               Auth_Yadis_identifierScheme('xri://=john'), 'XRI');
    }
}

class Tests_Auth_Yadis_XriEscapingTestCase extends PHPUnit_Framework_TestCase {
    function test_escaping_percents()
    {
        $this->assertEquals(Auth_Yadis_escapeForIRI('@example/abc%2Fd/ef'),
                            '@example/abc%252Fd/ef');
    }

    function runTest()
    {
        // no escapes
        $this->assertEquals('@example/foo/(@bar)',
               Auth_Yadis_escapeForIRI('@example/foo/(@bar)'));

        // escape slashes
        $this->assertEquals('@example/foo/(@bar%2Fbaz)',
               Auth_Yadis_escapeForIRI('@example/foo/(@bar/baz)'));

        $this->assertEquals('@example/foo/(@bar%2Fbaz)/(+a%2Fb)',
               Auth_Yadis_escapeForIRI('@example/foo/(@bar/baz)/(+a/b)'));

        // escape query ? and fragment
        $this->assertEquals('@example/foo/(@baz%3Fp=q%23r)?i=j#k',
               Auth_Yadis_escapeForIRI('@example/foo/(@baz?p=q#r)?i=j#k'));
    }
}

class Tests_Auth_Yadis_ProxyQueryTestCase extends PHPUnit_Framework_TestCase {
    function setUp()
    {
        $this->proxy_url = 'http://xri.example.com/';
        $this->fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
        $this->proxy = new Auth_Yadis_ProxyResolver($this->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';
    }

    function runTest()
    {
        $st = $this->servicetype;
        $ste = $this->servicetype_enc;
        $args_esc = "_xrd_r=application%2Fxrds%2Bxml&_xrd_t=" . $ste;
        $h = $this->proxy_url;
        $this->assertEquals($h . '=foo?' . $args_esc,
                            $this->proxy->queryURL('=foo', $st));
        $this->assertEquals($h . '=foo/bar?baz&' . $args_esc,
                            $this->proxy->queryURL('=foo/bar?baz', $st));
        $this->assertEquals($h . '=foo/bar?baz=quux&' . $args_esc,
                            $this->proxy->queryURL('=foo/bar?baz=quux', $st));
        $this->assertEquals($h . '=foo/bar?mi=fa&so=la&' . $args_esc,
                            $this->proxy->queryURL('=foo/bar?mi=fa&so=la', $st));

        $args_esc = "_xrd_r=application%2Fxrds%2Bxml&_xrd_t=" . $ste;
        $h = $this->proxy_url;
        $this->assertEquals($h . '=foo/bar??' . $args_esc,
                            $this->proxy->queryURL('=foo/bar?', $st));
        $this->assertEquals($h . '=foo/bar????' . $args_esc,
                            $this->proxy->queryURL('=foo/bar???', $st));
    }
}

class Tests_Auth_Yadis_TestGetRootAuthority extends PHPUnit_Framework_TestCase {
    function runTest()
    {
        $xris = array(
                      array("@foo", "@"),
                      array("@foo*bar", "@"),
                      array("@*foo*bar", "@"),
                      array("@foo/bar", "@"),
                      array("!!990!991", "!"),
                      array("!1001!02", "!"),
                      array("=foo*bar", "="),
                      array("(example.com)/foo", "(example.com)"),
                      array("(example.com)*bar/foo", "(example.com)"),
                      array("baz.example.com/foo", "baz.example.com"),
                      array("baz.example.com:8080/foo", "baz.example.com:8080")
                      // Looking at the ABNF in XRI Syntax 2.0, I don't think you can
                      // have example.com*bar.  You can do (example.com)*bar, but that
                      // would mean something else.
                      // ("example.com*bar/(=baz)", "example.com*bar"),
                      // ("baz.example.com!01/foo", "baz.example.com!01"),
                      );

        foreach ($xris as $tupl) {
            list($thexri, $expected_root) = $tupl;
            $this->assertEquals(Auth_Yadis_XRI($expected_root),
                                Auth_Yadis_rootAuthority($thexri),
                                'rootAuthority test ('.$thexri.')');
        }
    }
}

class Tests_Auth_Yadis_XRI extends PHPUnit_Framework_TestSuite {
    function getName()
    {
        return "Tests_Auth_Yadis_XRI";
    }

    function Tests_Auth_Yadis_XRI()
    {
        $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());
    }
}

license: mit


code:
<?php

/**
 * Tests for the core of the PHP Yadis library.
 */

require_once 'Auth/Yadis/Yadis.php';
require_once 'Tests/Auth/Yadis/TestUtil.php';

class Tests_Auth_Yadis_DiscoveryTest extends PHPUnit_Framework_TestCase {

    function Tests_Auth_Yadis_DiscoveryTest($input_url, $redir_uri,
                                                $xrds_uri, $num)
    {
        $this->input_url = $input_url;
        $this->redir_uri = $redir_uri;
        $this->xrds_uri = $xrds_uri;
        $this->num = $num;
    }

    function getName()
    {
        return "Yadis discovery test ".$this->num;
    }

    function runTest()
    {
        $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
        $y = Auth_Yadis_Yadis::discover(
             $this->input_url, $fetcher);
        $this->assertTrue($y !== null);

        // Compare parts of returned Yadis object to expected URLs.
        $this->assertEquals($this->redir_uri, $y->normalized_uri, "tried $this->input_url");

        if ($this->xrds_uri) {
            $this->assertEquals($this->xrds_uri, $y->xrds_uri);
            // Compare contents of actual HTTP GET with that of Yadis
            // response.
            $f = Auth_Yadis_Yadis::getHTTPFetcher();
            $http_response = $f->get($this->xrds_uri);

            $this->assertEquals($http_response->body, $y->response_text);
        } else {
            $this->assertTrue($y->xrds_uri === null);
        }
    }
}

class Tests_Auth_Yadis_Yadis extends PHPUnit_Framework_TestSuite {

    function getName()
    {
        return "Tests_Auth_Yadis_Yadis";
    }

    function parseTests($data)
    {
        $cases = explode("\n", $data);
        $tests = array();

        foreach ($cases as $line) {
            if ($line && ($line[0] != "#")) {
                $tests[] = explode("\t", $line, 3);
            }
        }

        return $tests;
    }

    function Tests_Auth_Yadis_Yadis()
    {
        $test_data = file_get_contents('http://www.openidenabled.com/resources/yadis-test/discover/manifest.txt');

        $test_cases = $this->parseTests($test_data);

        $i = 0;
        foreach ($test_cases as $case) {
            $i++;
            list($input, $redir, $xrds) = $case;
            $this->addTest(new Tests_Auth_Yadis_DiscoveryTest($input,
                                                                  $redir,
                                                                  $xrds, $i));
        }
    }

}


code:
delegated-20060809.xrds    - results from proxy.xri.net, determined by
                             Drummond and Kevin to be incorrect.
delegated-20060809-r1.xrds - Drummond's 1st correction
delegated-20060809-r2.xrds - Drummond's 2nd correction

spoofs: keturn's (=!E4)'s attempts to log in with Drummond's i-number (=!D2)
spoof1.xrds
spoof2.xrds
spoof3.xrds - attempt to steal @!C0!D2 by having "at least one" CanonicalID
    match the $res service ProviderID.

ref.xrds - resolving @ootao*test.ref, which refers to a neustar XRI.


code:
# Accept: [Accept: header value from RFC2616,
#     http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html]
# Available: [whitespace-separated content types]
# Expected: [Accept-header like list, containing the available content
#     types with their q-values]

Accept: */*
Available: text/plain
Expected: text/plain; q=1.0

Accept: */*
Available: text/plain, text/html
Expected: text/plain; q=1.0, text/html; q=1.0

# The order matters
Accept: */*
Available: text/html, text/plain
Expected: text/html; q=1.0, text/plain; q=1.0

Accept: text/*, */*; q=0.9
Available: text/plain, image/jpeg
Expected: text/plain; q=1.0, image/jpeg; q=0.9

Accept: text/*, */*; q=0.9
Available: image/jpeg, text/plain
Expected: text/plain; q=1.0, image/jpeg; q=0.9

# wildcard subtypes still reject differing main types
Accept: text/*
Available: image/jpeg, text/plain
Expected: text/plain; q=1.0

Accept: text/html
Available: text/html
Expected: text/html; q=1.0

Accept: text/html, text/*
Available: text/html
Expected: text/html; q=1.0

Accept: text/html, text/*
Available: text/plain, text/html
Expected: text/plain; q=1.0, text/html; q=1.0

Accept: text/html, text/*; q=0.9
Available: text/plain, text/html
Expected: text/html; q=1.0, text/plain; q=0.9

# If a more specific type has a higher q-value, then the higher value wins
Accept: text/*; q=0.9, text/html
Available: text/plain, text/html
Expected: text/html; q=1.0, text/plain; q=0.9

Accept: */*, text/*; q=0.9, text/html; q=0.1
Available: text/plain, text/html, image/monkeys
Expected: image/monkeys; q=1.0, text/plain; q=0.9, text/html; q=0.1

Accept: text/*, text/html; q=0
Available: text/html
Expected:

Accept: text/*, text/html; q=0
Available: text/html, text/plain
Expected: text/plain; q=1.0

Accept: text/html
Available: text/plain
Expected:

Accept: application/xrds+xml, text/html; q=0.9
Available: application/xrds+xml, text/html
Expected: application/xrds+xml; q=1.0, text/html; q=0.9

Accept: application/xrds+xml, */*; q=0.9
Available: application/xrds+xml, text/html
Expected: application/xrds+xml; q=1.0, text/html; q=0.9

Accept: application/xrds+xml, application/xhtml+xml; q=0.9, text/html; q=0.8, text/xml; q=0.7
Available: application/xrds+xml, text/html
Expected: application/xrds+xml; q=1.0, text/html; q=0.8

# See http://www.rfc-editor.org/rfc/rfc3023.txt, section A.13
Accept: application/xrds
Available: application/xrds+xml
Expected:

Accept: application/xrds+xml
Available: application/xrds
Expected:

Accept: application/xml
Available: application/xrds+xml
Expected:

Available: application/xrds+xml
Accept: application/xml
Expected:

#################################################
# The tests below this line are documentation of how this library
# works. If the implementation changes, it's acceptable to change the
# test to reflect that. These are specified so that we can make sure
# that the current implementation actually works the way that we
# expect it to given these inputs.

Accept: text/html;level=1
Available: text/html
Expected: text/html; q=1.0

Accept: text/html; level=1, text/html; level=9; q=0.1
Available: text/html
Expected: text/html; q=1.0

Accept: text/html; level=9; q=0.1, text/html; level=1
Available: text/html
Expected: text/html; q=1.0


code:
<?xml version="1.0" encoding="UTF-8"?>
<xrds:XRDS
    xmlns:xrds="xri://$xrds"
    xmlns:openid="http://openid.net/xmlns/1.0"
    xmlns="xri://$xrd*($v*2.0)">
  <XRD>

    <Service priority="2">
      <Type>http://openid.net/signon/1.1</Type>
      <URI>http://www.myopenid.com/server</URI>
      <openid:Delegate>http://frank.myopenid.com/</openid:Delegate>
    </Service>

  </XRD>
  <XRD>

    <Service priority="1">
      <Type>http://bar.com/</Type>
      <URI>http://bar.com/server</URI>
    </Service>

    <Service priority="2">
      <Type>http://foo.com</Type>
      <URI>http://foo.com/server</URI>
    </Service>

  </XRD>
  <XRD>

    <Service priority="0">
      <Type>http://openid.net/signon/1.0</Type>
      <URI>http://www.myopenid.com/server</URI>
      <openid:Delegate>http://brian.myopenid.com/</openid:Delegate>
    </Service>

  </XRD>
</xrds:XRDS>


code:
<?xml version="1.0" encoding="UTF-8"?>
<xrds:XRDS
    xmlns:xrds="xri://$xrds"
    xmlns:openid="http://openid.net/xmlns/1.0"
    xmlns="xri://$xrd*($v*2.0)">
  <XRD>

    <Service>
      <Type>http://openid.net/signon/1.0</Type>
      <URI>http://www.myopenid.com/server</URI>
      <URI>http://example.com/server</URI>
    </Service>

  </XRD>
</xrds:XRDS>


code:
<?xml version="1.0" encoding="UTF-8"?>
<xrds:XRDS
    xmlns:xrds="xri://$xrds"
    xmlns:openid="http://openid.net/xmlns/1.0"
    xmlns="xri://$xrd*($v*2.0)">
  <XRD>

    <Service priority="0">
      <Type>http://openid.net/signon/1.0</Type>
      <URI>http://www.myopenid.com/server</URI>
      <openid:Delegate>http://brian.myopenid.com/</openid:Delegate>
    </Service>

  </XRD>
</xrds:XRDS>


code:
<?xml version="1.0" encoding="UTF-8"?>
<xrds:XRDS
    xmlns:xrds="xri://$xrds"
    xmlns:openid="http://openid.net/xmlns/1.0"
    xmlns="xri://$xrd*($v*2.0)">
  <XRD>

    <Service priority="2">
      <Type>http://openid.net/signon/1.0</Type>
      <URI>http://www.schtuff.com/?action=openid_server</URI>
      <openid:Delegate>http://users.schtuff.com/brian</openid:Delegate>
    </Service>

    <Service priority="1">
      <Type>http://openid.net/signon/1.0</Type>
      <URI>http://www.myopenid.com/server</URI>
      <openid:Delegate>http://brian.myopenid.com/</openid:Delegate>
    </Service>

  </XRD>
</xrds:XRDS>


code:
<?xml version="1.0" encoding="UTF-8"?>
<XRDS ref="xri://@ootao*test1" xmlns="xri://$xrds">
 <XRD xmlns="xri://$xrd*($v*2.0)">
  <Query>*ootao</Query>
  <Status code="100"/>
  <Expires>2006-08-09T22:07:13.000Z</Expires>
  <ProviderID>xri://@</ProviderID>
  <LocalID priority="10">!5BAD.2AA.3C72.AF46</LocalID>
  <CanonicalID priority="10">@!5BAD.2AA.3C72.AF46</CanonicalID>
  <Service priority="10">
   <Type>xri://$res*auth*($v*2.0)</Type>
   <ProviderID>xri://!!1003</ProviderID>
   <MediaType>application/xrds+xml;trust=none</MediaType>
   <URI priority="10">http://resolve.ezibroker.net/resolve/@ootao/</URI>
  </Service>
  <Service priority="10">
   <Type select="true">http://openid.net/signon/1.0</Type>
   <ProviderID/>
   <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI>
  </Service>
 </XRD>
 <XRD xmlns="xri://$xrd*($v*2.0)">
  <Query>*test1</Query>
  <Status code="100">SUCCESS</Status>
  <ProviderID>xri://!!1003</ProviderID>
  <LocalID>!0000.0000.3B9A.CA01</LocalID>
  <CanonicalID>@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01</CanonicalID>
  <Service>
   <Type select="true">http://openid.net/signon/1.0</Type>
   <ProviderID/>
   <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI>
  </Service>
 </XRD>
</XRDS>


code:
<?xml version="1.0" encoding="UTF-8"?>
<XRDS ref="xri://@ootao*test1" xmlns="xri://$xrds">
 <XRD xmlns="xri://$xrd*($v*2.0)">
  <Query>*ootao</Query>
  <Status code="100"/>
  <Expires>2006-08-09T22:07:13.000Z</Expires>
  <ProviderID>xri://@</ProviderID>
  <LocalID priority="10">!5BAD.2AA.3C72.AF46</LocalID>
  <CanonicalID priority="10">@!5BAD.2AA.3C72.AF46</CanonicalID>
  <Service priority="10">
   <Type>xri://$res*auth*($v*2.0)</Type>
   <ProviderID>xri://@!5BAD.2AA.3C72.AF46</ProviderID>
   <MediaType>application/xrds+xml;trust=none</MediaType>
   <URI priority="10">http://resolve.ezibroker.net/resolve/@ootao/</URI>
  </Service>
  <Service priority="10">
   <Type select="true">http://openid.net/signon/1.0</Type>
   <ProviderID/>
   <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI>
  </Service>
 </XRD>
 <XRD xmlns="xri://$xrd*($v*2.0)">
  <Query>*test1</Query>
  <Status code="100">SUCCESS</Status>
  <ProviderID>xri://@!5BAD.2AA.3C72.AF46</ProviderID>
  <LocalID>!0000.0000.3B9A.CA01</LocalID>
  <CanonicalID>@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01</CanonicalID>
  <Service>
   <Type select="true">http://openid.net/signon/1.0</Type>
   <ProviderID/>
   <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI>
  </Service>
 </XRD>
</XRDS>


code:
<?xml version="1.0" encoding="UTF-8"?>
<XRDS ref="xri://@ootao*test1" xmlns="xri://$xrds">
 <XRD xmlns="xri://$xrd*($v*2.0)">
  <Query>*ootao</Query>
  <Status code="100"/>
  <Expires>2006-08-09T22:07:13.000Z</Expires>
  <ProviderID>xri://@</ProviderID>
  <LocalID priority="10">!5BAD.2AA.3C72.AF46</LocalID>
  <CanonicalID priority="10">@!5BAD.2AA.3C72.AF46</CanonicalID>
  <Service priority="10">
   <Type>xri://$res*auth*($v*2.0)</Type>
   <ProviderID/>
   <MediaType>application/xrds+xml;trust=none</MediaType>
   <URI priority="10">http://resolve.ezibroker.net/resolve/@ootao/</URI>
  </Service>
  <Service priority="10">
   <Type select="true">http://openid.net/signon/1.0</Type>
   <ProviderID/>
   <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI>
  </Service>
 </XRD>
 <XRD xmlns="xri://$xrd*($v*2.0)">
  <Query>*test1</Query>
  <Status code="100">SUCCESS</Status>
  <ProviderID>xri://!!1003</ProviderID>
  <LocalID>!0000.0000.3B9A.CA01</LocalID>
  <CanonicalID>@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01</CanonicalID>
  <Service>
   <Type select="true">http://openid.net/signon/1.0</Type>
   <ProviderID/>
   <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI>
  </Service>
 </XRD>
</XRDS>


code:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Sample XRDS file at: NAME -->
<xrds:XRDS
    xmlns:xrds="xri://$xrds"
    xmlns="xri://$xrd*($v*2.0)">
  <XRD>

    <Service priority="0">
      <Type>http://example.com/</Type>
      <URI>http://www.openidenabled.com/</URI>
    </Service>

  </XRD>
</xrds:XRDS>


code:
<?xml version="1.0" encoding="UTF-8"?>
<xrds:XRDS
    xmlns:xrds="xri://$xrds"
    xmlns:openid="http://openid.net/xmlns/1.0"
    xmlns:typekey="http://typekey.com/xmlns/1.0"
    xmlns="xri://$xrd*($v*2.0)">
</xrds:XRDS>


code:
<?xml version="1.0" encoding="UTF-8"?>
<x></x>


code:
<?xml version="1.0" encoding="UTF-8"?>
<xrds:XRDS
  xmlns:xrds="xri://$xrds"
  xmlns:openid="http://openid.net/xmlns/1.0"
  xmlns="xri://$xrd*($v*2.0)">
  <XRD>

    <Service priority="10">
      <Type>http://openid.net/signon/1.1</Type>
      <Type>http://openid.net/sreg/1.0</Type>
      <URI>https://pip.verisignlabs.com/server</URI>
    </Service>

    <Service priority="20">
      <Type>http://openid.net/signon/1.0</Type>
      <Type>http://openid.net/sreg/1.0</Type>
      <URI>https://pip.verisignlabs.com/server</URI>
    </Service>

  </XRD>
</xrds:XRDS>


code:
<?xml version="1.0" encoding="UTF-8"?>
<XRDS ref="xri://@ootao*test1" xmlns="xri://$xrds">
 <XRD xmlns="xri://$xrd*($v*2.0)">
  <Query>*ootao</Query>
  <Status code="100"/>
  <Expires>2006-08-09T22:07:13.000Z</Expires>
  <ProviderID>xri://@</ProviderID>
  <LocalID priority="10">!5BAD.2AA.3C72.AF46</LocalID>
  <CanonicalID priority="10">@!5BAD.2AA.3C72.AF46</CanonicalID>
  <Service priority="10">
   <Type>xri://$res*auth*($v*2.0)</Type>
   <ProviderID>xri://@!5BAD.2AA.3C72.AF46</ProviderID>
   <MediaType>application/xrds+xml;trust=none</MediaType>
   <URI priority="10">http://resolve.ezibroker.net/resolve/@ootao/</URI>
  </Service>
  <Service priority="10">
   <Type select="true">http://openid.net/signon/1.0</Type>
   <ProviderID/>
   <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI>
  </Service>
 </XRD>
 <XRD xmlns="xri://$xrd*($v*2.0)">
  <Query>*test1</Query>
  <Status code="100">SUCCESS</Status>
  <ProviderID>xri://@!5BAD.2AA.3C72.AF46</ProviderID>
  <LocalID>!0000.0000.3B9A.CA01</LocalID>
  <CanonicalID>xri://@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01</CanonicalID>
  <Service>
   <Type select="true">http://openid.net/signon/1.0</Type>
   <ProviderID/>
   <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI>
  </Service>
 </XRD>
</XRDS>


code:
<?xml version="1.0" encoding="UTF-8"?>
<XRDS ref="xri://@ootao*test.ref" xmlns="xri://$xrds">
 <XRD xmlns="xri://$xrd*($v*2.0)">
  <Query>*ootao</Query>
  <Status code="100"/>
  <Expires>2006-08-15T18:56:09.000Z</Expires>
  <ProviderID>xri://@</ProviderID>
  <LocalID priority="10">!5BAD.2AA.3C72.AF46</LocalID>
  <CanonicalID priority="10">@!5BAD.2AA.3C72.AF46</CanonicalID>
  <Service priority="10">
   <Type>xri://$res*auth*($v*2.0)</Type>
   <ProviderID/>
   <MediaType>application/xrds+xml;trust=none</MediaType>
   <URI priority="10">http://resolve.ezibroker.net/resolve/@ootao/</URI>
  </Service>
  <Service priority="10">
   <Type select="true">http://openid.net/signon/1.0</Type>
   <ProviderID/>
   <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI>
  </Service>
 </XRD>
 <XRD xmlns="xri://$xrd*($v*2.0)">
  <Query>*test.ref</Query>
  <Status code="100">SUCCESS</Status>
  <ProviderID>xri://!!1003</ProviderID>
  <LocalID>!0000.0000.3B9A.CA03</LocalID>
  <CanonicalID>@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA03</CanonicalID>
  <Ref>@!BAE.A650.823B.2475</Ref>
  <Service>
   <Type select="true">http://openid.net/signon/1.0</Type>
   <ProviderID/>
   <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI>
  </Service>
 </XRD>
 <XRDS ref="xri://@!BAE.A650.823B.2475" xmlns="xri://$xrds">
  <XRD xmlns="xri://$xrd*($v*2.0)">
   <Query>!BAE.A650.823B.2475</Query>
   <Status code="100"/>
   <Expires>2006-08-15T18:56:10.000Z</Expires>
   <ProviderID>xri://@</ProviderID>
   <LocalID priority="10">!BAE.A650.823B.2475</LocalID>
   <CanonicalID priority="10">@!BAE.A650.823B.2475</CanonicalID>
   <Service priority="10">
    <Type select="true">(+wdnc)</Type>
    <ProviderID/>
    <Path select="true">(+wdnc)</Path>
    <URI append="none" priority="10">http://www.tcpacompliance.us</URI>
   </Service>
   <Service priority="10">
    <Type match="content" select="true">xri://$res*auth*($v*2.0)</Type>
    <ProviderID/>
    <MediaType match="content" select="false">application/xrds+xml;trust=none</MediaType>
    <URI priority="10">http://dev.dready.org/cgi-bin/xri</URI>
   </Service>
   <Service priority="10">
    <Type match="content" select="true">(+i-name)</Type>
    <ProviderID/>
    <Path match="content" select="true">(+i-name)</Path>
    <URI append="none" priority="10">http://www.inames.net</URI>
   </Service>
   <Service priority="10">
    <Type select="true">xri://+i-service*(+contact)*($v*1.0)</Type>
    <Type match="default" select="false"/>
    <ProviderID>xri://!!1001</ProviderID>
    <Path select="true">(+contact)</Path>
    <Path match="null" select="false"/>
    <MediaType select="false">text/html</MediaType>
    <MediaType match="default" select="false"/>
    <URI append="none" priority="10">http://www.neustar.biz</URI>
   </Service>
  </XRD>
 </XRDS>
 <XRD xmlns="xri://$xrd*($v*2.0)">
  <Query>!BAE.A650.823B.2475</Query>
  <Status code="100"/>
  <Expires>2006-08-15T18:56:10.000Z</Expires>
  <ProviderID>xri://@</ProviderID>
  <LocalID priority="10">!BAE.A650.823B.2475</LocalID>
  <CanonicalID priority="10">@!BAE.A650.823B.2475</CanonicalID>
  <Service priority="10">
   <Type select="true">(+wdnc)</Type>
   <ProviderID/>
   <Path select="true">(+wdnc)</Path>
   <URI append="none" priority="10">http://www.tcpacompliance.us</URI>
  </Service>
  <Service priority="10">
   <Type match="content" select="true">xri://$res*auth*($v*2.0)</Type>
   <ProviderID/>
   <MediaType match="content" select="false">application/xrds+xml;trust=none</MediaType>
   <URI priority="10">http://dev.dready.org/cgi-bin/xri</URI>
  </Service>
  <Service priority="10">
   <Type match="content" select="true">(+i-name)</Type>
   <ProviderID/>
   <Path match="content" select="true">(+i-name)</Path>
   <URI append="none" priority="10">http://www.inames.net</URI>
  </Service>
  <Service priority="10">
   <Type select="true">xri://+i-service*(+contact)*($v*1.0)</Type>
   <Type match="default" select="false"/>
   <ProviderID>xri://!!1001</ProviderID>
   <Path select="true">(+contact)</Path>
   <Path match="null" select="false"/>
   <MediaType select="false">text/html</MediaType>
   <MediaType match="default" select="false"/>
   <URI append="none" priority="10">http://www.neustar.biz</URI>
  </Service>
 </XRD>
</XRDS>


code:
<?xml version="1.0" encoding="UTF-8"?>
<XRDS ref="xri://@ootao*test1" xmlns="xri://$xrds">
 <XRD xmlns="xri://$xrd*($v*2.0)">
  <Query>*ootao</Query>
  <Status code="100"/>
  <Expires>2006-08-09T22:07:13.000Z</Expires>
  <ProviderID>xri://@</ProviderID>
  <LocalID priority="10">!5BAD.2AA.3C72.AF46</LocalID>
  <CanonicalID priority="10">xri://@!5BAD.2AA.3C72.AF46</CanonicalID>
  <Service priority="10">
   <Type>xri://$res*auth*($v*2.0)</Type>
   <ProviderID>xri://@!5BAD.2AA.3C72.AF46</ProviderID>
   <MediaType>application/xrds+xml;trust=none</MediaType>
   <URI priority="10">http://resolve.ezibroker.net/resolve/@ootao/</URI>
  </Service>
  <Service priority="10">
   <Type select="true">http://openid.net/signon/1.0</Type>
   <ProviderID/>
   <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI>
  </Service>
 </XRD>
 <XRD xmlns="xri://$xrd*($v*2.0)">
  <Query>*test1</Query>
  <Status code="100">SUCCESS</Status>
  <ProviderID>xri://@!5BAD.2AA.3C72.AF46</ProviderID>
  <LocalID>!0000.0000.3B9A.CA01</LocalID>
  <CanonicalID>@!5BAD.2AA.3C72.AF46!0000.0000.3B9A.CA01</CanonicalID>
  <Service>
   <Type select="true">http://openid.net/signon/1.0</Type>
   <ProviderID/>
   <URI append="qxri" priority="1">https://linksafe.ezibroker.net/server/</URI>
  </Service>
 </XRD>
</XRDS>


code:
<?xml version="1.0" encoding="UTF-8"?>
<XRDS ref="xri://=keturn*isDrummond" xmlns="xri://$xrds">
 <XRD xmlns="xri://$xrd*($v*2.0)">
 <Query>*keturn</Query>
 <ProviderID>xri://=</ProviderID>
 <LocalID>!E4</LocalID>
 <CanonicalID>=!E4</CanonicalID>

 <Service>
   <Type>xri://$res*auth*($v*2.0)</Type>
   <URI>http://keturn.example.com/resolve/</URI>
   <ProviderID>=!E4</ProviderID>
 </Service>
 </XRD>
 <XRD xmlns="xri://$xrd*($v*2.0)">
  <Query>*isDrummond</Query>
  <ProviderID>=!E4</ProviderID>
  <LocalID>!D2</LocalID>
  <CanonicalID>=!D2</CanonicalID>
  <Service>
    <Type>http://openid.net/signon/1.0</Type>
    <URI>http://keturn.example.com/openid</URI>
  </Service>
 </XRD>
</XRDS>


code:
<?xml version="1.0" encoding="UTF-8"?>
<XRDS ref="xri://=keturn*isDrummond" xmlns="xri://$xrds">
 <XRD xmlns="xri://$xrd*($v*2.0)">
 <Query>*keturn</Query>
 <ProviderID>xri://=</ProviderID>
 <LocalID>!E4</LocalID>
 <CanonicalID>=!E4</CanonicalID>

 <Service>
   <Type>xri://$res*auth*($v*2.0)</Type>
   <URI>http://keturn.example.com/resolve/</URI>
   <ProviderID>xri://=</ProviderID>
 </Service>
 </XRD>
 <XRD xmlns="xri://$xrd*($v*2.0)">
  <Query>*isDrummond</Query>
  <ProviderID>xri://=</ProviderID>
  <LocalID>!D2</LocalID>
  <CanonicalID>=!D2</CanonicalID>
  <Service>
    <Type>http://openid.net/signon/1.0</Type>
    <URI>http://keturn.example.com/openid</URI>
  </Service>
 </XRD>
</XRDS>


code:
<?xml version="1.0" encoding="UTF-8"?>
<XRDS ref="xri://=keturn*isDrummond" xmlns="xri://$xrds">
 <XRD xmlns="xri://$xrd*($v*2.0)">
 <Query>*keturn</Query>
 <ProviderID>xri://@</ProviderID>
 <LocalID>@E4</LocalID>
 <CanonicalID>@!E4</CanonicalID>

 <Service>
   <Type>xri://$res*auth*($v*2.0)</Type>
   <URI>http://keturn.example.com/resolve/</URI>
   <ProviderID>@!E4</ProviderID>
 </Service>
 </XRD>
 <XRD xmlns="xri://$xrd*($v*2.0)">
  <Query>*is</Query>
  <ProviderID>@!E4</ProviderID>
  <LocalID>!D2</LocalID>
  <CanonicalID>=!C0</CanonicalID>
  <CanonicalID>=!E4!01</CanonicalID>
  <Service>
    <Type>xri://$res*auth*($v*2.0)</Type>
    <URI>http://keturn.example.com/resolve/</URI>
    <ProviderID>@!C0</ProviderID>
  </Service>
 </XRD>
 <XRD xmlns="xri://$xrd*($v*2.0)">
  <Query>*drummond</Query>
  <ProviderID>@!C0</ProviderID>
  <LocalID>!D2</LocalID>
  <CanonicalID>@!C0!D2</CanonicalID>
  <Service>
    <Type>http://openid.net/signon/1.0</Type>
    <URI>http://keturn.example.com/openid</URI>
  </Service>
 </XRD>
</XRDS>


code:
<?xml version="1.0" encoding="UTF-8"?>
<XRDS ref="xri://=nishitani*masaki" xmlns="xri://$xrds">
 <XRD xmlns="xri://$xrd*($v*2.0)">
  <Query>*nishitani</Query>
  <Status code="100"/>
  <Expires>2007-12-25T11:33:39.000Z</Expires>
  <ProviderID>xri://=</ProviderID>
  <LocalID priority="10">!E117.EF2F.454B.C707</LocalID>
  <CanonicalID priority="10">=!E117.EF2F.454B.C707</CanonicalID>
  <Service priority="10">
   <Type select="true">http://openid.net/signon/1.0</Type>
   <ProviderID>xri://!!1003!103</ProviderID>
   <URI append="none" priority="1">https://linksafe.ezibroker.net/server/</URI>
  </Service>
  <Service priority="10">
   <Type select="true">xri://$res*auth*($v*2.0)</Type>
   <ProviderID>xri://!!1003!103</ProviderID>
   <MediaType>application/xrds+xml;trust=none</MediaType>
   <URI priority="10">http://resolve.ezibroker.net/resolve/=nishitani/</URI>
  </Service>
  <Service priority="1">
   <Type match="content" select="true">xri://+i-service*(+forwarding)*($v*1.0)</Type>
   <Type match="null" select="false"/>
   <ProviderID>xri://!!1003!103</ProviderID>
   <Path match="content">(+index)</Path>
   <Path match="default"/>
   <URI append="qxri" priority="1">http://linksafe-forward.ezibroker.net/forwarding/</URI>
  </Service>
 </XRD>
 <XRD xmlns="xri://$xrd*($v*2.0)">
  <Query>*masaki</Query>
  <Status code="100">SUCCESS</Status>
  <ProviderID>xri://!!1003</ProviderID>
  <LocalID>!0000.0000.3B9A.CA01</LocalID>
  <CanonicalID>=!E117.EF2F.454B.C707!0000.0000.3B9A.CA01</CanonicalID>
  <Service>
   <Type select="true">http://openid.net/signon/1.0</Type>
   <ProviderID>xri://!!1003!103</ProviderID>
   <URI append="none" priority="1">https://linksafe.ezibroker.net/server/</URI>
  </Service>
  <Service>
   <Type select="true">xri://+i-service*(+contact)*($v*1.0)</Type>
   <Type match="null"/>
   <ProviderID>xri://!!1003!103</ProviderID>
   <Path select="true">(+contact)</Path>
   <Path match="null"/>
   <URI append="authority" priority="1">http://linksafe-contact.ezibroker.net/contact/</URI>
  </Service>
  <Service priority="1">
   <Type match="content" select="true">xri://+i-service*(+forwarding)*($v*1.0)</Type>
   <Type match="null" select="false"/>
   <ProviderID>xri://!!1003!103</ProviderID>
   <Path match="content">(+index)</Path>
   <Path match="default"/>
   <URI append="qxri" priority="1">http://linksafe-forward.ezibroker.net/forwarding/</URI>
  </Service>
 </XRD>
</XRDS>


code:
equiv
Status: 200 OK
Content-Type: text/html

<meta http-equiv="YADIS_HEADER" content="URL_BASE/xrds">
<title>Joe Schmoe's Homepage</title>

Joe Schmoe's Homepage

Blah blah blah blah blah blah blah

header
Status: 200 OK
Content-Type: text/html
YADIS_HEADER: URL_BASE/xrds

<title>Joe Schmoe's Homepage</title>

Joe Schmoe's Homepage

Blah blah blah blah blah blah blah

xrds
Status: 200 OK
Content-Type: application/xrds+xml

<XRDS Content>

xrds_ctparam
Status: 200 OK
Content-Type: application/xrds+xml; charset=UTF8

<XRDS Content>

xrds_ctcase
Status: 200 OK
Content-Type: appliCATION/XRDS+xml

<XRDS Content>

xrds_html
Status: 200 OK
Content-Type: text/html

<XRDS Content>

redir_equiv
Status: 302 Found
Content-Type: text/plain
Location: URL_BASE/equiv

You are presently being redirected.

redir_header
Status: 302 Found
Content-Type: text/plain
Location: URL_BASE/header

You are presently being redirected.

redir_xrds
Status: 302 Found
Content-Type: application/xrds+xml
Location: URL_BASE/xrds

<XRDS Content>

redir_xrds_html
Status: 302 Found
Content-Type: text/plain
Location: URL_BASE/xrds_html

You are presently being redirected.

redir_redir_equiv
Status: 302 Found
Content-Type: text/plain
Location: URL_BASE/redir_equiv

You are presently being redirected.

lowercase_header
Status: 200 OK
Content-Type: text/html
x-xrds-location: URL_BASE/xrds

<title>Joe Schmoe's Homepage</title>

Joe Schmoe's Homepage

Blah blah blah blah blah blah blah

404_server_response
Status: 404 Not Found

EEk!

500_server_response
Status: 500 Server error

EEk!

201_server_response
Status: 201 Created

EEk!

404_with_header
Status: 404 Not Found
YADIS_HEADER: URL_BASE/xrds

EEk!

404_with_meta
Status: 404 Not Found
Content-Type: text/html

<meta http-equiv="YADIS_HEADER" content="URL_BASE/xrds">
<title>Joe Schmoe's Homepage</title>

Joe Schmoe's Homepage

Blah blah blah blah blah blah blah


code:
found

<meta http-equiv="X-XRDS-Location" content="found">

found

<meta http-equiv="X-XRDS-Location" content="found" />

found

<meta http-equiv="X-XRDS-Location" content="found"/>

found

<meta http-equiv="X-XRDS-Location" content="found">

found

</porky><meta http-equiv="X-XRDS-Location" content="found">

found

<meta http-equiv="x-xrds-location" content="found">

found

<meta http-equiv="X-XRDS-Location" content="found">

found

<META http-equiv="X-XRDS-Location" content="found">

EOF


code:
<?xml version="1.0" encoding="UTF-8"?>
<xrds:XRDS
    xmlns:xrds="xri://$xrds"
    xmlns:openid="http://openid.net/xmlns/1.0"
    xmlns:typekey="http://typekey.com/xmlns/1.0"
    xmlns="xri://$xrd*($v*2.0)">
  <XRD>

    <Service priority="0">
      <Type>http://openid.net/signon/1.0</Type>
      <URI>http://www.myopenid.com/server</URI>
      <openid:Delegate>http://josh.myopenid.com/</openid:Delegate>
    </Service>

    <Service priority="20">
      <Type>http://lid.netmesh.org/sso/2.0b5</Type>
      <Type>http://lid.netmesh.org/2.0b5</Type>
      <URI>http://mylid.net/josh</URI>
    </Service>

    <Service priority="10">
      <Type>http://openid.net/signon/1.0</Type>
      <URI>http://www.livejournal.com/openid/server.bml</URI>
      <openid:Delegate>http://www.livejournal.com/users/nedthealpaca/</openid:Delegate>
    </Service>

    <Service priority="15">
      <Type>http://typekey.com/services/1.0</Type>
      <typekey:MemberName>joshhoyt</typekey:MemberName>
    </Service>

    <Service priority="5">
      <Type>http://openid.net/signon/1.0</Type>
      <URI>http://www.schtuff.com/openid</URI>
      <openid:Delegate>http://users.schtuff.com/josh</openid:Delegate>
    </Service>

  </XRD>
</xrds:XRDS>


code:
<?xml version="1.0" encoding="UTF-8"?>
<xrds:XRDS
    xmlns:xrds="xri://$xrds"
    xmlns:openid="http://openid.net/xmlns/1.0"
    xmlns="xri://$xrd*($v*2.0)">
  <XRD>

    <Service>
      <Type>http://openid.net/signon/1.0</Type>
      <URI>http://no.priority/</URI>
      <URI priority="1">http://one.priority/</URI>
      <URI priority="0">http://zero.priority/</URI>
    </Service>

  </XRD>
</xrds:XRDS>


code:
<?php

/**
 * A driver for the PHP OpenID unit tests.
 *
 * PHP versions 4 and 5
 *
 * LICENSE: See the COPYING file included in this distribution.
 *
 * @package OpenID
 * @author JanRain, Inc. <openid@janrain.com>
 * @copyright 2005-2008 Janrain, Inc.
 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache
 */

require_once 'PHPUnit/Framework.php';
//require_once 'PHPUnit/GUI/HTML.php';

error_reporting(E_ALL | E_STRICT);

global $__test_errors;
$__test_errors = array();

function __handler($code, $message)
{
    global $__test_errors;

    if ($code == E_USER_WARNING) {
        $__test_errors[] = $message;
    }
}

function __raiseError($message)
{
    set_error_handler('__handler');
    trigger_error($message, E_USER_WARNING);
    restore_error_handler();
}

function __getError()
{
    global $__test_errors;
    if ($__test_errors) {
        return array_pop($__test_errors);
    }
    return null;
}

/**
 * Load the tests that are defined in the named modules.
 *
 * If you have Tests/Foo.php which defines a test class called
 * Tests_Foo, the call would look like:
 *
 * loadTests('Tests/', array('Foo'))
 *
 * @param string $test_dir The root of the test hierarchy. Must end
 * with a /
 *
 * @param array $test_names The names of the modules in which the
 * tests are defined. This should not include the root of the test
 * hierarchy.
 */
function loadTests($test_dir, $test_names)
{
    global $_tests;
    $suites = array();

    foreach ($test_names as $filename) {
        $filename = $test_dir . $filename . '.php';

        if (!global_require_once($filename)) {
            continue;
        }

        $class_name = str_replace('/', '_', $filename);
        $class_name = basename($class_name, '.php');

        $suites[] = makeSuite($class_name);
    }

    return $suites;
}

function makeSuite($class_name) {
    $test = new $class_name($class_name);

    if (is_a($test, 'PHPUnit_Framework_TestCase')) {
        $s = new PHPUnit_Framework_TestSuite();
        $s->setName($class_name);
        $s->addTestSuite($class_name);
        $test = $s;
    }

    $tc_array_name = $class_name . '_other';
    if (array_key_exists($tc_array_name, $GLOBALS) &&
        is_array($GLOBALS[$tc_array_name])) {

        foreach ($GLOBALS[$tc_array_name] as $tc) {
            $test->addTestSuite(get_class($tc));
        }
    }

    return $test;
}

function global_require_once($name)
{
    $f = include_once $name;
    if (!$f) {
        print("global require once skipping $name\n");
        return false;
    }
    foreach (get_defined_vars() as $k => $v) {
        if (!in_array($k, array('name', 'GLOBALS'))) {
            $GLOBALS[$k] = $v;
        }
    }
    return true;
}

$_tests = array(
                array(
                      'dir' => 'Tests/Auth/OpenID/',
                      'files' => array(
                                       'Association',
                                       'AssociationResponse',
                                       'AuthRequest',
                                       'AX',
                                       'BigMath',
                                       'Consumer',
                                       'CryptUtil',
                                       'DiffieHellman',
                                       'Discover_OpenID',
                                       'Extension',
                                       'HMAC',
                                       'KVForm',
                                       'Message',
                                       'Negotiation',
                                       'Nonce',
                                       'OpenID_Yadis',
                                       'PAPE',
                                       'Parse',
                                       'RPVerify',
                                       'Server',
                                       'SReg',
                                       'StoreTest',
                                       'TrustRoot',
                                       'URINorm',
                                       'Util',
                                       'VerifyDisco'),
                      ),
                array(
                      'dir' => 'Tests/Auth/Yadis/',
                      'files' => array(
                                       'ParseHTML',
                                       'XRDS',
                                       'Yadis',
                                       'Discover_Yadis',
                                       'XRI'
                                       )
                      )
                );

function selectTests($package, $names)
{
    global $_tests;
    $lnames = array_map('strtolower', $names);
    $include = array();
    $exclude = array();
    foreach ($package['files'] as $t) {
        $l = strtolower($t);
        if (in_array($l, $lnames)) {
            $include[] = $t;
        }

        if (in_array("/$l", $lnames)) {
            $exclude[] = $t;
        }
    }

    return array_diff($include, $exclude);
}

// Load OpenID library tests
function loadSuite($names=null)
{
    global $_tests;
    $result = array();
    foreach ($_tests as $package) {
        if (!$names) {
            $selected = $package['files'];
        } else {
            $selected = selectTests($package, $names);
        }
        $result = array_merge($result, loadTests($package['dir'], $selected));
    }

    return $result;
}


code:
<?php

/**
 * Add a directory to the include path
 *
 * @param dir: The directory to add to the path
 * @param at_start: If true, place this directory at the beginning of
 * the include path. Otherwise, place it at the end.
 */
function includeAdd($dir, $at_start=false)
{
    $path = ini_get('include_path');
    if (strlen($path)) {
        $newpath = $at_start ? "$dir:$path" : "$path:$dir";
    } else {
        $newpath = $dir;
    }

    ini_set('include_path', $newpath);
}

/**
 * Return the parent directory of this module.
 */
function getParent()
{
    return dirname(dirname(realpath(__FILE__)));
}

?>


code:
#!/usr/bin/env perl -w

use strict;

my $filename = $ARGV[0];

if (!$filename) {
    print "Usage: modified_otb.pl <filename>\n";
    exit(1);
}

my @results = ();
my $line_num = 0;
my ($NONE, $BRACE, $PAREN) = (0, 1, 2);
my $looking_for = $NONE;
my $last_func_name = "";

open(HANDLE, "<", $filename) or die "Cannot open $filename\n";

# Read the file and track the lines with length > $max_length.
while (<HANDLE>) {
    $line_num++;
    # Subtract one because the newline doesn't count toward the
    # length.
    chomp;

    if (!$looking_for &&
        ($_ =~ /^\s*function/) &&
        ($_ =~ /\{/)) {
        # Done (bad): we found a function whose opening line ends with
        # a brace, which goes against the PEAR coding guidelines.

        ($last_func_name) = $_ =~ /function\s*(.*)\(/;

        push @results, "'$last_func_name' prototype ends with opening ".
            "brace, line $line_num";
    } elsif (!$looking_for &&
               ($_ =~ /^\s*function/) &&
               ($_ !~ /\)/)) {
        ($last_func_name) = $_ =~ /function\s*(.*)\(/;
        $looking_for = $PAREN;
    } elsif (($looking_for == $PAREN) &&
               ($_ =~ /\)/) &&
               ($_ =~ /\{/)) {
        # Done (bad): function prototype and brace are on the same
        # line.
        push @results, "'$last_func_name' prototype ends with with ".
            "opening brace, line $line_num";
        $looking_for = $NONE;
    } elsif (($looking_for == $PAREN) &&
               ($_ =~ /\)/) &&
               ($_ !~ /\{/)) {
        $looking_for = $BRACE;
    } elsif (!$looking_for &&
               ($_ =~ /^\s*function/) &&
               ($_ =~ /\)/) &&
               ($_ !~ /\{/)) {
        ($last_func_name) = $_ =~ /function\s*(.*)\(/;
        $looking_for = $BRACE;
    } elsif (($looking_for == $BRACE) &&
               ($_ eq "{")) {
        $looking_for = $NONE;
        # Done (good): the brace was found on the line after the
        # function prototype.
    } else {
        # We got here because we got a line that we're not interested
        # in.
        $looking_for = $NONE;
    }
}

# If any long lines were found, notify and exit(1); otherwise,
# exit(0).
if (@results) {
    foreach my $result (@results) {
        print "$filename: $result\n";
    }
    exit(1);
} else {
    exit(0);
}


code:
#!/usr/bin/env php
<?php
require_once $argv[1];
?>


code:
#!/usr/bin/env bash
./admin/findphp | xargs -L 1 ./admin/checkimport


code:
#!/usr/bin/env bash
#set -e

bad_files=$(./admin/findphp | xargs -L 1 /usr/bin/env perl admin/docblocks.pl)

if [ "$bad_files" ]
    then
    cat <<EOF 1>&2
These files do not start with docblocks:

$bad_files

EOF
    exit 1
fi


code:
#!/usr/bin/env perl -w

use strict;

my $filename = $ARGV[0];

if (!$filename) {
    print "Usage: docblocks.pl <filename>\n";
    exit(1);
}

my %allowed = ("" => 1,
               "<?php" => 1);

open(HANDLE, "<", $filename) or die "Cannot open $filename\n";

while (<HANDLE>) {
    chomp;

    if ($_ =~ /\/\*\*/) {
        exit(0);
    } elsif (!$allowed{$_}) {
        print $filename."\n";
        exit(1);
    }
}


code:
#!/usr/bin/env bash

find Auth Tests \
    -name _darcs -prune -o \
    \( -type f \
    -a -name \*.php \
    -a ! -name .\* \
    \)


code:
#!/usr/bin/env bash
# Find all PHP modules that are likely to have global variables
set -e

./admin/findphp | xargs grep '^\$'


code:
#!/usr/bin/env bash

find Auth Tests \
    -name _darcs -prune -o \
    \( -type f \
    -a -name \*.php \
    -a ! -name .\* \
    \) | grep -v Tests

path: vendor/openid/php-openid/admin/findphp


code:
#!/usr/bin/env bash
cat <<EOF | xargs chmod +x
admin/checkimport
admin/checkimports
admin/docblocks
admin/findphp
admin/findglobals
admin/fixperms
admin/makedoc.sh
admin/mathlib
admin/prepare-release
admin/runtests
admin/findallphp
admin/syntaxcheck
EOF

path: vendor/openid/php-openid/admin/fixperms


code:
"""
Fetch the current TLD list from the IANA Web site, parse it, and print
an expression suitable for direct insertion into each library's trust
root validation module

Usage:
  python gettlds.py (php|python|ruby)

Then cut-n-paste.
"""

import urllib2

import sys

langs = {
    'php': (r"'/\.(",
            "'", "|", "|' .",
            r")\.?$/'"),
    'python': ("['",
               "'", "', '", "',",
               "']"),
    'ruby': ("%w'",
             "", " ", "",
             "'"),
    }

lang = sys.argv[1]
prefix, line_prefix, separator, line_suffix, suffix = langs[lang]

f = urllib2.urlopen('http://data.iana.org/TLD/tlds-alpha-by-domain.txt')
tlds = []
output_line = ""
for input_line in f:
    if input_line.startswith('#'):
        continue

    tld = input_line.strip().lower()
    new_output_line = output_line + prefix + tld
    if len(new_output_line) > 60:
        print output_line + line_suffix
        output_line = line_prefix + tld
    else:
        output_line = new_output_line
    prefix = separator

print output_line + suffix


code:
#!/usr/bin/env perl -w

use strict;

my $filename = $ARGV[0];

if (!$filename) {
    print "Usage: longlines.pl <filename> [length]\n";
    exit(1);
}

# Set a default maximum line length.
my $max_length = $ARGV[1] || 80;

my @lines = ();
my $line_num = 0;

open(HANDLE, "<", $filename) or die "Cannot open $filename\n";

# Read the file and track the lines with length > $max_length.
while (<HANDLE>) {
    $line_num++;
    # Subtract one because the newline doesn't count toward the
    # length.
    if (length($_) - 1 > $max_length) {
        push @lines, $line_num;
    }
}

# If more than five long lines were found, truncate to five and
# indicate that others were present, too.
if (@lines > 5) {
    @lines = @lines[0..4];
    push @lines, "and others";
}

# If any long lines were found, notify and exit(1); otherwise,
# exit(0).
if (@lines) {
    print $filename." (line".((@lines > 1) ? "s" : "")." ".
        join(", ", @lines)." exceed".((@lines == 1) ? "s" : "").
        " length $max_length)\n";
    exit(1);
} else {
    exit(0);
}


code:
#!/bin/sh
set -v
phpdoc -p on -t doc -d Auth,admin/tutorials -ti "JanRain OpenID Library" \
    --ignore \*~,BigMath.php,Discover.php,CryptUtil.php,DiffieHellman.php,HMACSHA1.php,KVForm.php,Parse.php,TrustRoot.php,HTTPFetcher.php,ParanoidHTTPFetcher.php,PlainHTTPFetcher.php,ParseHTML.php,URINorm.php,XRI.php,XRIRes.php,Misc.php \
    -dn "OpenID" -o "HTML:frames:phphtmllib"


code:
#!/usr/bin/env php
<?php

require_once 'adminutil.php';
includeAdd(getParent());

require_once 'Auth/OpenID/CryptUtil.php';

$lib =& Auth_OpenID_MathLibrary::getLibWrapper();

if ($lib === null) {
    fwrite(STDERR, 'No math library present\n');
    exit(1);
} else {
    print $lib->type;
}

?>

path: vendor/openid/php-openid/admin/mathlib


code:
#!/usr/bin/env bash
set -e

./admin/findphp | xargs -L 1 /usr/bin/env perl admin/brace_style.pl


code:
#!/usr/bin/env bash

bad=$(./admin/findphp | xargs egrep -n "^[^\'\"]*\b(TRUE|FALSE|NULL)\b")

if [ ! -z "$bad" ]
    then
    cat <<EOF 1>&2
These files contain wrongly capitalized constants:

$bad

EOF
    exit 1
fi


code:
#!/usr/bin/env bash

files_with_long_lines=$(./admin/findphp |
            xargs -L 1 -I FILENAME /usr/bin/env perl admin/longlines.pl FILENAME 80)

if [ "$files_with_long_lines" ]
    then
    cat <<EOF 1>&2
Found lines > 80 characters in:

$files_with_long_lines
EOF
    exit 1
fi


code:
#!/usr/bin/env bash
#
# Look in the local directory for PHP files that have tabs in them. If
# there are files with tabs, print the list of files and exit with
# non-zero status.

tabs=$(./admin/findphp | xargs egrep -n '	' | sort)

if [ ! -z "$tabs" ]
    then
    cat <<EOF 1>&2
Found tabs in:
$tabs
EOF
    exit 1
fi

path: vendor/openid/php-openid/admin/notabs


code:
#!/usr/bin/env bash

bad_files=$(./admin/findphp |
      xargs -L 1 grep -H -m 1 "<?php" -c |
      grep ":0" |
      awk -F: '{ print $1 }')

if [ "$bad_files" ]
    then
    cat <<EOF 1>&2
These PHP files do NOT begin with <?php :

$bad_files

EOF
    exit 1
fi


code:
<?php

function fail1() {
}

function pass1()
{
}

function fail2(
   ) {

}

function pass2(
   )
{
}

?>


code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<package version="1.0">
 <name>%(package_name)s</name>
 <summary>%(package_summary)s</summary>
 <description>
 %(package_description)s
 </description>
 <license>%(license_name)s</license>
 %(maintainers)s
 <release>
  <version>%(version)s</version>
  <date>%(date)s</date>
  <state>%(release_stability)s</state>
  <notes>
  <![CDATA[
  %(release_notes)s
  ]]>
  </notes>
  %(contents_version_1)s
 </release>
 <deps>
  <dep type="php" rel="ge" version="4.3.0" />
 </deps>
</package>


code:
<?xml version="1.0"?>
<package version="2.0" xmlns="http://pear.php.net/dtd/package-2.0"
    xmlns:tasks="http://pear.php.net/dtd/tasks-1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
http://pear.php.net/dtd/tasks-1.0.xsd
http://pear.php.net/dtd/package-2.0
http://pear.php.net/dtd/package-2.0.xsd">
 <name>%(package_name)s</name>
 <uri>%(uri)s</uri>
 <summary>%(package_summary)s</summary>
 <description>
   %(package_description)s
 </description>
 %(leads)s
 <date>%(date)s</date>
 <version>
   <release>%(version)s</release>
   <api>%(version)s</api>
 </version>
 <stability>
   <release>%(release_stability)s</release>
   <api>%(release_stability)s</api>
 </stability>
 <license uri="%(license_uri)s">%(license_name)s</license>
 <notes>
 <![CDATA[
 %(release_notes)s
 ]]>
 </notes>
 <contents>
 %(contents)s
 </contents>
 <dependencies>
   <required>
     <php>
       <min>4.3.0</min>
     </php>
     <pearinstaller>
       <min>1.4.5</min>
     </pearinstaller>
   </required>
   <optional>
     <package>
       <name>PHPUnit</name>
       <channel>pear.php.net</channel>
       <min>1.1.1</min>
     </package>
     <package>
       <name>PEAR_DB</name>
       <channel>pear.php.net</channel>
       <min>1.80</min>
     </package>
     <extension>
       <name>pgsql</name>
     </extension>
     <extension>
       <name>mysql</name>
     </extension>
     <extension>
       <name>sqlite</name>
     </extension>
     <extension>
       <name>bcmath</name>
     </extension>
     <extension>
       <name>gmp</name>
     </extension>
   </optional>
 </dependencies>
 <!-- There really isn't much we should put in the phprelease tag,
 although we should probably make a windows-specific release tag. -->
 <phprelease/>
</package>


code:
#!/usr/bin/python

import os
import os.path

def makeMaintainerXML(leads):
    maintainer_template = """
  <maintainer>
   <user>%(user)s</user>
   <name>%(name)s</name>
   <email>%(email)s</email>
   <role>lead</role>
  </maintainer>
  """

    return "<maintainers>" + \
           "".join([maintainer_template % l for l in leads]) + \
           "</maintainers>"

def makeLeadXML(leads):
    lead_template = """
<lead>
  <name>%(name)s</name>
  <user>%(user)s</user>
  <email>%(email)s</email>
  <active>%(active)s</active>
</lead>
    """

    return "".join([lead_template % l for l in leads])

INDENT_STRING = "  "

def buildContentsXMLFordir(dir_or_file, roles, depth=0, dir_role=None,
                           all_files=False):
    """
    Returns a list of strings, each of which is either a <file> XML
    element for the given file or a <dir> element which contains other
    <file> elements.
    """

    try:
        entries = os.listdir(dir_or_file)
        dir_role_s = ''
        if dir_role:
            dir_role_s = ' role="%s"' % (dir_role)
        lines = ['%s<dir name="%s"%s>' % (INDENT_STRING * depth,
                                          os.path.basename(dir_or_file),
                                          dir_role_s)]

        for entry in entries:
            lines += buildContentsXMLFordir(dir_or_file + os.sep + entry, roles,
                                            depth + 1, dir_role, all_files)

        lines.append('%s</dir>' % (INDENT_STRING * depth))

        return lines
    except OSError:
        try:
            extension = dir_or_file.split(".")[-1]
        except:
            if not all_files:
                return []

        if all_files and dir_role:
            return ['%s<file name="%s" role="%s" />' %
                    (INDENT_STRING * depth, os.path.basename(dir_or_file), dir_role)]
        elif extension in roles: # Ends in an extension we care about
            return ['%s<file name="%s" role="%s" />' %
                    (INDENT_STRING * depth, os.path.basename(dir_or_file),
                     roles[extension])]
        else:
            return []

def buildContentsXML(roles, *dirs):
    lines = []

    for directory in dirs:
        lines.append("\n".join(buildContentsXMLFordir(directory, roles, 1)))

    return "\n".join(lines)

def buildDocsXML(*dirs):
    lines = []

    for directory in dirs:
        lines.append("\n".join(buildContentsXMLFordir(directory, {}, 1, 'doc',
                                                      all_files=True)))

    return "\n".join(lines)

if __name__ == "__main__":
    def usage(progname):
        print "Usage: %s <package version> <xml template file> <release notes file>" % (progname)

    import sys
    import time

    try:
        import xmlconfig
    except:
        print "Could not import XML configuration module xmlconfig"
        sys.exit(1)

    # Expect sys.argv[2] to be the name of the XML file template to
    # use for processing.
    try:
        template_f = open(sys.argv[2], 'r')
    except Exception, e:
        usage(sys.argv[0])
        print "Could not open template file:", str(e)
        sys.exit(1)

    # Expect sys.argv[1] to be the version number to include in the
    # package.xml file.
    try:
        version = sys.argv[1]
    except:
        usage(sys.argv[0])
        sys.exit(2)

    # Expect sys.argv[3] to be the name of the release notes file.
    try:
        release_file = sys.argv[3]
        release_file_h = open(release_file, 'r')
        release_notes = release_file_h.read().strip()
        release_file_h.close()
    except Exception, e:
        usage(sys.argv[0])
        print str(e)
        sys.exit(3)

    data = xmlconfig.__dict__.copy()

    contentsXml = buildContentsXML({'php': 'php'}, *xmlconfig.contents_dirs)
    docsXml = buildDocsXML(*xmlconfig.docs_dirs)

    contents = '<dir name="/">\n' + contentsXml + \
               "\n" + docsXml + '\n  </dir>'

    contents_v1 = '<filelist><dir name="/" baseinstalldir="Auth">\n' + contentsXml + \
                  "\n" + docsXml + '\n  </dir></filelist>'

    data['contents'] = contents
    data['contents_version_1'] = contents_v1
    data['leads'] = makeLeadXML(xmlconfig.leads)
    data['maintainers'] = makeMaintainerXML(xmlconfig.leads)
    data['date'] = time.strftime("%Y-%m-%d")
    data['version'] = version
    data['uri'] = "%s%s-%s.tgz" % (data['package_base_uri'], data['package_name'],
                                   version)
    data['release_notes'] = release_notes

    template_data = template_f.read()
    print template_data % data


code:
#!/usr/bin/env python

"""This script searches files for functions that are just aliases in
PHP source code. This is not 100% reliable, so it should not be
automated, but it's useful to run once in a while to make sure that
all of the matches it finds are not really legitimate aliases.

Usage:

  parse_aliases.py <name of alias file> [PHP source code filename]...
"""

import sys

# Fetch this URL to get the file that is parsed into the aliases list
alias_url = 'http://www.zend.com/phpfunc/all_aliases.php'

header_tok = '';
footer_tok = '';

# Example line of the table that we parse:
# '
bzclose	php-src/ext/bz2/bz2.c	fclose
'

import re

line_re = re.compile(r'''
\A

]+">

"]+\.php">([^<>]+)

]+">[^<>]+

(?:
    ]+\.php">
    ( [^<>]+ )

|   ( [^<>]+ )
)

\Z
''', re.VERBOSE)

def parseString(s):
    _, rest = s.split(header_tok, 1)
    body, _ = rest.split(footer_tok, 1)

    lines = body.split('\n')
    assert [s.strip() for s in lines[-2:]] == ['
', '']
    assert lines[0].strip().startswith('<table')
    del lines[0], lines[-2:]
    aliases = {}
    for line in lines:
        mo = line_re.match(line)
        assert mo, line
        alias, master1, master2 = mo.groups()
        if master1:
            master = master1
        else:
            assert master2
            master = master2
        aliases[alias] = master

    return aliases

def parseFile(f):
    return parseString(f.read())

def parseFileName(fn):
    return parseFile(file(fn, 'r'))

def parseURL(url):
    return parseFile(urllib2.urlopen(url))

def getAliasRE(aliases):
    return re.compile(r'(->|\$|)\s*\b(%s)\b' % ('|'.join(aliases.keys())))

def checkAliasesFile(alias_re, f):
    found = []
    line_num = 1
    for line in f:
        for mo in alias_re.finditer(line):
            if mo.group(1):
                continue
            alias = mo.group(2)
            found.append((line_num, alias))
        line_num += 1
    return found

def checkAliases(alias_re, filename):
    return checkAliasesFile(alias_re, file(filename, 'r'))

def checkAliasesFiles(alias_re, filenames):
    found = []
    for filename in filenames:
        file_found = checkAliases(alias_re, filename)
        found.extend([(filename, n, a) for (n, a) in file_found])
    return found

def dumpResults(aliases, found, out=sys.stdout):
    for filename, n, a in found:
        print >>out, "%s:%d %s -> %s" % (filename, n, a, aliases[a])

def main(alias_file, *filenames):
    aliases = parseFileName(alias_file)
    alias_re = getAliasRE(aliases)
    found = checkAliasesFiles(alias_re, filenames)
    dumpResults(aliases, found)
    return found

if __name__ == '__main__':
    found = main(*sys.argv[1:])
    if found:
        sys.exit(1)


code:
#!/usr/bin/env bash
#
# Prepare this repository for release

REPO_ROOT=$(dirname $(dirname $(readlink --canonicalize "$0")))
cd "$REPO_ROOT"

bash ./admin/fixperms

./admin/makedoc.sh

darcs changes --from-tag=. --summary > CHANGELOG


code:
#!/usr/bin/env bash

# Get the absolute path containing this script
cd $(dirname "$0")
HERE=$PWD

test_import () {
    ./admin/checkimports
}

test_syntax () {
    ./admin/syntaxcheck
}

test_tabs () {
    /usr/bin/env bash "$HERE/notabs"
}

test_longlines () {
    /usr/bin/env bash "$HERE/nolonglines"
}

test_nobadbraces () {
    /usr/bin/env bash "$HERE/nobadbraces"
}

test_nobadcase () {
    /usr/bin/env bash "$HERE/nobadcase"
}

test_opentag () {
    /usr/bin/env bash "$HERE/open_tag"
}

test_docblocks () {
    /usr/bin/env bash "$HERE/docblocks"
}

test_php () {
    if uname -a | grep -i cygwin >/dev/null 2>/dev/null ; then
        /usr/bin/env php "$(dirname "$0")/texttest.php" --insecure-rand \
            $TEXTTEST_ARGS
    else
        /usr/bin/env php "$HERE/texttest.php" $TEXTTEST_ARGS
    fi
}

tests="syntax tabs longlines nobadbraces nobadcase opentag docblocks php import"

failures=

# Run in repository root (parent of this directory)
cd $(dirname "$HERE")

chmod +x ./admin/fixperms
./admin/fixperms

for test_name in $tests
  do
  echo "Running test $test_name" 1>&2
  if ! eval "test_$test_name"
      then
      failures="$failures $test_name"
  fi
done

if [ ! -z "$failures" ]
    then
    echo "Failures in: $failures" 1>&2
    exit 1
fi

path: vendor/openid/php-openid/admin/runtests


code:
#!/usr/bin/env bash

for file in `./admin/findallphp`
  do php -l $file
done


code:
<?php

require_once 'Tests/TestDriver.php';
require_once 'PHPUnit/Framework.php';
require_once 'Console/Getopt.php';

class TextTestResult extends PHPUnit_Framework_TestResult {
  function addError(&$test, &$t, $time=0)
    {
      parent::addError($test, $t, $time);
        echo "E";
    }

    function addFailure(&$test, &$t, $time=0)
    {
        parent::addFailure($test, $t, $time);
        echo "F";
    }

    function addPassedTest(&$test)
    {
        parent::addPassedTest($test);
        echo ".";
    }

    function dumpBadResults()
    {
        foreach ($this->failures() as $failure) {
            echo $failure->toString();
        }

        foreach ($this->errors() as $failure) {
            echo $failure->toString();
        }
    }
}

function microtime_float()
{
   list($usec, $sec) = explode(" ", microtime());
   return ((float)$usec + (float)$sec);
}

$longopts = array('no-math',
                  'buggy-gmp',
                  'no-curl',
                  'math-lib=',
                  'insecure-rand',
                  'thorough',
                  'extra-tests=');

$con  = new Console_Getopt;
$args = $con->readPHPArgv();
array_shift($args);
$options = $con->getopt2($args, "", $longopts);

if (PEAR::isError($options)) {
    print $options->message . "\n";
    exit(1);
}

list($flags, $tests_to_run) = $options;

$math_type = array();
$extra_test_modules = array();
$thorough = false;
foreach ($flags as $flag) {
    list($option, $value) = $flag;
    switch ($option) {
    case '--insecure-rand':
        define('Auth_OpenID_RAND_SOURCE', null);
        break;
    case '--no-math':
        define('Auth_OpenID_NO_MATH_SUPPORT', true);
        break;
    case '--buggy-gmp':
        define('Auth_OpenID_BUGGY_GMP', true);
        break;
    case '--no-curl':
        define('Auth_Yadis_CURL_OVERRIDE', true);
        break;
    case '--thorough':
        define('Tests_Auth_OpenID_thorough', true);
        break;
    case '--extra-tests':
        $extra_test_modules[] = $value;
        break;
    default:
        print "Unrecognized option: $option\n";
        exit(1);
    }
}

// ******** Math library selection ***********
// XXX FIXME
//     case '--math-lib':
//         $math_type[] = $value;
//         break;
if ($math_type && false) {
    if (defined('Auth_OpenID_NO_MATH_SUPPORT')) {
        print "--no-math and --math-lib are mutually exclusive\n";
        exit(1);
    }
    require_once('Auth/OpenID/BigMath.php');
    $new_extensions = array();
    foreach ($math_type as $lib) {
        $found = false;
        foreach (Auth_OpenID_math_extensions() as $ext) {
            if ($ext['extension'] == $lib) {
                $new_extensions[] = $ext;
                $found = true;
                break;
            }
        }

        if (!$found) {
            print "Unknown math library specified: $lib\n";
            exit(1);
        }
    }
    $_Auth_OpenID_math_extensions = $new_extensions;
}

// ******** End math library selection **********

$suites = loadSuite($tests_to_run);

// ******** Load additional test suites ********
foreach ($extra_test_modules as $filename) {
    if (!global_require_once($filename)) {
        continue;
    }
    $module_name = basename($filename, '.php');
    $class_name = "Tests_Auth_OpenID_${module_name}_Test";
    $suites[] = makeSuite($class_name);
}

$totals = array(
    'run' => 0,
    'error' => 0,
    'failure' => 0,
    'time' => 0
    );

foreach ($suites as $suite) {
    $name = $suite->getName();
    echo "==========================================
Test suite: $name
------------------------------------------
";

    $result = new TextTestResult();
    $before = microtime_float();
    $suite->run($result);
    $after = microtime_float();

    $run = $result->count();
    $error = $result->errorCount();
    $failure = $result->failureCount();
    $delta = $after - $before;
    $totals['run'] += $run;
    $totals['error'] += $error;
    $totals['failure'] += $failure;
    $totals['time'] += $delta;
    $human_delta = round($delta, 3);
    echo "\nRan $run tests in $human_delta seconds";
    if ($error || $failure) {
        echo " with $error errors, $failure failures";
    }
    echo "
==========================================

";

    $failures = $result->failures();
    foreach($failures as $failure) {
        $test = $failure->failedTest();
        $testName = $test->getName();
        $exception = $failure->thrownException();
        echo "* Failure in $testName: $exception

";
    }
}

$before = microtime_float();
$run = $totals['run'];
$error = $totals['error'];
$failure = $totals['failure'];
$time = round($totals['time'], 3);
echo "Ran a total of $run tests in $time seconds with $error errors, $failure failures\n";
if ($totals['error'] || $totals['failure']) {
    exit(1);
}

?>


code:
<refentry id="{@id}">
 <refnamediv>
  <refname>PHP OpenID API</refname>

 </refnamediv>
 <refsynopsisdiv>
  <author>
   JanRain, Inc.
   <authorblurb>
    {@link mailto:openid@janrain.com openid@janrain.com}
   </authorblurb>
  </author>
 </refsynopsisdiv>

 <para>
 This is a complete implementation of the OpenID authentication
 protocol.  This package contains:

   <itemizedlist>
     <listitem>An OpenID server</listitem>
     <listitem>An OpenID consumer</listitem>
     <listitem>Stores for MySQL, PostgreSQL, SQLite, and filesystem-based OpenID data storage</listitem>
     <listitem>PHPUnit unit tests</listitem>
     <listitem>An example server and consumer</listitem>
   </itemizedlist>
 </para>

 <refsect1 id="{@id users}">
   <title>For Package Users</title>

   <para>
    To install this package, copy the <literal>Auth/</literal>
    directory in this package to a directory in your PHP include path.
    Alternatively, modify your PHP include path to include the
    directory that contains <literal>Auth/</literal>.  Any
    applications that need this package will then be able to use it.
   </para>

 </refsect1>

 <refsect1 id="{@id developers}">
   <title>For Developers</title>

   <para>

    See the server and consumer examples in the
    <literal>examples/</literal> directory of the package.  For
    details on how to run the examples, see
    <literal>examples/README</literal>.  If you want to create your
    own OpenID data storage class, please see the {@link Auth_OpenID_OpenIDStore}
     class.  For information on integrating OpenID relying party support into your site, see
    the class documentation for {@link Consumer.php}.

   </para>

 </refsect1>

 <refsect1 id="{@id references}">
  <title>References</title>
  <para>
   <itemizedlist>
    <listitem>
     {@link http://github.com/openid/php-openid PHP OpenID Library}
    </listitem>

    <listitem>
     {@link http://www.janrain.com JanRain, Inc.}
    </listitem>

    <listitem>
     {@link http://openid.net/developers/dev-mailing-lists/ OpenID Development Discussion Lists}
    </listitem>
   </itemizedlist>
  </para>
 </refsect1>

</refentry>


code:
<?php

require_once 'Tests/TestDriver.php';

$suites = loadSuite();

// Create and run the user interface
$gui = new PHPUnit_GUI_HTML();
$gui->addSuites($suites);
$gui->show();

?>


code:
"""
This is the package.xml data needed for the PHP OpenID PEAR
package.xml file.  Use the 'packagexml.py' program to generate a
package.xml file for a release of this library.
"""

# This is a list of dicts describing the project leads.  This will be
# used to generate <lead> XML elements.
leads = [
    {'name': 'Jonathan Daugherty',
     'user': 'cygnus',
     'email': 'cygnus@janrain.com',
     'active': 'yes'},
    {'name': 'Josh Hoyt',
     'user': 'jhoyt',
     'email': 'josh@janrain.com',
     'active': 'yes'}
    ]

# The package name.
package_name = 'Auth_OpenID'

# The package description.
package_description = 'An implementation of the OpenID single sign-on authentication protocol.'

# Package summary.
package_summary = 'PHP OpenID'

# License string.
license_name = 'Apache'

# License URI.
license_uri = 'http://www.apache.org/licenses/LICENSE-2.0'

# Director(ies) containing package source, relative to the admin/
# directory.  All .php files in these directories will be included in
# the <contents> element of the output XML and will be assigned the
# role 'php'.
contents_dirs = ['../Auth',]

# Director(ies) containing package documentation.  All files and
# subdirectories in these directories will be included in the
# <contents> element in the output XML and will be assigned the role
# 'doc'.
docs_dirs = ['../doc', '../examples']

# The HTTP package base URI.  This is the place on the web where the
# PEAR-installable tarballs will live, and this (plus the package
# tarball name) will be the URL that users pass to "pear install".
package_base_uri = 'http://www.openidenabled.com/resources/downloads/php-openid/pear/'

# The release stability.  Maybe this should be a commandline parameter
# since it might differ from release to release.
release_stability = 'stable'


openid/php-openid

description: OpenID library for PHP5

keywords: openid authentication yadis auth


code:
<?php

/**
 * Introduces the notion of an Attribute Provider that attests and signs
 * attributes
 * Uses OpenID Signed Assertions(Sxip draft) for attesting attributes
 * PHP versions 4 and 5
 *
 * LICENSE: See the COPYING file included in this distribution.
 *
 * @package OpenID
 * @author Santosh Subramanian <subrasan@cs.sunysb.edu>
 * @author Shishir Randive <srandive@cs.sunysb.edu>
 * Stony Brook University.
 *
 */
require_once 'Auth/OpenID/SAML.php';
/**
 * The Attribute_Provider class which signs the attribute,value pair
 * for a given openid.
 */
class Attribute_Provider
{
   private $public_key_certificate=null;
   private $private_key=null;
   private $authenticatedUser=null;
   private $notBefore=null;
   private $notOnOrAfter=null;
   private $rsadsa=null;
   private $acsURI=null;
   private $attribute=null;
   private $value=null;
   private $assertionTemplate=null;
   /**
    * Creates an Attribute_Provider object initialized with startup values.
    * @param string $public_key_certificate - The public key certificate
	of the signer.
    * @param string $private_key - The private key of the signer.
    * @param string $notBefore - Certificate validity time
    * @param string $notOnOrAfter - Certificate validity time
    * @param string $rsadsa - Choice of the algorithm (RSA/DSA)
    * @param string $acsURI - URI of the signer.
    * @param string $assertionTemplate - SAML template used for assertion
    */
   function Attribute_Provider($public_key_certificate,$private_key,$notBefore,$notOnOrAfter,$rsadsa,$acsURI,
                               $assertionTemplate)
   {
      $this->public_key_certificate=$public_key_certificate;
           $this->private_key=$private_key;
      $this->notBefore=$notBefore;
      $this->notOnOrAfter=$notOnOrAfter;
      $this->rsadsa=$rsadsa;
      $this->acsURI=$acsURI;
      $this->assertionTemplate=$assertionTemplate;
   }
   /**
    * Create the signed assertion.
    * @param string $openid - Openid of the entity being asserted.
    * @param string $attribute - The attribute name being asserted.
    * @param string $value - The attribute value being asserted.
    */
   function sign($openid,$attribute,$value)
   {
      $samlObj = new SAML();
      $responseXmlString = $samlObj->createSamlAssertion($openid,
                                                         $this->notBefore,
                                                         $this->notOnOrAfter,
                                                         $this->rsadsa,
                                                         $this->acsURI,
                                                         $attribute,
                                                         sha1($value),
                                                      $this->assertionTemplate);
      $signedAssertion=$samlObj->signAssertion($responseXmlString,
                                               $this->private_key,
                                               $this->public_key_certificate);
      return $signedAssertion;
   }
}
/**
 * The Attribute_Verifier class which verifies the signed assertion at the Relying party.
 */
class Attribute_Verifier
{
   /**
    * The certificate the Relying party trusts.
   */
   private $rootcert;
   /**
    * This function loads the public key certificate that the relying party trusts.
    * @param string $cert - Trusted public key certificate.
    */
   function load_trusted_root_cert($cert)
   {
      $this->rootcert=$cert;
   }
   /**
    * Verifies the certificate given the SAML document.
    * @param string - signed SAML assertion
    * return @boolean - true if verification is successful, false if unsuccessful.
   */
   function verify($responseXmlString)
   {
      $samlObj = new SAML();
      $ret = $samlObj->verifyAssertion($responseXmlString,$this->rootcert);
      return $ret;
   }
}

/**
 * This is a Store Request creating class at the Attribute Provider.
 */
class AP_OP_StoreRequest
{
   /**
    * Creates store request and adds it as an extension to AuthRequest object
      passed to it.
    * @param &Auth_OpenID_AuthRequest &$auth_request - A reference to
      the AuthRequest object.
    * @param &Attribute_Provider &$attributeProvider - A reference to the
      Attribute Provider object.
    * @param string $attribute - The attribute name being asserted.
    * @param string $value - The attribute value being asserted.
    * @param string $openid - Openid of the entity being asserted.
    * @return &Auth_OpenID_AuthRequest - Auth_OpenID_AuthRequest object
                                   returned with StoreRequest extension.
   */
   static function createStoreRequest(&$auth_request,&$attributeProvider,
                                               $attribute,$value,$openid)
   {
      if(!$auth_request){
         return null;
      }
      $signedAssertion=$attributeProvider->sign($openid,$attribute,$value);
      $store_request=new Auth_OpenID_AX_StoreRequest;
      $store_request->addValue($attribute,base64_encode($value));
      $store_request->addValue($attribute.'/signature',
                                           base64_encode($signedAssertion));
      if($store_request) {
         $auth_request->addExtension($store_request);
         return $auth_request;
      }
   }
}

/*
 *This is implemented at the RP Takes care of getting the attribute from the
 *AX_Fetch_Response object and verifying it.
 */
class RP_OP_Verify
{
   /**
    * Verifies a given signed assertion.
    * @param &Attribute_Verifier &$attributeVerifier - An instance of the class
                                            passed for the verification.
    * @param Auth_OpenID_Response - Response object for extraction.
    * @return boolean - true if successful, false if verification fails.
    */
   function verifyAssertion(&$attributeVerifier,$response)
   {
      $ax_resp=Auth_OpenID_AX_FetchResponse::fromSuccessResponse($response);
      if($ax_resp instanceof Auth_OpenID_AX_FetchResponse){
         $ax_args=$ax_resp->getExtensionArgs();
         if($ax_args) {
            $value=base64_decode($ax_args['value.ext1.1']);
            if($attributeVerifier->verify($value)){
               return base64_decode($ax_args['value.ext0.1']);
            } else {
               return null;
            }
         } else {
            return null;
         }
      } else {
         return null;
      }
   }
}

?>


code:
<?php
/**
 ** PHP versions 4 and 5
 **
 ** LICENSE: See the COPYING file included in this distribution.
 **
 ** @package OpenID
 ** @author Santosh Subramanian <subrasan@cs.sunysb.edu>
 ** @author Shishir Randive <srandive@cs.sunysb.edu>
 ** Stony Brook University.
 ** largely derived from
 **
 * Copyright (C) 2007 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 **/

class SAML{
   private $assertionTemplate=null;
   /**
    * Returns a SAML response with various elements filled in.
    * @param string $authenticatedUser The OpenId of the user
    * @param string $notBefore The ISO 8601 formatted date before which the
    response is invalid
    * @param string $notOnOrAfter The ISO 8601 formatted data after which the
    response is invalid
    * @param string $rsadsa 'rsa' if the response will be signed with RSA keys,
    'dsa' for DSA keys
    * @param string $requestID The ID of the request we're responding to
    * @param string $destination The ACS URL that the response is submitted to
    * @return string XML SAML response.
    */
   function createSamlAssertion($authenticatedUser, $notBefore, $notOnOrAfter, $rsadsa, $acsURI,$attribute,$value,$assertionTemplate)
   {
      $samlResponse = $assertionTemplate;
      $samlResponse = str_replace('USERNAME_STRING', $authenticatedUser, $samlResponse);
      $samlResponse = str_replace('RESPONSE_ID', $this->samlCreateId(), $samlResponse);
      $samlResponse = str_replace('ISSUE_INSTANT', $this->samlGetDateTime(time()), $samlResponse);
      $samlResponse = str_replace('NOT_BEFORE', $this->samlGetDateTime(strtotime($notBefore)), $samlResponse);
      $samlResponse = str_replace('NOT_ON_OR_AFTER', $this->samlGetDateTime(strtotime($notOnOrAfter)),$samlResponse);
      $samlResponse = str_replace('ASSERTION_ID',$this->samlCreateId(), $samlResponse);
      $samlResponse = str_replace('RSADSA', strtolower($rsadsa), $samlResponse);
      $samlResponse = str_replace('ISSUER_DOMAIN', $acsURI, $samlResponse);
      $samlResponse = str_replace('ATTRIBUTE_NAME', $attribute, $samlResponse);
      $samlResponse = str_replace('ATTRIBUTE_VALUE', $value, $samlResponse);
      return $samlResponse;
   }

   /**
    * Signs a SAML response with the given private key, and embeds the public key.
    * @param string $responseXmlString The unsigned Assertion which will be signed
    * @param string $priKey Private key to sign the certificate
    * @param string $cert Public key certificate of signee
    * @return string Signed Assertion
    */
   function signAssertion($responseXmlString,$privKey,$cert)
   {
      if (file_exists("/tmp/xml")) {
         $tempFileDir="/tmp/xml/";

      } else {
             mkdir("/tmp/xml",0777);
         $tempFileDir="/tmp/xml/";
      }
      $tempName = 'saml-response-' . $this->samlCreateId() . '.xml';
      $tempFileName=$tempFileDir.$tempName;
      while (file_exists($tempFileName))
         $tempFileName = 'saml-response-' . $this->samlCreateId() . '.xml';

      if (!$handle = fopen($tempFileName, 'w')) {
         return null;
      }
      if (fwrite($handle, $responseXmlString) === false) {
         return null;
      }
      fclose($handle);
      $cmd = 'xmlsec1 --sign --privkey-pem ' . $privKey .
         ',' . $cert . ' --output ' . $tempFileName .
         '.out ' . $tempFileName;
      exec($cmd, $resp);
      unlink($tempFileName);

      $xmlResult = @file_get_contents($tempFileName . '.out');
      if (!$xmlResult) {
         return null;
      } else {
         unlink($tempFileName . '.out');
         return $xmlResult;
      }
   }

   /**
    * Verify a saml response with the given public key.
    * @param string $responseXmlString Response to sign
    * @param string $rootcert trusted public key certificate
    * @return string Signed SAML response
    */
   function verifyAssertion($responseXmlString,$rootcert)
   {
      date_default_timezone_set("UTC");
      if (file_exists("/tmp/xml")) {
         $tempFileDir="/tmp/xml/";

      } else {
             mkdir("/tmp/xml",0777);
         $tempFileDir="/tmp/xml/";
      }

      $tempName = 'saml-response-' . $this->samlCreateId() . '.xml';
      $tempFileName=$tempFileDir.$tempName;
      while (file_exists($tempFileName))
         $tempFileName = 'saml-response-' . $this->samlCreateId() . '.xml';

      if (!$handle = fopen($tempFileName, 'w')) {
         return false;
      }

      if (fwrite($handle, $responseXmlString) === false) {
         return false;
      }

      $p=xml_parser_create();
      $result=xml_parse_into_struct($p,$responseXmlString,$vals,$index);
      xml_parser_free($p);
      $cert_info=$index["X509CERTIFICATE"];
      $conditions=$index["CONDITIONS"];
      foreach($cert_info as $key=>$value){
         file_put_contents($tempFileName.'.cert',$vals[$value]['value']);
      }
      $cert=$tempFileName.'.cert';
      $before=0;
      $after=0;
      foreach($conditions as $key=>$value){
         $before=$vals[$value]['attributes']['NOTBEFORE'];
         $after=$vals[$value]['attributes']['NOTONORAFTER'];
      }
      $before=$this->validSamlDateFormat($before);
      $after=$this->validSamlDateFormat($after);
      if(strtotime("now") < $before || strtotime("now") >= $after){
         unlink($tempFileName);
         unlink($cert);
         return false;
      }
      fclose($handle);
      $cmd = 'xmlsec1 --verify --pubkey-cert ' . $cert .'--trusted '.$rootcert. ' '.$tempFileName.'* 2>&1 1>/dev/null';
      exec($cmd,$resp);
      if(strcmp($resp[0],"FAIL") == 0){
         $value = false;
      }elseif(strcmp($resp[0],"ERROR") == 0){
         $value = false;
      }elseif(strcmp($resp[0],"OK") == 0){
         $value = TRUE;
      }
      unlink($tempFileName);
      unlink($cert);
      return $value;
   }

   /**
    * Creates a 40-character string containing 160-bits of pseudorandomness.
    * @return string Containing pseudorandomness of 160 bits
    */

   function samlCreateId()
   {
      $rndChars = 'abcdefghijklmnop';
      $rndId = '';
      for ($i = 0; $i < 40; $i++ ) {
         $rndId .= $rndChars[rand(0,strlen($rndChars)-1)];
      }
      return $rndId;
   }

   /**
    * Returns a unix timestamp in xsd:dateTime format.
    * @param timestamp int UNIX Timestamp to convert to xsd:dateTime
    * ISO 8601 format.
    * @return string
    */
   function samlGetDateTime($timestamp)
   {
      return gmdate('Y-m-d\TH:i:s\Z', $timestamp);
   }
   /**
    * Attempts to check whether a SAML date is valid.  Returns true or false.
    * @param string $samlDate
    * @return bool
    */

   function validSamlDateFormat($samlDate)
   {
      if ($samlDate == "") return false;
      $indexT = strpos($samlDate, 'T');
      $indexZ = strpos($samlDate, 'Z');
      if (($indexT != 10) || ($indexZ != 19)) {
         return false;
      }
      $dateString = substr($samlDate, 0, 10);
      $timeString = substr($samlDate, $indexT + 1, 8);
      list($year, $month, $day) = explode('-', $dateString);
      list($hour, $minute, $second) = explode(':', $timeString);
      $parsedDate = gmmktime($hour, $minute, $second, $month, $day, $year);
      if (($parsedDate === false) || ($parsedDate == -1)) return false;
      if (!checkdate($month, $day, $year)) return false;
      return $parsedDate;
   }

}
?>


code:
#!/usr/bin/env python
# SQL Store Upgrade Script
# for version 1.x to 2.0 of the OpenID library.
# Doesn't depend on the openid library, so you can run this python
# script to update databases for ruby or PHP as well.
#
# Testers note:
#
#   A SQLite3 db with the 1.2 schema exists in
#   openid/test/data/openid-1.2-consumer-sqlitestore.db if you want something
#   to try upgrading.
#
#   TODO:
#    * test data for mysql and postgresql.
#    * automated tests.

import os
import getpass
import sys
from optparse import OptionParser

def askForPassword():
    return getpass.getpass("DB Password: ")

def askForConfirmation(dbname,tablename):
    print """The table %s from the database %s will be dropped, and
    an empty table with the new nonce table schema will replace it."""%(
    tablename, dbname)
    return raw_input("Continue? ").lower().strip().startswith('y')

def doSQLiteUpgrade(db_conn, nonce_table_name='oid_nonces'):
    cur = db_conn.cursor()
    cur.execute('DROP TABLE %s'%nonce_table_name)
    sql = """
    CREATE TABLE %s (
        server_url VARCHAR,
        timestamp INTEGER,
        salt CHAR(40),
        UNIQUE(server_url, timestamp, salt)
    );
    """%nonce_table_name
    cur.execute(sql)
    cur.close()

def doMySQLUpgrade(db_conn, nonce_table_name='oid_nonces'):
    cur = db_conn.cursor()
    cur.execute('DROP TABLE %s'%nonce_table_name)
    sql = """
    CREATE TABLE %s (
        server_url BLOB,
        timestamp INTEGER,
        salt CHAR(40),
        PRIMARY KEY (server_url(255), timestamp, salt)
    )
    TYPE=InnoDB;
    """%nonce_table_name
    cur.execute(sql)
    cur.close()

def doPostgreSQLUpgrade(db_conn, nonce_table_name='oid_nonces'):
    cur = db_conn.cursor()
    cur.execute('DROP TABLE %s'%nonce_table_name)
    sql = """
    CREATE TABLE %s (
        server_url VARCHAR(2047),
        timestamp INTEGER,
        salt CHAR(40),
        PRIMARY KEY (server_url, timestamp, salt)
    );
    """%nonce_table_name
    cur.execute(sql)
    cur.close()
    db_conn.commit()

def main(argv=None):
    parser = OptionParser()
    parser.add_option("-u", "--user", dest="username",
                      default=os.environ.get('USER'),
                      help="User name to use to connect to the DB.  "
                      "Defaults to USER environment variable.")
    parser.add_option('-t', '--table', dest='tablename', default='oid_nonces',
                      help='The name of the nonce table to drop and recreate. '
                      ' Defaults to "oid_nonces", the default table name for '
                      'the openid stores.')
    parser.add_option('--mysql', dest='mysql_db_name',
                      help='Upgrade a table from this MySQL database.  '
                      'Requires username for database.')
    parser.add_option('--pg', '--postgresql', dest='postgres_db_name',
                      help='Upgrade a table from this PostgreSQL database.  '
                      'Requires username for database.')
    parser.add_option('--sqlite', dest='sqlite_db_name',
                      help='Upgrade a table from this SQLite database file.')
    parser.add_option('--host', dest='db_host',
                      default='localhost',
                      help='Host on which to find MySQL or PostgreSQL DB.')
    (options, args) = parser.parse_args(argv)

    db_conn = None

    if options.sqlite_db_name:
        try:
            from pysqlite2 import dbapi2 as sqlite
        except ImportError:
            print "You must have pysqlite2 installed in your PYTHONPATH."
            return 1
        try:
            db_conn = sqlite.connect(options.sqlite_db_name)
        except Exception, e:
            print "Could not connect to SQLite database:", str(e)
            return 1

        if askForConfirmation(options.sqlite_db_name, options.tablename):
            doSQLiteUpgrade(db_conn, nonce_table_name=options.tablename)

    if options.postgres_db_name:
        if not options.username:
            print "A username is required to open a PostgreSQL Database."
            return 1
        password = askForPassword()
        try:
            import psycopg
        except ImportError:
            print "You need psycopg installed to update a postgres DB."
            return 1

        try:
            db_conn = psycopg.connect(database = options.postgres_db_name,
                                      user = options.username,
                                      host = options.db_host,
                                      password = password)
        except Exception, e:
            print "Could not connect to PostgreSQL database:", str(e)
            return 1

        if askForConfirmation(options.postgres_db_name, options.tablename):
            doPostgreSQLUpgrade(db_conn, nonce_table_name=options.tablename)

    if options.mysql_db_name:
        if not options.username:
            print "A username is required to open a MySQL Database."
            return 1
        password = askForPassword()
        try:
            import MySQLdb
        except ImportError:
            print "You must have MySQLdb installed to update a MySQL DB."
            return 1

        try:
            db_conn = MySQLdb.connect(options.db_host, options.username,
                                      password, options.mysql_db_name)
        except Exception, e:
            print "Could not connect to MySQL database:", str(e)
            return 1

        if askForConfirmation(options.mysql_db_name, options.tablename):
            doMySQLUpgrade(db_conn, nonce_table_name=options.tablename)

    if db_conn:
        db_conn.close()
    else:
        parser.print_help()

    return 0

if __name__ == '__main__':
    retval = main()
    sys.exit(retval)