Auth_OpenID_Message::fromPostArgs PHP Method

fromPostArgs() static public method

static public fromPostArgs ( $args )
    static function fromPostArgs($args)
    {
        // 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;
        }
    }

Usage Example

Exemplo n.º 1
0
	/**
	 * Given an HTTP query in an array (key-value pairs), decode it
	 * into an Auth_OpenID_Request object.
	 */
	function decode($query)
	{
		if (!$query) {
			return null;
		}

		$message = Auth_OpenID_Message::fromPostArgs($query);

		if ($message === null) {
			/*
			 * It's useful to have a Message attached to a
			 * ProtocolError, so we override the bad ns value to build
			 * a Message out of it.  Kinda kludgy, since it's made of
			 * lies, but the parts that aren't lies are more useful
			 * than a 'None'.
			 */
			$old_ns = $query['openid.ns'];

			$query['openid.ns'] = Auth_OpenID_OPENID2_NS;
			$message = Auth_OpenID_Message::fromPostArgs($query);
			return new Auth_OpenID_ServerError(
			$message,
			sprintf("Invalid OpenID namespace URI: %s", $old_ns));
		}

		$mode = $message->getArg(Auth_OpenID_OPENID_NS, 'mode');
		if (!$mode) {
			return new Auth_OpenID_ServerError($message,
                                               "No mode value in message");
		}

		if (Auth_OpenID::isFailure($mode)) {
			return new Auth_OpenID_ServerError($message,
			$mode->message);
		}

		$handlerCls = Auth_OpenID::arrayGet($this->handlers, $mode,
		$this->defaultDecoder($message));

		if (!is_a($handlerCls, 'Auth_OpenID_ServerError')) {
			return call_user_func_array(array($handlerCls, 'fromMessage'),
			array($message, $this->server));
		} else {
			return $handlerCls;
		}
	}
All Usage Examples Of Auth_OpenID_Message::fromPostArgs