ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
Auth_OpenID Class Reference
+ Collaboration diagram for Auth_OpenID:

Static Public Member Functions

static isFailure ($thing)
 Return true if $thing is an Auth_OpenID_FailureResponse object; false if not.
static getQuery ($query_str=null)
 Gets the query data from the server environment based on the request method used.
static params_from_string ($str)
static ensureDir ($dir_name)
 Create dir_name as a directory if it does not exist.
static addPrefix ($values, $prefix)
 Adds a string prefix to all values of an array.
static arrayGet ($arr, $key, $fallback=null)
 Convenience function for getting array values.
static parse_str ($query)
 Replacement for PHP's broken parse_str.
static httpBuildQuery ($data)
 Implements the PHP 5 'http_build_query' functionality.
static appendArgs ($url, $args)
 "Appends" query arguments onto a URL.
static urlunparse ($scheme, $host, $port=null, $path= '/', $query= '', $fragment= '')
 Implements python's urlunparse, which is not available in PHP.
static normalizeUrl ($url)
 Given a URL, this "normalizes" it by adding a trailing slash and / or a leading http:// scheme where necessary.
static intval ($value)
 Replacement (wrapper) for PHP's intval() because it's broken.
static bytes ($str)
 Count the number of bytes in a string independently of multibyte support conditions.
static toBytes ($str)
 Get the bytes in a string independently of multibyte support conditions.
static urldefrag ($url)
static filter ($callback, &$sequence)
static update (&$dest, &$src)
static log ($format_string)
 Wrap PHP's standard error_log functionality.
static autoSubmitHTML ($form, $title="OpenId transaction in progress")

Detailed Description

Definition at line 110 of file OpenID.php.

Member Function Documentation

static Auth_OpenID::addPrefix (   $values,
  $prefix 
)
static

Adds a string prefix to all values of an array.

Returns a new array containing the prefixed values.

private

Definition at line 226 of file OpenID.php.

Referenced by Auth_OpenID_GenericConsumer\_doIdRes().

