Flesh out the settings

@param SecuritySettingsInterface $sourceSettings

@throws \Exception

@return OAuth2SecuritySettings
192509
public static function createFromArray(array $data, SecuritySettingsInterface $sourceSettings = null)
    {
        if ($sourceSettings && !$sourceSettings instanceof self) {
            throw new \InvalidArgumentException('Provide an instance of OAuth2SecuritySettings for $sourceSettings');
        }

        $settings = $sourceSettings ? clone $sourceSettings : new static();
        \assert($settings instanceof self);

        if (isset($data['authorizationUri'])) {
            $settings->setAuthorizationUri($data['authorizationUri']);
        }

        if (isset($data['accessTokenUri'])) {
            $settings->setAccessTokenUri($data['accessTokenUri']);
        }

        if (isset($data['authorizationGrants'])) {
            foreach ($data['authorizationGrants'] as $grant) {
                $settings->addAuthorizationGrants($grant);
            }
        }

        if (isset($data['scopes'])) {
            foreach ($data['scopes'] as $scope) {
                $settings->addScope($scope);
            }
        }

        return $settings;
    }
726665
public function validateFieldSettings($fieldSettings)
    {
        $validationErrors = array();

        foreach ($fieldSettings as $name => $value) {
            if (!isset($this->settingsSchema[$name])) {
                $validationErrors[] = new ValidationError(
                    "Setting '%setting%' is unknown",
                    null,
                    array(
                        '%setting%' => $name,
                    ),
                    "[$name]"
                );
                continue;
            }

            switch ($name) {
                case 'isMultiple':
                    if (!is_bool($value)) {
                        $validationErrors[] = new ValidationError(
                            "Setting '%setting%' value must be of boolean type",
                            null,
                            array(
                                '%setting%' => $name,
                            ),
                            "[$name]"
                        );
                    }
                    break;
            }
        }

        return $validationErrors;
    }
149555
public function validateFieldSettings($fieldSettings)
    {
        $validationErrors = array();

        foreach ($fieldSettings as $settingKey => $settingValue) {
            switch ($settingKey) {
                case 'isMultiple':
                    if (!is_bool($settingValue)) {
                        $validationErrors[] = new ValidationError(
                            "FieldType '%fieldType%' expects setting '%setting%' to be of type '%type%'",
                            null,
                            array(
                                '%fieldType%' => $this->getFieldTypeIdentifier(),
                                '%setting%' => $settingKey,
                                '%type%' => 'bool',
                            ),
                            "[$settingKey]"
                        );
                    }
                    break;
                case 'options':
                    if (!is_array($settingValue)) {
                        $validationErrors[] = new ValidationError(
                            "FieldType '%fieldType%' expects setting '%setting%' to be of type '%type%'",
                            null,
                            array(
                                '%fieldType%' => $this->getFieldTypeIdentifier(),
                                '%setting%' => $settingKey,
                                '%type%' => 'hash',
                            ),
                            "[$settingKey]"
                        );
                    }
                    break;
                case 'multilingualOptions':
                    if (!is_array($settingValue) && !is_array(reset($settingValue))) {
                        $validationErrors[] = new ValidationError(
                            "FieldType '%fieldType%' expects setting '%setting%' to be of type '%type%'",
                            null,
                            array(
                                '%fieldType%' => $this->getFieldTypeIdentifier(),
                                '%setting%' => $settingKey,
                                '%type%' => 'hash',
                            ),
                            "[$settingKey]"
                        );
                    }
                    break;
                default:
                    $validationErrors[] = new ValidationError(
                        "Setting '%setting%' is unknown",
                        null,
                        array(
                            '%setting%' => $settingKey,
                        ),
                        "[$settingKey]"
                    );
            }
        }

        return $validationErrors;
    }
763192
public static function createFromArray(array $data, SecuritySettingsInterface $sourceSettings = null)
    {
        if ($sourceSettings && !$sourceSettings instanceof self) {
            throw new \InvalidArgumentException('Provide an instance of DefaultSecuritySettings for $sourceSettings');
        }

        $settings = $sourceSettings ? clone $sourceSettings : new static();
        \assert($settings instanceof self);
        $settings->mergeSettings($data);

        return $settings;
    }
