Esempio n. 1
0
 /**
 * logs in host
 *
 * @param string $login
 * @param string $password
 * @param string $remoteAddress
 * @param bool $isMasterAccount
 *
 *@return null|SessionDeprecated
 * @throws ForbiddenException
 * @throws SessionAlreadyExistsException
 * @throws UnauthorizedException
 */
 public function createSessionInOracle($login, $password, $remoteAddress, $isMasterAccount = false)
 {
     $session = null;
     $now = new DateTimeImmutable();
     $sessionId = '';
     $sid = '';
     $uid = 0;
     $returnValue = 0;
     $isMasterAccount = $isMasterAccount ? 1 : 0;
     $this->oracle->plsql('P_HOST_SENDERTOOL_LOGIN_V8')->inString($login)->inString($password)->inString($remoteAddress)->inString('')->outInt($sessionId)->outString($sid, 40)->inInt($isMasterAccount)->outInt($uid)->outInt($returnValue)->call();
     if ($returnValue >= 0) {
         $sessionData = ['uid' => $uid, 'userType' => $this->userFactory->getUserTypeById($uid), 'login' => $login, 'isMasterAccount' => $isMasterAccount, 'sid' => $sessionId, 'sessionType' => SessionTypeEnum::SID_SESSION, 'validFrom' => $now, 'validUntil' => $now->add(new DateInterval('PT' . SidSessionType::TIMEOUT_HOST . 'S')), 'remoteAddress' => $remoteAddress, 'active' => true];
         $session = SessionDeprecated::createFromArray($sessionData);
     } else {
         $this->handleError($returnValue, $login);
     }
     return $session;
 }
Esempio n. 2
0
 /**
 * @param $sessionIdentifier
 *
 *@return SessionDeprecated|null
 */
 public function getHistorySession($sid)
 {
     if (!isset($this->session[$sid])) {
         $this->historySession[$sid] = $this->dataProvider->getHistorySessionFromRedis($sid);
     }
     if (!isset($this->session[$sid]) || isset($this->session[$sid]) && !$this->session[$sid]) {
         $this->historySession[$sid] = $this->dataProvider->getHistorySessionFromOracle($sid);
         if ($this->historySession[$sid]) {
             $host = $this->userFactory->getHostById($this->historySession[$sid]->getUserId());
             if ($host) {
                 $data = $host->asArray();
                 $data['sid'] = $sid;
                 $data['sessionType'] = SessionTypeEnum::SID_SESSION;
                 ObjectUtil::hydrateObject($this->historySession[$sid], $data);
             }
             $this->dataProvider->setHistorySessionToRedis($sid, $this->historySession[$sid]);
         }
     }
     return isset($this->historySession[$sid]) ? $this->historySession[$sid] : null;
 }
Esempio n. 3
0
 /**
  * @param $userId
  * @param $key
  * @param $lang
  * @return string
  */
 private function buildKey($userId, $key, $lang)
 {
     $userType = $this->userFactory->getUserTypeById($userId);
     return 'users:' . $userType . ':' . $userId . ':texts:' . $key . ':' . $lang;
 }