Performs actions related to security before kernel build (mainly settings injection).

@param PreBuildKernelWebHandlerEvent $event
435830
public function onLegacyKernelWebBuild(PreBuildKernelWebHandlerEvent $event)
    {
        if ($this->configResolver->getParameter('legacy_mode') === true) {
            return;
        }

        $injectedMergeSettings = $event->getParameters()->get('injected-merge-settings', []);
        $accessRules = [
            'access;disable',
            'module;user/login',
            'module;user/logout',
        ];
        // Merge existing settings with the new ones if needed.
        if (isset($injectedMergeSettings['site.ini/SiteAccessRules/Rules'])) {
            $accessRules = array_merge($injectedMergeSettings['site.ini/SiteAccessRules/Rules'], $accessRules);
        }
        $injectedMergeSettings['site.ini/SiteAccessRules/Rules'] = $accessRules;
        $event->getParameters()->set('injected-merge-settings', $injectedMergeSettings);
    }
468378
public function beforeUpdate($event)
    {
        foreach ($this->update as $field) {
            $event->sender->$field = time();
        }
    }
390728
public function targetStarted(BuildEvent $event)
    {
        $this->bar->setMessage($event->getTarget()->getName(), 'target');
        $this->determineDepth($event);
    }
1075275
public function onBefore(BeforeEvent $event)
    {
        $request = $event->getRequest();

        if (!$this->canCacheRequest($request)) {
            $this->cacheMiss($request);
            return;
        }

        if (!($response = $this->storage->fetch($request))) {
            $this->cacheMiss($request);
            return;
        }

        $response->setHeader('Age', Utils::getResponseAge($response));
        $valid = $this->validate($request, $response);

        // Validate that the response satisfies the request
        if ($valid) {
            $request->getConfig()->set('cache_lookup', 'HIT');
            $request->getConfig()->set('cache_hit', true);
            $event->intercept($response);
        } else {
            $this->cacheMiss($request);
        }
    }
776725
public function beforePrepare(Event $event)
	{
		$operation = $event['command']->getOperation();
		$client = $event['command']->getClient();

		if ($operation->hasParam('collection') === false) return;
		if (is_null($client->getCollectionName())) return;

		$operation->getParam('collection')->setDefault($client->getCollectionName());
		$operation->getParam('collection')->setStatic(true);

	}
991524
public function onBeforeNormalization(BeforeNormalizationEvent $event): void
    {
        $resource = $event->getResource();

        if ($resource instanceof RelatedResourceInterface) {
            $this->fixForRelations($resource);
        }

        if ($resource instanceof ActionedResourceInterface) {
            $this->fixForActions($resource);
        }
    }
1270451
public function preUpdate(PreUpdateEventArgs $event)
    {
        $entity = $event->getEntity();
        if ($entity instanceof CategorizableInterface) {
            $this
                ->categoryIntegrityFixer
                ->fixCategoriesIntegrity($entity);
        }
    }
357749
public function beforePrepare(Event $event)
	{
		$command = $event['command'];

		if ($command->getName() !== 'createEntity') return;
		if (!$command['_id']) return;

		$operation = $command->getOperation();
		$operation->setHttpMethod('PUT');
	}
86551
public function onKernelRequest(KernelEvent $event)
    {
        // TODO explicit transaction management in stead of this. See ZICHTDEV-119 for ideas on this
        if ($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST
            && preg_match($this->pattern, $event->getRequest()->getRequestUri())) {

            $this->wasTxStarted = true;
            $this->doctrine->getConnection()->beginTransaction();
        }
    }
