Example #1
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);
         }
     }
 }
Example #2
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());
     }
 }
Example #3
0
 /**
  * Logs calls and results of the authenticate() method of an authentication provider
  *
  * @FLOW3\AfterReturning("within(TYPO3\FLOW3\Security\Authentication\AuthenticationProviderInterface) && method(.*->authenticate())")
  * @param \TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint The current joinpoint
  * @return mixed The result of the target method if it has not been intercepted
  */
 public function logPersistedUsernamePasswordProviderAuthenticate(\TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint)
 {
     $token = $joinPoint->getMethodArgument('authenticationToken');
     switch ($token->getAuthenticationStatus()) {
         case \TYPO3\FLOW3\Security\Authentication\TokenInterface::AUTHENTICATION_SUCCESSFUL:
             $this->securityLogger->log('Successfully authenticated token: ' . $token, LOG_NOTICE, array(), 'TYPO3.FLOW3', $joinPoint->getClassName(), $joinPoint->getMethodName());
             $this->alreadyLoggedAuthenticateCall = TRUE;
             break;
         case \TYPO3\FLOW3\Security\Authentication\TokenInterface::WRONG_CREDENTIALS:
             $this->securityLogger->log('Wrong credentials given for token: ' . $token, LOG_WARNING, array(), 'TYPO3.FLOW3', $joinPoint->getClassName(), $joinPoint->getMethodName());
             break;
         case \TYPO3\FLOW3\Security\Authentication\TokenInterface::NO_CREDENTIALS_GIVEN:
             $this->securityLogger->log('No credentials given or no account found for token: ' . $token, LOG_WARNING, array(), 'TYPO3.FLOW3', $joinPoint->getClassName(), $joinPoint->getMethodName());
             break;
     }
 }
Example #4
0
 /**
  * Returns the privileges a specific role has for the given joinpoint. The returned array
  * contains the privilege's resource as key of each privilege.
  *
  * @param \TYPO3\FLOW3\Security\Policy\Role $role The role for which the privileges should be returned
  * @param \TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint The joinpoint for which the privileges should be returned
  * @return array Array of privileges
  * @throws \TYPO3\FLOW3\Security\Exception\NoEntryInPolicyException
  */
 public function getPrivilegesForJoinPoint(\TYPO3\FLOW3\Security\Policy\Role $role, \TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint)
 {
     $methodIdentifier = strtolower($joinPoint->getClassName() . '->' . $joinPoint->getMethodName());
     $roleIdentifier = (string) $role;
     if (!isset($this->acls[$methodIdentifier])) {
         throw new \TYPO3\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);
     }
     if (!isset($this->acls[$methodIdentifier][$roleIdentifier])) {
         return array();
     }
     $privileges = array();
     foreach ($this->acls[$methodIdentifier][$roleIdentifier] as $resource => $privilegeConfiguration) {
         if ($privilegeConfiguration['runtimeEvaluationsClosureCode'] !== FALSE) {
             // Make object manager usable as closure variable
             $objectManager = $this->objectManager;
             eval('$runtimeEvaluator = ' . $privilegeConfiguration['runtimeEvaluationsClosureCode'] . ';');
             if ($runtimeEvaluator->__invoke($joinPoint) === FALSE) {
                 continue;
             }
         }
         $privileges[$resource] = $privilegeConfiguration['privilege'];
     }
     return $privileges;
 }
Example #5
0
 /**
  * Passes the signal over to the Dispatcher
  *
  * @FLOW3\AfterReturning("methodAnnotatedWith(TYPO3\FLOW3\Annotations\Signal)")
  * @param \TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint The current join point
  * @return void
  */
 public function forwardSignalToDispatcher(\TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint)
 {
     $signalName = lcfirst(str_replace('emit', '', $joinPoint->getMethodName()));
     $this->dispatcher->dispatch($joinPoint->getClassName(), $signalName, $joinPoint->getMethodArguments());
 }