Exemplo n.º 1
0
 protected function verifySignature()
 {
     $publicAccountKey = PublicKey::formatPEM(SocialRecordManager::retrieveSocialRecord($this->headers[SONIC_HEADER__SOURCE_GID])->getAccountPublicKey());
     if (!Signature::verifySignature($this->getStringForRequestSignature(), $publicAccountKey, $this->headers[SONIC_HEADER__SIGNATURE])) {
         throw new MalformedRequestHeaderException("Invalid request signature!");
     } else {
         return true;
     }
 }
Exemplo n.º 2
0
 public function __construct($targetGID)
 {
     if (!GID::isValid($targetGID)) {
         throw new MalformedRequestException('Invalid GlobalID: [' . $targetGID . ']');
     }
     $this->targetGID = $targetGID;
     try {
         $this->targetSocialRecord = SocialRecordManager::retrieveSocialRecord($this->targetGID);
     } catch (\Exception $e) {
         throw new MalformedRequestException('Could not resolve GlobalID: [' . $this->targetGID . ']');
     }
 }
Exemplo n.º 3
0
 protected function verifySignature()
 {
     $socialRecord = SocialRecordManager::retrieveSocialRecord($this->headers[SONIC_HEADER__SOURCE_GID]);
     if ($this->expectedGID !== NULL) {
         if ($this->headers[SONIC_HEADER__SOURCE_GID] != $this->expectedGID && $this->headers[SONIC_HEADER__SOURCE_GID] != $socialRecord->getPlatformGID()) {
             throw new MalformedRequestHeaderException('Request signature from unexpected source GID. Expected [' . $this->expectedGID . '] found [' . $this->headers[SONIC_HEADER__SOURCE_GID] . ']');
         }
     }
     if (!Signature::verifySignature($this->getStringForResponseSignature(), $socialRecord->getAccountPublicKey(), $this->headers[SONIC_HEADER__SIGNATURE])) {
         throw new MalformedRequestHeaderException("Invalid response signature");
     } else {
         return true;
     }
 }
Exemplo n.º 4
0
 public function verify()
 {
     $personalPublicKey = SocialRecordManager::retrieveSocialRecord($this->globalID)->getPersonalPublicKey();
     return Signature::verifySignature($this->getStringForSignature(), $personalPublicKey, $this->signature);
 }