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(); }
/** * 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 testRandom() { $this->assertTrue(strlen(Random::getRandom()) == 16); $this->assertTrue(strlen(Random::getRandom(2)) == 2); }
/** * 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); }