Inject metadata info into php-saml settings array

@param array $settings      php-saml settings array
@param array $metadataInfo  array metadata info

@return array settings
512085
public static function injectIntoSettings($settings, $metadataInfo)
    {
        if (isset($metadataInfo['idp']) && isset($settings['idp'])) {
            if (isset($metadataInfo['idp']['x509certMulti']) && !empty($metadataInfo['idp']['x509certMulti']) && isset($settings['idp']['x509cert'])) {
                unset($settings['idp']['x509cert']);
            }

            if (isset($metadataInfo['idp']['x509cert']) && !empty($metadataInfo['idp']['x509cert']) && isset($settings['idp']['x509certMulti'])) {
                unset($settings['idp']['x509certMulti']);
            }
        }

        return array_replace_recursive($settings, $metadataInfo);
    }
189686
private function doctrine2MetadataToGeneratorMetadata(array $metadataCollection)
    {
        $metaDataCollection = new MetaDataCollection();

        foreach ($metadataCollection as $metadata) {
            $metaDataCollection->append(
                $this->hydrateDataObject($metadata)
            );
        }

        return $metaDataCollection;
    }
665273
public function injectSettings(array $settings) {
		if (isset($settings['server'])) {
			if (!is_array($settings['server'])) {
				throw new Exception('Invalid Flowpack.SingleSignOn.Client.server configuration', 1351688261);
			}
			$this->serverConfigurations = $settings['server'];
		}
	}
1215483
public function setMeta(array $meta)
    {
        $headers = [];
        $metaType = $this->objectMetaType();

        // We will replace any 'X-{Object}-Meta-' prefixes in meta name
        // and prepend final header names with same prefix so API will
        // receive sanitized headers and won't produce any errors.

        foreach ($meta as $name => $value) {
            $key = str_replace('X-'.$metaType.'-Meta-', '', $name);
            $headers['X-'.$metaType.'-Meta-'.$key] = $value;
        }

        $response = $this->apiClient()->request('POST', $this->absolutePath(), ['headers' => $headers]);

        if ($response->getStatusCode() !== 202) {
            throw new ApiRequestFailedException('Unable to update container meta data.', $response->getStatusCode());
        }

        return true;
    }
635531
public static function modules($settings)
    {
        return array_filter(
            array_map(
                function ($m) {
                    return is_array($m) ? key($m) : $m;
                },
                $settings['modules']['enabled'],
                array_keys($settings['modules']['enabled'])
            ),
            function ($m) use ($settings) {
                if (!isset($settings['modules']['disabled'])) {
                    return true;
                }
                return !in_array($m, $settings['modules']['disabled']);
            }
        );
    }
953338
public function getSamlSettings() {
        $settings = new Maestrano_Saml_Settings();

        // Configure SAML
        $settings->idpPublicCertificate = Maestrano::with($this->_preset)->param('sso.x509_certificate');
        $settings->spIssuer = Maestrano::with($this->_preset)->param('api.id');
        // TODO: default value?
        // $settings->requestedNameIdFormat = Maestrano::with($this->_preset)->param('sso.name_id_format');
        $settings->idpSingleSignOnUrl = $this->getIdpUrl();
        $settings->spReturnUrl = $this->getConsumeUrl();

        return $settings;
    }
746216
public function UpdateOrganizationSettings(\Google\Cloud\SecurityCenter\V1\UpdateOrganizationSettingsRequest $argument,
      $metadata = [], $options = []) {
        return $this->_simpleRequest('/google.cloud.securitycenter.v1.SecurityCenter/UpdateOrganizationSettings',
        $argument,
        ['\Google\Cloud\SecurityCenter\V1\OrganizationSettings', 'decode'],
        $metadata, $options);
    }
1370254
public function resolve(array $settings = [])
    {
        return (new Configuration())->newDefaultAnnotationDriver(
            Arr::get($settings, 'paths', []),
            Arr::get($settings, 'simple', false)
        );
    }
721382
public function loadSettings(array $settings)
    {
        $relationalManagerKey = $this->getOption(static::RELATIONAL_MANAGER_KEY);
        if (array_key_exists($relationalManagerKey, $settings)) {
            $this->registerEntityManagers((array) $settings[$relationalManagerKey]);
        }

        $mongoDBManagerKey = $this->getOption(static::MONGODB_MANAGER_KEY);
        if (array_key_exists($mongoDBManagerKey, $settings)) {
            $this->registerMongoDBDocumentManagers((array) $settings[$mongoDBManagerKey]);
        }

        $couchDBManagerKey = $this->getOption(static::COUCHDB_MANAGER_KEY);
        if (array_key_exists($couchDBManagerKey, $settings)) {
            $this->registerCouchDBDocumentManagers((array) $settings[$couchDBManagerKey]);
        }

        return $this;
    }
