ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
XRI.php File Reference

Go to the source code of this file.

Namespaces

namespace  OpenID
 This module contains code for dealing with associations between consumers and servers.

Functions

 Auth_Yadis_getDefaultProxy ()
 Auth_Yadis_getXRIAuthorities ()
 Auth_Yadis_getEscapeRE ()
 Auth_Yadis_getXrefRE ()
 Auth_Yadis_identifierScheme ($identifier)
 Auth_Yadis_toIRINormal ($xri)
 _escape_xref ($xref_match)
 Auth_Yadis_escapeForIRI ($xri)
 Auth_Yadis_toURINormal ($xri)
 Auth_Yadis_iriToURI ($iri)
 Auth_Yadis_XRIAppendArgs ($url, $args)
 Auth_Yadis_providerIsAuthoritative ($providerID, $canonicalID)
 Auth_Yadis_rootAuthority ($xri)
 Auth_Yadis_XRI ($xri)
 Auth_Yadis_getCanonicalID ($iname, $xrds)

Function Documentation

_escape_xref (   $xref_match)

Definition at line 63 of file XRI.php.

{
$xref = $xref_match[0];
$xref = str_replace('/', '%2F', $xref);
$xref = str_replace('?', '%3F', $xref);
$xref = str_replace('#', '%23', $xref);
return $xref;
}
Auth_Yadis_escapeForIRI (   $xri)

Definition at line 72 of file XRI.php.

References Auth_Yadis_getXrefRE().

Referenced by Auth_Yadis_toIRINormal().

{
$xri = str_replace('%', '%25', $xri);
$xri = preg_replace_callback(Auth_Yadis_getXrefRE(),
'_escape_xref', $xri);
return $xri;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_Yadis_getCanonicalID (   $iname,
  $xrds 
)

Definition at line 187 of file XRI.php.

References Auth_Yadis_providerIsAuthoritative(), Auth_Yadis_rootAuthority(), and Auth_Yadis_XRI().

Referenced by Auth_Yadis_ProxyResolver\query().

{
// 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[0];
$canonicalID = Auth_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, '!'));
$parentCID = $parser->evalXPath('xrd:CanonicalID', $xrd);
if (!$parentCID) {
return false;
}
$parentCID = Auth_Yadis_XRI($parser->content($parentCID[0]));
if (strcasecmp($parent_sought, $parentCID)) {
// raise XRDSFraud.
return false;
}
$childID = $parent_sought;
}
$root = Auth_Yadis_rootAuthority($iname);
if (!Auth_Yadis_providerIsAuthoritative($root, $childID)) {
// raise XRDSFraud.
return false;
}
return $canonicalID;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_Yadis_getDefaultProxy ( )

Definition at line 16 of file XRI.php.

Referenced by Auth_Yadis_ProxyResolver\Auth_Yadis_ProxyResolver().

{
return 'http://xri.net/';
}

+ Here is the caller graph for this function:

Auth_Yadis_getEscapeRE ( )

Definition at line 26 of file XRI.php.

References $n, Auth_Yadis_getIPrivateChars(), and Auth_Yadis_getUCSChars().

Referenced by Auth_Yadis_iriToURI().