{
$new_values = array();
foreach ($values as $s) {
$new_values[] = $prefix . $s;

+ Here is the caller graph for this function:

static Auth_OpenID::appendArgs (   $url,
  $args 
)
static

"Appends" query arguments onto a URL.

The URL may or may not already have arguments (following a question mark).

private

Parameters
string$urlA URL, which may or may not already have arguments.
array$argsEither an array key/value pairs or an array of arrays, each of which holding two values: a key and a value, sequentially. If $args is an ordinary key/value array, the parameters will be added to the URL in sorted alphabetical order; if $args is an array of arrays, their order will be preserved.
Returns
string $url The original URL with the new parameters added.

Definition at line 324 of file OpenID.php.

Referenced by Auth_OpenID_AuthRequest\getMessage(), and Auth_OpenID_Message\toURL().

{
if (count($args) == 0) {
return $url;
}
// Non-empty array; if it is an array of arrays, use
// multisort; otherwise use sort.
if (array_key_exists(0, $args) &&
is_array($args[0])) {
// Do nothing here.
} else {
$keys = array_keys($args);
sort($keys);
$new_args = array();
foreach ($keys as $key) {
$new_args[] = array($key, $args[$key]);
}
$args = $new_args;
}
$sep = '?';
if (strpos($url, '?') !== false) {
$sep = '&';
}

+ Here is the caller graph for this function:

static Auth_OpenID::arrayGet (   $arr,
  $key,
  $fallback = null 
)
static

Convenience function for getting array values.

Given an array $arr and a key $key, get the corresponding value from the array or return $default if the key is absent.

private

Definition at line 242 of file OpenID.php.

Referenced by Auth_OpenID_GenericConsumer\_checkReturnTo(), Auth_OpenID_Association\_makePairs(), Auth_OpenID_GenericConsumer\_verifyReturnToArgs(), Auth_OpenID_getSessionTypes(), Auth_OpenID_PAPE_Response\Auth_OpenID_PAPE_Response(), Auth_OpenID_GenericConsumer\complete(), Auth_OpenID_Decoder\decode(), Auth_OpenID_SRegResponse\extractResponse(), Auth_OpenID_Parse\findFirstHref(), Auth_OpenID_AssociateRequest\fromMessage(), Auth_OpenID_SRegResponse\get(), and Auth_OpenID_SRegRequest\parseExtensionArgs().

{
if (is_array($arr)) {
if (array_key_exists($key, $arr)) {
return $arr[$key];
} else {
return $fallback;
}
} else {
trigger_error("Auth_OpenID::arrayGet (key = ".$key.") expected " .
"array as first parameter, got " .
gettype($arr), E_USER_WARNING);

+ Here is the caller graph for this function:

static Auth_OpenID::autoSubmitHTML (   $form,
  $title = "OpenId transaction in progress" 
)
static

Definition at line 532 of file OpenID.php.

Referenced by Auth_OpenID_AuthRequest\htmlMarkup(), Auth_OpenID_ServerError\toHTML(), and Auth_OpenID_ServerResponse\toHTML().

{
return("<html>".
"<head><title>".
"</title></head>".
"<body onload='document.forms[0].submit();'>".
$form .
"<script>".
"var elements = document.forms[0].elements;".
"for (var i = 0; i < elements.length; i++) {".
" elements[i].style.display = \"none\";".
"}".
"</script>".

+ Here is the caller graph for this function:

static Auth_OpenID::bytes (   $str)
static

Count the number of bytes in a string independently of multibyte support conditions.

Parameters
string$strThe string of bytes to count.
Returns
int The number of bytes in $str.

Definition at line 462 of file OpenID.php.

Referenced by Auth_OpenID_SQLStore\_octify(), Auth_OpenID_HMACSHA1(), Auth_OpenID_MathLibrary\rand(), and Auth_OpenID_DiffieHellman\xorSecret().

{

+ Here is the caller graph for this function:

static Auth_OpenID::ensureDir (   $dir_name)
static

Create dir_name as a directory if it does not exist.

If it exists, make sure that it is, in fact, a directory. Returns true if the operation succeeded; false if not.

private

Definition at line 204 of file OpenID.php.

Referenced by Auth_OpenID_FileStore\_setup(), and Auth_OpenID_FileStore\Auth_OpenID_FileStore().

{
if (is_dir($dir_name) || @mkdir($dir_name)) {
return true;
} else {
$parent_dir = dirname($dir_name);
// Terminal case; there is no parent directory to create.
if ($parent_dir == $dir_name) {
return true;
}

+ Here is the caller graph for this function:

static Auth_OpenID::filter (   $callback,
$sequence 
)
static

Definition at line 498 of file OpenID.php.

{
$result = array();
foreach ($sequence as $item) {
if (call_user_func_array($callback, array($item))) {
$result[] = $item;
}
}
static Auth_OpenID::getQuery (   $query_str = null)
static

Gets the query data from the server environment based on the request method used.

If GET was used, this looks at $_SERVER['QUERY_STRING'] directly. If POST was used, this fetches data from the special php://input file stream.

Returns an associative array of the query arguments.

Skips invalid key/value pairs (i.e. keys with no '=value' portion).

Returns an empty array if neither GET nor POST was used, or if POST was used but php://input cannot be opened.

See background: http://lists.openidenabled.com/pipermail/dev/2007-March/000395.html

private

Definition at line 142 of file OpenID.php.

Referenced by Auth_OpenID_Consumer\complete(), and Auth_OpenID_Server\decodeRequest().

{
$data = array();
if ($query_str !== null) {
} else if (!array_key_exists('REQUEST_METHOD', $_SERVER)) {
// Do nothing.
} else {
// XXX HACK FIXME HORRIBLE.
//
// POSTing to a URL with query parameters is acceptable, but
// we don't have a clean way to distinguish those parameters
// when we need to do things like return_to verification
// which only want to look at one kind of parameter. We're
// going to emulate the behavior of some other environments
// by defaulting to GET and overwriting with POST if POST
// data is available.
$data = Auth_OpenID::params_from_string($_SERVER['QUERY_STRING']);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$str = file_get_contents('php://input');
if ($str === false) {
$post = array();
} else {
}
$data = array_merge($data, $post);
}
}

+ Here is the caller graph for this function:

static Auth_OpenID::httpBuildQuery (   $data)
static

Implements the PHP 5 'http_build_query' functionality.

private

Parameters
array$dataEither an array key/value pairs or an array of arrays, each of which holding two values: a key and a value, sequentially.
Returns
string $result The result of url-encoding the key/value pairs from $data into a URL query string (e.g. "username=bob&id=56").

Definition at line 296 of file OpenID.php.

Referenced by Auth_Yadis_XRIAppendArgs(), and Auth_OpenID_Message\toURLEncoded().

{
$pairs = array();
foreach ($data as $key => $value) {
if (is_array($value)) {
$pairs[] = urlencode($value[0])."=".urlencode($value[1]);
} else {
$pairs[] = urlencode($key)."=".urlencode($value);
}

+ Here is the caller graph for this function:

static Auth_OpenID::intval (   $value)
static

Replacement (wrapper) for PHP's intval() because it's broken.

private

Definition at line 444 of file OpenID.php.

Referenced by Auth_OpenID_GenericConsumer\_extractAssociation(), and Auth_OpenID_PAPE_Response\Auth_OpenID_PAPE_Response().

{
$re = "/^\\d+$/";
if (!preg_match($re, $value)) {
return false;
}

+ Here is the caller graph for this function:

static Auth_OpenID::log (   $format_string)
static

Wrap PHP's standard error_log functionality.

Use this to perform all logging. It will interpolate any additional arguments into the format string before logging.

Parameters
string$format_stringThe sprintf format for the message

Definition at line 525 of file OpenID.php.

Referenced by Auth_OpenID_NamespaceMap\addAlias(), Auth_Yadis_ParanoidHTTPFetcher\get(), Auth_Yadis_ParanoidHTTPFetcher\post(), and Auth_OpenID_Message\setOpenIDNamespace().

{
$args = func_get_args();

+ Here is the caller graph for this function:

static Auth_OpenID::normalizeUrl (   $url)
static

Given a URL, this "normalizes" it by adding a trailing slash and / or a leading http:// scheme where necessary.

Returns null if the original URL is malformed and cannot be normalized.

private

Parameters
string$urlThe URL to be normalized.
Returns
mixed $new_url The URL after normalization, or null if $url was malformed.

Definition at line 413 of file OpenID.php.

Referenced by Auth_OpenID_discoverURI().

{
@$parsed = parse_url($url);
if (!$parsed) {
return null;
}
if (isset($parsed['scheme']) &&
isset($parsed['host'])) {
$scheme = strtolower($parsed['scheme']);
if (!in_array($scheme, array('http', 'https'))) {
return null;
}
} else {
$url = 'http://' . $url;
}
$normalized = Auth_OpenID_urinorm($url);
if ($normalized === null) {
return null;
}

+ Here is the caller graph for this function:

static Auth_OpenID::params_from_string (   $str)
static

Definition at line 178 of file OpenID.php.

{
$chunks = explode("&", $str);
$data = array();
foreach ($chunks as $chunk) {
$parts = explode("=", $chunk, 2);
if (count($parts) != 2) {
continue;
}
list($k, $v) = $parts;
$data[urldecode($k)] = urldecode($v);
}
static Auth_OpenID::parse_str (   $query)
static

Replacement for PHP's broken parse_str.

Definition at line 262 of file OpenID.php.

Referenced by Auth_OpenID_GenericConsumer\_verifyReturnToArgs().

{
if ($query === null) {
return null;
}
$parts = explode('&', $query);
$new_parts = array();
for ($i = 0; $i < count($parts); $i++) {
$pair = explode('=', $parts[$i]);
if (count($pair) != 2) {
continue;
}
list($key, $value) = $pair;
$new_parts[urldecode($key)] = urldecode($value);
}

+ Here is the caller graph for this function:

static Auth_OpenID::toBytes (   $str)
static

Get the bytes in a string independently of multibyte support conditions.

Definition at line 471 of file OpenID.php.

Referenced by Auth_OpenID_FileStore\_filenameEscape().

{
$hex = bin2hex($str);
if (!$hex) {
return array();
}
$b = array();
for ($i = 0; $i < strlen($hex); $i += 2) {
$b[] = chr(base_convert(substr($hex, $i, 2), 16, 10));
}

+ Here is the caller graph for this function:

static Auth_OpenID::update ( $dest,
$src 
)
static

Definition at line 511 of file OpenID.php.

{
foreach ($src as $k => $v) {
static Auth_OpenID::urldefrag (   $url)
static

Definition at line 487 of file OpenID.php.

Referenced by Auth_OpenID_GenericConsumer\_verifyDiscoverySingle().

{
$parts = explode("#", $url, 2);
if (count($parts) == 1) {
return array($parts[0], "");
} else {

+ Here is the caller graph for this function:

static Auth_OpenID::urlunparse (   $scheme,
  $host,
  $port = null,
  $path = '/',
  $query = '',
  $fragment = '' 
)
static

Implements python's urlunparse, which is not available in PHP.

Given the specified components of a URL, this function rebuilds and returns the URL.

private

Parameters
string$schemeThe scheme (e.g. 'http'). Defaults to 'http'.
string$hostThe host. Required.
string$portThe port.
string$pathThe path.
string$queryThe query.
string$fragmentThe fragment.
Returns
string $url The URL resulting from assembling the specified components.

Definition at line 368 of file OpenID.php.

{
if (!$scheme) {
$scheme = 'http';
}
if (!$host) {
return false;
}
if (!$path) {
$path = '';
}
$result = $scheme . "://" . $host;
if ($port) {
$result .= ":" . $port;
}
$result .= $path;
if ($query) {
$result .= "?" . $query;
}
if ($fragment) {
$result .= "#" . $fragment;
}

The documentation for this class was generated from the following file: