当前位置: 首页>>代码示例>>PHP>>正文


PHP Agent::checkSourceId方法代码示例

本文整理汇总了PHP中Agent::checkSourceId方法的典型用法代码示例。如果您正苦于以下问题:PHP Agent::checkSourceId方法的具体用法?PHP Agent::checkSourceId怎么用?PHP Agent::checkSourceId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Agent的用法示例。


在下文中一共展示了Agent::checkSourceId方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processEvent

 private function processEvent()
 {
     $dom = $this->dom;
     $headerNode = $dom->getElementsByTagName('SIF_Header')->item(0);
     $originalMsgId = $headerNode->getElementsByTagName('SIF_MsgId')->item(0)->nodeValue;
     $originalSourceId = $headerNode->getElementsByTagName('SIF_SourceId')->item(0)->nodeValue;
     $originalTimestamp = $headerNode->getElementsByTagName('SIF_Timestamp')->item(0)->nodeValue;
     $validSourceId = Agent::checkSourceId($originalSourceId);
     if (!$validSourceId) {
         RegisterError::invalidSourceId($agent->sourceId, $originalMsgId);
     } else {
         $agent = new Agent($originalSourceId);
         if ($agent->isRegistered()) {
             $eventObjectNode = $dom->getElementsByTagName('SIF_EventObject')->item(0);
             $objectName = $eventObjectNode->getAttribute('ObjectName');
             $objectAction = $eventObjectNode->getAttribute('Action');
             $objectAction = strtolower($objectAction);
             if (!DataObject::objectExists($objectName)) {
                 ProvisionError::invalidObject($originalSourceId, $originalMsgId, $objectName);
                 exit;
             } else {
                 $allowed = $this->hasPermission($objectName, $objectAction, $agent->agentId);
                 if ($allowed) {
                     $provider = DataObject::isProvider($objectName, $agent->agentId);
                     if ($provider) {
                         $this->publishEvent($agent->agentId, $objectName, $objectAction, $_SESSION['ZONE_VERSION'], $dom->saveXml($headerNode));
                         $timestamp = Utility::createTimestamp();
                         $msgId = Utility::createMessageId();
                         $sifMessageNode = $dom->getElementsByTagName('SIF_Message')->item(0);
                         XmlHelper::buildSuccessMessage($msgId, $timestamp, $originalSourceId, $originalMsgId, 0, $originalMsg = null, $desc = null);
                     } else {
                         ProvisionError::notProviderError($originalSourceId, $originalMsgId);
                     }
                 } else {
                     switch ($objectAction) {
                         case 'add':
                             ProvisionError::invalidPermissionToPublishAdd($originalSourceId, $originalMsgId, $objectName);
                             break;
                         case 'change':
                             ProvisionError::invalidPermissionToPublishChange($originalSourceId, $originalMsgId, $objectName);
                             break;
                         case 'delete':
                             ProvisionError::invalidPermissionToPublishDelete($originalSourceId, $originalMsgId, $objectName);
                             break;
                     }
                     //switch for error message
                 }
                 //allowed
             }
             //object exist
         } else {
             RegisterError::notRegisteredError($originalSourceId, $originalMsgId);
         }
         //not registered
     }
     //valid sourceId
 }
开发者ID:Koulio,项目名称:OpenZIS,代码行数:57,代码来源:Event2.php

示例2: processAck

 public function processAck($m)
 {
     $dom = $this->dom;
     $headerNode = $m->headerNode;
     $msgId = $m->msgId;
     $agentSourceId = $m->sourceId;
     #        $msgId           = $headerNode->getElementsByTagName('SIF_MsgId')->item(0)->nodeValue;
     #        $agentSourceId   = $headerNode->getElementsByTagName('SIF_SourceId')->item(0)->nodeValue;
     $originalMsgId = $dom->getElementsByTagName('SIF_OriginalMsgId')->item(0)->nodeValue;
     $timestamp = $headerNode->getElementsByTagName('SIF_Timestamp')->item(0)->nodeValue;
     $status = $dom->getElementsByTagName('SIF_Status');
     $status = $status->item(0)->nodeValue;
     $validSourceId = Agent::checkSourceId($agentSourceId);
     if (!$validSourceId) {
         RegisterError::invalidSourceId($agentSourceId, $msgId);
     } else {
         $agent = new Agent($agentSourceId);
         if ($agent->isRegistered()) {
             if ($status == 1) {
                 $agent->unFreezeAgent();
                 $this->updateMessageQueue($agent, $originalMsgId, $msgId);
             } else {
                 if ($status == 3) {
                     //done processing
                     if ($originalMsgId == $agent->frozenMsgId) {
                         $agent->unFreezeAgent();
                         $this->updateMessageQueue($agent, $originalMsgId, $msgId);
                     } else {
                         GeneralError::EventACKError($this->xml);
                     }
                 } else {
                     if ($status == 2) {
                         //Intermediate wait for final
                         $agent->freezeAgent();
                         $agent->setFrozenMsgId($originalMsgId);
                         $timestamp = Utility::createTimestamp();
                         $msgId_u = Utility::createMessageId();
                         XmlHelper::buildSuccessMessage($msgId_u, $timestamp, $agent->sourceId, $msgId, 0, $originalMsg = null, $desc = null);
                     }
                 }
             }
         } else {
             RegisterError::notRegisteredError($agentSourceId, $msgId);
         }
     }
 }
开发者ID:Koulio,项目名称:OpenZIS,代码行数:46,代码来源:Ack.php

