/** * Runs a validation of the structure of the SocialRecord * * return true if structure is ok, otherwise a SocialRecordFormatException is thrown */ public function verify() { // TODO check structure if ($this->type != SocialRecord::TYPE_PLATFORM && $this->type != SocialRecord::TYPE_USER) { throw new SocialRecordFormatException('invalid type value [' . $this->type . ']'); } if (!GID::isValid($this->globalID)) { throw new SocialRecordFormatException('invalid globalID value'); } if (!GID::isValid($this->platformGID)) { throw new SocialRecordFormatException('invalid platformGID value'); } if (!GID::verifyGID($this->personalPublicKey, $this->salt, $this->globalID)) { throw new SocialRecordFormatException('invalid globalID value'); } if (!XSDDateTime::isValid($this->datetime)) { throw new SocialRecordFormatException('invalid date value [' . $this->datetime . ']'); } /*if($this->) throw new SocialRecordFormatException('invalid value'); */ return true; }
public function build() { if ($this->globalID == NULL) { throw new \Exception('GlobalID is not set'); } if ($this->key == NULL) { throw new \Exception('Key is not set'); } if ($this->datetime == NULL) { throw new \Exception('Datetime is not set'); } if ($this->reason == NULL) { throw new \Exception('Reason is not set'); } if (!GID::isValid($this->globalID)) { throw new \Exception('Invalid value for GlobalID'); } if (!XSDDateTime::isValid($this->datetime)) { throw new \Exception('Invalid value for Datetime'); } if ($this->signature == NULL) { if ($this->personalPrivateKey = NULL) { throw new \Exception('Signing key not set'); } $this->sign($this->personalPrivateKey); } if (!$this->verify()) { throw new \Exception('Invalid signature for KeyRevocationCertificate!'); } return new KeyRevocationCertificate($this); }