ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
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.
 setValues ($type_uri, &$values)
 Set the values for the given attribute type.
 _getExtensionKVArgs ($aliases)
 Get the extension arguments for the key/value pairs contained in this message.
 parseExtensionArgs ($ax_args)
 Parse attribute exchange key/value arguments into this object.
 getSingle ($type_uri, $default=null)
 Get a single value for an attribute.
 get ($type_uri)
 Get the list of values for this attribute in the fetch_response.
 count ($type_uri)
 Get the number of responses for a particular attribute in this fetch_response message.
- 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.
 _newArgs ()
 Return a set of attribute exchange arguments containing the basic information that must be in every attribute exchange message.
- Public Member Functions inherited from Auth_OpenID_Extension
 getExtensionArgs ()
 Get the string arguments that should be added to an OpenID message for this extension.
 toMessage ($message)
 Add the arguments from this extension to the provided message.

Additional Inherited Members

- Data Fields inherited from Auth_OpenID_AX_Message
 $ns_alias = 'ax'
 ns_alias: The preferred namespace alias for attribute exchange messages
 $mode = null
 mode: The type of this attribute exchange message.
 $ns_uri = Auth_OpenID_AX_NS_URI

Detailed Description

Definition at line 540 of file AX.php.

Member Function Documentation

Auth_OpenID_AX_KeyValueMessage::_getExtensionKVArgs (   $aliases)

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

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

private

Definition at line 589 of file AX.php.

{
if ($aliases === null) {
}
$ax_args = array();
foreach ($this->data as $type_uri => $values) {
$alias = $aliases->add($type_uri);
$ax_args['type.' . $alias] = $type_uri;
$ax_args['count.' . $alias] = strval(count($values));
foreach ($values as $i => $value) {
$key = sprintf('value.%s.%d', $alias, $i + 1);
$ax_args[$key] = $value;
}
}
return $ax_args;
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_uri,:The URI for the attribute
value,:The value to add to the response to the relying party for this attribute
Returns
null

Definition at line 558 of file AX.php.

{
if (!array_key_exists($type_uri, $this->data)) {
$this->data[$type_uri] = array();
}
$values =& $this->data[$type_uri];
$values[] = $value;
Auth_OpenID_AX_KeyValueMessage::Auth_OpenID_AX_KeyValueMessage ( )

Definition at line 542 of file AX.php.

Referenced by Auth_OpenID_AX_FetchResponse\Auth_OpenID_AX_FetchResponse().

{
$this->data = array();

+ Here is the caller graph for this function:

Auth_OpenID_AX_KeyValueMessage::count (   $type_uri)

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

Parameters
type_uri,:The 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.

{
if (array_key_exists($type_uri, $this->data)) {
return count($this->get($type_uri));
} else {
sprintf("Type URI %s not found in response",
$type_uri)
);
}
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_uri,:The 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.

{
if (array_key_exists($type_uri, $this->data)) {
return $this->data[$type_uri];
} else {
sprintf("Type URI %s not found in response",
$type_uri)
);
}
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_uri,:The URI for the attribute
default,:The 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.

{
$values = Auth_OpenID::arrayGet($this->data, $type_uri);
if (!$values) {
return $default;
} else if (count($values) == 1) {
return $values[0];
} else {
sprintf('More than one value present for %s',
$type_uri)
);
}
Auth_OpenID_AX_KeyValueMessage::parseExtensionArgs (   $ax_args)

Parse attribute exchange key/value arguments into this object.

Parameters
ax_args,:The 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.

{
$result = $this->_checkMode($ax_args);
return $result;
}
foreach ($ax_args as $key => $value) {
if (strpos($key, 'type.') === 0) {
$type_uri = $value;
$alias = substr($key, 5);
return $result;
}
$alias = $aliases->addAlias($type_uri, $alias);
if ($alias === null) {
sprintf("Could not add alias %s for URI %s",
$alias, $type_uri)
);
}
}
}
foreach ($aliases->iteritems() as $pair) {
list($type_uri, $alias) = $pair;
if (array_key_exists('count.' . $alias, $ax_args) && ($ax_args['count.' . $alias] !== Auth_OpenID_AX_UNLIMITED_VALUES)) {
$count_key = 'count.' . $alias;
$count_s = $ax_args[$count_key];
$count = Auth_OpenID::intval($count_s);
if ($count === false) {
sprintf("Integer value expected for %s, got %s",
'count. %s' . $alias, $count_s,
);
}
$values = array();
for ($i = 1; $i < $count + 1; $i++) {
$value_key = sprintf('value.%s.%d', $alias, $i);
if (!array_key_exists($value_key, $ax_args)) {
sprintf(
"No value found for key %s",
$value_key));
}
$value = $ax_args[$value_key];
$values[] = $value;
}
} else {
$key = 'value.' . $alias;
if (!array_key_exists($key, $ax_args)) {
sprintf(
"No value found for key %s",
$key));
}
$value = $ax_args['value.' . $alias];
if ($value == '') {
$values = array();
} else {
$values = array($value);
}
}
$this->data[$type_uri] = $values;
}
return true;
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_uri,:The URI for the attribute
values,:A list of values to send for this attribute.

Definition at line 575 of file AX.php.

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

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