/** * Create exception from Yadis response * * Creates an exception from a passed yadis result. * * @param string $request_uri The target URI for the failed * request * @param Auth_Yadis_HTTPResponse $result The result of the failed * request * * @return OMB_RemoteServiceException A new exception */ public static function fromYadis($request_uri, $result) { if ($result->status == 200) { $err = 'Got wrong response ' . $result->body; } else { $err = 'Got error code ' . $result->status . ' with response ' . $result->body; } return OMB_RemoteServiceException::forRequest($request_uri, $err); }
/** * Handle an OMB request * * Performs common OMB request handling. * * @param string $uri The URI defining the OMB endpoint being served * * @access protected * * @return array(OAuthRequest, OMB_Profile) */ protected function handleOMBRequest($uri) { OMB_Helper::removeMagicQuotesFromRequest(); $req = OAuthRequest::from_request('POST'); $listenee = $req->get_parameter('omb_listenee'); try { list($consumer, $token) = $this->getOAuthServer()->verify_request($req); } catch (OAuthException $e) { header('HTTP/1.1 403 Forbidden'); throw OMB_RemoteServiceException::forRequest($uri, 'Revoked accesstoken for ' . $listenee); } $version = $req->get_parameter('omb_version'); if ($version !== OMB_VERSION) { header('HTTP/1.1 400 Bad Request'); throw OMB_RemoteServiceException::forRequest($uri, 'Wrong OMB version ' . $version); } $profile = $this->datastore->getProfile($listenee); if (is_null($profile)) { header('HTTP/1.1 400 Bad Request'); throw OMB_RemoteServiceException::forRequest($uri, 'Unknown remote profile ' . $listenee); } $subscribers = $this->datastore->getSubscriptions($listenee); if (count($subscribers) === 0) { header('HTTP/1.1 403 Forbidden'); throw OMB_RemoteServiceException::forRequest($uri, 'No subscriber for ' . $listenee); } return array($req, $profile); }