ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
Auth_OpenID_Message Class Reference
+ Collaboration diagram for Auth_OpenID_Message:

Public Member Functions

 Auth_OpenID_Message ($openid_namespace=null)
 isOpenID1 ()
 isOpenID2 ()
 _fromOpenIDArgs ($openid_args)
 private
 _getDefaultNamespace ($mystery_alias)
 setOpenIDNamespace ($openid_ns_uri, $implicit)
 getOpenIDNamespace ()
 copy ()
 toPostArgs ()
 toArgs ()
 toFormMarkup ($action_url, $form_tag_attrs=null, $submit_text="Continue")
 toURL ($base_url)
 toKVForm ()
 toURLEncoded ()
 _fixNS ($namespace)
 private
 hasKey ($namespace, $ns_key)
 getKey ($namespace, $ns_key)
 getArg ($namespace, $key, $default=null)
 getArgs ($namespace)
 updateArgs ($namespace, $updates)
 setArg ($namespace, $key, $value)
 delArg ($namespace, $key)
 getAliasedArg ($aliased_key, $default=null)

Static Public Member Functions

static fromPostArgs ($args)
static fromOpenIDArgs ($openid_args)
static fromKVForm ($kvform_string)

Detailed Description

Definition at line 414 of file Message.php.

Member Function Documentation

Auth_OpenID_Message::_fixNS (   $namespace)

private

Definition at line 728 of file Message.php.

Referenced by delArg(), getArg(), getArgs(), getKey(), hasKey(), setArg(), and updateArgs().

{
// Convert an input value into the internally used values of
// this object
if ($this->_openid_ns_uri === null) {
return new Auth_OpenID_FailureResponse(null,
'OpenID namespace not set');
} else {
$namespace = $this->_openid_ns_uri;
}
}
(!is_string($namespace))) {
//TypeError
$err_msg = sprintf("Namespace must be Auth_OpenID_BARE_NS, ".
"Auth_OpenID_OPENID_NS or a string. got %s",
print_r($namespace, true));
return new Auth_OpenID_FailureResponse(null, $err_msg);
}
(strpos($namespace, ':') === false)) {
// fmt = 'OpenID 2.0 namespace identifiers SHOULD be URIs. Got %r'
// warnings.warn(fmt % (namespace,), DeprecationWarning)
if ($namespace == 'sreg') {
// fmt = 'Using %r instead of "sreg" as namespace'
// warnings.warn(fmt % (SREG_URI,), DeprecationWarning,)
}
}
return $namespace;

+ Here is the caller graph for this function:

Auth_OpenID_Message::_fromOpenIDArgs (   $openid_args)

private

Definition at line 495 of file Message.php.

{
// Takes an Auth_OpenID_Mapping instance OR an array.
if (!Auth_OpenID_Mapping::isA($openid_args)) {
$openid_args = new Auth_OpenID_Mapping($openid_args);
}
$ns_args = array();
// Resolve namespaces
foreach ($openid_args->items() as $pair) {
list($rest, $value) = $pair;
$parts = explode('.', $rest, 2);
if (count($parts) == 2) {
list($ns_alias, $ns_key) = $parts;
} else {
$ns_key = $rest;
}
if ($ns_alias == 'ns') {
if ($this->namespaces->addAlias($value, $ns_key) === null) {
return false;
}
} else if (($ns_alias == Auth_OpenID_NULL_NAMESPACE) &&
($ns_key == 'ns')) {
// null namespace
if ($this->setOpenIDNamespace($value, false) === false) {
return false;
}
} else {
$ns_args[] = array($ns_alias, $ns_key, $value);
}
}
if (!$this->getOpenIDNamespace()) {
false) {
return false;
}
}
// Actually put the pairs into the appropriate namespaces
foreach ($ns_args as $triple) {
list($ns_alias, $ns_key, $value) = $triple;
$ns_uri = $this->namespaces->getNamespaceURI($ns_alias);
if ($ns_uri === null) {
$ns_uri = $this->_getDefaultNamespace($ns_alias);
if ($ns_uri === null) {
$ns_key = sprintf('%s.%s', $ns_alias, $ns_key);
} else {
$this->namespaces->addAlias($ns_uri, $ns_alias, true);
}
}
$this->setArg($ns_uri, $ns_key, $value);
}
return true;
Auth_OpenID_Message::_getDefaultNamespace (   $mystery_alias)

