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

Public Member Functions

 Auth_OpenID_AX_KeyValueMessage ()
 
 addValue ($type_uri, $value)
 Add a single value for the given attribute type to the message. More...
 
 setValues ($type_uri, &$values)
 Set the values for the given attribute type. More...
 
 _getExtensionKVArgs ($aliases)
 Get the extension arguments for the key/value pairs contained in this message. More...
 
 parseExtensionArgs ($ax_args)
 Parse attribute exchange key/value arguments into this object. More...
 
 getSingle ($type_uri, $default=null)
 Get a single value for an attribute. More...
 
 get ($type_uri)
 Get the list of values for this attribute in the fetch_response. More...
 
 count ($type_uri)
 Get the number of responses for a particular attribute in this fetch_response message. 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...
 

Additional Inherited Members

- 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 540 of file AX.php.

Member Function Documentation

◆ _getExtensionKVArgs()

Auth_OpenID_AX_KeyValueMessage::_getExtensionKVArgs (   $aliases)

Get the extension arguments for the key/value pairs contained in this message.

Parameters
aliasesAn alias mapping. Set to None if you don't care about the aliases for this request.

@access private

Definition at line 589 of file AX.php.

591 {
592 if ($aliases === null) {
593 $aliases = new Auth_OpenID_NamespaceMap();
594 }
595
596 $ax_args = array();
597
598 foreach ($this->data as $type_uri => $values) {
599 $alias = $aliases->add($type_uri);
600
601 $ax_args['type.' . $alias] = $type_uri;
602 $ax_args['count.' . $alias] = strval(count($values));
603
604 foreach ($values as $i => $value) {
605 $key = sprintf('value.%s.%d', $alias, $i + 1);
606 $ax_args[$key] = $value;
607 }
608 }
609
610 return $ax_args;
count($type_uri)
Get the number of responses for a particular attribute in this fetch_response message.
Definition: AX.php:774

◆ addValue()

Auth_OpenID_AX_KeyValueMessage::addValue (   $type_uri,
  $value 
)

Add a single value for the given attribute type to the message.

If there are already values specified for this type, this value will be sent in addition to the values already specified.

Parameters
type_uriThe URI for the attribute
valueThe value to add to the response to the relying party for this attribute
Returns
null

Definition at line 558 of file AX.php.

560 {
561 if (!array_key_exists($type_uri, $this->data)) {
562 $this->data[$type_uri] = array();
563 }
564
565 $values =& $this->data[$type_uri];
566 $values[] = $value;

◆ Auth_OpenID_AX_KeyValueMessage()

Auth_OpenID_AX_KeyValueMessage::Auth_OpenID_AX_KeyValueMessage ( )

Definition at line 542 of file AX.php.

544 {
545 $this->data = array();

Referenced by Auth_OpenID_AX_FetchResponse\Auth_OpenID_AX_FetchResponse().

+ Here is the caller graph for this function:

◆ count()

Auth_OpenID_AX_KeyValueMessage::count (   $type_uri)

Get the number of responses for a particular attribute in this fetch_response message.

Parameters
type_uriThe URI of the attribute
Returns
int The number of values sent for this attribute. If the attribute was not sent in the response, returns Auth_OpenID_AX_Error.

Definition at line 774 of file AX.php.

776 {
777 if (array_key_exists($type_uri, $this->data)) {
778 return count($this->get($type_uri));
779 } else {
780 return new Auth_OpenID_AX_Error(
781 sprintf("Type URI %s not found in response",
782 $type_uri)
783 );
784 }

◆ get()

Auth_OpenID_AX_KeyValueMessage::get (   $type_uri)

Get the list of values for this attribute in the fetch_response.

XXX: what to do if the values are not present? default parameter? this is funny because it's always supposed to return a list, so the default may break that, though it's provided by the user's code, so it might be okay. If no default is supplied, should the return be None or []?

Parameters
type_uriThe URI of the attribute
Returns
$values The list of values for this attribute in the response. May be an empty list. If the attribute was not sent in the response, returns Auth_OpenID_AX_Error.

Definition at line 752 of file AX.php.

754 {
755 if (array_key_exists($type_uri, $this->data)) {
756 return $this->data[$type_uri];
757 } else {
758 return new Auth_OpenID_AX_Error(
759 sprintf("Type URI %s not found in response",
760 $type_uri)
761 );
762 }

◆ getSingle()

Auth_OpenID_AX_KeyValueMessage::getSingle (   $type_uri,
  $default = null 
)

Get a single value for an attribute.

If no value was sent for this attribute, use the supplied default. If there is more than one value for this attribute, this method will fail.

Parameters
type_uriThe URI for the attribute
defaultThe value to return if the attribute was not sent in the fetch_response.
Returns
$value Auth_OpenID_AX_Error on failure or the value of the attribute in the fetch_response message, or the default supplied

Definition at line 721 of file AX.php.

723 {
724 $values = Auth_OpenID::arrayGet($this->data, $type_uri);
725 if (!$values) {
726 return $default;
727 } else if (count($values) == 1) {
728 return $values[0];
729 } else {
730 return new Auth_OpenID_AX_Error(
731 sprintf('More than one value present for %s',
732 $type_uri)
733 );
734 }
static arrayGet($arr, $key, $fallback=null)
Convenience function for getting array values.
Definition: OpenID.php:242

◆ parseExtensionArgs()

Auth_OpenID_AX_KeyValueMessage::parseExtensionArgs (   $ax_args)

Parse attribute exchange key/value arguments into this object.

Parameters
ax_argsThe attribute exchange fetch_response arguments, with namespacing removed.
Returns
Auth_OpenID_AX_Error or true

Reimplemented in Auth_OpenID_AX_FetchResponse.

Definition at line 620 of file AX.php.

622 {
623 $result = $this->_checkMode($ax_args);
625 return $result;
626 }
627
628 $aliases = new Auth_OpenID_NamespaceMap();
629
630 foreach ($ax_args as $key => $value) {
631 if (strpos($key, 'type.') === 0) {
632 $type_uri = $value;
633 $alias = substr($key, 5);
634
636
638 return $result;
639 }
640
641 $alias = $aliases->addAlias($type_uri, $alias);
642
643 if ($alias === null) {
644 return new Auth_OpenID_AX_Error(
645 sprintf("Could not add alias %s for URI %s",
646 $alias, $type_uri)
647 );
648 }
649 }
650 }
651
652 foreach ($aliases->iteritems() as $pair) {
653 list($type_uri, $alias) = $pair;
654
655 if (array_key_exists('count.' . $alias, $ax_args) && ($ax_args['count.' . $alias] !== Auth_OpenID_AX_UNLIMITED_VALUES)) {
656
657 $count_key = 'count.' . $alias;
658 $count_s = $ax_args[$count_key];
659
660 $count = Auth_OpenID::intval($count_s);
661
662 if ($count === false) {
663 return new Auth_OpenID_AX_Error(
664 sprintf("Integer value expected for %s, got %s",
665 'count. %s' . $alias, $count_s,
667 );
668 }
669
670 $values = array();
671 for ($i = 1; $i < $count + 1; $i++) {
672 $value_key = sprintf('value.%s.%d', $alias, $i);
673
674 if (!array_key_exists($value_key, $ax_args)) {
675 return new Auth_OpenID_AX_Error(
676 sprintf(
677 "No value found for key %s",
678 $value_key));
679 }
680
681 $value = $ax_args[$value_key];
682 $values[] = $value;
683 }
684 } else {
685 $key = 'value.' . $alias;
686
687 if (!array_key_exists($key, $ax_args)) {
688 return new Auth_OpenID_AX_Error(
689 sprintf(
690 "No value found for key %s",
691 $key));
692 }
693
694 $value = $ax_args['value.' . $alias];
695
696 if ($value == '') {
697 $values = array();
698 } else {
699 $values = array($value);
700 }
701 }
702
703 $this->data[$type_uri] = $values;
704 }
705
706 return true;
const Auth_OpenID_AX_UNLIMITED_VALUES
Definition: AX.php:21
Auth_OpenID_AX_checkAlias($alias)
Check an alias for invalid characters; raise AXError if any are found.
Definition: AX.php:50
$result
_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 isError($thing)
Definition: AX.php:40
static intval($value)
Replacement (wrapper) for PHP's intval() because it's broken.
Definition: OpenID.php:444

◆ setValues()

Auth_OpenID_AX_KeyValueMessage::setValues (   $type_uri,
$values 
)

Set the values for the given attribute type.

This replaces any values that have already been set for this attribute.

Parameters
type_uriThe URI for the attribute
valuesA list of values to send for this attribute.

Definition at line 575 of file AX.php.

577 {
578 $this->data[$type_uri] =& $values;

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