Ejemplo n.º 1
0
 /**
  * @return string
  */
 protected function createFormToken()
 {
     $token = StringGenerator::randomAlnum(128);
     $cacheKey = self::$formTokenApcCacheKey . $token;
     apc_store($cacheKey, true, self::$formTokenExpirationTime);
     return $token;
 }
 public function __construct()
 {
     $this->setVariables(new ArrayCollection());
     $this->setToken(StringGenerator::randomAlnum(self::TOKEN_LENGHT));
     $this->generateExpirationDate();
 }
Ejemplo n.º 3
0
 /**
  * @param string $redirectUrl
  * @return string
  */
 protected function createRedirectToken($redirectUrl)
 {
     $token = StringGenerator::randomAlnum(16);
     apc_store(self::$redirectTokenApcCacheKey . $token, $redirectUrl);
     return $token;
 }
Ejemplo n.º 4
0
 public function testRandomUuid()
 {
     $string = StringGenerator::randomUuid();
     $this->assertRegExp("/^[a-z0-9]{8,8}-[a-z0-9]{4,4}-[a-z0-9]{4,4}-[a-z0-9]{4,4}-[a-z0-9]{12,12}\$/", $string);
 }
Ejemplo n.º 5
0
 /**
  * generate new token
  * by uniqId and time requested
  * @param null $namespace
  * @param int $length
  * @return string
  */
 public static function generate($namespace = null, $length = 25)
 {
     $uniqValue = uniqid(rand(), true) . time();
     $uniqValue .= !is_null($namespace) ? $namespace : '';
     return strtoupper(sha1($uniqValue)) . StringGenerator::randomAlnum($length, true);
 }