{
$parts = array();
foreach (array_merge(Auth_Yadis_getUCSChars(),
list($m, $n) = $pair;
$parts[] = sprintf("%s-%s", chr($m), chr($n));
}
return sprintf('/[%s]/', implode('', $parts));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_Yadis_getXrefRE ( )

Definition at line 38 of file XRI.php.

Referenced by Auth_Yadis_escapeForIRI().

{
return '/\((.*?)\)/';
}

+ Here is the caller graph for this function:

Auth_Yadis_getXRIAuthorities ( )

Definition at line 21 of file XRI.php.

Referenced by Auth_Yadis_identifierScheme(), and Auth_Yadis_rootAuthority().

{
return array('!', '=', '@', '+', '$', '(');
}

+ Here is the caller graph for this function:

Auth_Yadis_identifierScheme (   $identifier)

Definition at line 43 of file XRI.php.

References Auth_Yadis_getXRIAuthorities(), and Auth_Yadis_startswith().

Referenced by Auth_OpenID_discover().

{
if (Auth_Yadis_startswith($identifier, 'xri://') ||
($identifier &&
in_array($identifier[0], Auth_Yadis_getXRIAuthorities()))) {
return "XRI";
} else {
return "URI";
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_Yadis_iriToURI (   $iri)

Definition at line 85 of file XRI.php.

References Auth_Yadis_getEscapeRE().

Referenced by Auth_Yadis_toURINormal().

{
if (1) {
return $iri;
} else {
// According to RFC 3987, section 3.1, "Mapping of IRIs to URIs"
return preg_replace_callback(Auth_Yadis_getEscapeRE(),
'Auth_Yadis_pct_escape_unicode', $iri);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_Yadis_providerIsAuthoritative (   $providerID,
  $canonicalID 
)

Definition at line 137 of file XRI.php.

Referenced by Auth_Yadis_getCanonicalID().

{
$lastbang = strrpos($canonicalID, '!');
$p = substr($canonicalID, 0, $lastbang);
return $p == $providerID;
}

+ Here is the caller graph for this function:

Auth_Yadis_rootAuthority (   $xri)

Definition at line 144 of file XRI.php.

References Auth_Yadis_getXRIAuthorities(), Auth_Yadis_startswith(), and Auth_Yadis_XRI().

Referenced by Auth_Yadis_getCanonicalID().

{
// Return the root authority for an XRI.
$root = null;
if (Auth_Yadis_startswith($xri, 'xri://')) {
$xri = substr($xri, 6);
}
$authority = explode('/', $xri, 2);
$authority = $authority[0];
if ($authority[0] == '(') {
// Cross-reference.
// XXX: This is incorrect if someone nests cross-references so
// there is another close-paren in there. Hopefully nobody
// does that before we have a real xriparse function.
// Hopefully nobody does that *ever*.
$root = substr($authority, 0, strpos($authority, ')') + 1);
} else if (in_array($authority[0], Auth_Yadis_getXRIAuthorities())) {
// Other XRI reference.
$root = $authority[0];
} else {
// IRI reference.
$_segments = explode("!", $authority);
$segments = array();
foreach ($_segments as $s) {
$segments = array_merge($segments, explode("*", $s));
}
$root = $segments[0];
}
return Auth_Yadis_XRI($root);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_Yadis_toIRINormal (   $xri)

Definition at line 54 of file XRI.php.

References Auth_Yadis_escapeForIRI(), and Auth_Yadis_startswith().

Referenced by Auth_Yadis_toURINormal().

{
if (!Auth_Yadis_startswith($xri, 'xri://')) {
$xri = 'xri://' . $xri;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_Yadis_toURINormal (   $xri)

Definition at line 80 of file XRI.php.

References Auth_Yadis_iriToURI(), and Auth_Yadis_toIRINormal().

Referenced by Auth_Yadis_ProxyResolver\queryURL().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_Yadis_XRI (   $xri)

Definition at line 179 of file XRI.php.

References Auth_Yadis_startswith().

Referenced by Auth_Yadis_getCanonicalID(), and Auth_Yadis_rootAuthority().

{
if (!Auth_Yadis_startswith($xri, 'xri://')) {
$xri = 'xri://' . $xri;
}
return $xri;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_Yadis_XRIAppendArgs (   $url,
  $args 
)

Definition at line 97 of file XRI.php.

References Auth_OpenID\httpBuildQuery().

Referenced by Auth_Yadis_ProxyResolver\queryURL().

{
// Append some arguments to an HTTP query. Yes, this is just like
// OpenID's appendArgs, but with special seasoning for XRI
// queries.
if (count($args) == 0) {
return $url;
}
// Non-empty array; if it is an array of arrays, use multisort;
// otherwise use sort.
if (array_key_exists(0, $args) &&
is_array($args[0])) {
// Do nothing here.
} else {
$keys = array_keys($args);
sort($keys);
$new_args = array();
foreach ($keys as $key) {
$new_args[] = array($key, $args[$key]);
}
$args = $new_args;
}
// According to XRI Resolution section "QXRI query parameters":
//
// "If the original QXRI had a null query component (only a
// leading question mark), or a query component consisting of
// only question marks, one additional leading question mark MUST
// be added when adding any XRI resolution parameters."
if (strpos(rtrim($url, '?'), '?') !== false) {
$sep = '&';
} else {
$sep = '?';
}
return $url . $sep . Auth_OpenID::httpBuildQuery($args);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function: