Exemple #1
0
 function getFullSpot($msgId)
 {
     # initialize some variables
     $spotParser = new SpotParser();
     $spot = array('xml' => '', 'user-signature' => '', 'user-key' => '', 'verified' => false, 'messageid' => $msgId, 'userid' => '', 'xml-signature' => '');
     # Vraag de volledige article header van de spot op
     $header = $this->getHeader('<' . $msgId . '>');
     # Parse de header
     foreach ($header as $str) {
         $keys = explode(':', $str);
         switch ($keys[0]) {
             case 'X-XML':
                 $spot['xml'] .= substr($str, 7);
                 break;
             case 'X-User-Signature':
                 $spot['user-signature'] = base64_decode($spotParser->unspecialString(substr($str, 18)));
                 break;
             case 'X-XML-Signature':
                 $spot['xml-signature'] = substr($str, 17);
                 break;
             case 'X-User-Key':
                 $xml = simplexml_load_string(substr($str, 12));
                 if ($xml !== false) {
                     $spot['user-key']['exponent'] = (string) $xml->Exponent;
                     $spot['user-key']['modulo'] = (string) $xml->Modulus;
                 }
                 # if
                 break;
                 # x-user-key
         }
         # switch
     }
     # foreach
     # Valideer de signature van de XML, deze is gesigned door de user zelf
     if (!empty($spot['user-signature']) && !empty($spot['user-key'])) {
         $spot['verified'] = $spotParser->checkRsaSignature('<' . $spot['messageid'] . '>', $spot['user-signature'], $spot['user-key']);
         if (!$spot['verified']) {
             $spot['verified'] = $spotParser->checkRsaSignature($spot['xml-signature'], $spot['user-signature'], $spot['user-key']);
         }
         # if
     } else {
         $spot['verified'] = false;
     }
     # else
     # als de spot verified is, toon dan de userid van deze user
     if ($spot['verified']) {
         $spot['userid'] = $spotParser->calculateUserid($spot['user-key']['modulo']);
     }
     # if
     # Parse nu de XML file, alles wat al gedefinieerd is eerder wordt niet overschreven
     $spot = array_merge($spotParser->parseFull($spot['xml']), $spot);
     return $spot;
 }