808369
public function setupSigner(ServerIssuedCredentials $serverIssuedCredentials = null)
    {
        if ($this->shouldSignWithClientCredentials()) {
            $this->signer->setClientCredentials($this->config->getClientCredentials());
        }

        if ($this->shouldSignWithServerIssuedCredentials($serverIssuedCredentials)) {
            $this->signer->setServerIssuedCredentials($serverIssuedCredentials);
        }

        return $this->signer;
    }
984161
public function connectOauth2($options)
    {
        $token = false;

        // source oauth provider
        $oauthProvider = $this->getProvider();

        // error
        if(\Craft\craft()->request->getParam('error'))
        {
            throw new \Exception("An error occured: ".\Craft\craft()->request->getParam('error'));
        }

        $state = \Craft\craft()->request->getParam('state');
        $code = \Craft\craft()->request->getParam('code');
        $oauth2state = \Craft\craft()->httpSession->get('oauth2state');

        if (is_null($code))
        {
            $authorizationOptions = $options['authorizationOptions'];

            if(count($options['scope']) > 0)
            {
                $authorizationOptions['scope'] = $options['scope'];
            }

            $authorizationUrl = $oauthProvider->getAuthorizationUrl($authorizationOptions);

            $state = $oauthProvider->getState();

            \Craft\craft()->httpSession->add('oauth2state', $state);

            OauthPlugin::log('OAuth 2.0 Connect - Redirect to the authorization URL'."\r\n".
	            "authorizationUrl: ".$authorizationUrl."\r\n".
	            "oauth2state: ".\Craft\craft()->httpSession->get('oauth2state')
	        , LogLevel::Info);

            \Craft\craft()->request->redirect($authorizationUrl);
        }
        elseif (!$state || $state !== $oauth2state)
        {
            OauthPlugin::log('OAuth 2.0 Connect - Invalid State'."\r\n".print_r([
                'state' => $state,
                'oauth2state' => $oauth2state,
            ], true), LogLevel::Info);

            \Craft\craft()->httpSession->remove('oauth2state');

            throw new \Exception("Invalid state");

        }
        else
        {
            OauthPlugin::log('OAuth 2.0 Connect - Authorization code retrieved: '.$code, LogLevel::Info);

            $token = $oauthProvider->getAccessToken('authorization_code', [
                'code' => $code
            ]);

            OauthPlugin::log("OAuth 2.0 Connect - Get Access Token\r\n".
	            "Access token: \r\n".
	            print_r($token, true)
	        , LogLevel::Info);
        }

        return $token;
    }
630949
public function injectSettings(array $settings)
    {
        if (isset($settings['security']['cryptography']['RSAWalletServicePHP']['openSSLConfiguration'])
            && is_array($settings['security']['cryptography']['RSAWalletServicePHP']['openSSLConfiguration'])) {
            $this->openSSLConfiguration = $settings['security']['cryptography']['RSAWalletServicePHP']['openSSLConfiguration'];
        }

        if (isset($settings['security']['cryptography']['RSAWalletServicePHP']['keystorePath'])) {
            $this->keystorePathAndFilename = $settings['security']['cryptography']['RSAWalletServicePHP']['keystorePath'];
        } else {
            throw new MissingConfigurationException('The configuration setting Neos.Flow.security.cryptography.RSAWalletServicePHP.keystorePath is missing. Please specify it in your Settings.yaml file. Beware: This file must not be accessible by the public!', 1305711354);
        }

        if (isset($settings['security']['cryptography']['RSAWalletServicePHP']['paddingAlgorithm']) && is_int($settings['security']['cryptography']['RSAWalletServicePHP']['paddingAlgorithm'])) {
            $this->paddingAlgorithm = $settings['security']['cryptography']['RSAWalletServicePHP']['paddingAlgorithm'];
        } else {
            throw new SecurityException('The padding algorithm given in security.cryptography.RSAWalletServicePHP.paddingAlgorithm is not available.', 1556785429);
        }
    }
