Perform an ACL check when a AuthorizedDirectObject is dispatched.

@param \Zend\Mvc\MvcEvent $event
@return null|array
964306
public function onDispatchDirect(Event $event)
    {
        $object = $event->getParam('object');
        $method = $event->getParam('rpc')->getMethod();

        // Check ACL
        if ($object instanceof \JaztecAcl\Direct\AuthorizedDirectObject) {
            if (!$object->checkAcl($method)) {
                $event->stopPropagation(true);

                return $object->notAllowed();
            }
        }
    }
839407
public function finishEvent(MvcEvent $event)
    {
        $matchRoute = $event->getRouteMatch();

        if (empty($matchRoute)) {
            return null;
        }

        /** @var \Rcm\EventListener\EventFinishListener $eventFinishListener */
        $eventFinishListener = $this->serviceLocator->get(
            \Rcm\EventListener\EventFinishListener::class
        );

        $return = $eventFinishListener->processRcmResponses($event);

        if (!empty($return)) {
            return $return;
        }

        return null;
    }
612952
public function deliveryAuthorized(AuthorizationGranted $event)
    {
        $deliveryExecution = $event->getDeliveryExecution();
        $data = $this->createMonitoringData($deliveryExecution);

        $data->update(DeliveryMonitoringService::AUTHORIZED_BY, $event->getAuthorizer()->getIdentifier());
        if (!$this->partialSave($data)) {
            \common_Logger::w('monitor cache for authorization could not be updated');
        }
    }
1079783
public function getAdminPanel(MvcEvent $event)
    {
        $matchRoute = $event->getRouteMatch();

        if (empty($matchRoute)) {
            return null;
        }

        /** @var \RcmAdmin\Controller\AdminPanelController $adminPanelController */
        $adminPanelController = $this->serviceLocator->get(
            \RcmAdmin\Controller\AdminPanelController::class
        );

        $adminPanelController->setEvent($event);

        $adminWrapper = $adminPanelController->getAdminWrapperAction();

        if (!$adminWrapper instanceof ViewModel) {
            return;
        }

        /** @var \Zend\View\Model\ViewModel $viewModel */
        $layout = $event->getViewModel();
        $layout->addChild($adminWrapper, 'rcmAdminPanel');
    }
370372
public function routeLoad(MvcEvent $event)
    {
        $request = $event->getRequest();
        if(!(
            $request instanceof HttpRequest &&
            $request->isGet() &&
            $request->getQuery()->count() == 0
        )) {
            // We do not cache route match for requests that can produce
            // different match.
            return;
        }

        $event->setParam('route-cacheable', true);

        // check if we have data in our cache
        $path = $request->getUri()->getPath();

        $services = $event->getApplication()->getServiceManager();

        $cacheName = $services->get(RouterCacheOptions::class)->getCache();
        $cache = $services->get($cacheName);

        $cacheKey = $this->getCacheKey($path);
        $cachedData = $cache->getItem($cacheKey);

        if($cachedData) {
            $event->setParam('route-cached', true);
            $router = $event->getRouter();
            $router->addRoute($cachedData['name'], $cachedData['spec'], round(PHP_INT_MAX/2));
        }
    }
57608
public function doLogout(MvcEvent $event)
    {
        $application = $event->getApplication();
        $sm = $application->getServiceManager();
        /** @var \RcmUser\Service\RcmUserService $rcmUserService */
        $rcmUserService = $this->serviceLocator->get(
            \RcmUser\Service\RcmUserService::class
        );

        /** @var $request \Zend\Http\Request */
        $request = $sm->get('request');
        $logout = (bool)$request->getQuery('logout', 0);

        if ($logout) {
            $rcmUserService->clearIdentity();
            session_destroy();
            $request = explode('?', $_SERVER['REQUEST_URI']);
            header('Location: //' . $_SERVER['HTTP_HOST'] . $request[0]);
            die;
        }
    }
299271
private function checkPermission(ActionEvent $event)
    {
        $environment = $event->getEnvironment();

        if (true === $environment->getDataDefinition()->getBasicDefinition()->isEditable()) {
            return true;
        }

        $event->setResponse(
            \sprintf(
                '<div style="text-align:center; font-weight:bold; padding:40px;">
                    You have no permission for toggle %s.
                </div>',
                $this->getOperation($event->getAction(), $environment)->getToggleProperty()
            )
        );

        return false;
    }
713807
private function checkPermission(ActionEvent $event)
    {
        $environment = $event->getEnvironment();

        if (true === $environment->getDataDefinition()->getBasicDefinition()->isEditable()) {
            return true;
        }

        $inputProvider = $environment->getInputProvider();

        $event->setResponse(
            \sprintf(
                '<div style="text-align:center; font-weight:bold; padding:40px;">
                    You have no permission for edit model %s.
                </div>',
                ModelId::fromSerialized($inputProvider->getParameter('id'))->getSerialized()
            )
        );

        return false;
    }
