protected function isMethodAvailable($requestObject)
 {
     $ownerService = parent::isMethodAvailable($requestObject);
     if ($ownerService->isAuthenticationRequired($requestObject, $ownerService)) {
         if ($this->isAuthenticatedRequest()) {
             return $ownerService;
         } else {
             throw new Exception("Authentication required");
         }
     } else {
         return $ownerService;
     }
 }
예제 #2
0
<?php

include '../JsonRpcException.php';
include '../JsonRpcServer.php';
include 'MathService.php';
include 'DataService.php';
include 'OptionalParamsService.php';
function verifyAPI($auth)
{
    if (empty($auth)) {
        throw new JsonRpcMissingAuthException();
    }
    if ($auth == "qIQlg9S28mbK2Iolm8yffr97Yp6zMxiF") {
        return true;
    }
    throw new JsonRpcInvalidAuthException();
}
$math = new MathService();
$data = new DataService();
$optional = new OptionalParamsService();
$server = new JsonRpcServer("verifyAPI");
// Callable to the verification routine above
$server->addService($math);
$server->addService($data);
$server->addService($optional);
$request = file_get_contents("php://input");
$result = $server->process($request);
if ($result !== null) {
    echo $result;
}
 function Send()
 {
     $objRPCServer = new JsonRpcServer(file_get_contents("php://input"));
     eval('$objRPCServer->addService(new ' . ucfirst(Dispatcher::Instance()->mAction) . ucfirst(Dispatcher::Instance()->mSubModule) . '());');
     $objRPCServer->processingRequests();
 }
예제 #4
0
파일: jsonrpc.php 프로젝트: horrabin/opendb
require_once "./include/begin.inc.php";
include_once "./lib/JsonRpcServer.class.php";
// TODO - enable a plugin layer
include_once "./lib/jsonrpc/ItemSearch.class.php";
function request_http_basic_auth()
{
    header('WWW-Authenticate: Basic realm="' . htmlspecialchars(get_opendb_title()) . '"');
    header('HTTP/1.0 401 Unauthorized');
}
if (is_site_enabled()) {
    if (!isset($_SERVER['PHP_AUTH_USER'])) {
        request_http_basic_auth();
    } else {
        $userId = $_SERVER['PHP_AUTH_USER'];
        $password = $_SERVER['PHP_AUTH_PW'];
        if (is_user_active($userId) && validate_user_passwd($userId, $password)) {
            $server = new JsonRpcServer();
            // TODO - currently no role based permissions are being performed for these services.
            $server->registerClass(new ItemSearch());
            $server->handle();
        } else {
            request_http_basic_auth();
        }
    }
} else {
    header('HTTP/1.0 503 Service Unavailable');
    echo "<h1>" . get_opendb_lang_var('site_is_disabled') . "</h1>";
    echo get_opendb_lang_var('site_is_disabled');
}
// Cleanup after begin.inc.php
require_once "./include/end.inc.php";
 /**
  * Constructor. Takes the jsonrpc request string as argument
  * @param $jsonrpcRequest
  * @return unknown_type
  */
 function __construct($jsonrpcRequest)
 {
     $this->jsonrpcRequest = $jsonrpcRequest;
     parent::__construct();
 }
 /**
  * Starts a singleton instance of the server. Must be called statically.
  */
 public static function run()
 {
     $_this = JsonRpcServer::getInstance();
     $_this->start();
 }
예제 #7
0
/*
 * qooxdoo - the new era of web development
 *
 * http://qooxdoo.org
 *
 * Copyright:
 *   2006-2009 Derrell Lipman, Christian Boulanger
 *
 * License:
 *   LGPL: http://www.gnu.org/licenses/lgpl.html
 *   EPL: http://www.eclipse.org/org/documents/epl-v10.php
 *   See the LICENSE file in the project's top-level directory for details.
 *
 * Authors:
 *  * Derrell Lipman (derrell)
 *  * Christian Boulanger (cboulanger) Error-Handling and OO-style rewrite
 */
//
// This is the entry script for rpc requests
//
/*
 * set error level
 */
error_reporting(E_ALL ^ E_NOTICE);
/*
 * start jsonrpc server
 */
require dirname(__FILE__) . "/server/JsonRpcServer.php";
JsonRpcServer::run();