1181942
private function composeAuthorization(
        SettingsProviderInterface $settingsProvider,
        FileSystemInterface $fileSystem,
        string $singular,
        string $plural
    ): TemplateOutput {
        $folder = $settingsProvider
                      ->get(AuthorizationSettingsInterface::class)[AuthorizationSettingsInterface::KEY_POLICIES_FOLDER];

        $outputRootFolder = $this->filterOutFolderMask($folder);
        $outputFileName   = $singular . 'Rules.php';
        $outputContent    = $this->composeTemplateContent(
            $fileSystem,
            $this->getTemplatePath('ApiAuthorization.txt'),
            [
                '{%SINGULAR_CC%}' => $singular,
                '{%PLURAL_CC%}'   => $plural,
                '{%SINGULAR_LC%}' => strtolower($singular),
                '{%PLURAL_UC%}'   => strtoupper($plural),
                '{%SINGULAR_UC%}' => strtoupper($singular),
            ]
        );

        return new TemplateOutput($outputRootFolder, $outputFileName, $outputContent);
    }
355796
public function setSettings(array $settings = []) : self
    {
        $this->settings = array_merge($this->settings, $settings);
        // loop through checking each setting
        foreach ($this->allowedSettings as $name => $allowed) {
            $this->validateSettings->__invoke($name, $this->settings[$name], $allowed);
        }

        return $this;
    }
976693
public static function settingsSend($settings, $settings_url, &$debug_log=false) {

        $key_key = self::ltiParameter('key_key');
        $secret = self::decrypt_secret(self::ltiParameter('secret'));

        $retval = LTI::sendJSONSettings($settings, $settings_url, $key_key, $secret, $debug_log);
        return $retval;
    }
413435
public function setSources(array $sources)
    {
        $parameters = $this
            ->configuration
            ->getParameters();
        $parameters['sources'] = $sources;

        $this
            ->configuration
            ->setParameters($parameters);
    }
1095099
public function mergeSettings($newSettings)
    {
        if (\is_object($this->getSettings())) {
            $settingsClass = \get_class($this->getSettings());
            $settings = $settingsClass::createFromArray($newSettings, $this->getSettings());
        } else {
            $settings = \array_replace($this->getSettings(), $newSettings);
        }

        $this->setSettings($settings);
    }
167473
protected function validateConfig(LinkedInAuthSettings $settings) {
    $client_id = $settings->getClientId();
    $client_secret = $settings->getClientSecret();

    if (!$client_id || !$client_secret) {
      $this->loggerFactory
        ->get('social_auth_linkedin')
        ->error('Define Client ID and Client Secret on module settings.');

      return FALSE;
    }

    return TRUE;
  }
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;
    }
66668
public function setSettings(array $settings)
    {
        $this->settings = array_merge($this->settings, $settings);
        
        if (isset($settings['templates_path'])) {
            $this->view->templatesPath = $this->settings['templates_path'];
        }
        
        return $this;
    }
693748
protected function setOptions($options = null)
    {
        if ($options instanceof TokenInterface) {
            $this->_owner = UserSecurityIdentity::fromToken($options);
        }

        return $this;
    }
510606
public function setConfig(SourceConfig $sourceConfig)
    {
        // FILTERS
        // 1. Setting message status filter
        $filters = $sourceConfig->getFilter();
        if (isset($filters[self::MESSAGES_STATUS_FILTER])) {
            $messageStatus = $filters[self::MESSAGES_STATUS_FILTER];
            if ($messageStatus === self::UNREAD_ONLY_MESSAGES_FILTER) {
                $this->unreadOnly = true;
            }
        }
        // 2. Setting folder filter
        if (isset($filters[self::FOLDER_FILTER])) {
            $this->folder = $filters[self::FOLDER_FILTER];
        }

        // Calling parent method to set the rest of the required configuration
        parent::setConfig($sourceConfig);
    }