public function __construct(KeyRevocationCertificateBuilder $builder) { $this->key = $builder->getKey(); $this->datetime = $builder->getDatetime(); $this->reason = $builder->getReason(); $this->signature = $builder->getSignature(); }
/** * Creates a SocialRecord object from a JSON String * * @param $json (String) The serialized SocialRecord * * @return SocialRecord */ public static function buildFromJSON($json) { $jsonObject = json_decode($json); if (!property_exists($jsonObject, 'platformGID')) { throw new SocialRecordFormatException('SocialRecord: Property platformGID missing!'); } if (!property_exists($jsonObject, 'globalID')) { throw new SocialRecordFormatException('SocialRecord: Property globalID missing!'); } if (!property_exists($jsonObject, 'type')) { throw new SocialRecordFormatException('SocialRecord: Property type missing!'); } if (!property_exists($jsonObject, 'displayName')) { throw new SocialRecordFormatException('SocialRecord: Property displayName missing!'); } if (!property_exists($jsonObject, 'profileLocation')) { throw new SocialRecordFormatException('SocialRecord: Property profileLocation missing!'); } if (!property_exists($jsonObject, 'personalPublicKey')) { throw new SocialRecordFormatException('SocialRecord: Property personalPublicKey missing!'); } if (!property_exists($jsonObject, 'accountPublicKey')) { throw new SocialRecordFormatException('SocialRecord: Property accountPublicKey missing!'); } if (!property_exists($jsonObject, 'salt')) { throw new SocialRecordFormatException('SocialRecord: Property salt missing!'); } if (!property_exists($jsonObject, 'datetime')) { throw new SocialRecordFormatException('SocialRecord: Property datetime missing!'); } if (!property_exists($jsonObject, 'active')) { throw new SocialRecordFormatException('SocialRecord: Property active missing!'); } if (!property_exists($jsonObject, 'keyRevocationList')) { throw new SocialRecordFormatException('SocialRecord: Property keyRevocationList missing!'); } $krl = array(); foreach ($jsonObject->keyRevocationList as $krc) { $krl[] = KeyRevocationCertificateBuilder::buildFromJSON($krc); } return (new SocialRecordBuilder())->type($jsonObject->type)->globalID($jsonObject->globalID)->platformGID($jsonObject->platformGID)->displayName($jsonObject->displayName)->profileLocation($jsonObject->profileLocation)->personalPublicKey(PublicKey::formatPEM($jsonObject->personalPublicKey))->accountPublicKey(PublicKey::formatPEM($jsonObject->accountPublicKey))->salt($jsonObject->salt)->datetime($jsonObject->datetime)->active($jsonObject->active)->keyRevocationList($krl)->build(); }