コード例 #1
0
ファイル: OutgoingRequest.php プロジェクト: sgoendoer/sonic
 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();
 }
コード例 #2
0
ファイル: UOID.php プロジェクト: sgoendoer/sonic
 /**
  * Creates a new UOID for the current Sonic context
  * 
  * @param $gid String The global id part of the UOID
  * @param $id String The local id part of the UOID
  * 
  * @return A UOID
  */
 public static function createUOID($gid = NULL, $id = NULL)
 {
     if ($gid == NULL) {
         $gid = Sonic::getContextGlobalID();
     }
     if ($id == NULL) {
         $id = Random::getUniqueRandom();
     }
     $uoid = $gid . UOID::SEPARATOR . $id;
     return $uoid;
 }
コード例 #3
0
ファイル: OutgoingResponse.php プロジェクト: sgoendoer/sonic
 /**
  * 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';
 }
コード例 #4
0
ファイル: CryptUnitTest.php プロジェクト: sgoendoer/sonic
 public function testRandom()
 {
     $this->assertTrue(strlen(Random::getRandom()) == 16);
     $this->assertTrue(strlen(Random::getRandom(2)) == 2);
 }
コード例 #5
0
 /**
  * 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);
 }