示例3: processProvision

 private function processProvision()
 {
     $dom = $this->dom;
     $headerNode = $dom->getElementsByTagName('SIF_Header')->item(0);
     $this->originalMsgId = $headerNode->getElementsByTagName('SIF_MsgId')->item(0)->nodeValue;
     $this->originalSourceId = $headerNode->getElementsByTagName('SIF_SourceId')->item(0)->nodeValue;
     $this->originalTimestamp = $headerNode->getElementsByTagName('SIF_Timestamp')->item(0)->nodeValue;
     $validSourceId = Agent::checkSourceId($this->originalSourceId);
     if (!$validSourceId) {
         ProvisionError::invalidSourceId($this->originalSourceId, $this->originalMsgId);
         if (CODELEVEL != 3) {
             exit;
         } else {
             return false;
         }
     } else {
         $this->agent = new Agent($this->originalSourceId);
         if (!$this->agent->isRegistered()) {
             RegisterError::notRegisteredError($this->originalSourceId, $this->originalMsgId);
         } else {
             $provideObjectNode = $dom->getElementsByTagName('SIF_ProvideObjects')->item(0);
             $this->processProvideObjects($provideObjectNode);
             $subscribeObjectNode = $dom->getElementsByTagName('SIF_SubscribeObjects')->item(0);
             $this->processSubscribeObjects($subscribeObjectNode);
             $publishAddObjectNode = $dom->getElementsByTagName('SIF_PublishAddObjects')->item(0);
             $this->processPublishAddObjects($publishAddObjectNode);
             $publishChangeObjectNode = $dom->getElementsByTagName('SIF_PublishChangeObjects')->item(0);
             $this->processPublishChangeObjects($publishChangeObjectNode);
             $publishDeleteObjectNode = $dom->getElementsByTagName('SIF_PublishDeleteObjects')->item(0);
             $this->processPublishDeleteObjects($publishDeleteObjectNode);
             $requestObjectNode = $dom->getElementsByTagName('SIF_RequestObjects')->item(0);
             $this->processRequestObjects($requestObjectNode);
             $respondObjectNode = $dom->getElementsByTagName('SIF_RespondObjects')->item(0);
             $this->processRespondObjects($respondObjectNode);
             $this->saveProvisions();
             $timestamp = Utility::createTimestamp();
             $msgId = Utility::createMessageId();
             $sifMessageNode = $dom->getElementsByTagName('SIF_Message')->item(0);
             XmlHelper::buildSuccessMessage($msgId, $timestamp, $this->originalSourceId, $this->originalMsgId, 0, $originalMsg = null, $desc = null);
         }
     }
 }
开发者ID:Koulio,项目名称:OpenZIS,代码行数:42,代码来源:Provision.php

示例4: processUnregistration

 public function processUnregistration()
 {
     $dom = $this->xmlDom;
     $headerNode = $dom->getElementsByTagName('SIF_Header')->item(0);
     $originalMsgId = $headerNode->getElementsByTagName('SIF_MsgId')->item(0)->nodeValue;
     $originalSourceId = $headerNode->getElementsByTagName('SIF_SourceId')->item(0)->nodeValue;
     $originalTimestamp = $headerNode->getElementsByTagName('SIF_Timestamp')->item(0)->nodeValue;
     $validSourceId = Agent::checkSourceId($originalSourceId);
     if (!$validSourceId) {
         RegisterError::invalidSourceId($agent->sourceId, $originalMsgId);
     } else {
         $agent = new Agent($originalSourceId);
         if ($agent->isRegistered()) {
             if ($agent->unRegister()) {
                 XmlHelper::buildSuccessMessage(Utility::createMessageId(), Utility::createTimestamp(), $agent->sourceId, $originalMsgId, 0);
             } else {
                 RegisterError::genericError($agent->sourceId, $originalMsgId);
             }
         } else {
             RegisterError::notRegisteredError($originalSourceId, $originalMsgId);
         }
     }
 }
开发者ID:Koulio,项目名称:OpenZIS,代码行数:23,代码来源:UnRegister.php

