/**
  * 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;
     }
 }
 /**
  * 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;
 }
 /**
  * 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;
     }
 }
 /**
  * Returns the privileges a specific role has for the given joinpoint
  *
  * @param \F3\FLOW3\Security\ACL\Role $role The role for which the privileges should be returned
  * @param \F3\FLOW3\AOP\JoinPointInterface $joinPoint The joinpoint for which the privileges should be returned
  * @param string $privilegeType If set we check only for this type of privilege
  * @return array Array of privileges
  * @author Andreas Förthner <*****@*****.**>
  */
 public function getPrivilegesForJoinPoint(\F3\FLOW3\Security\ACL\Role $role, \F3\FLOW3\AOP\JoinPointInterface $joinPoint, $privilegeType = '')
 {
     $methodIdentifier = $joinPoint->getClassName() . '->' . $joinPoint->getMethodName();
     if (!isset($this->acls[$methodIdentifier])) {
         throw new \F3\FLOW3\Security\Exception\NoEntryInPolicyException('The given joinpoint was not found in the policy cache. Most likely you have to recreate the AOP proxy classes.', 1222100851);
     }
     $privileges = $this->parsePrivileges($methodIdentifier, (string) $role, $privilegeType);
     if (!is_array($privileges)) {
         return array();
     }
     return $privileges;
 }
 /**
  * Mark object as cloned after cloning.
  *
  * Note: this is done even if an object explicitly implements the
  * DirtyMonitoringInterface to make sure it is proxied by the AOP
  * framework (we need that to happen)
  *
  * @param \F3\FLOW3\AOP\JoinPointInterface $joinPoint
  * @return void
  * @afterreturning method(.*->__clone())
  * @author Robert Lemke <*****@*****.**>
  */
 public function cloneObject(\F3\FLOW3\AOP\JoinPointInterface $joinPoint)
 {
     $proxy = $joinPoint->getProxy();
     $proxy->FLOW3_Persistence_clone = TRUE;
 }
 /**
  * Passes the signal over to the Dispatcher
  *
  * @afterreturning methodTaggedWith(signal)
  * @param F3\FLOW3\AOP\JoinPointInterface $joinPoint The current join point
  * @return void
  * @author Robert Lemke <*****@*****.**>
  */
 public function forwardSignalToDispatcher(\F3\FLOW3\AOP\JoinPointInterface $joinPoint)
 {
     $this->dispatcher->dispatch($joinPoint->getClassName(), $joinPoint->getMethodName(), $joinPoint->getMethodArguments());
 }