/** * Resolves the class name of an authentication provider. If a valid provider class name is given, it is just returned. * * @param string $providerName The (short) name of the provider * @return string The object name of the authentication provider * @throws \TYPO3\Flow\Security\Exception\NoAuthenticationProviderFoundException */ public function resolveProviderClass($providerName) { $resolvedObjectName = $this->objectManager->getCaseSensitiveObjectName($providerName); if ($resolvedObjectName !== false) { return $resolvedObjectName; } $resolvedObjectName = $this->objectManager->getCaseSensitiveObjectName('TYPO3\\Flow\\Security\\Authentication\\Provider\\' . $providerName); if ($resolvedObjectName !== false) { return $resolvedObjectName; } throw new \TYPO3\Flow\Security\Exception\NoAuthenticationProviderFoundException('An authentication provider with the name "' . $providerName . '" could not be resolved.', 1217154134); }
/** * Resolves the class name of a security interceptor. If a valid interceptor class name is given, it is just returned. * * @param string $name The (short) name of the interceptor * @return string The class name of the security interceptor, NULL if no class was found. * @throws \TYPO3\Flow\Security\Exception\NoInterceptorFoundException */ public function resolveInterceptorClass($name) { $resolvedObjectName = $this->objectManager->getCaseSensitiveObjectName($name); if ($resolvedObjectName !== false) { return $resolvedObjectName; } $resolvedObjectName = $this->objectManager->getCaseSensitiveObjectName('TYPO3\\Flow\\Security\\Authorization\\Interceptor\\' . $name); if ($resolvedObjectName !== false) { return $resolvedObjectName; } throw new \TYPO3\Flow\Security\Exception\NoInterceptorFoundException('A security interceptor with the name: "' . $name . '" could not be resolved.', 1217154134); }
/** * Resolves the class name of a request pattern. If a valid request pattern class name is given, it is just returned. * * @param string $name The (short) name of the pattern * @return string The class name of the request pattern, NULL if no class was found. * @throws \TYPO3\Flow\Security\Exception\NoRequestPatternFoundException */ public function resolveRequestPatternClass($name) { $resolvedObjectName = $this->objectManager->getCaseSensitiveObjectName($name); if ($resolvedObjectName !== FALSE) { return $resolvedObjectName; } $resolvedObjectName = $this->objectManager->getCaseSensitiveObjectName('TYPO3\\Flow\\Security\\RequestPattern\\' . $name); if ($resolvedObjectName !== FALSE) { return $resolvedObjectName; } throw new \TYPO3\Flow\Security\Exception\NoRequestPatternFoundException('A request pattern with the name: "' . $name . '" could not be resolved.', 1217154134); }
/** * Merge the default plugin arguments of the Plugin with the arguments in the request * and generate a controllerObjectName * * @param object $request * @param array $arguments * @return string $controllerObjectName */ public function getControllerObjectName($request, array $arguments) { $controllerName = $arguments['controllerName'] !== null ? $arguments['controllerName'] : $request->getControllerName(); $subPackageKey = $arguments['subPackageKey'] !== null ? $arguments['subPackageKey'] : $request->getControllerSubpackageKey(); $packageKey = $arguments['packageKey'] !== null ? $arguments['packageKey'] : $request->getControllerPackageKey(); $possibleObjectName = '@package\\@subpackage\\Controller\\@controllerController'; $possibleObjectName = str_replace('@package', str_replace('.', '\\', $packageKey), $possibleObjectName); $possibleObjectName = str_replace('@subpackage', $subPackageKey, $possibleObjectName); $possibleObjectName = str_replace('@controller', $controllerName, $possibleObjectName); $possibleObjectName = str_replace('\\\\', '\\', $possibleObjectName); $controllerObjectName = $this->objectManager->getCaseSensitiveObjectName($possibleObjectName); return $controllerObjectName !== false ? $controllerObjectName : ''; }
/** * Returns the object name of the controller defined by the package, subpackage key and * controller name * * @param string $packageKey the package key of the controller * @param string $subPackageKey the subpackage key of the controller * @param string $controllerName the controller name excluding the "Controller" suffix * @return string The controller's Object Name or NULL if the controller does not exist */ protected function getControllerObjectName($packageKey, $subPackageKey, $controllerName) { $possibleObjectName = '@package\\@subpackage\\Controller\\@controllerController'; $possibleObjectName = str_replace('@package', str_replace('.', '\\', $packageKey), $possibleObjectName); $possibleObjectName = str_replace('@subpackage', $subPackageKey, $possibleObjectName); $possibleObjectName = str_replace('@controller', $controllerName, $possibleObjectName); $possibleObjectName = str_replace('\\\\', '\\', $possibleObjectName); $controllerObjectName = $this->objectManager->getCaseSensitiveObjectName($possibleObjectName); return $controllerObjectName !== false ? $controllerObjectName : null; }
/** * Returns the object name of the controller defined by the package, subpackage key and * controller name * * @param string $packageKey the package key of the controller * @param string $subPackageKey the subpackage key of the controller * @param string $controllerName the controller name excluding the "Controller" suffix * @return string The controller's Object Name or NULL if the controller does not exist * @api */ public function getControllerObjectName($packageKey, $subPackageKey, $controllerName) { $possibleObjectName = $this->controllerObjectNamePattern; $possibleObjectName = str_replace('@package', str_replace('.', '\\', $packageKey), $possibleObjectName); $possibleObjectName = str_replace('@subpackage', $subPackageKey, $possibleObjectName); $possibleObjectName = str_replace('@controller', $controllerName, $possibleObjectName); $possibleObjectName = str_replace('\\\\', '\\', $possibleObjectName); $controllerObjectName = $this->objectManager->getCaseSensitiveObjectName($possibleObjectName); return $controllerObjectName !== FALSE ? $controllerObjectName : NULL; }
/** * Tries to resolve the given transformation name into a class name. * * The name can be a fully qualified class name or a name relative to the * TYPO3\TYPO3CR\Migration\Transformations namespace. * * @param string $transformationName * @return string * @throws \TYPO3\TYPO3CR\Migration\Exception\MigrationException */ protected function resolveTransformationClassName($transformationName) { $resolvedObjectName = $this->objectManager->getCaseSensitiveObjectName($transformationName); if ($resolvedObjectName !== false) { return $resolvedObjectName; } $resolvedObjectName = $this->objectManager->getCaseSensitiveObjectName('TYPO3\\TYPO3CR\\Migration\\Transformations\\' . $transformationName); if ($resolvedObjectName !== false) { return $resolvedObjectName; } throw new \TYPO3\TYPO3CR\Migration\Exception\MigrationException('A transformation with the name "' . $transformationName . '" could not be found.', 1343293064); }
/** * Resolves the class name for the filter by first assuming it is a full qualified class name and otherwise searching * in this package (so filters delivered in TYPO3.TYPO3CR can be used by simply giving the class name without namespace). * * @param string $name * @return string * @throws MigrationException */ protected function resolveFilterClass($name) { $resolvedObjectName = $this->objectManager->getCaseSensitiveObjectName($name); if ($resolvedObjectName !== false) { return $resolvedObjectName; } $resolvedObjectName = $this->objectManager->getCaseSensitiveObjectName('TYPO3\\TYPO3CR\\Migration\\Filters\\' . $name); if ($resolvedObjectName !== false) { return $resolvedObjectName; } throw new MigrationException('A filter with the name "' . $name . '" could not be found.', 1343199467); }
/** * Explicitly sets the object name of the controller * * @param string $unknownCasedControllerObjectName The fully qualified controller object name * @return void * @throws \TYPO3\Flow\Object\Exception\UnknownObjectException * @api */ public function setControllerObjectName($unknownCasedControllerObjectName) { $controllerObjectName = $this->objectManager->getCaseSensitiveObjectName($unknownCasedControllerObjectName); if ($controllerObjectName === false) { throw new UnknownObjectException('The object "' . $unknownCasedControllerObjectName . '" is not registered.', 1268844071); } $this->controllerPackageKey = $this->objectManager->getPackageKeyByObjectName($controllerObjectName); $matches = array(); $subject = substr($controllerObjectName, strlen($this->controllerPackageKey) + 1); preg_match('/ ^( Controller | (?P<subpackageKey>.+)\\\\Controller ) \\\\(?P<controllerName>[a-z\\\\]+)Controller $/ix', $subject, $matches); $this->controllerSubpackageKey = isset($matches['subpackageKey']) ? $matches['subpackageKey'] : null; $this->controllerName = $matches['controllerName']; }
/** * Determines the fully qualified view object name. * * @return mixed The fully qualified view object name or FALSE if no matching view could be found. * @api */ protected function resolveViewObjectName() { $possibleViewObjectName = $this->viewObjectNamePattern; $packageKey = $this->request->getControllerPackageKey(); $subpackageKey = $this->request->getControllerSubpackageKey(); $format = $this->request->getFormat(); if ($subpackageKey !== NULL && $subpackageKey !== '') { $packageKey .= '\\' . $subpackageKey; } $possibleViewObjectName = str_replace('@package', str_replace('.', '\\', $packageKey), $possibleViewObjectName); $possibleViewObjectName = str_replace('@controller', $this->request->getControllerName(), $possibleViewObjectName); $possibleViewObjectName = str_replace('@action', $this->request->getControllerActionName(), $possibleViewObjectName); $viewObjectName = $this->objectManager->getCaseSensitiveObjectName(strtolower(str_replace('@format', $format, $possibleViewObjectName))); if ($viewObjectName === FALSE) { $viewObjectName = $this->objectManager->getCaseSensitiveObjectName(strtolower(str_replace('@format', '', $possibleViewObjectName))); } if ($viewObjectName === FALSE && isset($this->viewFormatToObjectNameMap[$format])) { $viewObjectName = $this->viewFormatToObjectNameMap[$format]; } return $viewObjectName; }
/** * Shows the methods represented by the given security resource * * @param string $resourceName The name of the resource as stated in the policy * @return void */ public function showMethodsForResourceCommand($resourceName) { if ($this->policyCache->has('acls')) { $classes = array(); $acls = $this->policyCache->get('acls'); foreach ($acls as $classAndMethodName => $aclEntry) { if (strpos($classAndMethodName, '->') === FALSE) { continue; } list($className, $methodName) = explode('->', $classAndMethodName); $className = $this->objectManager->getCaseSensitiveObjectName($className); $reflectionClass = new \ReflectionClass($className); foreach ($reflectionClass->getMethods() as $casSensitiveMethodName) { if ($methodName === strtolower($casSensitiveMethodName->getName())) { $methodName = $casSensitiveMethodName->getName(); break; } } foreach ($aclEntry as $resources) { if (array_key_exists($resourceName, $resources)) { $classes[$className][$methodName] = $methodName; break; } } } if (count($classes) === 0) { $this->outputLine('The given Resource did not match any method or is unknown.'); $this->quit(1); } foreach ($classes as $className => $methods) { $this->outputLine(PHP_EOL . $className); foreach ($methods as $methodName) { $this->outputLine(' ' . $methodName); } } } else { $this->outputLine('Could not find any policy entries, please warmup caches!'); } }
/** * Initialize the given ViewHelper and adds it to the current node and to * the stack. * * @param ParsingState $state Current parsing state * @param string $namespaceIdentifier Namespace identifier - being looked up in $this->namespaces * @param string $methodIdentifier Method identifier * @param array $argumentsObjectTree Arguments object tree * @return boolean whether the viewHelper was found and added to the stack or not * @throws Exception */ protected function initializeViewHelperAndAddItToStack(ParsingState $state, $namespaceIdentifier, $methodIdentifier, $argumentsObjectTree) { if ($this->isNamespaceValid($namespaceIdentifier, $methodIdentifier) === FALSE) { return FALSE; } $resolvedViewHelperClassName = $this->resolveViewHelperName($namespaceIdentifier, $methodIdentifier); $actualViewHelperClassName = $this->objectManager->getCaseSensitiveObjectName($resolvedViewHelperClassName); if ($actualViewHelperClassName === FALSE) { throw new Exception(sprintf('The ViewHelper "<%s:%s>" could not be resolved.' . chr(10) . 'Based on your spelling, the system would load the class "%s", however this class does not exist.', $namespaceIdentifier, $methodIdentifier, $resolvedViewHelperClassName), 1407060572); } elseif ($actualViewHelperClassName !== $resolvedViewHelperClassName) { throw new Exception(sprintf('The ViewHelper "<%s:%s>" inside your template is not written correctly upper/lowercased.' . chr(10) . 'Based on your spelling, the system would load the (non-existant) class "%s", however the real class name is "%s".' . chr(10) . 'This error can be fixed by making sure the ViewHelper is written in the correct upper/lowercase form.', $namespaceIdentifier, $methodIdentifier, $resolvedViewHelperClassName, $actualViewHelperClassName), 1407060573); } $viewHelper = $this->objectManager->get($actualViewHelperClassName); // The following three checks are only done *in an uncached template*, and not needed anymore in the cached version $expectedViewHelperArguments = $viewHelper->prepareArguments(); $this->abortIfUnregisteredArgumentsExist($expectedViewHelperArguments, $argumentsObjectTree); $this->abortIfRequiredArgumentsAreMissing($expectedViewHelperArguments, $argumentsObjectTree); $this->rewriteBooleanNodesInArgumentsObjectTree($expectedViewHelperArguments, $argumentsObjectTree); /** @var $currentViewHelperNode ViewHelperNode */ $currentViewHelperNode = $this->objectManager->get(\TYPO3\Fluid\Core\Parser\SyntaxTree\ViewHelperNode::class, $viewHelper, $argumentsObjectTree); $this->callInterceptor($currentViewHelperNode, InterceptorInterface::INTERCEPT_OPENING_VIEWHELPER, $state); if ($viewHelper instanceof ChildNodeAccessInterface && !$viewHelper instanceof CompilableInterface) { $state->setCompilable(FALSE); } // PostParse Facet if ($viewHelper instanceof PostParseInterface) { // Don't just use $viewHelper::postParseEvent(...), // as this will break with PHP < 5.3. call_user_func(array($viewHelper, 'postParseEvent'), $currentViewHelperNode, $argumentsObjectTree, $state->getVariableContainer()); } $state->pushNodeToStack($currentViewHelperNode); return TRUE; }