Ejemplo n.º 1
0
 public function testCheckTimestamp()
 {
     static::assertTrue($this->validator->checkTimestamp(time()));
     static::assertTrue($this->validator->checkTimestamp(time() + 180));
     static::assertTrue($this->validator->checkTimestamp(time() - 180));
     static::assertFalse($this->validator->checkTimestamp(time() + 181));
     static::assertFalse($this->validator->checkTimestamp(time() - 181));
 }
Ejemplo n.º 2
0
 /**
  * @param string            $uid
  * @param int               $timestamp Unix Timestamp
  * @param string            $signature
  * @param ResponseInterface $response
  *
  * @throws InvalidTimestampException
  * @throws InvalidUidSignatureException
  *
  * @return bool
  */
 private function assertUid($uid, $timestamp, $signature, ResponseInterface $response)
 {
     if (!$this->signature->checkTimestamp($timestamp)) {
         throw new InvalidTimestampException($timestamp, $response);
     }
     $expected = $this->signature->getUidSignature($uid, $timestamp, $this->secret);
     if ($signature !== $expected) {
         throw new InvalidUidSignatureException($uid, $expected, $signature, $response);
     }
     return true;
 }