Esempio n. 1
0
 /**
  *
  *
  * @return string
  */
 public function indexAction()
 {
     \Admin\Core\API::addTitleSegment("Admin");
     \Admin\Core\API::addTitleSegment("Login");
     $users = $this->userRepository->findAll();
     if ($users->count() < 1 || $this->helper->getSettings("Admin.DemoMode")) {
         $user = $this->objectManager->get("Admin\\Security\\User");
         $username = "******";
         if ($users->count() > 0) {
             $username .= $users->count() + 1;
         }
         $user->setAccountIdentifier($username);
         $user->setCredentialsSource("password");
         $user->setAdmin(true);
         $this->userRepository->add($user);
         $message = new \TYPO3\FLOW3\Error\Message('A User has been Created: ' . $username . '/password');
         $this->flashMessageContainer->addMessage($message);
         $message = new \TYPO3\FLOW3\Error\Warning('Please Change the Passwort after Login!');
         $this->flashMessageContainer->addMessage($message);
         $this->view->assign("username", $username);
         $this->view->assign("password", "password");
     } else {
         $this->view->assign("username", "");
         $this->view->assign("password", "");
     }
 }
Esempio n. 2
0
 /**
  * Add the Annotated Method to the Navigation
  *
  * @param \TYPO3\FLOW3\AOP\JoinPointInterface $joinPoint
  * @FLOW3\Before("method(public .*\Controller\.*Controller->.*Action(.*))")
  * @return void
  */
 public function addNavigationitem(\TYPO3\FLOW3\AOP\JoinPointInterface $joinPoint)
 {
     $currentClassName = $joinPoint->getClassName();
     $currentMethodName = $joinPoint->getMethodName();
     $controllers = $this->reflectionService->getAllSubClassNamesForClass("\\TYPO3\\FLOW3\\MVC\\Controller\\ActionController");
     foreach ($controllers as $className) {
         $methods = get_class_methods($className);
         if (is_array($methods)) {
             foreach ($methods as $methodName) {
                 if ($this->reflectionService->isMethodAnnotatedWith($className, $methodName, "Admin\\Annotations\\Navigation")) {
                     $annotations = $this->reflectionService->getMethodAnnotations($className, $methodName, "Admin\\Annotations\\Navigation");
                     foreach ($annotations as $annotation) {
                         $action = str_replace("Action", "", $methodName);
                         $controller = $this->helper->getControllerByClassName($className);
                         $package = $this->objectManager->getPackageKeyByObjectName($className);
                         $arguments = array("action" => $action, "controller" => $controller, "package" => $package);
                         $title = !is_null($annotation->title) ? $annotation->title : sprintf("%s (%s)", $controller, $action);
                         \Admin\Core\API::addNavigationitem($title, $annotation->position, $arguments, $annotation->priority, $annotation->parent);
                     }
                 }
             }
         }
     }
     $settings = $this->helper->getSettings("Admin.Navigation");
     foreach ($settings as $position => $items) {
         foreach ($items as $title => $conf) {
             $priority = isset($conf["priority"]) ? $conf["priority"] : 100;
             $arguments = $conf["Arguments"];
             \Admin\Core\API::addNavigationitem($title, strtolower($position), $arguments, $priority);
         }
     }
 }
Esempio n. 3
0
 /**
  * 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\FLOW3\Security\Exception\NoRequestPatternFoundException
  */
 public function resolveRequestPatternClass($name)
 {
     $resolvedObjectName = $this->objectManager->getCaseSensitiveObjectName($name);
     if ($resolvedObjectName !== FALSE) {
         return $resolvedObjectName;
     }
     $resolvedObjectName = $this->objectManager->getCaseSensitiveObjectName('TYPO3\\FLOW3\\Security\\RequestPattern\\' . $name);
     if ($resolvedObjectName !== FALSE) {
         return $resolvedObjectName;
     }
     throw new \TYPO3\FLOW3\Security\Exception\NoRequestPatternFoundException('A request pattern with the name: "' . $name . '" could not be resolved.', 1217154134);
 }