示例5: processRegistration

 private function processRegistration()
 {
     $dom = $this->xmlDom;
     $headerNode = $dom->getElementsByTagName('SIF_Header')->item(0);
     $authenticationLevel = $originalMsgId = $headerNode->getElementsByTagName('SIF_MsgId')->item(0)->nodeValue;
     $originalSourceId = $headerNode->getElementsByTagName('SIF_SourceId')->item(0)->nodeValue;
     if ($headerNode->getElementsByTagName('SIF_Timestamp')->item(0)) {
         $originalTimestamp = $headerNode->getElementsByTagName('SIF_Timestamp')->item(0)->nodeValue;
     } else {
         $originalTimestamp = Utility::createTimestamp();
     }
     $version = $_SESSION['ZONE_VERSION'];
     $buffer = $dom->getElementsByTagName('SIF_MaxBufferSize')->item(0)->nodeValue;
     $mode = $dom->getElementsByTagName('SIF_Mode')->item(0)->nodeValue;
     if ($dom->getElementsByTagName('SIF_Protocol')->item(0)) {
         $protocolType = $dom->getElementsByTagName('SIF_Protocol')->item(0)->attributes->item(0)->nodeValue;
         $protocolSecure = $dom->getElementsByTagName('SIF_Protocol')->item(0)->attributes->item(1)->nodeValue;
     }
     if ($dom->getElementsByTagName('SIF_URL')->item(0)) {
         $callBackUrl = $dom->getElementsByTagName('SIF_URL')->item(0)->nodeValue;
     }
     $validSourceId = Agent::checkSourceId($originalSourceId);
     if (!$validSourceId) {
         RegisterError::invalidSourceId($agent->sourceId, $originalMsgId);
     } else {
         //create agent object
         $agent = new Agent($originalSourceId);
         if (!Agent::allowedToRegister($agent->agentId)) {
             RegisterError::genericError($agent->sourceId, $originalMsgId);
         } else {
             /*				if($version != ZIT::checkVersion($version)){
             					RegisterError::invalidVersion($agent->sourceId, $originalMsgId);
             				}
             				else{
             */
             if ($buffer < ZIT::getMinBuffer()) {
                 RegisterError::invalidMaxBuffer($agent->sourceId, $originalMsgId);
             } else {
                 $empty = null;
                 $agent->authenticationLevel = $this->getSecurityLevel();
                 $agent->maxBuffersize = $buffer;
                 $agent->protocol = isset($protocolType) ? $protocolType : $empty;
                 $agent->callBackUrl = isset($callBackUrl) ? urlencode($callBackUrl) : $empty;
                 $agent->agentMode = Agent::convertAgentMode(isset($mode) ? $mode : $empty);
                 $agent->secure = Agent::convertSecure(isset($protocolSecure) ? $protocolSecure : $empty);
                 $agent->version = $version;
                 if ($agent->isRegistered()) {
                     if ($agent->updateRegistration()) {
                         $this->createAclAckMessage($agent->sourceId, $originalMsgId);
                     } else {
                         RegisterError::genericError($agent->sourceId, $originalMsgId, 'Error Registering Agent at agent->updateRegistration()');
                     }
                     //try to update registration
                 } else {
                     if ($agent->register()) {
                         $this->createAclAckMessage($agent->sourceId, $originalMsgId);
                     } else {
                         RegisterError::genericError($agent->sourceId, $originalMsgId, 'Error Registering Agent at agent->register()');
                     }
                     //try to register
                 }
                 //check if agent is registered
             }
             //check if buffer size is valid
             //				}//check if version is valid
         }
         //check if agent allowed to register
     }
     //check if sourceId is valid
 }
开发者ID:neilberget,项目名称:OpenZIS,代码行数:70,代码来源:Register.php

示例6: processRequest

 private function processRequest($m)
 {
     $dom = $m->dom;
     $this->originalSourceId = $m->sourceId;
     $originalSourceId = $m->sourceId;
     $this->originalMsgId = $m->msgId;
     $originalMsgId = $m->msgId;
     $headerNode = $m->headerNode;
     $this->headerNode = $headerNode;
     $validSourceId = Agent::checkSourceId($originalSourceId);
     if (!$validSourceId) {
         RegisterError::invalidSourceId($agent->sourceId, $originalMsgId);
         exit;
     } else {
         $agent = new Agent($originalSourceId);
         if (!$agent->isRegistered()) {
             RegisterError::notRegisteredError($originalSourceId, $originalMsgId);
             exit;
         } else {
             $sentBufferSize = $dom->getElementsByTagName('SIF_MaxBufferSize')->item(0)->nodeValue;
             if (!Agent::bufferSizeAllowed($sentBufferSize, $agent->agentId)) {
                 $timestamp = Utility::createTimestamp();
                 $msgId = Utility::createMessageId();
                 XmlHelper::buildSuccessMessage($msgId, $timestamp, $this->originalSourceId, $this->originalMsgId, 0, $originalMsg = null, $desc = null);
             } else {
                 $messageNode = $dom->getElementsByTagName('SIF_Message');
                 $len = $messageNode->item(0)->childNodes->item(0)->childNodes->length - 1;
                 $Mode = $messageNode->item(0)->childNodes->item(0)->childNodes->item($len)->nodeName;
                 if ($Mode == 'SIF_Query') {
                     $sifObjectNode = $dom->getElementsByTagName('SIF_QueryObject')->item(0);
                     $objectName = $sifObjectNode->getAttribute('ObjectName');
                 } else {
                     $sifObjectNode = $dom->getElementsByTagName('SIF_From')->item(0);
                     $objectName = $sifObjectNode->getAttribute('ObjectName');
                 }
                 if (!DataObject::objectExists($objectName)) {
                     RequestError::invalidObject($originalSourceId, $originalMsgId, $objectName);
                     exit;
                 } else {
                     if (!DataObject::allowedToRequest($agent->agentId, $objectName)) {
                         ProvisionError::invalidPermissionToRequest($originalSourceId, $originalMsgId, $objectName);
                         exit;
                     } else {
                         $sifDestinationId = $dom->getElementsByTagName('SIF_DestinationId');
                         if ($sifDestinationId->length != 0) {
                             $sourceId = $sifDestinationId->item(0)->nodeValue;
                             if (!DataObject::validResponder($objectName, $sourceId)) {
                                 RequestError::invalidProvider($originalSourceId, $originalMsgId);
                             } else {
                                 $this->setupRequest($objectName, $sourceId, $agent);
                             }
                             //check if destination id is valid
                         } else {
                             $this->setupRequest($objectName, $sourceId = null, $agent);
                         }
                         //check if there is a destination id
                     }
                     //check if allowed to request
                 }
                 //check if allowed to request
             }
             //check object exist
         }
         //check if registered
     }
     //check sourceId
 }
开发者ID:neilberget,项目名称:OpenZIS,代码行数:67,代码来源:Request.php