212751
public function checkAccess(EventInterface $event) {
        if ($event->hasArgument('skipAccessControl') &&
            $event->getArgument('skipAccessControl') === true) {
            return;
        }

        $request = $event->getRequest();
        $aclAdapter = $event->getAccessControl();
        $resource = $event->getName();
        $publicKey = $request->getPublicKey();
        $user = $request->getUser();

        $hasAccess = $aclAdapter->hasAccess($publicKey, $resource, $user);

        if ($hasAccess) {
            return;
        }

        // If we're asking for info on a public key, and that public key happens to be the one
        // used to sign the request, accept this as a valid request and let the user have access
        // to the resource. Note that this requires the accessToken listener to be in place -
        // if disabled, any user can ask for the access rules for all public keys
        if (in_array($resource, $this->ownPublicKeyAllowedResources)) {
            $routePubKey = $request->getRoute()->get('publickey');
            if ($routePubKey === $publicKey) {
                return;
            }
        }

        // If a public key has access to resources within a resource group, allow the
        // public key to access the group resource to see which resources it contains
        if (in_array($resource, $this->groupLookupResources)) {
            $routeGroup = $request->getRoute()->get('group');
            $aclList = $aclAdapter->getAccessListForPublicKey($publicKey);

            foreach ($aclList as $aclRule) {
                if (isset($aclRule['groups']) && in_array($routeGroup, $aclRule['groups'])) {
                    return;
                }
            }
        }

        throw new RuntimeException('Permission denied (public key)', 400);
    }
281790
public function onBootstrap(MvcEvent $event)
    {
        $serviceManager = $event->getApplication()->getServiceManager();

        $request = $serviceManager->get('request');

        if ($request instanceof ConsoleRequest) {
            return;
        }

        //Add Domain Checker
        $eventWrapper = $serviceManager->get(
            \Rcm\EventListener\EventWrapper::class
        );

        /** @var \Zend\EventManager\EventManager $eventManager */
        $eventManager = $event->getApplication()->getEventManager();

        // Check for redirects from the CMS
        $eventManager->attach(
            MvcEvent::EVENT_ROUTE,
            [$eventWrapper, 'routeEvent'],
            10000
        );

        // Set the sites layout.
        $eventManager->attach(
            MvcEvent::EVENT_DISPATCH,
            [$eventWrapper, 'dispatchEvent'],
            10000
        );

        // Set the custom http response checker
        $eventManager->attach(
            MvcEvent::EVENT_FINISH,
            [$eventWrapper, 'finishEvent'],
            10000
        );

        $viewEventManager = $serviceManager->get('ViewManager')
            ->getView()
            ->getEventManager();

        // Set the plugin response over-ride
        $viewEventManager->attach(
            ViewEvent::EVENT_RESPONSE,
            [$eventWrapper, 'viewResponseEvent'],
            -10000
        );

        // Use the configured session handler.
        // Should we really boot this for every request though?
        $serviceManager->get(\Rcm\Service\SessionManager::class)->start();
    }
743295
public function authorizeRequest(Event $event)
    {
        /* @var \Guzzle\Service\Command\CommandInterface $command */
        $command = $event['command'];

        $request = $command->getRequest();
        $request->setAuth($this->apiKey);
    }
252663
public function onRoute(MvcEvent $event)
    {
        if ($event->isError()) {
            return $event->getResult();
        }
        $routeMatch = $event->getRouteMatch();
        $routeName  = $routeMatch->getMatchedRouteName();
        $resourceId = "route/$routeName";
        
        return $this->checkAcl($event, $resourceId);
    }
1158776
public function hasEvent($event) {
		return (bool) check_entity_relationship($event->guid, self::EVENT_CALENDAR_RELATIONSHIP, $this->guid);
	}
182658
public function resolve($event)
    {
        if ($event instanceof UserEvent) {
            return $this->getEventDetailsArray($event->getUser()->getUsername());
        }

        return null;
    }
744863
public function routeLoad(MvcEvent $event)
    {
        $request = $event->getRequest();
        if(!(
            $request->getMethod() == \Zend\Http\Request::METHOD_GET &&
            $request->getQuery()->count() == 0
        )) {
            // We do not cache route match for requests that can produce
            // different match.
            return ;
        }
    
        $event->setParam('route-cacheable', true);
    
        // check if we have data in our cache
        $path = $request->getUri()
                        ->getPath();
    
        $cache = $event->getApplication()->getServiceManager()->get('var-cache');
        $cacheKey = $this->getCacheKey($path);
        $cachedData = $cache->getItem($cacheKey);
    
        if(!empty($cachedData)) {
            $event->setParam('route-cached', true);
    
            $cachedRoute = \Zend\Mvc\Router\Http\Literal::factory($cachedData);
            $router = $event->getRouter();
            $router->addRoute($cachedData['name'], $cachedRoute, 99999);
        }
    }
704998
public function onBootstrap(MvcEvent $event)
    {
        $sharedEventManager = $event->getApplication()->getEventManager()->getSharedManager();
        $sharedEventManager->attach(
            AbstractActionController::class,
            MvcEvent::EVENT_DISPATCH,
            [$this, 'onDispatchedListener'],
            self::DISPATCH_PRIORITY
        );
    }
883215
public function onCorsPreflight(MvcEvent $event)
    {
        // Reset state flag
        $this->isPreflight = false;

        /** @var $request HttpRequest */
        $request = $event->getRequest();

        if (! $request instanceof HttpRequest) {
            return;
        }

        try {
            $isCorsRequest = $this->corsService->isCorsRequest($request);
        } catch (InvalidOriginException $exception) {
            /** @var HttpResponse $response */
            $response = $event->getResponse();
            $response->setStatusCode(400);
            $response->setReasonPhrase($exception->getMessage());
            return $response;
        }

        // If this isn't a preflight, done
        if (! $isCorsRequest || ! $this->corsService->isPreflightRequest($request)) {
            return;
        }

        // Preflight -- return a response now!
        $this->isPreflight = true;

        return $this->corsService->createPreflightCorsResponseWithRouteOptions($request, $event->getRouteMatch());
    }