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;
 }
 /**
  * @param $token Typo3OrgSsoToken
  * @throws StopActionException
  */
 public function authenticateAction(Typo3OrgSsoToken $token)
 {
     if ($token->isValid() && $this->typo3OrgSsoProvider->authenticate($token)) {
         $this->response->setStatus(200);
         $this->response->setContent('<html><head><script>window.close();</script></head></html>');
         throw new StopActionException();
     }
 }