Esempio n. 1
0
 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);
         }
     }
 }
Esempio n. 2
0
 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
 }