示例7: processMessage

 public static function processMessage($xmlStr)
 {
     try {
         $dom = new DomDocument();
         /***
         			Make sure that preserve white space is off for the the DomDocument object.
         			WhiteSpaces interfers with parsing the xml
         			***/
         $dom->preserveWhiteSpace = false;
         $res = $dom->loadXML($xmlStr);
         $headerNode = $dom->getElementsByTagName('SIF_Header')->item(0);
         $sourceId = $headerNode->getElementsByTagName('SIF_SourceId')->item(0)->nodeValue;
         $originalMsgId = $headerNode->getElementsByTagName('SIF_MsgId')->item(0)->nodeValue;
         $validSourceId = Agent::checkSourceId($sourceId);
         if (!$validSourceId) {
             RegisterError::invalidSourceId($sourceId, $originalMsgId);
         }
         SifProcessRequest::authenticateAgent($sourceId);
         SifProcessRequest::checkIfZitIsSleeping($dom);
         SifProcessRequest::checkIfZoneIsSleeping($dom);
         $messageNode = $dom->getElementsByTagName('SIF_Message');
         $messageType = isset($messageNode->item(0)->childNodes->item(0)->nodeName) ? $messageNode->item(0)->childNodes->item(0)->nodeName : 'default';
         switch ($messageType) {
             case 'SIF_Register':
                 $_SESSION['SIF_MESSAGE_TYPE'] = 5;
                 $register = new Register($dom);
                 break;
             case 'SIF_Unregister':
                 $_SESSION['SIF_MESSAGE_TYPE'] = 18;
                 $unregister = new UnRegister($dom);
                 break;
             case 'SIF_Ack':
                 $_SESSION['SIF_MESSAGE_TYPE'] = 1;
                 $ack = new Ack($dom, $xmlStr);
                 break;
             case 'SIF_SystemControl':
                 $systemControl = new SystemControl($dom, $xmlStr);
                 break;
             case 'SIF_Provision':
                 $_SESSION['SIF_MESSAGE_TYPE'] = 4;
                 $provision = new Provision($dom);
                 break;
             case 'SIF_Event':
                 $_SESSION['SIF_MESSAGE_TYPE'] = 2;
                 $event = new Event($dom);
                 break;
             case 'SIF_Provide':
                 $_SESSION['SIF_MESSAGE_TYPE'] = 3;
                 $provide = new Provide($dom);
                 break;
             case 'SIF_Unprovide':
                 $_SESSION['SIF_MESSAGE_TYPE'] = 17;
                 $unProvide = new UnProvide($dom);
                 break;
             case 'SIF_Subscribe':
                 $_SESSION['SIF_MESSAGE_TYPE'] = 8;
                 $subscribe = new Subscribe($dom);
                 break;
             case 'SIF_Unsubscribe':
                 $_SESSION['SIF_MESSAGE_TYPE'] = 19;
                 $unSubscribe = new UnSubscribe($dom);
                 break;
             case 'SIF_Request':
                 $_SESSION['SIF_MESSAGE_TYPE'] = 6;
                 $request = new Request($dom);
                 break;
             case 'SIF_Response':
                 $_SESSION['SIF_MESSAGE_TYPE'] = 7;
                 $response = new Response($dom, $xmlStr);
                 break;
             default:
                 echo '<FATAL_ERROR>INVALID_SIF_REQUEST</FATAL_ERROR>';
                 exit;
                 break;
         }
         //end switch
     } catch (Exception $e) {
         ZitLog::writeToErrorLog('[Error processing message]', "Error Message\n" . $e->getMessage() . "\n\nStack Trace\n" . $e->getTraceAsString(), 'Process Message', $_SESSION['ZONE_ID']);
     }
     //end exception block
 }
开发者ID:Koulio,项目名称:OpenZIS,代码行数:81,代码来源:SifProcessRequest_2.php

示例8: processResponseMessage

 private function processResponseMessage($xml, $zoneId, $contextId, $agentId)
 {
     $results = array('ImmediateUpdate' => true, 'Error' => false);
     $dom = new DomDocument();
     $dom->preserveWhiteSpace = false;
     $res = $dom->loadXML($xml);
     if ($res) {
         $headerNode = $dom->getElementsByTagName('SIF_Header')->item(0);
         $msgId = $headerNode->getElementsByTagName('SIF_MsgId')->item(0)->nodeValue;
         $agentSourceId = $headerNode->getElementsByTagName('SIF_SourceId')->item(0)->nodeValue;
         $timestamp = $headerNode->getElementsByTagName('SIF_Timestamp')->item(0)->nodeValue;
         $originalMsgId = $dom->getElementsByTagName('SIF_OriginalMsgId')->item(0)->nodeValue;
         $status = $dom->getElementsByTagName('SIF_Status');
         $status = $status->item(0)->nodeValue;
         $validSourceId = Agent::checkSourceId($agentSourceId);
         if (!$validSourceId) {
             ZitLog::writeToErrorLog('[Error Pushing Messages] Invalid Source Id In Response', "Reponse Xml:\n{$xml}", 'Push Message Response', $zoneId, $contextId, $agentId);
             $results['Error'] = true;
         } else {
             $agent = new Agent($agentSourceId, $zoneId, $contextId);
             if ($agent->isRegistered()) {
                 if ($status == 2) {
                     //Intermediate wait for final
                     $results['ImmediateUpdate'] = false;
                     $agent->freezeAgent();
                     $agent->setFrozenMsgId($originalMsgId);
                 }
             } else {
                 ZitLog::writeToErrorLog('[Error Pushing Messages] Response Agent Not Registered', "Response agent is not registered in the system", 'Push Message Response', $zoneId, $contextId, $agentId);
                 $results['Error'] = true;
             }
         }
     } else {
         ZitLog::writeToErrorLog('[Error Pushing Messages] Reponse Xml Invalid', $xml, 'Push Message Response', $zoneId, $contextId, $agentId);
         $results['Error'] = true;
     }
     return $results;
 }
