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->targetGID != "" && !GID::isValid($this->targetGID)) {
         throw new IllegalModelStateException('Invalid targetGID: ' . $this->targetGID);
     }
     if ($this->status == '' || $this->status == NULL) {
         throw new IllegalModelStateException('Invalid status: ' . $this->status);
     }
     if (!XSDDateTime::validateXSDDateTime($this->datetime)) {
         throw new IllegalModelStateException('Invalid datetime');
     }
     $conversationStatus = new ConversationStatusObject($this);
     if ($conversationStatus->getSignature() == NULL) {
         $conversationStatus->signObject();
     }
     if (!$conversationStatus->verifyObjectSignature()) {
         throw new IllegalModelStateException('Invalid signature');
     }
     return $conversationStatus;
 }
Example #2
0
 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->featureList == NULL) {
         $this->featureList = array();
     }
     if ($this->datetime == NULL) {
         $this->datetime = XSDDateTime::getXSDDateTime();
     }
     if ($this->expires == NULL) {
         $this->expires = $this->datetime;
     }
     if (!UOID::isValid($this->objectID)) {
         throw new IllegalModelStateException('Invalid objectID');
     }
     $featureList = new FeatureListObject($this);
     if ($this->signature == NULL) {
         $featureList->signObject();
     }
     if (!$featureList->verifyObjectSignature()) {
         throw new IllegalModelStateException('Invalid signature');
     }
     return $featureList;
 }
 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;
 }
Example #5
0
 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;
 }
Example #6
0
 public function build()
 {
     if ($this->objectID == NULL) {
         $this->objectID = UOID::createUOID();
     }
     if (!UOID::isValid($this->objectID)) {
         throw new IllegalModelStateException('Invalid objectID');
     }
     $featureObject = new FeatureObject($this);
     return $featureObject;
 }
 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);
 }
Example #8
0
 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);
 }
Example #9
0
 /**
  * determines if a globalID has access priviledges for a specific resource
  * 
  * @param $gid the GlobalID of the user accessing the content
  * @param $uoid UOID of the resource being accessed
  * 
  * @return boolean
  */
 public function hasContentAccessPriviledges($gid, $uoid)
 {
     if (!UOID::isValid($uoid) && $uoid) {
         throw new AccessControlManagerException('Illegal argument UOID: ' . $uoid);
     }
     try {
         $rules = $this->loadAccessControlRulesForUOID($gid, $uoid);
         return $this->executeAccessControlRules($gid, $rules);
     } catch (AccessControlManagerException $e) {
         if ($this->baseDirectiveInterface == AccessControlManager::DIRECTIVE_DENY) {
             return false;
         } else {
             return true;
         }
     }
 }
Example #10
0
 public function testUOID()
 {
     $uoid1 = '3Z51OUSP4UPXTEOOKSDXVZQLMYGNJQVY0SKYUKKGVT8QWD78T5:0b9357af0b74e6a4';
     // ok
     $uoid2 = '2Z51OUSP4UPXTEOOKSDXVZQLMYGNJQVY0:0b9357af0b74e6a4';
     // invalid GID
     $uoid3 = '2-Z51OUSP4UPXTEOOKSDXVZQLMYGNJQVY0SKYUKKGVT8QWD78T:0b9357af0b74e6a4';
     // invalid GID
     $uoid4 = '3Z51OUSP4UPXTEOOKSDXVZQLMYGNJQVY0SKYUKKGVT8QWD78T5:0b94357af0b74e6a4';
     // invalid id
     $uoid5 = '3Z51OUSP4UPXTEOOKSDXVZQLMYGNJQVY0SKYUKKGVT8QWD78T5:0b94357_0b74e6a4';
     // invalid id
     $this->assertTrue(UOID::isValid($uoid1));
     $this->assertFalse(UOID::isValid($uoid2));
     $this->assertFalse(UOID::isValid($uoid3));
     $this->assertFalse(UOID::isValid($uoid4));
     $this->assertFalse(UOID::isValid($uoid5));
 }
 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->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);
 }
Example #14
0
 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;
 }
 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;
 }
 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 ($this->accept === true && $this->link == NULL) {
         throw new IllegalModelStateException('Invalid link');
     }
     if (!XSDDateTime::validateXSDDateTime($this->datetime)) {
         throw new IllegalModelStateException('Invalid datetime: ' . $this->datetime);
     }
     return new LinkResponseObject($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;
 }
 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);
 }
Example #19
0
 public function testSearch()
 {
     $searchQuery = (new SearchQueryObjectBuilder())->initiatingGID(Sonic::getContextGlobalID())->query((new ESQueryBuilder())->type('profile')->match('displayName', 'alice')->build())->datetime()->build();
     $this->assertTrue($searchQuery->validate());
     $this->assertEquals($searchQuery, SearchQueryObjectBuilder::buildFromJSON($searchQuery->getJSONString()));
     $profile = (new ProfileObjectBuilder())->globalID(Sonic::getContextGlobalID())->displayName($this->aliceSocialRecord->getDisplayName())->param('x', 'y')->build();
     $searchResult = (new SearchResultObjectBuilder())->targetID($searchQuery->getObjectID())->resultOwnerGID($profile->getGlobalID())->resultObjectID($profile->getObjectID())->resultIndex($searchQuery->getQuery()->getIndex())->resultType($searchQuery->getQuery()->getType())->displayName($profile->getDisplayName())->datetime()->build();
     $this->assertTrue($searchResult->validate());
     $this->assertEquals($searchResult, SearchResultObjectBuilder::buildFromJSON($searchResult->getJSONString()));
     $searchResultCollection = (new SearchResultCollectionObjectBuilder())->objectID(UOID::createUOID($this->platformSocialRecord->getGlobalID()))->targetID($searchQuery->getObjectID())->platformGID($this->platformSocialRecord->getGlobalID())->datetime()->result($searchResult)->build();
     $this->assertTrue($searchResultCollection->validate());
     $this->assertEquals($searchResultCollection, SearchResultCollectionObjectBuilder::buildFromJSON($searchResultCollection->getJSONString()));
 }