Active Access-control-Expose-Headers

@param  array $excepted
@return AccessControl
@throws AccessControlException
337033
public function exposeHeaders(array $excepted)
    {
        if (count($excepted) == 0) {
            throw new AccessControlException(
                'Le tableau est vide.' . gettype($excepted) . ' donner.',
                E_USER_ERROR
            );
        }

        return $this->push('Access-Control-Expose-Headers', implode(', ', $excepted));
    }
1119704
protected function initArrayFields(array $except = [])
    {
        $reflection = new ReflectionClass(static::class);
        $docs = ($reflection->getDocComment());
        $docs = preg_replace("~[*/]+~", ' ', $docs);
        preg_match_all("~@property\s+(array|mixed|ListObject|FillableFieldsList)\s+\\$(.*)\r?\n+~", $docs, $result);

        if ($result) {
            $fields = array_diff($result[2], $except);

            foreach ($fields as $field) {
                $this->properties[$field] = new ListObject();
            }
        }
    }
603306
public function withHeaders(array $headers): self
    {
        return tap($this, function ($request) use ($headers) {
            return $this->options = array_merge_recursive($this->options, [
                'headers' => $headers,
            ]);
        });
    }
786256
public function setAccessKey( $accessKey ) {
		$accessKey = is_string( $accessKey ) && strlen( $accessKey ) ? $accessKey : null;

		if ( $this->accessKey !== $accessKey ) {
			if ( $accessKey !== null ) {
				$this->accessKeyed->setAttributes( [ 'accesskey' => $accessKey ] );
			} else {
				$this->accessKeyed->removeAttributes( [ 'accesskey' ] );
			}
			$this->accessKey = $accessKey;

			// Only if this is a TitledElement
			if ( method_exists( $this, 'updateTitle' ) ) {
				$this->updateTitle();
			}
		}

		return $this;
	}
1368812
public static function acl($requester, $controlled) {
		$self = static::_object();
		$aro = $self->_classes['aro'];
		$aco = $self->_classes['aco'];

		if (!(($aroNode = $aro::node($requester)) && ($acoNode = $aco::node($controlled)))) {
			return false;
		}

		$acl = static::find('first', [
				'conditions' => [
					key(static::relations('Aro')->key()) => $aroNode[0]['id'],
					key(static::relations('Aco')->key()) => $acoNode[0]['id']
				],
				'return' => 'array'
		]);
		if (isset($acl['privileges'])) {
			$acl['privileges'] = json_decode($acl['privileges'], true);
		}

		return [
			'aro' => $aroNode[0]['id'],
			'aco' => $acoNode[0]['id'],
			'acl' => isset($acl) ? $acl: []
		];
	}
42046
public void setAccessControlList(java.util.Collection<Grant> accessControlList) {
        if (accessControlList == null) {
            this.accessControlList = null;
            return;
        }

        this.accessControlList = new java.util.ArrayList<Grant>(accessControlList);
    }
159703
public function handleRequest(AdminEvent $event)
    {
        if (!$this->applicationConfiguration->getParameter('enable_security')) {
            return;
        }
        $user = $this->getUser();

        if (!$this->authorizationChecker->isGranted($user->getRoles(), $user)) {
            throw new AccessDeniedException();
        }
        $configuration = $event->getAdmin()->getConfiguration();
        $allowed = false;

        foreach ($user->getRoles() as $role) {
            if ($role instanceof Role) {
                $role = $role->getRole();
            }

            if ($configuration->getParameter('permissions') === $role) {
                $allowed = true;
            }
        }
        if (!$allowed) {
            throw new AccessDeniedException();
        }
    }
616442
public function setEventAccessLevel($eventId, $accessLevel, $password)
    {
        if (is_null($accessLevel) || $accessLevel == '') {
            throw new Exception('The access level is required.');
        }

        $params = array(
            'method' => 'sp.event.set_access_level',
            'event_id' => $eventId,
            'access_level' => $accessLevel,
            'password' => $password
        );

        return $this->_makeApiRequest($params);
    }
1308119
public function indexAction()
    {
        $tools = $this->toolManager->getAdminToolsByRoles($this->tokenStorage->getToken()->getRoles());

        if (count($tools) === 0) {
            throw new AccessDeniedException();
        }

        return $this->redirect($this->generateUrl('claro_admin_open_tool', array('toolName' => $tools[0]->getName())));
    }
926764
function setHeaders($headers)
    {
        if ($headers instanceof iHeaders) {
            $tHeaders = array();
            foreach($headers as $h)
                $tHeaders[] = $h;
            $headers = $tHeaders;
        }

        if (! is_array($headers) )
            throw new \InvalidArgumentException;

        foreach ($headers as $label => $h) {
            if (! $h instanceof iHeader ) {
                if (is_int($label) && is_string($h))
                    // ['X-Powered-By: PHP/5.5.9-1ubuntu4.16', ]
                    // in form of headers_list()
                    $valuable = $h;
                else
                    $valuable = array($label => $h);
                        
                $h = FactoryHttpHeader::of($valuable);
            }

            $this->headers()->insert($h);
        }

        return $this;
    }
1186322
public function setAccessor(
        Context $context,
        NameValue $name,
        callable $getter,
        callable $setter = null,
        int $settings = AccessControl::DEFAULT_ACCESS,
        int $attributes = PropertyAttribute::NONE
    ): bool {
    }
