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

Detailed Description

Definition at line 110 of file OpenID.php.

Member Function Documentation

◆ addPrefix()

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.

@access private

Definition at line 226 of file OpenID.php.

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

Referenced by Auth_OpenID_GenericConsumer\_doIdRes().

+ Here is the caller graph for this function:

◆ appendArgs()

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).

@access 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.

328 {
329 if (count($args) == 0) {
330 return $url;
331 }
332
333 // Non-empty array; if it is an array of arrays, use
334 // multisort; otherwise use sort.
335 if (array_key_exists(0, $args) &&
336 is_array($args[0])) {
337 // Do nothing here.
338 } else {
339 $keys = array_keys($args);
340 sort($keys);
341 $new_args = array();
342 foreach ($keys as $key) {
343 $new_args[] = array($key, $args[$key]);
344 }
345 $args = $new_args;
346 }
347
348 $sep = '?';
349 if (strpos($url, '?') !== false) {
350 $sep = '&';
351 }
$url
Definition: shib_logout.php:72

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

+ Here is the caller graph for this function:

◆ arrayGet()

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.

@access private

Definition at line 242 of file OpenID.php.

246 {
247 if (is_array($arr)) {
248 if (array_key_exists($key, $arr)) {
249 return $arr[$key];
250 } else {
251 return $fallback;
252 }
253 } else {
254 trigger_error("Auth_OpenID::arrayGet (key = ".$key.") expected " .
255 "array as first parameter, got " .
256 gettype($arr), E_USER_WARNING);
257
$fallback
Definition: en-x-test.php:5

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().

+ Here is the caller graph for this function:

◆ autoSubmitHTML()

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

Definition at line 532 of file OpenID.php.

536 {
537 return("<html>".
538 "<head><title>".
539 $title .
540 "</title></head>".
541 "<body onload='document.forms[0].submit();'>".
542 $form .
543 "<script>".
544 "var elements = document.forms[0].elements;".
545 "for (var i = 0; i < elements.length; i++) {".
546 " elements[i].style.display = \"none\";".
547 "}".
548 "</script>".

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

+ Here is the caller graph for this function:

◆ bytes()

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.

466 {

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:

◆ ensureDir()

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.

@access private

Definition at line 204 of file OpenID.php.

208 {
209 if (is_dir($dir_name) || @mkdir($dir_name)) {
210 return true;
211 } else {
212 $parent_dir = dirname($dir_name);
213
214 // Terminal case; there is no parent directory to create.
215 if ($parent_dir == $dir_name) {
216 return true;
217 }
218

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

+ Here is the caller graph for this function:

◆ filter()

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

Definition at line 498 of file OpenID.php.

502 {
503 $result = array();
504
505 foreach ($sequence as $item) {
506 if (call_user_func_array($callback, array($item))) {
507 $result[] = $item;
508 }
509 }
$result

◆ getQuery()

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

@access private

Definition at line 142 of file OpenID.php.

146 {
147 $data = array();
148
149 if ($query_str !== null) {
151 } else if (!array_key_exists('REQUEST_METHOD', $_SERVER)) {
152 // Do nothing.
153 } else {
154 // XXX HACK FIXME HORRIBLE.
155 //
156 // POSTing to a URL with query parameters is acceptable, but
157 // we don't have a clean way to distinguish those parameters
158 // when we need to do things like return_to verification
159 // which only want to look at one kind of parameter. We're
160 // going to emulate the behavior of some other environments
161 // by defaulting to GET and overwriting with POST if POST
162 // data is available.
164
165 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
166 $str = file_get_contents('php://input');
167
168 if ($str === false) {
169 $post = array();
170 } else {
172 }
173
174 $data = array_merge($data, $post);
175 }
176 }
static params_from_string($str)
Definition: OpenID.php:178
$data
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']

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

+ Here is the caller graph for this function:

◆ httpBuildQuery()

static Auth_OpenID::httpBuildQuery (   $data)
static

Implements the PHP 5 'http_build_query' functionality.

@access 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.

300 {
301 $pairs = array();
302 foreach ($data as $key => $value) {
303 if (is_array($value)) {
304 $pairs[] = urlencode($value[0])."=".urlencode($value[1]);
305 } else {
306 $pairs[] = urlencode($key)."=".urlencode($value);
307 }

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

+ Here is the caller graph for this function:

◆ intval()

static Auth_OpenID::intval (   $value)
static

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

@access private

Definition at line 444 of file OpenID.php.

448 {
449 $re = "/^\\d+$/";
450
451 if (!preg_match($re, $value)) {
452 return false;
453 }

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

+ Here is the caller graph for this function:

◆ isFailure()

◆ log()

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.

529 {
530 $args = func_get_args();

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

+ Here is the caller graph for this function:

◆ normalizeUrl()

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.

@access 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.

417 {
418 @$parsed = parse_url($url);
419
420 if (!$parsed) {
421 return null;
422 }
423
424 if (isset($parsed['scheme']) &&
425 isset($parsed['host'])) {
426 $scheme = strtolower($parsed['scheme']);
427 if (!in_array($scheme, array('http', 'https'))) {
428 return null;
429 }
430 } else {
431 $url = 'http://' . $url;
432 }
433
434 $normalized = Auth_OpenID_urinorm($url);
435 if ($normalized === null) {
436 return null;
437 }
Auth_OpenID_urinorm($uri)
Definition: URINorm.php:142

Referenced by Auth_OpenID_discoverURI().

+ Here is the caller graph for this function:

◆ params_from_string()

static Auth_OpenID::params_from_string (   $str)
static

Definition at line 178 of file OpenID.php.

182 {
183 $chunks = explode("&", $str);
184
185 $data = array();
186 foreach ($chunks as $chunk) {
187 $parts = explode("=", $chunk, 2);
188
189 if (count($parts) != 2) {
190 continue;
191 }
192
193 list($k, $v) = $parts;
194 $data[urldecode($k)] = urldecode($v);
195 }

◆ parse_str()

static Auth_OpenID::parse_str (   $query)
static

Replacement for PHP's broken parse_str.

Definition at line 262 of file OpenID.php.

266 {
267 if ($query === null) {
268 return null;
269 }
270
271 $parts = explode('&', $query);
272
273 $new_parts = array();
274 for ($i = 0; $i < count($parts); $i++) {
275 $pair = explode('=', $parts[$i]);
276
277 if (count($pair) != 2) {
278 continue;
279 }
280
281 list($key, $value) = $pair;
282 $new_parts[urldecode($key)] = urldecode($value);
283 }

Referenced by Auth_OpenID_GenericConsumer\_verifyReturnToArgs().

+ Here is the caller graph for this function:

◆ toBytes()

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.

475 {
476 $hex = bin2hex($str);
477
478 if (!$hex) {
479 return array();
480 }
481
482 $b = array();
483 for ($i = 0; $i < strlen($hex); $i += 2) {
484 $b[] = chr(base_convert(substr($hex, $i, 2), 16, 10));
485 }

Referenced by Auth_OpenID_FileStore\_filenameEscape().

+ Here is the caller graph for this function:

◆ update()

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

Definition at line 511 of file OpenID.php.

515 {
516 foreach ($src as $k => $v) {

◆ urldefrag()

static Auth_OpenID::urldefrag (   $url)
static

Definition at line 487 of file OpenID.php.

491 {
492 $parts = explode("#", $url, 2);
493
494 if (count($parts) == 1) {
495 return array($parts[0], "");
496 } else {

Referenced by Auth_OpenID_GenericConsumer\_verifyDiscoverySingle().

+ Here is the caller graph for this function:

◆ urlunparse()

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.

@access 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.

373 {
374
375 if (!$scheme) {
376 $scheme = 'http';
377 }
378
379 if (!$host) {
380 return false;
381 }
382
383 if (!$path) {
384 $path = '';
385 }
386
387 $result = $scheme . "://" . $host;
388
389 if ($port) {
390 $result .= ":" . $port;
391 }
392
393 $result .= $path;
394
395 if ($query) {
396 $result .= "?" . $query;
397 }
398
399 if ($fragment) {
400 $result .= "#" . $fragment;
401 }
$path
Definition: index.php:22

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