ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Auth_OpenID_AX_FetchRequest Class Reference
+ Inheritance diagram for Auth_OpenID_AX_FetchRequest:
+ Collaboration diagram for Auth_OpenID_AX_FetchRequest:

Public Member Functions

 Auth_OpenID_AX_FetchRequest ($update_url=null)
 
 add ($attribute)
 Add an attribute to this attribute exchange request. More...
 
 getExtensionArgs ()
 Get the serialized form of this attribute fetch request. More...
 
 getRequiredAttrs ()
 Get the type URIs for all attributes that have been marked as required. More...
 
 parseExtensionArgs ($ax_args)
 Given attribute exchange arguments, populate this FetchRequest. More...
 
 iterAttrs ()
 Iterate over the AttrInfo objects that are contained in this fetch_request. More...
 
 iterTypes ()
 
 contains ($type_uri)
 Is the given type URI present in this fetch_request? More...
 
- Public Member Functions inherited from Auth_OpenID_AX_Message
 _checkMode ($ax_args)
 Return Auth_OpenID_AX_Error if the mode in the attribute exchange arguments does not match what is expected for this class; true otherwise. More...
 
 _newArgs ()
 Return a set of attribute exchange arguments containing the basic information that must be in every attribute exchange message. More...
 
- Public Member Functions inherited from Auth_OpenID_Extension
 getExtensionArgs ()
 Get the string arguments that should be added to an OpenID message for this extension. More...
 
 toMessage ($message)
 Add the arguments from this extension to the provided message. More...
 

Static Public Member Functions

static fromOpenIDRequest ($request)
 Extract a FetchRequest from an OpenID message. More...
 

Data Fields

 $mode = 'fetch_request'
 
- Data Fields inherited from Auth_OpenID_AX_Message
 $ns_alias = 'ax'
 ns_alias: The preferred namespace alias for attribute exchange messages More...
 
 $mode = null
 mode: The type of this attribute exchange message. More...
 
 $ns_uri = Auth_OpenID_AX_NS_URI
 
- Data Fields inherited from Auth_OpenID_Extension
 $ns_uri = null
 ns_uri: The namespace to which to add the arguments for this extension More...
 
 $ns_alias = null
 

Detailed Description

Definition at line 267 of file AX.php.

Member Function Documentation

◆ add()

Auth_OpenID_AX_FetchRequest::add (   $attribute)

Add an attribute to this attribute exchange request.

Parameters
attributeThe attribute that is being requested
Returns
true on success, false when the requested attribute is already present in this fetch request.

Definition at line 294 of file AX.php.

