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 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; }
protected function verifyDataFormat() { // TODO validate data and formats if (!XSDDateTime::validateXSDDateTime($this->headers[SONIC_HEADER__DATE])) { throw new MalformedRequestHeaderException("Malformed request: Header " . SONIC_HEADER__DATE . " malformed: " . $this->headers[SONIC_HEADER__DATE]); } return true; }
public function setDatePublished($datePublished) { if ($datePublished == NULL) { $this->datePublished = XSDDateTime::getXSDDateTime(); } else { $this->datePublished = $datePublished; } return $this; }
public function setDatetime($datetime = NULL) { if ($datetime == NULL) { $this->datetime = XSDDateTime::getXSDDateTime(); } else { $this->datetime = $datetime; } return $this; }
public function testXSDDateTime() { $time = 1449479356; $datetime = '2015-12-07T10:09:16+01:00'; //$this->assertEquals(false, XSDDateTime::validateXSDDateTime($impossible)); $this->assertEquals(true, XSDDateTime::validateXSDDateTime($datetime)); $this->assertEquals($datetime, XSDDateTime::getXSDDateTime($time)); $this->assertEquals($time, XSDDateTime::getUnixTimestamp($datetime)); }
public function __construct($expectedGID = NULL) { $this->headers = array(); $this->headers[SONIC_HEADER__RANDOM] = Random::getRandom(); $this->headers[SONIC_HEADER__DATE] = XSDDateTime::getXSDDatetime(); $this->headers[SONIC_HEADER__TARGET_API] = SONIC_SDK__API_VERSION; $this->headers[SONIC_HEADER__PLATFORM_GID] = Sonic::getPlatformGlobalID(); $this->headers[SONIC_HEADER__SOURCE_GID] = Sonic::getContextGlobalID(); }
public function setDateUpdated($dateUpdated = NULL) { if ($dateUpdated == NULL) { $this->dateUpdated = XSDDateTime::getXSDDateTime(); } else { $this->dateUpdated = $dateUpdated; } $this->invalidate(); return $this; }
/** * constructor for building a Sonic compliant HTTP response. */ public function __construct() { $this->headers = array(); $this->headers[SONIC_HEADER__RANDOM] = Random::getRandom(); $this->headers[SONIC_HEADER__DATE] = XSDDateTime::getXSDDatetime(); $this->headers[SONIC_HEADER__TARGET_API] = SONIC_SDK__API_VERSION; $this->headers[SONIC_HEADER__PLATFORM_GID] = Sonic::getPlatformGlobalID(); $this->headers[SONIC_HEADER__SOURCE_GID] = Sonic::getContextGlobalID(); $this->statusCode = 200; $this->statusMessage = 'OK'; }
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; }
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); }
/** * 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 (!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->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 ($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->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 (!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->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); }
/** * 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->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; }