/**
  * Around advice. Caches calls of parseTemplate() in classes implementing F3\Fluid\View\TemplateViewInterface.
  * This advice is only active if Fluid.syntaxTreeCache.enable is TRUE.
  *
  * @around within(F3\Fluid\View\TemplateViewInterface) && method(.*->parseTemplate()) && setting(Fluid.syntaxTreeCache.enable)
  * @param F3\FLOW3\AOP\JoinPointInterface $joinPoint The current join point
  * @return \F3\Fluid\Core\Parser\ParsedTemplateInterface template tree
  * @author Sebastian Kurfürst <*****@*****.**>
  * @author Bastian Waidelich <*****@*****.**>
  */
 public function cacheParseTemplateCall(\F3\FLOW3\AOP\JoinPointInterface $joinPoint)
 {
     $templatePathAndFilename = $joinPoint->getMethodArgument('templatePathAndFilename');
     if (array_key_exists($templatePathAndFilename, $this->localSyntaxTreeCache)) {
         return $this->localSyntaxTreeCache[$templatePathAndFilename];
     }
     $cacheIdentifier = md5($templatePathAndFilename);
     if ($this->syntaxTreeCache->has($cacheIdentifier)) {
         return $this->syntaxTreeCache->get($cacheIdentifier);
     }
     $parsedTemplate = $joinPoint->getAdviceChain()->proceed($joinPoint);
     $this->syntaxTreeCache->set($cacheIdentifier, $parsedTemplate);
     $this->localSyntaxTreeCache[$templatePathAndFilename] = $parsedTemplate;
     return $parsedTemplate;
 }
 /**
  * Logs calls and results of the authenticate() method of the PersistedUsernamePasswordProvider Authentication Provider
  *
  * @afterreturning method(F3\FLOW3\Security\Authentication\Provider\PersistedUsernamePasswordProvider->authenticate())
  * @param \F3\FLOW3\AOP\JoinPointInterface $joinPoint The current joinpoint
  * @return mixed The result of the target method if it has not been intercepted
  * @author Robert Lemke <*****@*****.**>
  */
 public function logPersistedUsernamePasswordProviderAuthenticate(\F3\FLOW3\AOP\JoinPointInterface $joinPoint)
 {
     $token = $joinPoint->getMethodArgument('authenticationToken');
     $credentials = $token->getCredentials();
     switch ($token->getAuthenticationStatus()) {
         case \F3\FLOW3\Security\Authentication\TokenInterface::AUTHENTICATION_SUCCESSFUL:
             $this->systemLogger->log('Successfully authenticated user "' . $credentials['username'] . '".', LOG_INFO, array(), 'FLOW3', 'F3\\FLOW3\\Security\\Authentication\\Provider\\PersistedUsernamePasswordProvider', 'authenticate');
             break;
         case \F3\FLOW3\Security\Authentication\TokenInterface::WRONG_CREDENTIALS:
             $this->systemLogger->log('Wrong password given for user "' . $credentials['username'] . '".', LOG_WARNING, array(), 'FLOW3', 'F3\\FLOW3\\Security\\Authentication\\Provider\\PersistedUsernamePasswordProvider', 'authenticate');
             break;
         case \F3\FLOW3\Security\Authentication\TokenInterface::NO_CREDENTIALS_GIVEN:
             $this->systemLogger->log('No credentials given or no account found with username "' . $credentials['username'] . '".', LOG_WARNING, array(), 'FLOW3', 'F3\\FLOW3\\Security\\Authentication\\Provider\\PersistedUsernamePasswordProvider', 'authenticate');
             break;
     }
 }
 /**
  * Catches AuthenticationRequired Exceptions and tries to call an authentication entry point,
  * if available.
  *
  * @afterthrowing method(F3\FLOW3\MVC\Dispatcher->dispatch()) && setting(FLOW3.security.enable)
  * @param F3\FLOW3\AOP\JoinPointInterface $joinPoint The current joinpoint
  * @return void
  * @author Andreas Förthner <*****@*****.**>
  */
 public function forwardAuthenticationRequiredExceptionsToAnAuthenticationEntryPoint(\F3\FLOW3\AOP\JoinPointInterface $joinPoint)
 {
     $exception = $joinPoint->getException();
     $request = $joinPoint->getMethodArgument('request');
     $response = $joinPoint->getMethodArgument('response');
     if (!$exception instanceof \F3\FLOW3\Security\Exception\AuthenticationRequiredException) {
         throw $exception;
     }
     $entryPointFound = FALSE;
     foreach ($this->securityContextHolder->getContext()->getAuthenticationTokens() as $token) {
         $entryPoint = $token->getAuthenticationEntryPoint();
         if ($entryPoint !== NULL && $entryPoint->canForward($request)) {
             $entryPointFound = TRUE;
             $entryPoint->startAuthentication($request, $response);
         }
     }
     if ($entryPointFound === FALSE) {
         throw $exception;
     }
 }
 /**
  * Around advice
  *
  * @around method(F3\FLOW3\MVC\Web\Routing\Router->resolve())
  * @param F3\FLOW3\AOP\JoinPointInterface $joinPoint The current join point
  * @return string Result of the target method
  * @author Bastian Waidelich <*****@*****.**>
  * @author Karsten Dambekalns <*****@*****.**>
  */
 public function cacheResolveCall(\F3\FLOW3\AOP\JoinPointInterface $joinPoint)
 {
     $routeValues = $joinPoint->getMethodArgument('routeValues');
     $routeValues = $this->convertObjectsToHashes($routeValues);
     \F3\FLOW3\Utility\Arrays::sortKeysRecursively($routeValues);
     $cacheIdentifier = md5(http_build_query($routeValues));
     if ($this->resolveCache->has($cacheIdentifier)) {
         return $this->resolveCache->get($cacheIdentifier);
     }
     $matchingUri = $joinPoint->getAdviceChain()->proceed($joinPoint);
     if ($matchingUri !== '') {
         $this->resolveCache->set($cacheIdentifier, $matchingUri);
     }
     return $matchingUri;
 }
 /**
  * Register an object's clean state, e.g. after it has been reconstituted
  * from the FLOW3 persistence layer
  *
  * The method takes an optional argument $propertyName to mark only the
  * specified property as clean. This was used in conjunction with lazy
  * loading...
  *
  * @param \F3\FLOW3\AOP\JoinPointInterface $joinPoint
  * @return void
  * @before F3\FLOW3\Persistence\Aspect\DirtyMonitoringAspect->needsDirtyCheckingAspect && method(.*->FLOW3_Persistence_memorizeCleanState())
  * @author Karsten Dambekalns <*****@*****.**>
  */
 public function memorizeCleanState(\F3\FLOW3\AOP\JoinPointInterface $joinPoint)
 {
     $proxy = $joinPoint->getProxy();
     if ($joinPoint->getMethodArgument('propertyName') !== NULL) {
         $propertyNames = array($joinPoint->getMethodArgument('propertyName'));
     } else {
         $propertyNames = array_keys($this->reflectionService->getClassSchema($joinPoint->getClassName())->getProperties());
     }
     foreach ($propertyNames as $propertyName) {
         if (is_object($proxy->FLOW3_AOP_Proxy_getProperty($propertyName))) {
             $proxy->FLOW3_Persistence_cleanProperties[$propertyName] = clone $proxy->FLOW3_AOP_Proxy_getProperty($propertyName);
         } else {
             $proxy->FLOW3_Persistence_cleanProperties[$propertyName] = $proxy->FLOW3_AOP_Proxy_getProperty($propertyName);
         }
     }
 }