public function build() { if ($this->objectID == NULL) { $this->objectID = UOID::createUOID(); } if (!UOID::isValid($this->objectID)) { throw new IllegalModelStateException('Invalid objectID'); } if (!UOID::isValid($this->targetID)) { throw new IllegalModelStateException('Invalid targetID'); } if (!GID::isValid($this->author)) { throw new IllegalModelStateException('Invalid author'); } if (!GID::isValid($this->tag)) { throw new IllegalModelStateException('Invalid tag'); } if (!XSDDateTime::validateXSDDateTime($this->datePublished)) { throw new IllegalModelStateException('Invalid date'); } $tag = new TagObject($this); if ($tag->getSignature() == NULL) { $tag->signObject(); } if (!$tag->verifyObjectSignature()) { throw new IllegalModelStateException('Invalid signature'); } return $tag; }
public function build() { if ($this->objectID == NULL) { $this->objectID = UOID::createUOID(); } if ($this->datetime == NULL) { $this->datetime = XSDDateTime::getXSDDateTime(); } if (!UOID::isValid($this->objectID)) { throw new IllegalModelStateException('Invalid objectID'); } if (!GID::isValid($this->owner)) { throw new IllegalModelStateException('Invalid owner'); } if (!GID::isValid($this->link)) { throw new IllegalModelStateException('Invalid link'); } if (!XSDDateTime::validateXSDDateTime($this->datetime)) { throw new IllegalModelStateException('Invalid datetime'); } $link = new LinkObject($this); if ($link->getSignature() == NULL) { $link->signObject(); } if (!$link->verifyObjectSignature()) { throw new IllegalModelStateException('Invalid signature'); } return $link; }
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 . ']'); } }
/** * Checks if a SocialRecord is available in the GSLS for a given GID * throws Exception * * return true if SocialRecord is available in the GSLS, otherwise false */ public static function socialRecordExists($globalID) { if (!GID::isValid($globalID)) { throw new \Exception('Illegal GID format'); } try { $result = GSLS::getSocialRecord($globalID); } catch (SocialRecordNotFoundException $e) { return false; } return true; }
public function build() { if ($this->objectID == NULL) { $this->objectID = UOID::createUOID(); } if (!UOID::isValid($this->objectID)) { throw new IllegalModelStateException('Invalid objectID'); } if (!GID::isValid($this->owner)) { throw new IllegalModelStateException('Invalid owner'); } return new LinkRosterObject($this); }
public function build() { if ($this->objectID == NULL) { $this->objectID = UOID::createUOID(); } if (!UOID::isValid($this->objectID)) { throw new IllegalModelStateException('Invalid objectID'); } if (!GID::isValid($this->globalID)) { throw new IllegalModelStateException('Invalid globalID'); } if ($this->displayName == '' || $this->displayName == NULL) { throw new IllegalModelStateException('Invalid displayName'); } return new ProfileObject($this); }
/** * Verifies, if a given UOID is valid * * @param $uoid String The UOID to verify * * @return true, of the UOID is valid, else false */ public static function isValid($uoid) { $uoid = explode(UOID::SEPARATOR, $uoid); if (count($uoid) != 2) { return false; } // check GID if (!GID::isValid($uoid[0])) { return false; } // check id if (!preg_match("/^[a-zA-Z0-9]+\$/", $uoid[1]) || strlen($uoid[1]) != 16) { return false; } return true; }
public function testGID() { $key = "-----BEGIN PUBLIC KEY-----MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnDOhWIumc12Cf4O1AqAnnv/vCbsgoSqAhMwtvl+7Yjb+aPwuT+EoKN2mGNZ1GMrKZrqHNzkhzJCyLGCo/Zg4V95Xza4f8QxRUH/mOMp132VjvUKlnRNMEqE5hv85mtG5D4dTpkfu4wxxhCfND9bG3GmIoTMYjVGjm0947Zy+VWH1TI4dPVYTvDlwSEsbT5uXQySLBx2XkThynp+e+LGSsmga46LVkt5JUAjIgEstWXaMSJrofGenizw+Yf9tcjgYVDaYsWJVFO24pLkQkVNVt33zZREHECgVObWSJIRX2f/DMrC6pWbNgPdmwodI4dqezg+MvfZ+x+tLFtaquZBx0YH+45wpqy1txgxYUEPUJEsKy+0VxRZTu28j6mKpINQFw0OGMTtcQmZgvdf+JnJOKy0jFjO/CI3kod7SwW3cmTXSfp7KLbHN6BF4hrSpAhro3/2Pixa5LTIDhN1B1oNghbfQ6vXH9Ge8ZAS0G1q3jn/3zicoN+hCn3B8Bxx02Ere2laytnUCNz2HT+DlEtji4gFZEvou/TjjCrwKtTR0XTyUSiNkkG0xFSR0p+ghImz593t128r5I8iWRYCreQq2Z5a0PgcdC/BpdjPvpW2NGWuP4BRPJXO8ddsroi+kSjSqVZDKmtnP5HzpJxJVI/Clich40yaUM6nGVMSQAljGvB0CAwEAAQ==-----END PUBLIC KEY-----"; $salt = "0b9357af0b74e6a4"; $gid1 = '3Z51OUSP4UPXTEOOKSDXVZQLMYGNJQVY0SKYUKKGVT8QWD78T5'; $gid2 = '2Z51OUSP4UPXTEOOKSDXVZQLMYGNJQVY0SKYUKKGVT8QWD78T5'; $gid3 = '2Z51OUSP4UPXTEOOKSDXVZQLMYGNJQVY0'; $gid4 = '2-Z51OUSP4UPXTEOOKSDXVZQLMYGNJQVY0SKYUKKGVT8QWD78T'; $this->assertEquals($gid1, GID::createGID($key, $salt)); $this->assertEquals(true, GID::isValid($gid1)); $this->assertEquals(true, GID::verifyGID($key, $salt, $gid1)); $this->assertNotEquals($gid2, GID::createGID($key, $salt)); $this->assertTrue(GID::isValid($gid2)); $this->assertFalse(GID::verifyGID($key, $salt, $gid2)); $this->assertFalse(GID::isValid($gid3)); $this->assertFalse(GID::isValid($gid4)); }
public function build() { if ($this->objectID == NULL) { $this->objectID = UOID::createUOID(); } if (!UOID::isValid($this->objectID)) { throw new IllegalModelStateException('Invalid objectID'); } if (!GID::isValid($this->owner)) { throw new IllegalModelStateException('Invalid owner'); } if ($this->displayName == NULL) { throw new IllegalModelStateException('Invalid displayName'); } if (!is_array($this->members)) { throw new IllegalModelStateException('Invalid members'); } return new AccessControlGroupObject($this); }
public function build() { if ($this->objectID == NULL) { $this->objectID = UOID::createUOID(); } if (!UOID::isValid($this->objectID)) { throw new IllegalModelStateException('Invalid objectID'); } if (!UOID::isValid($this->targetID)) { throw new IllegalModelStateException('Invalid targetID'); } if (!GID::isValid($this->platformGID)) { throw new IllegalModelStateException('Invalid platformGID'); } if (!XSDDateTime::validateXSDDateTime($this->datetime)) { throw new IllegalModelStateException('Invalid datetime'); } if (!is_array($this->results)) { throw new IllegalModelStateException('Invalid results value'); } return new SearchResultCollectionObject($this); }
public function build() { if ($this->objectID == NULL) { $this->objectID = UOID::createUOID(); } if ($this->datePublished == NULL) { $this->datePublished = XSDDateTime::getXSDDateTime(); } if (!UOID::isValid($this->objectID)) { throw new IllegalModelStateException('Invalid objectID'); } if (!UOID::isValid($this->targetID)) { throw new IllegalModelStateException('Invalid targetID'); } if (!GID::isValid($this->author)) { throw new IllegalModelStateException('Invalid author'); } if ($this->comment == '' || $this->comment == NULL) { throw new IllegalModelStateException('Invalid comment'); } if (!XSDDateTime::validateXSDDateTime($this->datePublished)) { throw new IllegalModelStateException('Invalid datePublished'); } if ($this->dateUpdated != NULL && !XSDDateTime::validateXSDDateTime($this->dateUpdated)) { throw new IllegalModelStateException('Invalid dateUpdated'); } $comment = new CommentObject($this); if ($this->signature == NULL) { $comment->signObject(); } if (!$comment->verifyObjectSignature()) { throw new IllegalModelStateException('Invalid signature'); } return $comment; }
/** * 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->objectID == NULL) { $this->objectID = UOID::createUOID(); } if ($this->datetime == NULL) { $this->datetime = XSDDateTime::getXSDDateTime(); } if (!UOID::isValid($this->objectID)) { throw new IllegalModelStateException('Invalid objectID'); } if (!UOID::isValid($this->targetID)) { throw new IllegalModelStateException('Invalid targetID'); } if (!GID::isValid($this->author)) { throw new IllegalModelStateException('Invalid author'); } if ($this->body == '' || $this->body == NULL) { throw new IllegalModelStateException('Invalid body'); } if (!XSDDateTime::validateXSDDateTime($this->datetime)) { throw new IllegalModelStateException('Invalid datetime'); } $conversationMessage = new ConversationMessageObject($this); if ($conversationMessage->getSignature() == NULL) { $conversationMessage->signObject(); } if (!$conversationMessage->verifyObjectSignature()) { throw new IllegalModelStateException('Invalid signature'); } return $conversationMessage; }
public function build() { if ($this->objectID == NULL) { $this->objectID = UOID::createUOID(); } if ($this->datetime == NULL) { $this->datetime = XSDDateTime::getXSDDateTime(); } if (!UOID::isValid($this->objectID)) { throw new IllegalModelStateException('Invalid objectID'); } if (!GID::isValid($this->initiatingGID)) { throw new IllegalModelStateException('Invalid initiatingGID'); } if (!GID::isValid($this->targetedGID)) { throw new IllegalModelStateException('Invalid targetedGID'); } if (!XSDDateTime::validateXSDDateTime($this->datetime)) { throw new IllegalModelStateException('Invalid datetime'); } return new LinkRequestObject($this); }
public function build() { if ($this->objectID == NULL) { $this->objectID = UOID::createUOID(); } if ($this->hopCount == NULL) { $this->hopCount = 0; } if ($this->datetime == NULL) { $this->datetime = XSDDateTime::getXSDDateTime(); } if (!UOID::isValid($this->objectID)) { throw new IllegalModelStateException('Invalid objectID'); } if (!GID::isValid($this->initiatingGID)) { throw new IllegalModelStateException('Invalid initiatingGID'); } if (!is_numeric($this->hopCount) || $this->hopCount > 3) { throw new IllegalModelStateException('Invalid value for hopCount'); } if (!XSDDateTime::validateXSDDateTime($this->datetime)) { throw new IllegalModelStateException('Invalid datetime'); } if ($this->query === NULL || !$this->query instanceof ESQuery) { throw new IllegalModelStateException('Invalid value for query'); } $searchQuery = new SearchQueryObject($this); if ($searchQuery->getSignature() == NULL) { $searchQuery->signObject(); } if (!$searchQuery->verifyObjectSignature()) { throw new IllegalModelStateException('Invalid signature'); } return $searchQuery; }
/** * Builder method that creates the actual SocialRecord object * * @throws SocialRecordFormatException * * @return The SocialRecord (SocialRecord) */ public function build() { if ($this->displayName == NULL) { throw new SocialRecordFormatException('SocialRecord: displayName must be specified for instantiation'); } if ($this->profileLocation == NULL) { throw new SocialRecordFormatException('SocialRecord: profileLocation must be specified for instantiation'); } if ($this->personalPublicKey == NULL) { throw new SocialRecordFormatException('SocialRecord: personalPublicKey must be specified for instantiation'); } if ($this->accountPublicKey == NULL) { throw new SocialRecordFormatException('SocialRecord: accountPublicKey must be specified for instantiation'); } if ($this->type == NULL) { throw new SocialRecordFormatException('SocialRecord: type must be specified for instantiation'); } if ($this->type != SocialRecord::TYPE_PLATFORM && $this->type != SocialRecord::TYPE_USER) { throw new SocialRecordFormatException('SocialRecord: Invalid type value [' . $this->type . ']'); } if ($this->salt == NULL) { $this->salt = Random::getRandom(SocialRecord::SALT_CHARS); } if ($this->datetime == NULL) { $this->datetime = XSDDateTime::getXSDDateTime(); } if ($this->globalID == NULL) { $this->globalID = GID::createGID($this->personalPublicKey, $this->salt); } if (!GID::isValid($this->globalID)) { throw new SocialRecordFormatException('SocialRecord: Invalid globalID value [' . $this->globalID . ']'); } if ($this->platformGID == NULL && $this->type == SocialRecord::TYPE_PLATFORM) { $this->platformGID = $this->globalID; } if ($this->platformGID == NULL) { throw new SocialRecordFormatException('SocialRecord: platformID must be specified for instantiation'); } if (!GID::isValid($this->platformGID)) { throw new SocialRecordFormatException('SocialRecord: Invalid platformGID value [' . $this->platformGID . ']'); } if ($this->keyRevocationList == NULL) { $this->keyRevocationList = array(); } if ($this->active == NULL) { $this->active = 1; } return new SocialRecord($this); }
public function build() { if ($this->objectID == NULL) { $this->objectID = UOID::createUOID(); } if ($this->datetime == NULL) { $this->datetime = XSDDateTime::getXSDDateTime(); } if (!UOID::isValid($this->objectID)) { throw new IllegalModelStateException('Invalid objectID'); } if (!UOID::isValid($this->conversationID)) { throw new IllegalModelStateException('Invalid conversationID'); } if (!UOID::isValid($this->targetID)) { throw new IllegalModelStateException('Invalid targetID'); } if (!GID::isValid($this->author)) { throw new IllegalModelStateException('Invalid author'); } if ($this->status == '' || $this->status == NULL) { throw new IllegalModelStateException('Invalid status: ' . $this->status); } if ($this->status != ConversationMessageStatusObject::STATUS_READ && $this->status != ConversationMessageStatusObject::STATUS_RECEIVED && $this->status != ConversationMessageStatusObject::STATUS_DELETED) { throw new IllegalModelStateException('Invalid status: ' . $this->status); } if (!XSDDateTime::validateXSDDateTime($this->datetime)) { throw new IllegalModelStateException('Invalid datetime: ' . $this->datetime); } $conversationMessageStatus = new ConversationMessageStatusObject($this); if ($conversationMessageStatus->getSignature() == NULL) { $conversationMessageStatus->signObject(); } if (!$conversationMessageStatus->verifyObjectSignature()) { throw new IllegalModelStateException('Invalid signature'); } return $conversationMessageStatus; }
public function build() { if ($this->objectID == NULL) { $this->objectID = UOID::createUOID(); } if (!UOID::isValid($this->objectID)) { throw new IllegalModelStateException('Invalid objectID'); } if (!GID::isValid($this->owner)) { throw new IllegalModelStateException('Invalid owner'); } if (!GID::isValid($this->author)) { throw new IllegalModelStateException('Invalid author'); } if ($this->activity == '' || $this->activity == NULL) { throw new IllegalModelStateException('Invalid activity'); } if (!XSDDateTime::validateXSDDateTime($this->datetime)) { throw new IllegalModelStateException('Invalid datetime'); } $streamItem = new StreamItemObject($this); if ($streamItem->getSignature() == NULL) { $streamItem->signObject(); } if (!$streamItem->verifyObjectSignature()) { throw new IllegalModelStateException('Invalid signature'); } return $streamItem; }
public function build() { if ($this->objectID == NULL) { $this->objectID = UOID::createUOID(); } if ($this->index == NULL || !is_numeric($this->index) || $this->index < 0) { $this->index = 0; } if (!UOID::isValid($this->objectID)) { throw new IllegalModelStateException('Invalid objectID'); } if (!GID::isValid($this->owner)) { throw new IllegalModelStateException('Invalid owner'); } if ($this->entityType == NULL) { throw new IllegalModelStateException('Invalid entityType'); } if ($this->entityID == NULL) { throw new IllegalModelStateException('Invalid entityID'); } if ($this->directive != AccessControlRuleObject::DIRECTIVE_DENY && $this->directive != AccessControlRuleObject::DIRECTIVE_ALLOW) { throw new IllegalModelStateException('Invalid directive'); } if ($this->entityType != AccessControlRuleObject::ENTITY_TYPE_ALL && $this->entityType != AccessControlRuleObject::ENTITY_TYPE_FRIENDS && $this->entityType != AccessControlRuleObject::ENTITY_TYPE_GROUP && $this->entityType != AccessControlRuleObject::ENTITY_TYPE_INDIVIDUAL) { throw new IllegalModelStateException('Invalid entityType'); } if (($this->entityType == AccessControlRuleObject::ENTITY_TYPE_ALL || $this->entityType == AccessControlRuleObject::ENTITY_TYPE_FRIENDS) && $this->entityID != AccessControlRuleObject::WILDCARD) { throw new IllegalModelStateException('Invalid combination of entityType and entityID'); } if ($this->entityType == AccessControlRuleObject::ENTITY_TYPE_GROUP && !UOID::isValid($this->entityID)) { throw new IllegalModelStateException('entityType GROUP requires a valid UOID as entityID'); } if ($this->entityType == AccessControlRuleObject::ENTITY_TYPE_INDIVIDUAL && !GID::isValid($this->entityID)) { throw new IllegalModelStateException('entityType INDIVIDUAL requires a valid GlobalID as entityID'); } if ($this->targetType != AccessControlRuleObject::TARGET_TYPE_INTERFACE && $this->targetType != AccessControlRuleObject::TARGET_TYPE_CONTENT) { throw new IllegalModelStateException('Invalid targetType'); } if ($this->target == NULL) { throw new IllegalModelStateException('Invalid target'); } if ($this->accessType != AccessControlRuleObject::ACCESS_TYPE_READ && $this->accessType != AccessControlRuleObject::ACCESS_TYPE_WRITE && $this->accessType != AccessControlRuleObject::WILDCARD) { throw new IllegalModelStateException('Invalid accessType'); } return new AccessControlRuleObject($this); }
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); }
public function build() { if ($this->objectID == NULL) { $this->objectID = UOID::createUOID(); } if ($this->members == NULL) { $this->members = array(); } if ($this->datetime == NULL) { $this->datetime = XSDDateTime::getXSDDateTime(); } if (!UOID::isValid($this->objectID)) { throw new IllegalModelStateException('Invalid objectID'); } if (!GID::isValid($this->owner)) { throw new IllegalModelStateException('Invalid owner'); } if (!XSDDateTime::validateXSDDateTime($this->datetime)) { throw new IllegalModelStateException('Invalid datetime'); } if (!is_array($this->members)) { throw new IllegalModelStateException('Invalid members'); } $conversation = new ConversationObject($this); if ($this->signature == NULL) { $conversation->signObject(); } if (!$conversation->verifyObjectSignature()) { throw new IllegalModelStateException('Invalid signature'); } return $conversation; }