Esempio n. 4
0
 /**
  * @test
  */
 public function ifCommandCantBeResolvedTheHelpScreenIsShown()
 {
     // The following call is only made to satisfy PHPUnit. For some weird reason PHPUnit complains that the
     // mocked method ("getObjectNameByClassName") does not exist _if the mock object is not used_.
     $this->mockObjectManager->getObjectNameByClassName('Acme\\Test\\Command\\DefaultCommandController');
     $this->mockCommandManager->getCommandByIdentifier('acme.test:default:list');
     $mockCommandManager = $this->getMock('TYPO3\\FLOW3\\Cli\\CommandManager');
     $mockCommandManager->expects($this->any())->method('getCommandByIdentifier')->with('test:default:list')->will($this->throwException(new \TYPO3\FLOW3\Mvc\Exception\NoSuchCommandException()));
     $this->requestBuilder->injectCommandManager($mockCommandManager);
     $request = $this->requestBuilder->build('test:default:list');
     $this->assertSame('TYPO3\\FLOW3\\Command\\HelpCommandController', $request->getControllerObjectName());
 }
Esempio n. 5
0
 /**
  * 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\FLOW3\Security\Exception\NoInterceptorFoundException
  */
 public function resolveInterceptorClass($name)
 {
     $resolvedObjectName = $this->objectManager->getCaseSensitiveObjectName($name);
     if ($resolvedObjectName !== FALSE) {
         return $resolvedObjectName;
     }
     $resolvedObjectName = $this->objectManager->getCaseSensitiveObjectName('TYPO3\\FLOW3\\Security\\Authorization\\Interceptor\\' . $name);
     if ($resolvedObjectName !== FALSE) {
         return $resolvedObjectName;
     }
     throw new \TYPO3\FLOW3\Security\Exception\NoInterceptorFoundException('A security interceptor with the name: "' . $name . '" could not be resolved.', 1217154134);
 }
Esempio n. 6
0
 /**
  * Lifecycle method, called after all dependencies have been injected.
  * Here, the typeConverter array gets initialized.
  *
  * @return void
  * @throws \TYPO3\FLOW3\Property\Exception\DuplicateTypeConverterException
  */
 public function initializeObject()
 {
     foreach ($this->reflectionService->getAllImplementationClassNamesForInterface('TYPO3\\FLOW3\\Property\\TypeConverterInterface') as $typeConverterClassName) {
         $typeConverter = $this->objectManager->get($typeConverterClassName);
         foreach ($typeConverter->getSupportedSourceTypes() as $supportedSourceType) {
             if (isset($this->typeConverters[$supportedSourceType][$typeConverter->getSupportedTargetType()][$typeConverter->getPriority()])) {
                 throw new \TYPO3\FLOW3\Property\Exception\DuplicateTypeConverterException('There exist at least two converters which handle the conversion from "' . $supportedSourceType . '" to "' . $typeConverter->getSupportedTargetType() . '" with priority "' . $typeConverter->getPriority() . '": ' . get_class($this->typeConverters[$supportedSourceType][$typeConverter->getSupportedTargetType()][$typeConverter->getPriority()]) . ' and ' . get_class($typeConverter), 1297951378);
             }
             $this->typeConverters[$supportedSourceType][$typeConverter->getSupportedTargetType()][$typeConverter->getPriority()] = $typeConverter;
         }
     }
 }
 /**
  *
  * @param object $value
  * @param string $partial
  * @param string $fallbacks
  * @param array $vars
  * @return string Rendered string
  * @author Marc Neuhaus <*****@*****.**>
  * @api
  */
 public function render($as = "widget")
 {
     $this->reflectionService = $this->objectManager->get("TYPO3\\FLOW3\\Reflection\\ReflectionService");
     $output = "";
     foreach ($this->reflectionService->getAllImplementationClassNamesForInterface('\\Admin\\Core\\DashboardWidgets\\DashboardWidgetInterface') as $className) {
         $widget = new $className($this->viewHelperVariableContainer->getView());
         $this->templateVariableContainer->add($as, $widget);
         $output .= $this->renderChildren();
         $this->templateVariableContainer->remove($as, $widget);
     }
     return $output;
 }
 /**
  * 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\FLOW3\Security\Exception\NoAuthenticationProviderFoundException
  */
 public function resolveProviderClass($providerName)
 {
     $resolvedObjectName = $this->objectManager->getCaseSensitiveObjectName($providerName);
     if ($resolvedObjectName !== FALSE) {
         return $resolvedObjectName;
     }
     $resolvedObjectName = $this->objectManager->getCaseSensitiveObjectName('TYPO3\\FLOW3\\Security\\Authentication\\Provider\\' . $providerName);
     if ($resolvedObjectName !== FALSE) {
         return $resolvedObjectName;
     }
     throw new \TYPO3\FLOW3\Security\Exception\NoAuthenticationProviderFoundException('An authentication provider with the name "' . $providerName . '" could not be resolved.', 1217154134);
 }
