Esempio n. 1
0
 /**
  * constructor.
  * @param array $config optional key/value pairs in an associative array. Used to override default configuration values.
  */
 public function  __construct(array $config = null) {
     $filterManager = FilterManager::getInstance();
     $filterManager->addFilter(ServiceRouter::FILTER_SERVICE_OBJECT, $this, "filterServiceObject");
     $filterManager->addFilter(AmfHandler::FILTER_AMF_REQUEST_HEADER_HANDLER, $this, "filterAmfRequestHeaderHandler");
     $this->headerUserId = null;
     $this->headerPassword = null;
 }
Esempio n. 2
0
 /**
  * constructor.
  * @param array $config optional key/value pairs in an associative array. Used to override default configuration values.
  */
 public function  __construct(array $config = null) {
     $filterManager = FilterManager::getInstance();
     $filterManager->addFilter(Gateway::FILTER_SERIALIZED_REQUEST, $this, "filterSerializedRequest");
     $filterManager->addFilter(Gateway::FILTER_DESERIALIZED_REQUEST, $this, "filterDeserializedRequest");
     $filterManager->addFilter(Gateway::FILTER_DESERIALIZED_RESPONSE, $this, "filterDeserializedResponse");
     $filterManager->addFilter(Gateway::FILTER_SERIALIZED_RESPONSE, $this, "filterSerializedResponse");
 }
Esempio n. 3
0
	/**
	 * constructor. Add filters on the HookManager.
	 * @param array $config optional key/value pairs in an associative array. Used to override default configuration values.
	 */
	public function  __construct(array $config = null) {
		$filterManager = FilterManager::getInstance();
		$filterManager->addFilter(Gateway::FILTER_DESERIALIZER, $this, "filterHandler");
		$filterManager->addFilter(Gateway::FILTER_DESERIALIZED_REQUEST_HANDLER, $this, "filterHandler");
		$filterManager->addFilter(Gateway::FILTER_EXCEPTION_HANDLER, $this, "filterHandler");
		$filterManager->addFilter(Gateway::FILTER_SERIALIZER, $this, "filterHandler");
		$filterManager->addFilter(Gateway::FILTER_HEADERS, $this, "filterHeaders");
	}
 /**
  * constructor.
  * @param array $config optional key/value pairs in an associative array. Used to override default configuration values.
  */
 public function  __construct(array $config = null) {
     //default
     $this->customClassFolderPaths = array(AMFPHP_ROOTPATH . "/Services/Vo/");
     if($config){
         if(isset($config["customClassFolderPaths"])){
             $this->customClassFolderPaths = $config["customClassFolderPaths"];
         }
     }
     $filterManager = FilterManager::getInstance();
     $filterManager->addFilter(Gateway::FILTER_DESERIALIZED_REQUEST, $this, "filterDeserializedRequest");
     $filterManager->addFilter(Gateway::FILTER_DESERIALIZED_RESPONSE, $this, "filterDeserializedResponse");
 }
Esempio n. 5
0
 /**
  * constructor.
  * @param array $config optional key/value pairs in an associative array. Used to override default configuration values.
  */
 public function  __construct(array $config = null) {
     FilterManager::getInstance()->addFilter(AmfHandler::FILTER_AMF_REQUEST_MESSAGE_HANDLER, $this, "filterAmfRequestMessageHandler");
     FilterManager::getInstance()->addFilter(AmfHandler::FILTER_AMF_EXCEPTION_HANDLER, $this, "filterAmfExceptionHandler");
     $this->clientUsesFlexMessaging = false;
 }
Esempio n. 6
0
    /**
     * get the response headers. Creates an associative array of headers, then filters them, then returns an array of strings
     * 
	 * @return array
     */
    public function getResponseHeaders(){        
        $filterManager = FilterManager::getInstance();
        $headers = array("Content-Type" => $this->contentType);
        $headers = $filterManager->callFilters(self::FILTER_HEADERS, $headers, $this->contentType);
        $ret = array();
        foreach($headers as $key => $value){
            $ret[] = $key . ": " . $value;
        }
        return $ret;
    }
Esempio n. 7
0
    /**
	 * Loads and instanciates a service class matching $serviceName, then calls the function defined by $methodName using $parameters as parameters
     * throws an exception if service not found.
     * if the service exists but not the function, an exception is thrown by call_user_func_array. It is pretty explicit, so no furher code was added
     *
     * @param string $serviceName
     * @param string $methodName
     * @param array $parameters
     * 
     * @return mixed the result of the function call
     *
     */
    public function executeServiceCall($serviceName, $methodName, array $parameters){
        $serviceObject = $this->getServiceObject($serviceName);
        $serviceObject = FilterManager::getInstance()->callFilters(self::FILTER_SERVICE_OBJECT, $serviceObject, $serviceName, $methodName);

        if(!method_exists($serviceObject, $methodName)){
            throw new RemotingException("method $methodName not found on $serviceName object ");
        }

        return call_user_func_array(array($serviceObject, $methodName), $parameters);

    }
Esempio n. 8
0
    /**
     * constructor.
     * @param array $config optional key/value pairs in an associative array. Used to override default configuration values.
     */
    public function  __construct(array $config = null) {
        //defaults
        $this->clientCharset = "utf-8";
        $this->phpCharset = "utf-8";
        $this->method = self::METHOD_NONE;
        if($config){
            if(isset ($config["clientCharset"])){
                $this->clientCharset = $config["clientCharset"];
            }
            if(isset ($config["phpCharset"])){
                $this->phpCharset = $config["phpCharset"];
            }
            if(isset ($config["method"])){
                $this->method = $config["method"];
            }
        }

        //only add filters if conversion is necessary
        if($this->method == self::METHOD_NONE){
            return;
        }
        if($this->clientCharset == $this->phpCharset){
            return;
        }
        $filterManager = FilterManager::getInstance();
        $filterManager->addFilter(Gateway::FILTER_DESERIALIZED_REQUEST, $this, "filterDeserializedRequest");
        $filterManager->addFilter(Gateway::FILTER_DESERIALIZED_RESPONSE, $this, "filterDeserializedResponse");
    }
Esempio n. 9
0
	/**
	 * @see IExceptionHandler
	 */
	public function handleException(Exception $exception){
		$errorPacket = new AmfPacket();
		$filterManager = FilterManager::getInstance();
		$fromFilters = $filterManager->callFilters(self::FILTER_AMF_EXCEPTION_HANDLER, null);
		if($fromFilters){
			$handler = $fromFilters;
			return $handler->generateErrorResponse($exception);
		}

		//no special handling by plugins. generate a simple error response with information about the exception
		$errorResponseMessage = null;
		$errorResponseMessage = new AmfMessage();
		$errorResponseMessage->targetUri = $this->lastRequestMessageResponseUri . AmfConstants::CLIENT_FAILURE_METHOD;
		//not specified
		$errorResponseMessage->responseUri = "null";
		$errorResponseMessage->data = new stdClass();
		$errorResponseMessage->data->faultCode = $exception->getCode();
		$errorResponseMessage->data->faultString = $exception->getMessage();
		
		$details = $exception->getTraceAsString();
		// localizes the paths of the stack-trace.
		if(defined(WEB_ROOT)){
			$details = str_replace(WEB_ROOT, "", $details);	
		}
		$errorResponseMessage->data->faultDetail = $details;

		$errorPacket->messages[] = $errorResponseMessage;
		return $errorPacket;
		
	}