Ejemplo n.º 1
0
 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
 }