/**
  * Automatically expires the session if the user has been inactive for too long.
  *
  * @return boolean TRUE if the session expired, FALSE if not
  */
 protected function autoExpire()
 {
     $lastActivitySecondsAgo = $this->now - $this->lastActivityTimestamp;
     $expired = false;
     if ($this->inactivityTimeout !== 0 && $lastActivitySecondsAgo > $this->inactivityTimeout) {
         $this->started = true;
         $this->sessionIdentifier = $this->sessionCookie->getValue();
         $this->destroy(sprintf('Session %s was inactive for %s seconds, more than the configured timeout of %s seconds.', $this->sessionIdentifier, $lastActivitySecondsAgo, $this->inactivityTimeout));
         $expired = true;
     }
     return $expired;
 }
 /**
  * Sets a cookie
  *
  * @param \TYPO3\Flow\Http\Cookie $cookie
  * @return void
  * @api
  */
 public function setCookie(Cookie $cookie)
 {
     $this->cookies[$cookie->getName()] = $cookie;
 }
 /**
  * @test
  */
 public function createCookieFromRawSetsHttpOnlyIfPresent()
 {
     $cookie = Cookie::createFromRawSetCookieHeader('ckName=someValue; HttpOnly; more=nothing');
     $this->assertTrue($cookie->isHttpOnly());
 }
 /**
  * @param \TYPO3\Flow\Security\Account $account
  * @param \TYPO3\Flow\Http\Cookie $sessionCookie
  * @return \stdClass
  */
 protected function buildAccountDTO(\TYPO3\Flow\Security\Account $account, \TYPO3\Flow\Http\Cookie $sessionCookie = NULL)
 {
     $person = $this->partyService->getAssignedPartyOfAccount($account);
     $simpleAccount = new \stdClass();
     $simpleAccount->displayName = (string) $person->getName();
     if ($sessionCookie !== NULL) {
         $simpleAccount->sessionIdentifier = $sessionCookie->getValue();
     }
     $simpleAccount->profile = sprintf('//typo3.org/services/userimage.php?username=%s&size=big', $account->getAccountIdentifier());
     $simpleAccount->roles = [];
     foreach ($account->getRoles() as $role) {
         /** @var $role \TYPO3\Flow\Security\Policy\Role */
         $simpleAccount->roles[] = $role->getName();
     }
     return $simpleAccount;
 }
 /**
  * Creates a response from the given raw, that is plain text, HTTP response.
  *
  * @param string $rawResponse
  * @param \TYPO3\Flow\Http\Response $parentResponse Parent response, if called recursively
  *
  * @throws \InvalidArgumentException
  * @return \TYPO3\Flow\Http\Response
  */
 public static function createFromRaw($rawResponse, Response $parentResponse = NULL)
 {
     $response = new static($parentResponse);
     $lines = explode(chr(10), $rawResponse);
     $firstLine = array_shift($lines);
     if (substr($firstLine, 0, 5) !== 'HTTP/') {
         throw new \InvalidArgumentException('The given raw HTTP message is not a valid response.', 1335175601);
     }
     list(, $statusCode, $statusMessage) = explode(' ', $firstLine, 3);
     $response->setStatus((int) $statusCode, trim($statusMessage));
     $parsingHeader = TRUE;
     $contentLines = array();
     $headers = new Headers();
     foreach ($lines as $line) {
         if ($parsingHeader) {
             if (trim($line) === '') {
                 $parsingHeader = FALSE;
                 continue;
             }
             $fieldName = trim(substr($line, 0, strpos($line, ':')));
             $fieldValue = trim(substr($line, strlen($fieldName) + 1));
             if (strtoupper(substr($fieldName, 0, 10)) === 'SET-COOKIE') {
                 $cookie = Cookie::createFromRawSetCookieHeader($fieldValue);
                 if ($cookie !== NULL) {
                     $headers->setCookie($cookie);
                 }
             } else {
                 $headers->set($fieldName, $fieldValue, FALSE);
             }
         } else {
             $contentLines[] = $line;
         }
     }
     $content = implode(chr(10), $contentLines);
     $response->setHeaders($headers);
     $response->setContent($content);
     return $response;
 }