451026
public function onBeforeSend(Event $event)
    {
        global $logger;
        $req        = $event['request'];
        $options    = $this->_options;
        $algorithms = array(
            'sha1',
            'sha256',
            'sha512'
        );

        if(empty($options['key']))
            $options['key'] = $this->_app->getConfiguration()->getSharedKey();
        if(empty($options['secret']))
            $options['secret'] = $this->_app->getConfiguration()->getSecretKey();

        if (!isset($options['key']) || !is_string($options['key']))
            throw new \Exception("options.key must be a String");
        if (isset($options['algorithm']) && !is_string($options['algorithm']))
            throw new \Exception("options.algorithm must be a String");
        if (isset($options['headers']) && !is_array($options['headers']))
            throw new \Exception("options.headers must be an array of Strings");

        $reqDate = $this->_rfc1123();
        if ($req->getHeader('date') === null) {
            $req->setHeader('Date', $reqDate); 
        }

        if (!isset($options['headers'])) {
            $options['headers'] = array(); 
        } 
        
        if (!in_array('Date', $options['headers'])) {
            $options['headers'][]= 'Date'; 
        }
        if (!in_array('X-Hmac-Nonce', $options['headers'])) {
            $options['headers'][]= 'X-Hmac-Nonce'; 
        }
        $req->setHeader('X-HMAC-Date', $reqDate); 
        $req->setHeader('X-HMAC-Nonce', 'Thohn2Mohd2zugoo');

        $headersToSign = array();
        foreach($options['headers'] as $hdr) {
            $headersToSign[$hdr] = $req->getHeader($hdr); 
        } 
        
        if (!isset($options['algorithm']))
            $options['algorithm'] = 'sha512';
        $options['algorithm'] = strtolower($options['algorithm']);

        if (!in_array($options['algorithm'], $algorithms))
            throw new \Exception($options['algorithm']." is not supported");

        $canonicalRepresentation = HmacUtils::createCanonicalRepresentation($req->getMethod(), $headersToSign, $req->getUrl());
        $signature = HmacUtils::computeSignature($canonicalRepresentation, $options['secret'], $options['algorithm']);
        //$logger->debug('Canonical Representation ', array($canonicalRepresentation, $signature)); 
        $req->setHeader('Authorization', $options['algorithm'].' '.$options['key'].' '.$signature);
    }
563173
public function taskStarted(BuildEvent $event)
    {
        $name = $event->getTask()->getTaskName();
        $now = Phing::currentTimeMillis();
        $this->logStart($event, $now, $name);
        $this->profileData[] = $now;
    }
705018
public function beforeFilter(Event $event)
    {
        EventManager::trigger('Controller.setup', $this);

        $pluginEvent = Plugin::getData('Core', 'Controller.beforeFilter');
        if (is_callable($pluginEvent->find(0)) && Plugin::hasManifestEvent('Controller.beforeFilter')) {
            call_user_func_array($pluginEvent->find(0), [$this, $event]);
        }
    }
845048
public function beforeRender(Event $event)
    {
        if (!Configure::read('debug')) {
            return;
        }

        $this->_action()->setConfig('serialize.queryLog', 'queryLog');
        $this->_controller()->set('queryLog', $this->_getQueryLogs());
    }
114756
protected function beforeSave($event)
    {
        if ($this->autoSave) {
            $this->saveFile($this->owner->{$this->uploadAttribute}, $this->name, $this->path);
        }
    }
420821
public function targetStarted(BuildEvent $event)
    {
        if (Project::MSG_INFO <= $this->msgOutputLevel
            && $event->getTarget()->getName() != ''
        ) {
            $showLongTargets = $event->getProject()->getProperty("phing.showlongtargets");
            $msg = PHP_EOL . $event->getProject()->getName() . ' > ' . $event->getTarget()->getName() . ($showLongTargets ? ' [' . $event->getTarget()->getDescription() . ']' : '') . ':' . PHP_EOL;
            $this->printMessage($msg, $this->out, $event->getPriority());
        }
    }
146784
public function onKernelBuilt(PostBuildKernelEvent $event)
    {
        // Ignore if not in web context, if legacy_mode is active or if user is not authenticated
        if (
            $this->enabled === false
            || !$event->getKernelHandler() instanceof ezpWebBasedKernelHandler
            || $this->configResolver->getParameter('legacy_mode') === true
            || !$this->isUserAuthenticated()
        ) {
            return;
        }

        $currentUser = $this->repository->getCurrentUser();
        $event->getLegacyKernel()->runCallback(
            static function () use ($currentUser) {
                $legacyUser = eZUser::fetch($currentUser->id);
                eZUser::setCurrentlyLoggedInUser($legacyUser, $legacyUser->attribute('contentobject_id'), eZUser::NO_SESSION_REGENERATE);
            },
            false,
            false
        );
    }
441530
public function beforeFilter(Event $event)
    {
        if (!$this->_controller()->Auth->user() &&
            $this->_controller()->Cookie->read('CookieAuth')) {

            $user = $this->_controller()->Auth->identify();
            if ($user) {
                $this->_controller()->Auth->setUser($user);
            } else {
                $this->_controller()->Cookie->delete('CookieAuth');
            }
        }
    }