Definition at line 563 of file Message.php.

References $Auth_OpenID_registered_aliases, and isOpenID1().

{
if ($this->isOpenID1()) {
return @$Auth_OpenID_registered_aliases[$mystery_alias];
}
return null;

+ Here is the call graph for this function:

Auth_OpenID_Message::Auth_OpenID_Message (   $openid_namespace = null)

Definition at line 416 of file Message.php.

References Auth_OpenID_isOpenID1(), Auth_OpenID_OPENID1_NS, Auth_OpenID_OPENID2_NS, Auth_OpenID_THE_OTHER_OPENID1_NS, and setOpenIDNamespace().

Referenced by fromOpenIDArgs(), and fromPostArgs().

{
// Create an empty Message
$this->allowed_openid_namespaces = array(
$this->args = new Auth_OpenID_Mapping();
$this->namespaces = new Auth_OpenID_NamespaceMap();
if ($openid_namespace === null) {
$this->_openid_ns_uri = null;
} else {
$implicit = Auth_OpenID_isOpenID1($openid_namespace);
$this->setOpenIDNamespace($openid_namespace, $implicit);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_OpenID_Message::copy ( )

Definition at line 603 of file Message.php.

{
return $this;
Auth_OpenID_Message::delArg (   $namespace,
  $key 
)

Definition at line 876 of file Message.php.

References $namespace, _fixNS(), and Auth_OpenID\isFailure().

{
return $namespace;
} else {
return $this->args->del(array($namespace, $key));
}

+ Here is the call graph for this function:

static Auth_OpenID_Message::fromKVForm (   $kvform_string)
static

Definition at line 596 of file Message.php.

References fromOpenIDArgs(), and Auth_OpenID_KVForm\toArray().

Referenced by Auth_OpenID_GenericConsumer\_httpResponseToMessage().

{
// Create a Message from a KVForm string
Auth_OpenID_KVForm::toArray($kvform_string));

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static Auth_OpenID_Message::fromOpenIDArgs (   $openid_args)
static

Definition at line 479 of file Message.php.

References Auth_OpenID_Message().

Referenced by Auth_OpenID_GenericConsumer\_createAssociateRequest(), and fromKVForm().

{
// Takes an array.
// Construct a Message from a parsed KVForm message
$obj = new Auth_OpenID_Message();
if ($obj->_fromOpenIDArgs($openid_args)) {
return $obj;
} else {
return null;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static Auth_OpenID_Message::fromPostArgs (   $args)
static

Definition at line 444 of file Message.php.

References $rest, Auth_OpenID_BARE_NS, and Auth_OpenID_Message().

Referenced by Auth_OpenID_GenericConsumer\_verifyReturnToArgs(), Auth_OpenID_Consumer\complete(), and Auth_OpenID_Decoder\decode().

{
// Construct a Message containing a set of POST arguments
$obj = new Auth_OpenID_Message();
// Partition into "openid." args and bare args
$openid_args = array();
foreach ($args as $key => $value) {
if (is_array($value)) {
return null;
}
$parts = explode('.', $key, 2);
if (count($parts) == 2) {
list($prefix, $rest) = $parts;
} else {
$prefix = null;
}
if ($prefix != 'openid') {
$obj->args->set(array(Auth_OpenID_BARE_NS, $key), $value);
} else {
$openid_args[$rest] = $value;
}
}
if ($obj->_fromOpenIDArgs($openid_args)) {
return $obj;
} else {
return null;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_OpenID_Message::getAliasedArg (   $aliased_key,
  $default = null 
)

Definition at line 887 of file Message.php.

References getArg(), and getOpenIDNamespace().

{
if ($aliased_key == 'ns') {
// Return the namespace URI for the OpenID namespace
return $this->getOpenIDNamespace();
}
$parts = explode('.', $aliased_key, 2);
if (count($parts) != 2) {
$ns = null;
} else {
list($alias, $key) = $parts;
if ($alias == 'ns') {
// Return the namespace URI for a namespace alias
// parameter.
return $this->namespaces->getNamespaceURI($key);
} else {
$ns = $this->namespaces->getNamespaceURI($alias);
}
}
if ($ns === null) {
$key = $aliased_key;
$ns = $this->getOpenIDNamespace();
}
return $this->getArg($ns, $key, $default);

+ Here is the call graph for this function:

Auth_OpenID_Message::getArg (   $namespace,
  $key,
  $default = null 
)

Definition at line 804 of file Message.php.

References $namespace, _fixNS(), Auth_OpenID_NO_DEFAULT, and Auth_OpenID\isFailure().

Referenced by getAliasedArg().

{
// Get a value for a namespaced key.
return $namespace;
} else {
if ((!$this->args->contains(array($namespace, $key))) &&
($default == Auth_OpenID_NO_DEFAULT)) {
$err_msg = sprintf("Namespace %s missing required field %s",
$namespace, $key);
return new Auth_OpenID_FailureResponse(null, $err_msg);
} else {
return $this->args->get(array($namespace, $key), $default);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_OpenID_Message::getArgs (   $namespace)

Definition at line 823 of file Message.php.

References $namespace, _fixNS(), and Auth_OpenID\isFailure().

{
// Get the arguments that are defined for this namespace URI
return $namespace;
} else {
$stuff = array();
foreach ($this->args->items() as $pair) {
list($key, $value) = $pair;
list($pair_ns, $ns_key) = $key;
if ($pair_ns == $namespace) {
$stuff[$ns_key] = $value;
}
}
return $stuff;
}

+ Here is the call graph for this function:

Auth_OpenID_Message::getKey (   $namespace,
  $ns_key 
)

Definition at line 777 of file Message.php.

References $namespace, _fixNS(), Auth_OpenID_BARE_NS, Auth_OpenID_NULL_NAMESPACE, and Auth_OpenID\isFailure().

Referenced by toPostArgs().

{
// Get the key for a particular namespaced argument
return $namespace;
}
return $ns_key;
}
$ns_alias = $this->namespaces->getAlias($namespace);
// No alias is defined, so no key can exist
if ($ns_alias === null) {
return null;
}
if ($ns_alias == Auth_OpenID_NULL_NAMESPACE) {
$tail = $ns_key;
} else {
$tail = sprintf('%s.%s', $ns_alias, $ns_key);
}
return 'openid.' . $tail;

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_OpenID_Message::getOpenIDNamespace ( )

Definition at line 591 of file Message.php.

Referenced by getAliasedArg(), isOpenID1(), and isOpenID2().

{
return $this->_openid_ns_uri;

+ Here is the caller graph for this function:

Auth_OpenID_Message::hasKey (   $namespace,
  $ns_key 
)

Definition at line 766 of file Message.php.

References $namespace, _fixNS(), and Auth_OpenID\isFailure().

{
// XXX log me
return false;
} else {
return $this->args->contains(array($namespace, $ns_key));
}

+ Here is the call graph for this function:

Auth_OpenID_Message::isOpenID1 ( )

Definition at line 434 of file Message.php.

References Auth_OpenID_isOpenID1(), and getOpenIDNamespace().

Referenced by _getDefaultNamespace().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_OpenID_Message::isOpenID2 ( )

Definition at line 439 of file Message.php.

References Auth_OpenID_OPENID2_NS, and getOpenIDNamespace().

+ Here is the call graph for this function:

Auth_OpenID_Message::setArg (   $namespace,
  $key,
  $value 
)

Definition at line 860 of file Message.php.

References $namespace, _fixNS(), Auth_OpenID_BARE_NS, and Auth_OpenID\isFailure().

Referenced by Auth_OpenID_CheckIDRequest\getCancelURL(), and updateArgs().

{
// Set a single argument in this namespace
return $namespace;
} else {
$this->args->set(array($namespace, $key), $value);
$this->namespaces->add($namespace);
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_OpenID_Message::setOpenIDNamespace (   $openid_ns_uri,
  $implicit 
)

Definition at line 572 of file Message.php.

References Auth_OpenID_NULL_NAMESPACE, and Auth_OpenID\log().

Referenced by Auth_OpenID_Message().

{
if (!in_array($openid_ns_uri, $this->allowed_openid_namespaces)) {
Auth_OpenID::log('Invalid null namespace: "%s"', $openid_ns_uri);
return false;
}
$succeeded = $this->namespaces->addAlias($openid_ns_uri,
$implicit);
if ($succeeded === false) {
return false;
}
$this->_openid_ns_uri = $openid_ns_uri;
return true;

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_OpenID_Message::toArgs ( )

Definition at line 639 of file Message.php.

References toPostArgs().

Referenced by toKVForm().

{
// Return all namespaced arguments, failing if any
// non-namespaced arguments exist.
$post_args = $this->toPostArgs();
$kvargs = array();
foreach ($post_args as $k => $v) {
if (strpos($k, 'openid.') !== 0) {
// raise ValueError(
// 'This message can only be encoded as a POST, because it '
// 'contains arguments that are not prefixed with "openid."')
return null;
} else {
$kvargs[substr($k, 7)] = $v;
}
}
return $kvargs;

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_OpenID_Message::toFormMarkup (   $action_url,
  $form_tag_attrs = null,
  $submit_text = "Continue" 
)

Definition at line 659 of file Message.php.

References toPostArgs().

{
$form = "<form accept-charset=\"UTF-8\" ".
"enctype=\"application/x-www-form-urlencoded\"";
if (!$form_tag_attrs) {
$form_tag_attrs = array();
}
$form_tag_attrs['action'] = $action_url;
$form_tag_attrs['method'] = 'post';
unset($form_tag_attrs['enctype']);
unset($form_tag_attrs['accept-charset']);
if ($form_tag_attrs) {
foreach ($form_tag_attrs as $name => $attr) {
$form .= sprintf(" %s=\"%s\"", $name, $attr);
}
}
$form .= ">\n";
foreach ($this->toPostArgs() as $name => $value) {
$form .= sprintf(
"<input type=\"hidden\" name=\"%s\" value=\"%s\" />\n",
$name, $value);
}
$form .= sprintf("<input type=\"submit\" value=\"%s\" />\n",
$submit_text);
$form .= "</form>\n";
return $form;

+ Here is the call graph for this function:

Auth_OpenID_Message::toKVForm ( )

Definition at line 704 of file Message.php.

References Auth_OpenID_KVForm\fromArray(), and toArgs().

{
// Generate a KVForm string that contains the parameters in
// this message. This will fail if the message contains
// arguments outside of the 'openid.' prefix.

+ Here is the call graph for this function:

Auth_OpenID_Message::toPostArgs ( )

Definition at line 608 of file Message.php.

References Auth_OpenID_NULL_NAMESPACE, and getKey().

Referenced by toArgs(), toFormMarkup(), toURL(), and toURLEncoded().

{
// Return all arguments with openid. in front of namespaced
// arguments.
$args = array();
// Add namespace definitions to the output
foreach ($this->namespaces->iteritems() as $pair) {
list($ns_uri, $alias) = $pair;
if ($this->namespaces->isImplicit($ns_uri)) {
continue;
}
if ($alias == Auth_OpenID_NULL_NAMESPACE) {
$ns_key = 'openid.ns';
} else {
$ns_key = 'openid.ns.' . $alias;
}
$args[$ns_key] = $ns_uri;
}
foreach ($this->args->items() as $pair) {
list($ns_parts, $value) = $pair;
list($ns_uri, $ns_key) = $ns_parts;
$key = $this->getKey($ns_uri, $ns_key);
$args[$key] = $value;
}
return $args;

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_OpenID_Message::toURL (   $base_url)

Definition at line 697 of file Message.php.

References Auth_OpenID\appendArgs(), and toPostArgs().

{
// Generate a GET URL with the parameters in this message
// attached as query parameters.
return Auth_OpenID::appendArgs($base_url, $this->toPostArgs());

+ Here is the call graph for this function:

Auth_OpenID_Message::toURLEncoded ( )

Definition at line 712 of file Message.php.

References Auth_OpenID\httpBuildQuery(), and toPostArgs().

{
// Generate an x-www-urlencoded string
$args = array();
foreach ($this->toPostArgs() as $k => $v) {
$args[] = array($k, $v);
}
sort($args);

+ Here is the call graph for this function:

Auth_OpenID_Message::updateArgs (   $namespace,
  $updates 
)

Definition at line 844 of file Message.php.

References $namespace, _fixNS(), Auth_OpenID\isFailure(), and setArg().

Referenced by Auth_OpenID_CheckIDRequest\encodeToURL().

{
// Set multiple key/value pairs in one call
return $namespace;
} else {
foreach ($updates as $k => $v) {
$this->setArg($namespace, $k, $v);
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


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