Esempio n. 9
0
 /**
  * Around advice, wrapping every method of a scope session object. It redirects
  * all method calls to the session object once there is one.
  *
  * @param \TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint The current join point
  * @return mixed
  * @FLOW3\Around("filter(TYPO3\FLOW3\Session\Aspect\SessionObjectMethodsPointcutFilter)")
  */
 public function callMethodOnOriginalSessionObject(\TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint)
 {
     $objectName = $this->objectManager->getObjectNameByClassName(get_class($joinPoint->getProxy()));
     $methodName = $joinPoint->getMethodName();
     $proxy = $joinPoint->getProxy();
     if (!isset($this->sessionOriginalInstances[$objectName])) {
         $this->sessionOriginalInstances[$objectName] = $this->objectManager->get($objectName);
     }
     if ($this->sessionOriginalInstances[$objectName] === $proxy) {
         return $joinPoint->getAdviceChain()->proceed($joinPoint);
     } else {
         return call_user_func_array(array($this->sessionOriginalInstances[$objectName], $methodName), $joinPoint->getMethodArguments());
     }
 }
Esempio n. 10
0
 /**
  * Starts or resumes a session
  *
  * @return mixed If a session was resumed, the number of seconds it has been inactive previously. If a new session was started: TRUE
  */
 protected function startOrResume()
 {
     session_start();
     $this->sessionId = session_id();
     $this->started = TRUE;
     $previousInactivityInSeconds = TRUE;
     if ($this->hasKey('TYPO3_FLOW3_Session_LastActivity')) {
         $previousInactivityInSeconds = time() - $this->getData('TYPO3_FLOW3_Session_LastActivity');
     }
     $this->putData('TYPO3_FLOW3_Session_LastActivity', time());
     if ($this->hasKey('TYPO3_FLOW3_Object_ObjectManager') === TRUE) {
         $sessionObjects = $this->getData('TYPO3_FLOW3_Object_ObjectManager');
         if (is_array($sessionObjects)) {
             foreach ($sessionObjects as $object) {
                 if ($object instanceof \TYPO3\FLOW3\Object\Proxy\ProxyInterface) {
                     $objectName = $this->objectManager->getObjectNameByClassName(get_class($object));
                     if ($this->objectManager->getScope($objectName) === ObjectConfiguration::SCOPE_SESSION) {
                         $this->objectManager->setInstance($objectName, $object);
                         $this->lazyLoadingAspect->registerSessionInstance($objectName, $object);
                         $object->__wakeup();
                     }
                 }
             }
         } else {
             // Fallback for some malformed session data, if it is no array but something else.
             // In this case, we reset all session objects (graceful degradation).
             $this->putData('TYPO3_FLOW3_Object_ObjectManager', array());
         }
     }
     return $previousInactivityInSeconds;
 }
Esempio n. 11
0
 /**
  * Builds a CLI request object from a command line.
  *
  * The given command line may be a string (e.g. "mypackage:foo do-that-thing --force") or
  * an array consisting of the individual parts. The array must not include the script
  * name (like in $argv) but start with command right away.
  *
  * @param mixed $commandLine The command line, either as a string or as an array
  * @return \TYPO3\FLOW3\Cli\Request The CLI request as an object
  */
 public function build($commandLine)
 {
     $request = new Request();
     $request->setControllerObjectName('TYPO3\\FLOW3\\Command\\HelpCommandController');
     $rawCommandLineArguments = is_array($commandLine) ? $commandLine : explode(' ', $commandLine);
     if (count($rawCommandLineArguments) === 0) {
         $request->setControllerCommandName('helpStub');
         return $request;
     }
     $commandIdentifier = trim(array_shift($rawCommandLineArguments));
     try {
         $command = $this->commandManager->getCommandByIdentifier($commandIdentifier);
     } catch (\TYPO3\FLOW3\Mvc\Exception\CommandException $exception) {
         $request->setArgument('exception', $exception);
         $request->setControllerCommandName('error');
         return $request;
     }
     $controllerObjectName = $this->objectManager->getObjectNameByClassName($command->getControllerClassName());
     $controllerCommandName = $command->getControllerCommandName();
     $request->setControllerObjectName($controllerObjectName);
     $request->setControllerCommandName($controllerCommandName);
     list($commandLineArguments, $exceedingCommandLineArguments) = $this->parseRawCommandLineArguments($rawCommandLineArguments, $controllerObjectName, $controllerCommandName);
     $request->setArguments($commandLineArguments);
     $request->setExceedingArguments($exceedingCommandLineArguments);
     return $request;
 }
