/**
  * Around advice
  *
  * @around method(F3\FLOW3\MVC\Web\Routing\Router->findMatchResults())
  * @param F3\FLOW3\AOP\JoinPointInterface $joinPoint The current join point
  * @return array Result of the target method
  * @author Bastian Waidelich <*****@*****.**>
  */
 public function cacheMatchingCall(\F3\FLOW3\AOP\JoinPointInterface $joinPoint)
 {
     $requestPath = $joinPoint->getMethodArgument('requestPath');
     $cacheIdentifier = md5($requestPath);
     if ($this->findMatchResultsCache->has($cacheIdentifier)) {
         return $this->findMatchResultsCache->get($cacheIdentifier);
     }
     $matchResults = $joinPoint->getAdviceChain()->proceed($joinPoint);
     if ($matchResults !== NULL) {
         $this->findMatchResultsCache->set($cacheIdentifier, $matchResults);
     }
     return $matchResults;
 }
 /**
  * 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;
 }
 /**
  * Checks if the given encrypted password is correct by
  * comparing it's md5 hash. The salt is appendend to the decrypted password string before hashing.
  *
  * @param string $encryptedPassword The received, RSA encrypted password to check
  * @param string $passwordHash The md5 hashed password string (md5(md5(password) . salt))
  * @param string $salt The salt used in the md5 password hash
  * @param UUID $uuid The uuid to identify to correct private key
  * @return boolean TRUE if the password is correct
  * @throws F3\FLOW3\Security\Exception\InvalidKeyPairIdException If the given UUID identifies no valid keypair
  * @author Andreas Förthner <*****@*****.**>
  */
 public function checkRSAEncryptedPassword($encryptedPassword, $passwordHash, $salt, $uuid)
 {
     if ($uuid === NULL || !$this->keystoreCache->has($uuid)) {
         throw new \F3\FLOW3\Security\Exception\InvalidKeyPairIdException('Invalid keypair UUID given', 1233655216);
     }
     $keyPair = $this->keystoreCache->get($uuid);
     $decryptedPassword = $this->decryptWithPrivateKey($encryptedPassword, $keyPair['privateKey']);
     return $passwordHash === md5(md5($decryptedPassword) . $salt);
 }
 /**
  * Tries to load the reflection data from this service's cache.
  *
  * @return void
  * @author Robert Lemke <*****@*****.**>
  */
 protected function loadFromCache()
 {
     if ($this->dataCache->has('ReflectionData')) {
         $data = $this->dataCache->get('ReflectionData');
         foreach ($data as $propertyName => $propertyValue) {
             $this->{$propertyName} = $propertyValue;
         }
         $this->cachedClassNames = $this->reflectedClassNames;
     }
 }
 /**
  * Initializes the AOP framework.
  *
  * During initialization the specified configuration of objects is searched for possible
  * aspect annotations. If an aspect class is found, the poincut expressions are parsed and
  * a new aspect with one or more advisors is added to the aspect registry of the AOP framework.
  * Finally all advices are woven into their target classes by generating proxy classes.
  *
  * The class names of all proxied classes is stored back in the $objectConfigurations array.
  *
  * @param array &$objectConfigurations
  * @return void
  * @author Robert Lemke <*****@*****.**>
  */
 public function initialize(array &$objectConfigurations)
 {
     if ($this->isInitialized) {
         throw new \F3\FLOW3\AOP\Exception('The AOP framework has already been initialized!', 1169550994);
     }
     $this->isInitialized = TRUE;
     if ($this->proxyBuildInformationCache->has('targetAndProxyClassNames')) {
         $this->targetAndProxyClassNames = $this->proxyBuildInformationCache->get('targetAndProxyClassNames');
     }
     if (!$this->proxyBuildInformationCache->has('allProxyClassesUpToDate')) {
         $allAvailableClassNames = $this->getAllImplementationClassesFromObjectConfigurations($objectConfigurations);
         $cachedTargetClassNames = $this->proxyBuildInformationCache->has('targetClassNames') ? $this->proxyBuildInformationCache->get('targetClassNames') : array();
         $cachedAspectClassNames = $this->proxyBuildInformationCache->has('aspectClassNames') ? $this->proxyBuildInformationCache->get('aspectClassNames') : array();
         $actualTargetClassNames = $this->getProxyableClasses($allAvailableClassNames);
         $actualAspectClassNames = $this->reflectionService->getClassNamesByTag('aspect');
         sort($actualTargetClassNames);
         sort($actualAspectClassNames);
         $this->aspectContainers = $this->buildAspectContainers($allAvailableClassNames);
         $dirtyTargetClassNames = $actualTargetClassNames;
         if ($cachedAspectClassNames === $actualAspectClassNames) {
             $validProxyClassesCount = 0;
             $outdatedProxyClassesCount = 0;
             foreach ($this->targetAndProxyClassNames as $targetClassName => $proxyClassName) {
                 if ($this->proxyClassesCache->has(str_replace('\\', '_', $proxyClassName))) {
                     $validProxyClassesCount++;
                     $dirtyTargetClassNames = array_diff($dirtyTargetClassNames, array($targetClassName));
                 } else {
                     $outdatedProxyClassesCount++;
                     unset($this->targetAndProxyClassNames[$targetClassName]);
                 }
             }
             $this->systemLogger->log(sprintf('At least one target class changed, aspects unchanged. Found %s valid and %s outdated proxy classes.', $validProxyClassesCount, $outdatedProxyClassesCount), LOG_INFO);
         } else {
             $this->systemLogger->log(sprintf('At least one aspect changed, rebuilding proxy classes for %s target classes.', count($actualTargetClassNames)), LOG_INFO);
             $this->proxyClassesCache->flush();
             $this->targetAndProxyClassNames = array();
         }
         foreach ($dirtyTargetClassNames as $targetClassName) {
             $proxyBuildResult = $this->proxyClassBuilder->buildProxyClass($targetClassName, $this->aspectContainers, $this->objectManager->getContext());
             if ($proxyBuildResult !== FALSE) {
                 $this->targetAndProxyClassNames[$targetClassName] = $proxyBuildResult['proxyClassName'];
                 $this->systemLogger->log(sprintf('Built proxy class "%s" for target class "%s" (length: %s).', $proxyBuildResult['proxyClassName'], $targetClassName, strlen($proxyBuildResult['proxyClassCode'])), LOG_DEBUG);
                 $this->proxyClassesCache->set(str_replace('\\', '_', $proxyBuildResult['proxyClassName']), $proxyBuildResult['proxyClassCode'], array($this->proxyClassesCache->getClassTag($targetClassName)));
             } else {
                 unset($this->targetAndProxyClassNames[$targetClassName]);
             }
         }
         $aspectClassesTags = array();
         foreach ($actualAspectClassNames as $aspectClassName) {
             $aspectClassesTags[] = $this->proxyBuildInformationCache->getClassTag($aspectClassName);
         }
         $this->proxyBuildInformationCache->set('targetAndProxyClassNames', $this->targetAndProxyClassNames);
         $this->proxyBuildInformationCache->set('aspectClassNames', $actualAspectClassNames, $aspectClassesTags);
         $this->proxyBuildInformationCache->set('targetClassNames', $actualTargetClassNames);
         $this->proxyBuildInformationCache->set('allProxyClassesUpToDate', '', array($this->proxyClassesCache->getClassTag()));
     }
     foreach ($this->targetAndProxyClassNames as $targetClassName => $proxyClassName) {
         if (class_exists($proxyClassName, FALSE)) {
             throw new \F3\FLOW3\AOP\Exception('Class ' . $proxyClassName . ' already exists.', 1229361833);
         }
         if (!$this->proxyClassesCache->has(str_replace('\\', '_', $proxyClassName))) {
             throw new \F3\FLOW3\AOP\Exception('No proxy class code for class "' . $proxyClassName . '" found in cache.', 1229362833);
         }
         $this->proxyClassesCache->requireOnce(str_replace('\\', '_', $proxyClassName));
         foreach ($objectConfigurations as $objectName => $objectConfiguration) {
             if ($objectConfiguration->getClassName() === $targetClassName) {
                 $objectConfigurations[$objectName]->setClassName($proxyClassName);
             }
         }
     }
 }
 /**
  * Initializes this monitor
  *
  * @return void
  * @author Robert Lemke <*****@*****.**>
  */
 public function initializeObject()
 {
     if ($this->cache->has('directoriesAndFiles')) {
         $this->directoriesAndFiles = $this->cache->get('directoriesAndFiles');
     }
 }
 /**
  * Initializes this strategy
  *
  * @return void
  * @author Robert Lemke <*****@*****.**>
  */
 public function initializeObject()
 {
     if ($this->cache->has('filesAndModificationTimes')) {
         $this->filesAndModificationTimes = $this->cache->get('filesAndModificationTimes');
     }
 }