296 {
297 if ($this->contains($attribute->type_uri)) {
298 return new Auth_OpenID_AX_Error(
299 sprintf("The attribute %s has already been requested",
300 $attribute->type_uri));
301 }
302
303 $this->requested_attributes[$attribute->type_uri] = $attribute;
304
305 return true;
contains($type_uri)
Is the given type URI present in this fetch_request?
Definition: AX.php:527

◆ Auth_OpenID_AX_FetchRequest()

Auth_OpenID_AX_FetchRequest::Auth_OpenID_AX_FetchRequest (   $update_url = null)

requested_attributes: The attributes that have been requested thus far, indexed by the type URI.

update_url: A URL that will accept responses for this attribute exchange request, even in the absence of the user who made this request.

Definition at line 271 of file AX.php.

273 {
278 $this->requested_attributes = array();
279
285 $this->update_url = $update_url;

◆ contains()

Auth_OpenID_AX_FetchRequest::contains (   $type_uri)

Is the given type URI present in this fetch_request?

Definition at line 527 of file AX.php.

529 {
530 return in_array($type_uri, $this->iterTypes());

◆ fromOpenIDRequest()

static Auth_OpenID_AX_FetchRequest::fromOpenIDRequest (   $request)
static

Extract a FetchRequest from an OpenID message.

Parameters
requestThe OpenID request containing the attribute fetch request
Returns
mixed An Auth_OpenID_AX_Error or the Auth_OpenID_AX_FetchRequest extracted from the request message if successful

Definition at line 388 of file AX.php.

390 {
391 $m = $request->message;
392 $obj = new Auth_OpenID_AX_FetchRequest();
393 $ax_args = $m->getArgs($obj->ns_uri);
394
395 $result = $obj->parseExtensionArgs($ax_args);
396
398 return $result;
399 }
400
401 if ($obj->update_url) {
402 // Update URL must match the openid.realm of the
403 // underlying OpenID 2 message.
404 $realm = $m->getArg(Auth_OpenID_OPENID_NS, 'realm',
405 $m->getArg(
407 'return_to'));
408
409 if (!$realm) {
410 $obj = new Auth_OpenID_AX_Error(
411 sprintf("Cannot validate update_url %s " .
412 "against absent realm", $obj->update_url));
413 } else if (!Auth_OpenID_TrustRoot::match($realm,
414 $obj->update_url)) {
415 $obj = new Auth_OpenID_AX_Error(
416 sprintf("Update URL %s failed validation against realm %s",
417 $obj->update_url, $realm));
418 }
419 }
420
421 return $obj;
$result
const Auth_OpenID_OPENID_NS
Definition: Message.php:42
Auth_OpenID_AX_FetchRequest($update_url=null)
Definition: AX.php:271
static isError($thing)
Definition: AX.php:40
static match($trust_root, $url)
Does this URL match the given trust root?
Definition: TrustRoot.php:270

◆ getExtensionArgs()

Auth_OpenID_AX_FetchRequest::getExtensionArgs ( )

Get the serialized form of this attribute fetch request.

Returns
Auth_OpenID_AX_FetchRequest The fetch request message parameters

Reimplemented from Auth_OpenID_Extension.

Definition at line 312 of file AX.php.

314 {
315 $aliases = new Auth_OpenID_NamespaceMap();
316
317 $required = array();
318 $if_available = array();
319
320 $ax_args = $this->_newArgs();
321
322 foreach ($this->requested_attributes as $type_uri => $attribute) {
323 if ($attribute->alias === null) {
324 $alias = $aliases->add($type_uri);
325 } else {
326 $alias = $aliases->addAlias($type_uri, $attribute->alias);
327
328 if ($alias === null) {
329 return new Auth_OpenID_AX_Error(
330 sprintf("Could not add alias %s for URI %s",
331 $attribute->alias, $type_uri
332 ));
333 }
334 }
335
336 if ($attribute->required) {
337 $required[] = $alias;
338 } else {
339 $if_available[] = $alias;
340 }
341
342 if ($attribute->count != 1) {
343 $ax_args['count.' . $alias] = strval($attribute->count);
344 }
345
346 $ax_args['type.' . $alias] = $type_uri;
347 }
348
349 if ($required) {
350 $ax_args['required'] = implode(',', $required);
351 }
352
353 if ($if_available) {
354 $ax_args['if_available'] = implode(',', $if_available);
355 }
356
357 return $ax_args;
_newArgs()
Return a set of attribute exchange arguments containing the basic information that must be in every a...
Definition: AX.php:125

◆ getRequiredAttrs()

Auth_OpenID_AX_FetchRequest::getRequiredAttrs ( )

Get the type URIs for all attributes that have been marked as required.

Returns
A list of the type URIs for attributes that have been marked as required.

Definition at line 366 of file AX.php.

368 {
369 $required = array();
370 foreach ($this->requested_attributes as $type_uri => $attribute) {
371 if ($attribute->required) {
372 $required[] = $type_uri;
373 }
374 }
375
376 return $required;

◆ iterAttrs()

Auth_OpenID_AX_FetchRequest::iterAttrs ( )

Iterate over the AttrInfo objects that are contained in this fetch_request.

Definition at line 514 of file AX.php.

516 {
517 return array_values($this->requested_attributes);

◆ iterTypes()

Auth_OpenID_AX_FetchRequest::iterTypes ( )

Definition at line 519 of file AX.php.

521 {
522 return array_keys($this->requested_attributes);

◆ parseExtensionArgs()

Auth_OpenID_AX_FetchRequest::parseExtensionArgs (   $ax_args)

Given attribute exchange arguments, populate this FetchRequest.

Returns
$result Auth_OpenID_AX_Error if the data to be parsed does not follow the attribute exchange specification. At least when 'if_available' or 'required' is not specified for a particular attribute type. Returns true otherwise.

Definition at line 431 of file AX.php.

433 {
434 $result = $this->_checkMode($ax_args);
436 return $result;
437 }
438
439 $aliases = new Auth_OpenID_NamespaceMap();
440
441 foreach ($ax_args as $key => $value) {
442 if (strpos($key, 'type.') === 0) {
443 $alias = substr($key, 5);
444 $type_uri = $value;
445
446 $alias = $aliases->addAlias($type_uri, $alias);
447
448 if ($alias === null) {
449 return new Auth_OpenID_AX_Error(
450 sprintf("Could not add alias %s for URI %s",
451 $alias, $type_uri)
452 );
453 }
454
455 $count_s = Auth_OpenID::arrayGet($ax_args, 'count.' . $alias);
456 if ($count_s) {
457 $count = Auth_OpenID::intval($count_s);
458 if (($count === false) &&
459 ($count_s === Auth_OpenID_AX_UNLIMITED_VALUES)) {
460 $count = $count_s;
461 }
462 } else {
463 $count = 1;
464 }
465
466 if ($count === false) {
467 return new Auth_OpenID_AX_Error(
468 sprintf("Integer value expected for %s, got %s",
469 'count.' . $alias, $count_s));
470 }
471
472 $attrinfo = Auth_OpenID_AX_AttrInfo::make($type_uri, $count,
473 false, $alias);
474
475 if (Auth_OpenID_AX::isError($attrinfo)) {
476 return $attrinfo;
477 }
478
479 $this->add($attrinfo);
480 }
481 }
482
483 $required = Auth_OpenID_AX_toTypeURIs($aliases,
484 Auth_OpenID::arrayGet($ax_args, 'required'));
485
486 foreach ($required as $type_uri) {
487 $attrib = $this->requested_attributes[$type_uri];
488 $attrib->required = true;
489 }
490
491 $if_available = Auth_OpenID_AX_toTypeURIs($aliases,
492 Auth_OpenID::arrayGet($ax_args, 'if_available'));
493
494 $all_type_uris = array_merge($required, $if_available);
495
496 foreach ($aliases->iterNamespaceURIs() as $type_uri) {
497 if (!in_array($type_uri, $all_type_uris)) {
498 return new Auth_OpenID_AX_Error(
499 sprintf('Type URI %s was in the request but not ' .
500 'present in "required" or "if_available"',
501 $type_uri));
502
503 }
504 }
505
506 $this->update_url = Auth_OpenID::arrayGet($ax_args, 'update_url');
507
508 return true;
const Auth_OpenID_AX_UNLIMITED_VALUES
Definition: AX.php:21
Auth_OpenID_AX_toTypeURIs($namespace_map, $alias_list_s)
Given a namespace mapping and a string containing a comma-separated list of namespace aliases,...
Definition: AX.php:237
$attrib
Regular expression to match HTML/XML attribute pairs within a tag.
Definition: Sanitizer.php:41
static make($type_uri, $count=1, $required=false, $alias=null)
Construct an attribute information object.
Definition: AX.php:193
add($attribute)
Add an attribute to this attribute exchange request.
Definition: AX.php:294
_checkMode($ax_args)
Return Auth_OpenID_AX_Error if the mode in the attribute exchange arguments does not match what is ex...
Definition: AX.php:105
static arrayGet($arr, $key, $fallback=null)
Convenience function for getting array values.
Definition: OpenID.php:242
static intval($value)
Replacement (wrapper) for PHP's intval() because it's broken.
Definition: OpenID.php:444

Field Documentation

◆ $mode

Auth_OpenID_AX_FetchRequest::$mode = 'fetch_request'

Definition at line 269 of file AX.php.


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