Esempio n. 12
0
 /**
  * Execute a task
  *
  * @param string $task
  * @param \TYPO3\Deploy\Domain\Model\Node $node
  * @param \TYPO3\Deploy\Domain\Model\Application $application
  * @param \TYPO3\Deploy\Domain\Model\Deployment $deployment
  * @param array $options
  * @return void
  */
 public function execute($task, \TYPO3\Deploy\Domain\Model\Node $node, \TYPO3\Deploy\Domain\Model\Application $application, \TYPO3\Deploy\Domain\Model\Deployment $deployment, array $options = array())
 {
     list($packageKey, $taskName) = explode(':', $task, 2);
     $taskClassName = strtr($packageKey, '.', '\\') . '\\Task\\' . strtr($taskName, ':', '\\') . 'Task';
     $taskObjectName = $this->objectManager->getCaseSensitiveObjectName($taskClassName);
     if (!$this->objectManager->isRegistered($taskObjectName)) {
         throw new \Exception('Task "' . $task . '" not registered ' . $taskClassName);
     }
     $task = $this->objectManager->create($taskObjectName);
     if (!$deployment->isDryRun()) {
         $task->execute($node, $application, $deployment, $options);
     } else {
         $task->simulate($node, $application, $deployment, $options);
     }
     $this->taskHistory[] = array('task' => $task, 'node' => $node, 'application' => $application, 'deployment' => $deployment, 'options' => $options);
 }
