Example #1
0
 /**
  * This is the default Policy voter, it votes for the access privilege for the given join point
  *
  * @param TYPO3\FLOW3\Security\Context $securityContext The current securit context
  * @param TYPO3\FLOW3\AOP\JoinPointInterface $joinPoint The joinpoint to vote for
  * @return integer One of: VOTE_GRANT, VOTE_ABSTAIN, VOTE_DENY
  */
 public function voteForJoinPoint(\TYPO3\FLOW3\Security\Context $securityContext, \TYPO3\FLOW3\AOP\JoinPointInterface $joinPoint)
 {
     $proxy = $joinPoint->getProxy();
     if ($proxy instanceof \Admin\Controller\StandardController) {
         $arguments = $joinPoint->getMethodArguments();
         if (isset($arguments["being"])) {
             $arguments["action"] = $proxy->getAction();
             if ($arguments["action"] == "list") {
                 $arguments["action"] = "view";
             }
             #\dump($arguments, __FILE__ . ":" . __LINE__);
             $accessGrants = 0;
             $accessDenies = 0;
             foreach ($securityContext->getAuthenticationTokens() as $token) {
                 if (is_callable(array($token, "getUser"))) {
                     $user = $token->getUser();
                     if ($user->getAdmin()) {
                         return self::VOTE_GRANT;
                     }
                     foreach ($user->getRoles() as $role) {
                         foreach ($role->getGrant() as $policy) {
                             if ($this->comparePolicy($arguments, $policy)) {
                                 $accessGrants++;
                             }
                         }
                         #foreach ($role->getDeny() as $policy) {
                         #    if($this->comparePolicy($arguments, $policy)) $accessDenies++;
                         #}
                     }
                 }
             }
             if ($accessDenies > 0) {
                 return self::VOTE_DENY;
             }
             if ($accessGrants > 0) {
                 return self::VOTE_GRANT;
             }
         } else {
             return self::VOTE_ABSTAIN;
         }
     }
     return self::VOTE_ABSTAIN;
 }
Example #2
0
 /**
  * After returning advice, generates the value hash for the object
  *
  * @param \TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint The current join point
  * @return void
  * @FLOW3\Before("classAnnotatedWith(TYPO3\FLOW3\Annotations\ValueObject) && method(.*->__construct())")
  */
 public function generateValueHash(\TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint)
 {
     $proxy = $joinPoint->getProxy();
     $hashSource = get_class($proxy);
     if (property_exists($proxy, 'FLOW3_Persistence_Identifier')) {
         $hashSource .= \TYPO3\FLOW3\Reflection\ObjectAccess::getProperty($proxy, 'FLOW3_Persistence_Identifier', TRUE);
     }
     foreach ($joinPoint->getMethodArguments() as $argumentValue) {
         if (is_array($argumentValue)) {
             $hashSource .= $this->useIgBinary === TRUE ? igbinary_serialize($argumentValue) : serialize($argumentValue);
         } elseif (!is_object($argumentValue)) {
             $hashSource .= $argumentValue;
         } elseif (property_exists($argumentValue, 'FLOW3_Persistence_Identifier')) {
             $hashSource .= \TYPO3\FLOW3\Reflection\ObjectAccess::getProperty($argumentValue, 'FLOW3_Persistence_Identifier', TRUE);
         } elseif ($argumentValue instanceof \DateTime) {
             $hashSource .= $argumentValue->getTimestamp();
         }
     }
     $proxy = $joinPoint->getProxy();
     \TYPO3\FLOW3\Reflection\ObjectAccess::setProperty($proxy, 'FLOW3_Persistence_Identifier', sha1($hashSource), TRUE);
 }
Example #3
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());
 }