1275780
public function generateMetadataHeaders(array $metadata)
    {
        $metadataHeaders = [];

        if (is_array($metadata) && !is_null($metadata)) {
            foreach ($metadata as $key => $value) {
                $headerName = Resources::X_MS_META_HEADER_PREFIX;
                if (strpos($value, "\r") !== false
                    || strpos($value, "\n") !== false
                ) {
                    throw new \InvalidArgumentException(Resources::INVALID_META_MSG);
                }

                $headerName .= strtolower($key);
                $metadataHeaders[$headerName] = $value;
            }
        }

        return $metadataHeaders;
    }
631532
protected function perform_update_metadata( array $changes ) {
		if ( ! $this->meta_type ) {
			return;
		}

		$mapping = $this->get_mapping();

		$changes = $this->recently_created
			? array_keys( $mapping )
			: $this->get_changes_only( $changes, array_keys( $mapping ) );

		// Don't do anything if nothing changes.
		if ( empty( $changes ) ) {
			return;
		}

		$updated = [];
		foreach ( $changes as $attribute ) {
			$meta_key = $this->get_mapping_metakey( $attribute );
			if ( is_null( $meta_key ) ) {
				continue;
			}

			if ( $this->update_meta( $meta_key, $this->get_attribute( $attribute ) ) ) {
				$updated[] = $attribute;
			}
		}

		return $updated;
	}
623616
private function getFieldFilter(ClassMetadata $metadata, array $fields)
    {
        /* @var \Doctrine\ORM\Mapping\ClassMetadata $metadata */
        $filters = array();
        foreach ($fields as $field) {
            $fieldName = $this->getFieldName($metadata, $field);
            try {
                $filters[] = $metadata->getFieldMapping($fieldName);
            } catch (\Exception $ex) {
                $mapping = $metadata->getAssociationMapping($fieldName);
                $associationMatadata = $this->entityManager->getClassMetadata($mapping['targetEntity']);
                $associationFields = $associationMatadata->getFieldNames();
                $associationIdentifier = $associationMatadata->getIdentifierFieldNames();
                $associationFields = array_values(array_filter(
                    $associationFields,
                    function ($value) use ($associationIdentifier) {
                        return !in_array($value, $associationIdentifier);
                    }
                ));
                if ($associationFields) {
                    $filters[] = array_merge(array(
                        'join' => true,
                        'join_field' => $fieldName,
                        'join_alias' => $this->getAlias(),
                    ), $associationMatadata->getFieldMapping($associationFields[0]));
                }
            }
        }

        return $filters;
    }
344854
public function injectSettings(array $settings)
    {
        $this->sessionCookieName = $settings['session']['name'];
        $this->sessionCookieLifetime = (integer)$settings['session']['cookie']['lifetime'];
        $this->sessionCookieDomain = $settings['session']['cookie']['domain'];
        $this->sessionCookiePath = $settings['session']['cookie']['path'];
        $this->sessionCookieSecure = (boolean)$settings['session']['cookie']['secure'];
        $this->sessionCookieHttpOnly = (boolean)$settings['session']['cookie']['httponly'];
        $this->garbageCollectionProbability = $settings['session']['garbageCollection']['probability'];
        $this->garbageCollectionMaximumPerRun = $settings['session']['garbageCollection']['maximumPerRun'];
        $this->inactivityTimeout = (integer)$settings['session']['inactivityTimeout'];
    }
278665
function getMetadata()
    {
        $auth = $this->auth;
        $settings = $auth->getSettings();
        $metadata = $settings->getSPMetadata();
        $errors = $settings->validateMetadata($metadata);

        if (empty($errors)) {

            return $metadata;
        } else {

            throw new InvalidArgumentException(
                'Invalid SP metadata: ' . implode(', ', $errors),
                OneLogin_Saml2_Error::METADATA_SP_INVALID
            );
        }
    }