Esempio n. 13
0
 /**
  * Emits a signal when an Advice is invoked
  *
  * The advice is not proxyable, so the signal is dispatched manually here.
  *
  * @param object $aspectObject
  * @param string $methodName
  * @param \TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint
  * @return void
  * @FLOW3\Signal
  */
 protected function emitAdviceInvoked($aspectObject, $methodName, $joinPoint)
 {
     if ($this->dispatcher === NULL) {
         $this->dispatcher = $this->objectManager->get('TYPO3\\FLOW3\\SignalSlot\\Dispatcher');
     }
     $this->dispatcher->dispatch('TYPO3\\FLOW3\\Aop\\Advice\\AbstractAdvice', 'adviceInvoked', array($aspectObject, $methodName, $joinPoint));
 }
 /**
  * Returns the static value of the given operand, this might be also a global object
  *
  * @param mixed $expression The expression string representing the operand
  * @return mixed The calculated value
  */
 protected function getValueForOperand($expression)
 {
     if (is_array($expression)) {
         $result = array();
         foreach ($expression as $expressionEntry) {
             $result[] = $this->getValueForOperand($expressionEntry);
         }
         return $result;
     } else {
         if (is_numeric($expression)) {
             return $expression;
         } else {
             if ($expression === 'TRUE') {
                 return TRUE;
             } else {
                 if ($expression === 'FALSE') {
                     return FALSE;
                 } else {
                     if ($expression === 'NULL') {
                         return NULL;
                     } else {
                         if (strpos($expression, 'current.') === 0) {
                             $objectAccess = explode('.', $expression, 3);
                             $globalObjectsRegisteredClassName = $this->globalObjects[$objectAccess[1]];
                             $globalObject = $this->objectManager->get($globalObjectsRegisteredClassName);
                             return $this->getObjectValueByPath($globalObject, $objectAccess[2]);
                         } else {
                             return trim($expression, '"\'');
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 15
0
 /**
  * @test
  */
 public function resolveValidatorObjectNameCanResolveShortNamesOfBuiltInValidators()
 {
     $this->mockObjectManager->expects($this->at(0))->method('isRegistered')->with('Foo')->will($this->returnValue(FALSE));
     $this->mockObjectManager->expects($this->at(1))->method('isRegistered')->with('TYPO3\\FLOW3\\Validation\\Validator\\FooValidator')->will($this->returnValue(TRUE));
     $this->mockReflectionService->expects($this->atLeastOnce())->method('isClassImplementationOf')->with('TYPO3\\FLOW3\\Validation\\Validator\\FooValidator', 'TYPO3\\FLOW3\\Validation\\Validator\\ValidatorInterface')->will($this->returnValue(TRUE));
     $this->assertSame('TYPO3\\FLOW3\\Validation\\Validator\\FooValidator', $this->validatorResolver->_call('resolveValidatorObjectName', 'Foo'));
 }
Esempio n. 16
0
 /**
  * Factory method which creates an EntityManager.
  *
  * @return \Doctrine\ORM\EntityManager
  */
 public function create()
 {
     $config = new \Doctrine\ORM\Configuration();
     $config->setClassMetadataFactoryName('TYPO3\\FLOW3\\Persistence\\Doctrine\\Mapping\\ClassMetadataFactory');
     if (class_exists($this->settings['doctrine']['cacheImplementation'])) {
         // safeguard against apc being disabled in CLI...
         if ($this->settings['doctrine']['cacheImplementation'] !== 'Doctrine\\Common\\Cache\\ApcCache' || function_exists('apc_fetch')) {
             $cache = new $this->settings['doctrine']['cacheImplementation']();
             $config->setMetadataCacheImpl($cache);
             $config->setQueryCacheImpl($cache);
         }
     }
     if (class_exists($this->settings['doctrine']['sqlLogger'])) {
         $config->setSQLLogger(new $this->settings['doctrine']['sqlLogger']());
     }
     // must use ObjectManager in compile phase...
     $flow3AnnotationDriver = $this->objectManager->get('TYPO3\\FLOW3\\Persistence\\Doctrine\\Mapping\\Driver\\Flow3AnnotationDriver');
     $config->setMetadataDriverImpl($flow3AnnotationDriver);
     $proxyDirectory = \TYPO3\FLOW3\Utility\Files::concatenatePaths(array($this->environment->getPathToTemporaryDirectory(), 'Doctrine/Proxies'));
     \TYPO3\FLOW3\Utility\Files::createDirectoryRecursively($proxyDirectory);
     $config->setProxyDir($proxyDirectory);
     $config->setProxyNamespace('TYPO3\\FLOW3\\Persistence\\Doctrine\\Proxies');
     $config->setAutoGenerateProxyClasses(FALSE);
     $entityManager = \Doctrine\ORM\EntityManager::create($this->settings['backendOptions'], $config);
     $flow3AnnotationDriver->setEntityManager($entityManager);
     return $entityManager;
 }
Esempio n. 17
0
 /**
  * Starts the shutdown sequence
  *
  * @param string $runlevel Either "Compiletime" or "Runtime"
  * @return void
  */
 protected function shutdown($runlevel)
 {
     $this->bootstrap->shutdown($runlevel);
     if ($runlevel === 'Compiletime') {
         $this->objectManager->get('TYPO3\\FLOW3\\Core\\LockManager')->unlockSite();
     }
     exit($this->response->getExitCode());
 }
Esempio n. 18
0
 /**
  * Sets the internal filters based on the given configuration.
  *
  * @param array $filterSettings The filter settings
  * @return void
  */
 protected function buildFiltersFromSettings(array $filterSettings)
 {
     foreach ($filterSettings as $singleFilterSettings) {
         $requestPattern = $this->objectManager->get($this->requestPatternResolver->resolveRequestPatternClass($singleFilterSettings['patternType']));
         $requestPattern->setPattern($singleFilterSettings['patternValue']);
         $interceptor = $this->objectManager->get($this->interceptorResolver->resolveInterceptorClass($singleFilterSettings['interceptor']));
         $this->filters[] = $this->objectManager->get('TYPO3\\FLOW3\\Security\\Authorization\\RequestFilter', $requestPattern, $interceptor);
     }
 }
Esempio n. 19
0
 /**
  * Emits a signal when a Request has been dispatched
  *
  * The action request is not proxyable, so the signal is dispatched manually here.
  * The safeguard allows unit tests without the dispatcher dependency.
  *
  * @param \TYPO3\FLOW3\Configuration\ConfigurationManager $configurationManager
  * @return void
  * @FLOW3\Signal
  */
 protected function emitRequestDispatched($request)
 {
     if ($this->objectManager !== NULL) {
         $dispatcher = $this->objectManager->get('TYPO3\\FLOW3\\SignalSlot\\Dispatcher');
         if ($dispatcher !== NULL) {
             $dispatcher->dispatch('TYPO3\\FLOW3\\Mvc\\ActionRequest', 'requestDispatched', array($request));
         }
     }
 }
Esempio n. 20
0
 public function __toString()
 {
     if (is_object($this->objectManager)) {
         $reflectionService = $this->objectManager->get("TYPO3\\FLOW3\\Reflection\\ReflectionService");
         $class = get_class($this);
         if ($this instanceof \Doctrine\ORM\Proxy\Proxy) {
             $class = get_parent_class($this);
         }
         $properties = $reflectionService->getClassPropertyNames($class);
         $identity = array();
         $title = array();
         $goodGuess = null;
         $usualSuspects = array("title", "name");
         foreach ($properties as $property) {
             $tags = $reflectionService->getPropertyTagsValues($class, $property);
             if (in_array("title", array_keys($tags))) {
                 $title[] = \TYPO3\FLOW3\Reflection\ObjectAccess::getProperty($this, $property);
             }
             if (in_array("identity", array_keys($tags))) {
                 $value = \TYPO3\FLOW3\Reflection\ObjectAccess::getProperty($this, $property);
                 if (!is_object($value)) {
                     $identity[] = $value;
                 }
             }
             if (in_array($property, $usualSuspects) && $goodGuess === null) {
                 $value = \TYPO3\FLOW3\Reflection\ObjectAccess::getProperty($this, $property);
                 if (!is_object($value)) {
                     $goodGuess[] = $value;
                 }
             }
         }
         if (count($title) > 0) {
             $string = implode(", ", $title);
         }
         if (count($identity) > 0 && empty($string)) {
             $string = implode(", ", $identity);
         }
         if ($goodGuess !== null && empty($string)) {
             $string = implode(",", $goodGuess);
         }
     } else {
         $myProperties = get_object_vars($this);
         $strings = array();
         foreach ($myProperties as $key => $value) {
             if (is_string($value) && $key !== "FLOW3_Persistence_Identifier") {
                 $strings[] = $value;
             }
         }
         $string = implode(", ", $strings);
     }
     if (empty($string)) {
         return sprintf("Object (%s)", \Admin\Core\Helper::getShortName(get_class($this)));
     } else {
         return $string;
     }
 }
Esempio n. 21
0
 /**
  * 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;
 }
 public function getActionByShortName($action = null)
 {
     $actions = array();
     foreach ($this->reflectionService->getAllImplementationClassNamesForInterface('Admin\\Core\\Actions\\ActionInterface') as $actionClassName) {
         $actionName = \Admin\Core\Helper::getShortName($actionClassName);
         if (strtolower($actionName) == strtolower($action)) {
             return $this->objectManager->create($actionClassName, $this->getAdapter(), $this->request, $this->view, $this);
         }
     }
     return null;
 }
Esempio n. 23
0
 /**
  * Adds a CSRF token as argument in the URI builder
  *
  * @FLOW3\Before("setting(TYPO3.FLOW3.security.enable) && method(TYPO3\FLOW3\Mvc\Routing\UriBuilder->build())")
  * @param \TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint The current join point
  * @return void
  */
 public function addCsrfTokenToUri(\TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint)
 {
     $uriBuilder = $joinPoint->getProxy();
     $arguments = $joinPoint->getMethodArgument('arguments');
     $packageKey = isset($arguments['@package']) ? $arguments['@package'] : '';
     $subpackageKey = isset($arguments['@subpackage']) ? $arguments['@subpackage'] : '';
     $controllerName = isset($arguments['@controller']) ? $arguments['@controller'] : 'Standard';
     $actionName = (isset($arguments['@action']) ? $arguments['@action'] : 'index') . 'Action';
     $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);
     $lowercaseObjectName = strtolower($possibleObjectName);
     $className = $this->objectManager->getClassNameByObjectName($this->objectManager->getCaseSensitiveObjectName($lowercaseObjectName));
     if ($this->policyService->hasPolicyEntryForMethod($className, $actionName) && !$this->reflectionService->isMethodAnnotatedWith($className, $actionName, 'TYPO3\\FLOW3\\Annotations\\SkipCsrfProtection')) {
         $internalArguments = $uriBuilder->getArguments();
         $internalArguments['__csrfToken'] = $this->securityContext->getCsrfProtectionToken();
         $uriBuilder->setArguments($internalArguments);
     }
 }
Esempio n. 24
0
 /**
  * Returns instance of concrete formatter.
  *
  * The name provided has to be a name of existing class placed in
  * \TYPO3\FLOW3\I18n\Formatter package and implementing FormatterInterface
  * (also in this package). For example,  when $formatterName is 'number',
  * the \TYPO3\FLOW3\I18n\Formatter\NumberFormatter class has to exist.
  *
  * Throws exception if there is no formatter for name given.
  *
  * @param string $formatterName Name of the formatter class (without Formatter suffix)
  * @return \TYPO3\FLOW3\I18n\Formatter\FormatterInterface The concrete formatter class
  * @throws \TYPO3\FLOW3\I18n\Exception\UnknownFormatterException When formatter for a name given does not exist
  */
 protected function getFormatter($formatterName)
 {
     $formatterName = ucfirst($formatterName);
     if (isset($this->formatters[$formatterName])) {
         return $this->formatters[$formatterName];
     }
     try {
         $formatter = $this->objectManager->get('TYPO3\\FLOW3\\I18n\\Formatter\\' . $formatterName . 'Formatter');
     } catch (\TYPO3\FLOW3\Object\Exception\UnknownObjectException $exception) {
         throw new \TYPO3\FLOW3\I18n\Exception\UnknownFormatterException('Could not find formatter for "' . $formatterName . '".', 1278057791);
     }
     return $this->formatters[$formatterName] = $formatter;
 }
Esempio n. 25
0
 /**
  * Matches a \TYPO3\FLOW3\Mvc\RequestInterface against the configured CSRF pattern rules and searches for invalid
  * csrf tokens.
  *
  * @param \TYPO3\FLOW3\Mvc\RequestInterface $request The request that should be matched
  * @return boolean TRUE if the pattern matched, FALSE otherwise
  * @throws \TYPO3\FLOW3\Security\Exception\AuthenticationRequiredException
  */
 public function matchRequest(\TYPO3\FLOW3\Mvc\RequestInterface $request)
 {
     if ($this->authenticationManager->isAuthenticated() === FALSE) {
         return FALSE;
     }
     $controllerClassName = $this->objectManager->getClassNameByObjectName($request->getControllerObjectName());
     $actionName = $request->getControllerActionName() . 'Action';
     if ($this->policyService->hasPolicyEntryForMethod($controllerClassName, $actionName) && !$this->reflectionService->isMethodTaggedWith($controllerClassName, $actionName, 'skipcsrfprotection')) {
         $internalArguments = $request->getInternalArguments();
         if (!isset($internalArguments['__csrfToken'])) {
             return TRUE;
         }
         $csrfToken = $internalArguments['__csrfToken'];
         if (!$this->securityContext->hasCsrfProtectionTokens()) {
             throw new \TYPO3\FLOW3\Security\Exception\AuthenticationRequiredException('No tokens in security context, possible session timeout', 1317309673);
         }
         if ($this->securityContext->isCsrfProtectionTokenValid($csrfToken) === FALSE) {
             return TRUE;
         }
     }
     return FALSE;
 }
Esempio n. 26
0
 /**
  * Creates and sets the configured access decision voters
  *
  * @param array $voterClassNames Array of access decision voter class names
  * @return void
  * @throws \TYPO3\FLOW3\Security\Exception\VoterNotFoundException
  */
 protected function createAccessDecisionVoters(array $voterClassNames)
 {
     foreach ($voterClassNames as $voterClassName) {
         if (!$this->objectManager->isRegistered($voterClassName)) {
             throw new \TYPO3\FLOW3\Security\Exception\VoterNotFoundException('No voter of type ' . $voterClassName . ' found!', 1222267934);
         }
         $voter = $this->objectManager->get($voterClassName);
         if (!$voter instanceof \TYPO3\FLOW3\Security\Authorization\AccessDecisionVoterInterface) {
             throw new \TYPO3\FLOW3\Security\Exception\VoterNotFoundException('The found voter class did not implement \\TYPO3\\FLOW3\\Security\\Authorization\\AccessDecisionVoterInterface', 1222268008);
         }
         $this->accessDecisionVoters[] = $voter;
     }
 }
Esempio n. 27
0
 /**
  * Sets up security test requirements
  *
  * @return void
  */
 protected function setupSecurity()
 {
     $this->accessDecisionManager = $this->objectManager->get('TYPO3\\FLOW3\\Security\\Authorization\\AccessDecisionManagerInterface');
     $this->accessDecisionManager->setOverrideDecision(NULL);
     $this->authenticationManager = $this->objectManager->get('TYPO3\\FLOW3\\Security\\Authentication\\AuthenticationProviderManager');
     $this->testingProvider = $this->objectManager->get('TYPO3\\FLOW3\\Security\\Authentication\\Provider\\TestingProvider');
     $this->testingProvider->setName('TestingProvider');
     $this->securityContext = $this->objectManager->get('TYPO3\\FLOW3\\Security\\Context');
     $this->securityContext->clearContext();
     $this->securityContext->refreshTokens();
     $requestHandler = self::$bootstrap->getActiveRequestHandler();
     $actionRequest = $requestHandler->getHttpRequest()->createActionRequest();
     $this->securityContext->injectRequest($actionRequest);
 }
 /**
  * Build the rendering context
  *
  * @param \TYPO3\Fluid\Core\ViewHelper\TemplateVariableContainer $variableContainer
  * @return \TYPO3\Fluid\Core\Rendering\RenderingContext
  * @author Sebastian Kurfürst <*****@*****.**>
  */
 protected function buildRenderingContext(\TYPO3\Fluid\Core\ViewHelper\TemplateVariableContainer $variableContainer = NULL)
 {
     if ($variableContainer === NULL) {
         $variableContainer = $this->objectManager->create('TYPO3\\Fluid\\Core\\ViewHelper\\TemplateVariableContainer', $this->variables);
     }
     $renderingContext = $this->objectManager->create('TYPO3\\Fluid\\Core\\Rendering\\RenderingContext');
     $renderingContext->injectTemplateVariableContainer($variableContainer);
     if ($this->controllerContext !== NULL) {
         $renderingContext->setControllerContext($this->controllerContext);
     }
     $viewHelperVariableContainer = $this->objectManager->create('TYPO3\\Fluid\\Core\\ViewHelper\\ViewHelperVariableContainer');
     $viewHelperVariableContainer->setView($this->viewHelperVariableContainer->getView());
     $renderingContext->injectViewHelperVariableContainer($viewHelperVariableContainer);
     return $renderingContext;
 }
 public function getClassConfiguration($class)
 {
     $implementations = class_implements("\\" . ltrim($class, "\\"));
     if (in_array("Doctrine\\ORM\\Proxy\\Proxy", $implementations)) {
         $class = get_parent_class("\\" . ltrim($class, "\\"));
     }
     $this->class = $class;
     if (isset($this->settings["ConfigurationProvider"]) && !isset($this->runtimeCache[$class])) {
         $configuration = array();
         $configurationProviders = $this->settings["ConfigurationProvider"];
         foreach ($configurationProviders as $configurationProviderClass) {
             $configurationProvider = $this->objectManager->get($configurationProviderClass);
             $configurationProvider->setSettings($this->settings);
             $configuration = $this->merge($configuration, $configurationProvider->get($class));
         }
         $this->runtimeCache[$class] = $configuration;
     }
     return $this->runtimeCache[$class];
 }
Esempio n. 30
0
 /**
  * Finds and instantiates a controller that matches the current request.
  * If no controller can be found, an instance of NotFoundControllerInterface is returned.
  *
  * @param \TYPO3\FLOW3\Mvc\RequestInterface $request The request to dispatch
  * @return \TYPO3\FLOW3\Mvc\Controller\ControllerInterface
  * @throws \TYPO3\FLOW3\Mvc\Controller\Exception\InvalidControllerException
  */
 protected function resolveController(\TYPO3\FLOW3\Mvc\RequestInterface $request)
 {
     $exception = NULL;
     $controllerObjectName = $request->getControllerObjectName();
     if ($controllerObjectName === '') {
         $exception = new \TYPO3\FLOW3\Mvc\Controller\Exception\InvalidControllerException('No controller could be resolved which would match your request', 1303209195, NULL, $request);
     }
     if ($exception !== NULL) {
         $controller = $this->objectManager->get($this->settings['mvc']['notFoundController']);
         if (!$controller instanceof \TYPO3\FLOW3\Mvc\Controller\NotFoundControllerInterface) {
             throw new \TYPO3\FLOW3\Mvc\Controller\Exception\InvalidControllerException('The NotFoundController must implement "\\TYPO3\\FLOW3\\Mvc\\Controller\\NotFoundControllerInterface", ' . (is_object($controller) ? get_class($controller) : gettype($controller)) . ' given.', 1246714416, NULL, $request);
         }
         $controller->setException($exception);
     } else {
         $controller = $this->objectManager->get($controllerObjectName);
         if (!$controller instanceof \TYPO3\FLOW3\Mvc\Controller\ControllerInterface) {
             throw new \TYPO3\FLOW3\Mvc\Controller\Exception\InvalidControllerException('Invalid controller "' . $request->getControllerObjectName() . '". The controller must be a valid request handling controller, ' . (is_object($controller) ? get_class($controller) : gettype($controller)) . ' given.', 1202921619, NULL, $request);
         }
     }
     return $controller;
 }