Exemplo n.º 1
0
 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"));
     foreach ($xris as $tupl) {
         list($thexri, $expected_root) = $tupl;
         $this->assertEquals(Services_Yadis_XRI($expected_root), Services_Yadis_rootAuthority($thexri), 'rootAuthority test (' . $thexri . ')');
     }
 }
Exemplo n.º 2
0
 function _getCanonicalID($iname, $xrds, $expectedID)
 {
     if ($expectedID === null) {
         $result = Services_Yadis_getCanonicalID($iname, $xrds);
         if ($result !== false) {
             $this->fail($iname . ' (got ' . $result . ')');
         }
     } else {
         $cid = Services_Yadis_getCanonicalID($iname, $xrds);
         $this->assertEquals(Services_Yadis_XRI($expectedID), $cid);
     }
 }
Exemplo n.º 3
0
function Services_Yadis_getCanonicalID($iname, $xrds)
{
    // Returns FALSE or a canonical ID value.
    // Now nodes are in reverse order.
    $xrd_list = array_reverse($xrds->allXrdNodes);
    $parser =& $xrds->parser;
    $node = $xrd_list[0];
    $canonicalID_nodes = $parser->evalXPath('xrd:CanonicalID', $node);
    if (!$canonicalID_nodes) {
        return false;
    }
    $canonicalID = $canonicalID_nodes[count($canonicalID_nodes) - 1];
    $canonicalID = Services_Yadis_XRI($parser->content($canonicalID));
    $childID = $canonicalID;
    for ($i = 1; $i < count($xrd_list); $i++) {
        $xrd = $xrd_list[$i];
        $parent_sought = substr($childID, 0, strrpos($childID, '!'));
        $parent_list = array();
        foreach ($parser->evalXPath('xrd:CanonicalID', $xrd) as $c) {
            $parent_list[] = Services_Yadis_XRI($parser->content($c));
        }
        if (!in_array($parent_sought, $parent_list)) {
            // raise XRDSFraud.
            return false;
        }
        $childID = $parent_sought;
    }
    $root = Services_Yadis_rootAuthority($iname);
    if (!Services_Yadis_providerIsAuthoritative($root, $childID)) {
        // raise XRDSFraud.
        return false;
    }
    return $canonicalID;
}
Exemplo n.º 4
0
 function test_useCanonicalID()
 {
     // When there is no delegate, the CanonicalID should be used
     // with XRI.
     $endpoint = new Auth_OpenID_ServiceEndpoint();
     $endpoint->identity_url = "=example";
     $endpoint->canonicalID = Services_Yadis_XRI("=!1000");
     $this->assertEquals($endpoint->getServerID(), Services_Yadis_XRI("=!1000"));
 }