294658
public function injectSettings(array $settings)
    {
        if (isset($settings['security']['authentication']['authenticationStrategy'])) {
            $authenticationStrategyName = $settings['security']['authentication']['authenticationStrategy'];
            switch ($authenticationStrategyName) {
                case 'allTokens':
                    $this->authenticationStrategy = self::AUTHENTICATE_ALL_TOKENS;
                    break;
                case 'oneToken':
                    $this->authenticationStrategy = self::AUTHENTICATE_ONE_TOKEN;
                    break;
                case 'atLeastOneToken':
                    $this->authenticationStrategy = self::AUTHENTICATE_AT_LEAST_ONE_TOKEN;
                    break;
                case 'anyToken':
                    $this->authenticationStrategy = self::AUTHENTICATE_ANY_TOKEN;
                    break;
                default:
                    throw new Exception('Invalid setting "' . $authenticationStrategyName . '" for security.authentication.authenticationStrategy', 1291043022);
            }
        }

        if (isset($settings['security']['csrf']['csrfStrategy'])) {
            $csrfStrategyName = $settings['security']['csrf']['csrfStrategy'];
            switch ($csrfStrategyName) {
                case 'onePerRequest':
                    $this->csrfProtectionStrategy = self::CSRF_ONE_PER_REQUEST;
                    break;
                case 'onePerSession':
                    $this->csrfProtectionStrategy = self::CSRF_ONE_PER_SESSION;
                    break;
                case 'onePerUri':
                    $this->csrfProtectionStrategy = self::CSRF_ONE_PER_URI;
                    break;
                default:
                    throw new Exception('Invalid setting "' . $csrfStrategyName . '" for security.csrf.csrfStrategy', 1291043024);
            }
        }
    }
976421
public function GetOrganizationSettings(\Google\Cloud\SecurityCenter\V1\GetOrganizationSettingsRequest $argument,
      $metadata = [], $options = []) {
        return $this->_simpleRequest('/google.cloud.securitycenter.v1.SecurityCenter/GetOrganizationSettings',
        $argument,
        ['\Google\Cloud\SecurityCenter\V1\OrganizationSettings', 'decode'],
        $metadata, $options);
    }
809444
public function getSPMetadata()
    {
        $metadata = OneLogin_Saml2_Metadata::builder($this->_sp, $this->_security['authnRequestsSigned'], $this->_security['wantAssertionsSigned'], null, null, $this->getContacts(), $this->getOrganization());

        $certNew = $this->getSPcertNew();
        if (!empty($certNew)) {
            $metadata = OneLogin_Saml2_Metadata::addX509KeyDescriptors(
                $metadata,
                $certNew,
                $this->_security['wantNameIdEncrypted'] || $this->_security['wantAssertionsEncrypted']
            );
        }

        $cert = $this->getSPcert();
        if (!empty($cert)) {
            $metadata = OneLogin_Saml2_Metadata::addX509KeyDescriptors(
                $metadata,
                $cert,
                $this->_security['wantNameIdEncrypted'] || $this->_security['wantAssertionsEncrypted']
            );
        }

        //Sign Metadata
        if (isset($this->_security['signMetadata']) && $this->_security['signMetadata'] !== false) {
            if ($this->_security['signMetadata'] === true) {
                $keyMetadata = $this->getSPkey();
                $certMetadata = $cert;

                if (!$keyMetadata) {
                    throw new OneLogin_Saml2_Error(
                        'SP Private key not found.',
                        OneLogin_Saml2_Error::PRIVATE_KEY_FILE_NOT_FOUND
                    );
                }

                if (!$certMetadata) {
                    throw new OneLogin_Saml2_Error(
                        'SP Public cert not found.',
                        OneLogin_Saml2_Error::PUBLIC_CERT_FILE_NOT_FOUND
                    );
                }
            } else {
                if (!isset($this->_security['signMetadata']['keyFileName'])
                    || !isset($this->_security['signMetadata']['certFileName'])
                ) {
                    throw new OneLogin_Saml2_Error(
                        'Invalid Setting: signMetadata value of the sp is not valid',
                        OneLogin_Saml2_Error::SETTINGS_INVALID_SYNTAX
                    );
                }
                $keyFileName = $this->_security['signMetadata']['keyFileName'];
                $certFileName = $this->_security['signMetadata']['certFileName'];

                $keyMetadataFile = $this->_paths['cert'].$keyFileName;
                $certMetadataFile = $this->_paths['cert'].$certFileName;


                if (!file_exists($keyMetadataFile)) {
                    throw new OneLogin_Saml2_Error(
                        'SP Private key file not found: %s',
                        OneLogin_Saml2_Error::PRIVATE_KEY_FILE_NOT_FOUND,
                        array($keyMetadataFile)
                    );
                }

                if (!file_exists($certMetadataFile)) {
                    throw new OneLogin_Saml2_Error(
                        'SP Public cert file not found: %s',
                        OneLogin_Saml2_Error::PUBLIC_CERT_FILE_NOT_FOUND,
                        array($certMetadataFile)
                    );
                }
                $keyMetadata = file_get_contents($keyMetadataFile);
                $certMetadata = file_get_contents($certMetadataFile);
            }

            $signatureAlgorithm = $this->_security['signatureAlgorithm'];
            $digestAlgorithm = $this->_security['digestAlgorithm'];
            $metadata = OneLogin_Saml2_Metadata::signMetadata($metadata, $keyMetadata, $certMetadata, $signatureAlgorithm, $digestAlgorithm);
        }
        return $metadata;
    }