开发者ID:neilberget,项目名称:OpenZIS,代码行数:38,代码来源:PushMessageHandler.php

示例9: processMessage

 public static function processMessage($m)
 {
     try {
         $msgObj = $m;
         $dom = $m->dom;
         /***
         			Make sure that preserve white space is off for the the DomDocument object.
         			WhiteSpaces interfers with parsing the xml
         			***/
         #			$dom->preserveWhiteSpace = false;
         #			$res = $dom->loadXML($xmlStr);
         $headerNode = $msgObj->headerNode;
         $sourceId = $msgObj->sourceId;
         $originalMsgId = $msgObj->msgId;
         $validSourceId = Agent::checkSourceId($msgObj->sourceId);
         if (!$validSourceId) {
             RegisterError::invalidSourceId($msgObj->sourceId, $msgObj->msgId);
         }
         SifProcessRequest::authenticateAgent($msgObj->sourceId);
         SifProcessRequest::checkIfZitIsSleeping($msgObj);
         SifProcessRequest::checkIfZoneIsSleeping($msgObj);
         switch ($msgObj->messageType) {
             case 'SIF_Register':
                 require_once 'main_lib/register/Register.php';
                 $_SESSION['SIF_MESSAGE_TYPE'] = 5;
                 $register = new Register($msgObj->dom);
                 break;
             case 'SIF_Unregister':
                 require_once 'main_lib/register/RegisterError.php';
                 require_once 'main_lib/register/UnRegister.php';
                 $_SESSION['SIF_MESSAGE_TYPE'] = 18;
                 $unregister = new UnRegister($msgObj->dom);
                 break;
             case 'SIF_Ack':
                 require_once 'main_lib/register/RegisterError.php';
                 require_once 'main_lib/ack/Ack.php';
                 $_SESSION['SIF_MESSAGE_TYPE'] = 1;
                 $ack = new Ack($msgObj);
                 break;
             case 'SIF_SystemControl':
                 require_once 'main_lib/systemcontrol/SystemControl.php';
                 $systemControl = new SystemControl($msgObj);
                 break;
             case 'SIF_Provision':
                 require_once 'main_lib/provision/ProvisionError.php';
                 require_once 'main_lib/provision/Provision.php';
                 $_SESSION['SIF_MESSAGE_TYPE'] = 4;
                 $provision = new Provision($msgObj->dom);
                 break;
             case 'SIF_Event':
                 require_once 'main_lib/provision/ProvisionError.php';
                 require_once 'main_lib/event/Event.php';
                 $_SESSION['SIF_MESSAGE_TYPE'] = 2;
                 $event = new Event($msgObj);
                 break;
             case 'SIF_Provide':
                 require_once 'main_lib/provide/Provide.php';
                 $_SESSION['SIF_MESSAGE_TYPE'] = 3;
                 $provide = new Provide($msgObj->dom);
                 break;
             case 'SIF_Unprovide':
                 require_once 'main_lib/provide/UnProvide.php';
                 $_SESSION['SIF_MESSAGE_TYPE'] = 17;
                 $unProvide = new UnProvide($msgObj->dom);
                 break;
             case 'SIF_Subscribe':
                 require_once 'main_lib/subscribe/Subscribe.php';
                 $_SESSION['SIF_MESSAGE_TYPE'] = 8;
                 $subscribe = new Subscribe($msgObj->dom);
                 break;
             case 'SIF_Unsubscribe':
                 require_once 'main_lib/subscribe/UnSubscribe.php';
                 $_SESSION['SIF_MESSAGE_TYPE'] = 19;
                 $unSubscribe = new UnSubscribe($msgObj->dom);
                 break;
             case 'SIF_Request':
                 require_once 'main_lib/provision/ProvisionError.php';
                 #						require_once 'main_lib/FilterUtility.php';
                 require_once 'main_lib/RequestObject.php';
                 require_once 'main_lib/request/Request.php';
                 require_once 'main_lib/request/RequestError.php';
                 $_SESSION['SIF_MESSAGE_TYPE'] = 6;
                 $request = new Request($msgObj);
                 break;
             case 'SIF_Response':
                 #						require_once 'main_lib/FilterUtility.php';
                 require_once '../CLASSES/' . DB_TYPE . '/AgentPermissions.php';
                 require_once 'main_lib/ResponseObject.php';
                 require_once 'main_lib/RequestObject.php';
                 require_once 'main_lib/request/RequestError.php';
                 require_once 'main_lib/response/Response.php';
                 $_SESSION['SIF_MESSAGE_TYPE'] = 7;
                 $response = new Response($msgObj);
                 break;
             default:
                 echo '<FATAL_ERROR>INVALID_SIF_REQUEST</FATAL_ERROR>';
                 exit;
                 break;
         }
         //end switch
//.........这里部分代码省略.........
开发者ID:Koulio,项目名称:OpenZIS,代码行数:101,代码来源:SifProcessRequest.php

示例10: processSubscribe

 private function processSubscribe()
 {
     $dom = $this->dom;
     $headerNode = $dom->getElementsByTagName('SIF_Header')->item(0);
     $originalMsgId = $headerNode->getElementsByTagName('SIF_MsgId')->item(0)->nodeValue;
     $originalSourceId = $headerNode->getElementsByTagName('SIF_SourceId')->item(0)->nodeValue;
     if ($headerNode->getElementsByTagName('SIF_Timestamp')->item(0)) {
         $originalTimestamp = $headerNode->getElementsByTagName('SIF_Timestamp')->item(0)->nodeValue;
     } else {
         $originalTimestamp = Utility::createTimestamp();
     }
     $this->originalSourceId = $originalSourceId;
     $this->originalMsgId = $originalMsgId;
     $validSourceId = Agent::checkSourceId($originalSourceId);
     if (!$validSourceId) {
         ProvisionError::invalidSourceId($originalSourceId, $originalMsgId);
         exit;
     } else {
         $agent = new Agent($originalSourceId);
         $this->agent = $agent;
         if (!$this->agent->isRegistered()) {
             RegisterError::notRegisteredError($originalSourceId, $originalMsgId);
             exit;
         } else {
             $objects = $dom->getElementsByTagName('SIF_Object');
             foreach ($objects as $object) {
                 $objectName = $object->getAttribute('ObjectName');
                 $contexts = $object->getElementsByTagName('SIF_Context');
                 if (!DataObject::objectExists($objectName)) {
                     ProvisionError::invalidObject($originalSourceId, $originalMsgId, $objectName);
                     exit;
                 } else {
                     if ($contexts->length != 0) {
                         foreach ($contexts as $context) {
                             if (Context::isValidContext($context->nodeValue)) {
                                 $contextId = Context::getContextId($context->nodeValue);
                                 if (!DataObject::allowedToSubscribe($agent->agentId, $objectName, $contextId)) {
                                     ProvisionError::invalidPermissionToSubscribe($originalSourceId, $originalMsgId, $objectName);
                                     exit;
                                 } else {
                                     $dataObject = new DataObject($objectName);
                                     $dataObject->contextId = $contextId;
                                     array_push($this->subscribeObjects, $dataObject);
                                 }
                                 //check if allowed to subscribe
                             } else {
                                 ProvisionError::contextNotSupportedError($originalSourceId, $originalMsgId);
                                 exit;
                             }
                         }
                         //loop through contexts
                     } else {
                         if (!DataObject::allowedToSubscribe($agent->agentId, $objectName)) {
                             ProvisionError::invalidPermissionToSubscribe($originalSourceId, $originalMsgId, $objectName);
                             exit;
                         } else {
                             $dataObject = new DataObject($objectName);
                             array_push($this->subscribeObjects, $dataObject);
                         }
                         //check if allowed to subscribe
                     }
                     // check if there are contexts
                 }
                 //check if object is valid
             }
             //loop through objects
         }
         //check if registered
     }
     //check sourceId
 }
开发者ID:Koulio,项目名称:OpenZIS,代码行数:71,代码来源:Subscribe.php

示例11: processZoneStatus

 private function processZoneStatus()
 {
     $dom = $this->xmlDom;
     $headerNode = $dom->getElementsByTagName('SIF_Header')->item(0);
     $originalSourceId = $headerNode->getElementsByTagName('SIF_SourceId')->item(0)->nodeValue;
     $originalMsgId = $headerNode->getElementsByTagName('SIF_MsgId')->item(0)->nodeValue;
     $validSourceId = Agent::checkSourceId($originalSourceId);
     if (!$validSourceId) {
         RegisterError::invalidSourceId($originalSourceId, $originalMsgId);
     } else {
         $dom = new DOMDocument('1.0', 'iso-8859-1');
         $zoneStatusNode = $dom->createElement('SIF_ZoneStatus');
         $zoneStatusNode->setAttribute('ZoneId', $_SESSION['ZONE_NAME']);
         $dom->appendChild($zoneStatusNode);
         $zoneNameNode = $dom->createElement('SIF_Name');
         $zoneNameNode->appendChild($dom->createTextNode($_SESSION['ZONE_DESC']));
         $zoneStatusNode->appendChild($zoneNameNode);
         $sifVendorNode = $dom->createElement('SIF_Vendor');
         $sifVendorName = $dom->createElement('SIF_Name');
         $sifVendorName->appendChild($dom->createTextNode(VENDOR_NAME));
         $sifVendorNode->appendChild($sifVendorName);
         $sifVendorProduct = $dom->createElement('SIF_Product');
         $sifVendorProduct->appendChild($dom->createTextNode(VENDOR_PRODUCT));
         $sifVendorNode->appendChild($sifVendorProduct);
         $sifVendorVersion = $dom->createElement('SIF_Version');
         $sifVendorVersion->appendChild($dom->createTextNode(VENDOR_VERSION));
         $sifVendorNode->appendChild($sifVendorVersion);
         $zoneStatusNode->appendChild($sifVendorNode);
         $sifProvidersNode = $dom->createElement('SIF_Providers');
         $sifProvidersNode = $this->buildProviders($sifProvidersNode, $dom);
         $zoneStatusNode->appendChild($sifProvidersNode);
         $sifSubscribersNode = $dom->createElement('SIF_Subscribers');
         $sifSubscribersNode = $this->buildSubscribers($sifSubscribersNode, $dom);
         $zoneStatusNode->appendChild($sifSubscribersNode);
         $sifNodes = $dom->createElement('SIF_SIFNodes');
         $sifSubscribersNode = $this->buildNodeList($sifNodes, $dom);
         $zoneStatusNode->appendChild($sifNodes);
         /*$sifSupportedAuth = $dom->createElement('SIF_SupportedAuthentication');
         		$sifProtocolName  = $dom->createElement('SIF_ProtocolName');
         		$sifSupportedAuth->appendChild($sifProtocolName);
         		$zoneStatusNode->appendChild($sifSupportedAuth);*/
         $sifSupportedProtocols = $dom->createElement('SIF_SupportedProtocols');
         $sifProtocol = $dom->createElement('SIF_Protocol');
         $sifProtocol->setAttribute('Type', 'HTTP');
         $sifProtocol->setAttribute('Secure', 'No');
         $sifUrl = $dom->createElement('SIF_URL');
         $sifUrl->appendChild($dom->createTextNode(ZIT::getZitUrl()));
         $sifProtocol->appendChild($sifUrl);
         $sifSupportedProtocols->appendChild($sifProtocol);
         $zoneStatusNode->appendChild($sifSupportedProtocols);
         $sifSupportedVersions = $dom->createElement('SIF_SupportedVersions');
         $versions = ZIT::getVersions();
         foreach ($versions as $version) {
             $sifVersion = $dom->createElement('SIF_Version');
             $sifVersion->appendChild($dom->createTextNode($version['VERSION']));
             $sifSupportedVersions->appendChild($sifVersion);
         }
         $zoneStatusNode->appendChild($sifSupportedVersions);
         $sifAdminUrl = $dom->createElement('SIF_AdministrationURL');
         $sifAdminUrl->appendChild($dom->createTextNode(ZIT::getAdminUrl()));
         $zoneStatusNode->appendChild($sifAdminUrl);
         $sifContexts = $dom->createElement('SIF_Contexts');
         $sifContexts = $this->buildContexts($sifContexts, $dom);
         $zoneStatusNode->appendChild($sifContexts);
         $xml = $dom->saveXML($dom->documentElement);
         $msgId = Utility::createMessageId();
         $timestamp = Utility::createTimestamp();
         XmlHelper::buildSuccessMessage($msgId, $timestamp, $originalSourceId, $originalMsgId, 0, $originalMsg = $xml, $desc = null);
     }
 }
开发者ID:Koulio,项目名称:OpenZIS,代码行数:70,代码来源:SystemControl.php

示例12: processResponse

 private function processResponse($m)
 {
     $dom = $m->dom;
     $headerNode = $m->headerNode;
     $originalMsgId = $m->msgId;
     $this->originalMsgId = $m->msgId;
     $originalSourceId = $m->sourceId;
     $version = $m->version;
     $this->originalSourceId = $originalSourceId;
     $this->originalMsgId = $originalMsgId;
     $validSourceId = Agent::checkSourceId($originalSourceId);
     if (!$validSourceId) {
         RegisterError::invalidSourceId($agent->sourceId, $originalMsgId);
         exit;
     } else {
         $agent = new Agent($originalSourceId);
         if (!$agent->isRegistered()) {
             RegisterError::notRegisteredError($originalSourceId, $originalMsgId);
             exit;
         } else {
             $msgId = $dom->getElementsByTagName('SIF_RequestMsgId')->item(0)->nodeValue;
             if (!RequestObject::validRequestMsgId($msgId)) {
                 RequestError::invalidMsgId($originalSourceId, $originalMsgId);
             } else {
                 $requestObject = new RequestObject($msgId);
                 $sifResponseNode = $dom->getElementsByTagName('SIF_Response')->item(0);
                 $size = strlen($dom->saveXML($sifResponseNode));
                 if (!$requestObject->compareBufferSize($size)) {
                     $categoryCode = "8";
                     $sifCode = "11";
                     $shortDesc = "Response Error";
                     $longDesc = "SIF_Response is larger than requested SIF_MaxBufferSize";
                     $this->createResponseError($agent, $msgId, $categoryCode, $sifCode, $shortDesc, $longDesc);
                     SifLogEntry::CreateSifLogEvents($dom->saveXml($headerNode), 4, 2, 'Invalid buffersize for response to agent ' . $agent->sourceId . ' request');
                     RequestError::invalidBufferSize($originalSourceId, $originalMsgId);
                 } else {
                     $destinationId = $dom->getElementsByTagName('SIF_DestinationId')->item(0)->nodeValue;
                     if (!$requestObject->compareDestinationId($destinationId)) {
                         $categoryCode = "8";
                         $sifCode = "14";
                         $shortDesc = "Response Error";
                         $longDesc = "SIF_DestinationId does not match SIF_SourceId from SIF_Request";
                         $this->createResponseError($agent, $msgId, $categoryCode, $sifCode, $shortDesc, $longDesc);
                         SifLogEntry::CreateSifLogEvents($dom->saveXml($headerNode), 4, 1, 'Invalid destinationId for response to agent ' . $agent->sourceId . ' request');
                         RequestError::invalidDestination($originalSourceId, $originalMsgId);
                     } else {
                         if (RequestObject::validMessageVersion($msgId, $version)) {
                             if (ResponseObject::responseExist($msgId)) {
                                 $responseObject = new ResponseObject($msgId);
                                 $packetNum = $dom->getElementsByTagName('SIF_PacketNumber')->item(0)->nodeValue;
                                 if ($packetNum != $responseObject->nextPacketNum) {
                                     $categoryCode = "8";
                                     $sifCode = "12";
                                     $shortDesc = "SIF_PacketNumber is invalid in SIF_Response";
                                     $longDesc = 'Invalid packet number of ' . $packetNum . ' was expecting ' . $responseObject->nextPacketNum . 'for response to agent ' . $agent->sourceId . ' request';
                                     //$this->createResponseError($agent, $msgId, $categoryCode, $sifCode, $shortDesc, $longDesc);
                                     RequestError::invalidPacketNum($originalSourceId, $originalMsgId, $longDesc);
                                 } else {
                                     $this->setupResponseOld($agent, $msgId, $responseObject);
                                 }
                             } else {
                                 $packetNum = $dom->getElementsByTagName('SIF_PacketNumber')->item(0)->nodeValue;
                                 if ($packetNum != 1) {
                                     $categoryCode = "8";
                                     $sifCode = "12";
                                     $shortDesc = "Response Error";
                                     $longDesc = 'Invalid packet number of ' . $packetNum . ' was expecting 1 for response to agent ' . $agent->sourceId . ' request';
                                     RequestError::invalidPacketNum($originalSourceId, $originalMsgId, $longDesc);
                                 } else {
                                     $this->setupResponseNew($agent, $msgId, $m);
                                 }
                                 //check if packetnum is 1
                             }
                             //check if response with more packets
                         } else {
                             $categoryCode = "8";
                             $sifCode = "13";
                             $shortDesc = "Response Error";
                             $longDesc = "SIF_Response does not match any SIF_Version from SIF_Request.";
                             $this->createResponseError($agent, $msgId, $categoryCode, $sifCode, $shortDesc, $longDesc);
                             RequestError::invalidVersion($originalSourceId, $originalMsgId);
                         }
                         //check if version is valid
                     }
                     // check if valid destination
                 }
                 //check if valid buffer
             }
             //check if valid request message id
         }
         //check if registered
     }
     //check sourceId
 }
开发者ID:neilberget,项目名称:OpenZIS,代码行数:94,代码来源:Response.php

示例13: processRequest

 private function processRequest($m)
 {
     try {
         $dom = $m->dom;
         $this->originalSourceId = $m->sourceId;
         $originalSourceId = $m->sourceId;
         $this->originalMsgId = $m->msgId;
         $originalMsgId = $m->msgId;
         $headerNode = $m->headerNode;
         $this->headerNode = $headerNode;
         $validSourceId = Agent::checkSourceId($originalSourceId);
         if (!$validSourceId) {
             RegisterError::invalidSourceId($agent->sourceId, $originalMsgId);
             exit;
         } else {
             $agent = new Agent($originalSourceId);
             if (!$agent->isRegistered()) {
                 RegisterError::notRegisteredError($originalSourceId, $originalMsgId);
                 exit;
             } else {
                 $sentBufferSize = $dom->getElementsByTagName('SIF_MaxBufferSize')->item(0)->nodeValue;
                 if (!Agent::bufferSizeAllowed($sentBufferSize, $agent->agentId)) {
                     $timestamp = Utility::createTimestamp();
                     $msgId = Utility::createMessageId();
                     XmlHelper::buildSuccessMessage($msgId, $timestamp, $this->originalSourceId, $this->originalMsgId, 0, $originalMsg = null, $desc = null);
                 } else {
                     $messageNode = $dom->getElementsByTagName('SIF_Message');
                     $len = $messageNode->item(0)->childNodes->item(0)->childNodes->length - 1;
                     $Mode = $messageNode->item(0)->childNodes->item(0)->childNodes->item($len)->nodeName;
                     if ($Mode == 'SIF_Query') {
                         $sifObjectNode = $dom->getElementsByTagName('SIF_QueryObject')->item(0);
                         $objectName = $sifObjectNode->getAttribute('ObjectName');
                     } else {
                         $sifObjectNode = $dom->getElementsByTagName('SIF_From')->item(0);
                         $objectName = $sifObjectNode->getAttribute('ObjectName');
                     }
                     if (!DataObject::objectExists($objectName)) {
                         /*
                         This is a temporary fix that needs to be evaluated for correctness.
                         */
                         if ($objectName == 'SIF_ZoneStatus') {
                             require_once 'main_lib/systemcontrol/SystemControl.php';
                             $systemControl = new SystemControl($m, false, true);
                             exit;
                         }
                         RequestError::invalidObject($originalSourceId, $originalMsgId, $objectName);
                         exit;
                     } else {
                         if (!DataObject::allowedToRequest($agent->agentId, $objectName)) {
                             ProvisionError::invalidPermissionToRequest($originalSourceId, $originalMsgId, $objectName);
                             exit;
                         } else {
                             $sifDestinationId = $dom->getElementsByTagName('SIF_DestinationId');
                             if ($sifDestinationId->length != 0) {
                                 $sourceId = $sifDestinationId->item(0)->nodeValue;
                                 if (!DataObject::validResponder($objectName, $sourceId)) {
                                     RequestError::invalidProvider($originalSourceId, $originalMsgId);
                                 } else {
                                     $this->setupRequest($objectName, $sourceId, $agent);
                                 }
                                 //check if destination id is valid
                             } else {
                                 $this->setupRequest($objectName, $sourceId = null, $agent);
                             }
                             //check if there is a destination id
                         }
                         //check if allowed to request
                     }
                     //check if allowed to request
                 }
                 //check object exist
             }
             //check if registered
         }
         //check sourceId
     } catch (Exception $e) {
         ZitLog::writeToErrorLog("[processRequest]", "Errors:{$e->getTraceAsString}()", "Main Loop", $_SESSION['ZONE_ID']);
     }
 }
开发者ID:Koulio,项目名称:OpenZIS,代码行数:79,代码来源:Request.php


注:本文中的Agent::checkSourceId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。