1315516
public function getStructureDifferences($db, $excepted, $drop = false)
    {
        if (isset($excepted['table'])) {
            $excepted = array($excepted['table'] => $excepted);
        }
        $actions = array();
        foreach ($excepted as $table => $value) {
            $current = $this->getCurrentStructure($db, $table);
            if (count($current) > 0) {
                $dbTable = array_shift($current);
                if ($this->getHash($value) != $this->getHash($dbTable)) {

//                    if(strtolower($value['engine']) != strtolower($dbTable['engine'])) {
//                        $actions[] = array(
//                            'sql' => $this->getChangeEngine($table, $value['engine']),
//                            'action' => 'change_engine'
//                        );
//                    }

                    $subject1 = array($value['fields']);
                    $subject2 = array($dbTable['fields']);

                    foreach ($subject1 as $index => $test1) {
                        $test2 = $subject2[$index];
                        // Search for add and changes
                        foreach ($test1 as $key => $item) {
                            if (isset($test2[$key])) {
                                $item2 = $test2[$key];
                                // possible changes
                                if ($this->getHash($item) !== $this->getHash($item2)) {
                                    $actions[] = array(
                                        'sql' => $this->getAlterChange($table, $item),
                                        'action' => 'alter_field'
                                    );
                                }
                            } else {
                                // create the new instance
                                $actions[] = array('sql' => $this->getAlterAdd($table, $item), 'action' => 'add_field');
                            }
                        }
                        //Search for deletion
                        foreach ($test2 as $key => $item) {
                            if (!isset($test1[$key]) && $drop) {
                                $actions[] = array(
                                    'sql' => $this->getAlterDrop($table, $item, $key),
                                    'action' => 'drop_field'
                                );
                            }
                        }
                    }

                    $test1 = $value['keys'];
                    $test2 = $dbTable['keys'];
                    foreach ($test1 as $key => $item) {
                        if (!$this->haveKey($item, $test2)) {
                            $actions[] = array('sql' => $this->getAddKey($table, $item), 'action' => 'add_key');
                        }
                    }
                    //Search for deletion
                    foreach ($test2 as $key => $item) {
                        if (!$this->haveKey($item, $test1)) {
                            $actions[] = array(
                                'sql' => $this->getDropKey($table, $item),
                                'action' => 'drop_key'
                            );
                        }
                    }

                    $test1 = $value['unique'];
                    $test2 = $dbTable['unique'];
                    foreach ($test1 as $key => $item) {
                        if (!$this->haveUnique($item, $test2)) {
                            $actions[] = array('sql' => $this->getAddKey($table, $item), 'action' => 'add_unique');
                        }
                    }
                    //Search for deletion
                    foreach ($test2 as $key => $item) {
                        if (!$this->haveKey($item, $test1)) {
                            $actions[] = array(
                                'sql' => $this->getDropKey($table, $item),
                                'action' => 'drop_unique'
                            );
                        }
                    }

                }
            } else {
                //                if(!$value instanceof \stdClass) die_stack_trace();
                $actions[] = array('sql' => $this->getCreateTable($value), 'action' => 'create_table');
            }
        }
        if ($current) {
            foreach ($current as $table => $value) {
                if (!isset($excepted[$table]) && $drop) {
                    $actions[] = array('sql' => $this->getDropTable($value), 'action' => 'drop_table');
                }
            }
        }
        return $actions;
    }
1098808
public function manageOwnAction(Request $request)
    {
        $securityContext = $this->getSecurityContext();

        if (!$securityContext->getToken()) {
            throw new AccessDeniedException(
                $this->get('translator')->trans(
                    'must_be_logged_in_to_edit_own_settings',
                    array(),
                    'settings'
                )
            );
        }

        $securitySettings = $this->container->getParameter('settings_manager.security');
        if (!$securitySettings['users_can_manage_own_settings']) {
            throw new AccessDeniedException(
                $this->get('translator')->trans(
                    'not_allowed_to_edit_own_settings',
                    array(),
                    'settings'
                )
            );
        }

        $user = $securityContext->getToken()->getUser();

        if (!($user instanceof SettingsOwnerInterface)) {
            //For this to work the User entity must implement SettingsOwnerInterface
            throw new AccessDeniedException();
        }

        return $this->manage($request, $user);
    }
968593
public function setExposedHeaders(array $headers): self
    {
        // Optional: from #7.1.1 'simple response headers' will be available in any case so it does not
        // make sense to include those headers to exposed.
        $filtered = [];
        foreach ($headers as $header) {
            if (\in_array(\strtolower($header), static::SIMPLE_LC_RESPONSE_HEADERS) === false) {
                $filtered[] = $header;
            }
        }

        $this->exposedHeadersList = \implode(', ', $filtered);

        return $this;
    }
1251339
public function setAccessControlRequestMethod($accessControlRequestMethod)
    {
        // Validate access-control-request-method is string
        if (is_string($accessControlRequestMethod) === false) {
            throw new InvalidArgumentException(
                'Parameter "method" is not a string'
            );
        }

        // Valid access-control-request-method is not blank
        if ($accessControlRequestMethod === '') {
            throw new InvalidArgumentException(
                'Parameter "method" cannot be blank'
            );
        }

        $this->accessControlRequestMethod = $accessControlRequestMethod;

        return $this;
    }
937703
public function replicate(array $except = null)
	{
		$except = $except ?: [
			$this->getKeyName(),
			$this->getCreatedAtColumn(),
			$this->getUpdatedAtColumn(),
		];

		$attributes = array_except($this->attributes, $except);

		with($instance = new static)->setRawAttributes($attributes);

		return $instance->setRelations($this->relations);
	}
1187872
public function exposeHeaders($headers = '*')
    {
        $headers = array_map([HeaderHelper::class, 'normalizeHeaderName'], (array) $headers);
        $headers = implode(', ', $headers);

        $this->response = $this->response->withHeader('Access-Control-Allow-Headers', $headers);

        return $this;
    }