/**
  * @dataProvider isExpiredDataProvider
  */
 public function testIsExpired($timeString, $expireTimeout, $addSeconds, $isExpired)
 {
     $time = new \DateTime($timeString);
     $info = Info::factorySuccess('dummy', $time);
     $expireCheckTime = $time->getTimestamp() + $addSeconds;
     $this->assertSame($isExpired, $info->isExpired($expireTimeout, $expireCheckTime));
 }
 /**
  * Creates a new session for the provided user and saves it in the storage.
  * 
  * @param UserInterface $user
  * @param Authentication\Info $authenticationInfo
  * @throws Exception\MissingComponentException
  * @return Session
  */
 public function createSession(UserInterface $user, Authentication\Info $authenticationInfo)
 {
     $sessionIdGenerator = $this->getSessionIdGenerator();
     if (!$sessionIdGenerator) {
         throw new GeneralException\MissingDependencyException('session ID generator');
     }
     $serializer = $this->getUserSerializer();
     if (!$serializer) {
         throw new GeneralException\MissingDependencyException('user serializer');
     }
     $storage = $this->getStorageWithCheck();
     $sessionId = $sessionIdGenerator->generateId(array($user->getId()));
     $serializedUserData = $serializer->serialize($user);
     $dateTimeUtil = $this->getDateTimeUtil();
     $now = $dateTimeUtil->createDateTime();
     $expire = $dateTimeUtil->createExpireDateTime($now, $this->getSessionExpireInterval());
     $session = new Session(array(Session::FIELD_ID => $sessionId, Session::FIELD_USER_ID => $user->getId(), Session::FIELD_CREATE_TIME => $now, Session::FIELD_MODIFY_TIME => $now, Session::FIELD_AUTHENTICATION_TIME => $authenticationInfo->getTime(), Session::FIELD_EXPIRATION_TIME => $expire, Session::FIELD_AUTHENTICATION_METHOD => $authenticationInfo->getMethod(), Session::FIELD_USER_DATA => $serializedUserData));
     $storage->saveSession($session);
     return $session;
 }
 /**
  * Returns true, if the user has been authenticated.
  * 
  * @return boolean
  */
 public function isUserAuthenticated()
 {
     return $this->authenticationInfo instanceof Authentication\Info && $this->authenticationInfo->isAuthenticated();
 }
 protected function _initFailureAuthenticationInfo($error, $description = '')
 {
     return Info::factoryFailure($this->getLabel(), $error, $description);
 }