Example #1
0
	/**
	 * Sign an {@link Auth_OpenID_ServerResponse} and return an
	 * {@link Auth_OpenID_WebResponse}.
	 */
	function encode(&$response)
	{
		// the isinstance is a bit of a kludge... it means there isn't
		// really an adapter to make the interfaces quite match.
		if (!is_a($response, 'Auth_OpenID_ServerError') &&
		$response->needsSigning()) {

			if (!$this->signatory) {
				return new Auth_OpenID_ServerError(null,
                                       "Must have a store to sign request");
			}

			if ($response->fields->hasKey(Auth_OpenID_OPENID_NS, 'sig')) {
				return new Auth_OpenID_AlreadySigned($response);
			}
			$response = $this->signatory->sign($response);
		}

		return parent::encode($response);
	}