Exemplo n.º 1
0
 /**
  * @param Typo3OrgSsoToken $authenticationToken
  * @return bool
  */
 public function authenticate(Typo3OrgSsoToken $authenticationToken)
 {
     /** @var $account FrontendUser */
     $account = null;
     $credentials = $authenticationToken->getCredentials();
     if (is_array($credentials) && isset($credentials['username'])) {
         $account = $this->frontendUserRepository->findOneByUsername($credentials['username']);
     }
     $authenticated = false;
     $authenticationData = 'version=' . $credentials['version'] . '&user='******'username'] . '&tpa_id=' . $credentials['tpaId'] . '&expires=' . $credentials['expires'] . '&action=' . $credentials['action'] . '&flags=' . $credentials['flags'] . '&userdata=' . $credentials['userdata'];
     $authenticationDataIsValid = $this->verifySignature($authenticationData, $credentials['signature']);
     if ($authenticationDataIsValid && $credentials['expires'] > time()) {
         $userdata = $this->parseUserdata($credentials['userdata']);
         if (!is_object($account)) {
             $account = $this->createAccount($userdata);
             $this->frontendUserRepository->add($account);
         } elseif (is_object($account)) {
             $account = $this->updateAccount($account, $userdata);
             $this->frontendUserRepository->update($account);
         }
         $this->persistenceManager->persistAll();
         $this->authenticationService->registerSession($account);
         $authenticated = true;
     }
     return $authenticated;
 }
 public function logoutAction()
 {
     $user = $this->frontendUserRepository->findCurrentUser();
     if ($user !== null) {
         $this->authenticationService->unregisterSession();
     }
 }