Prepares the OAuth signing key

@return void prepared signing key is stored in a class variables
507706
private function prepare_signing_key() {
    $this->signing_key = $this->safe_encode($this->config['consumer_secret']) . '&' . $this->safe_encode($this->config['user_secret']);
  }
386771
protected function registerAuthBindings()
    {
        $this->singleton('auth', function () {
            return $this->loadComponent('auth', 'Illuminate\Auth\AuthServiceProvider', 'auth');
        });

        $this->singleton('auth.driver', function () {
            return $this->loadComponent('auth', 'Illuminate\Auth\AuthServiceProvider', 'auth.driver');
        });

        $this->singleton('Illuminate\Contracts\Auth\Access\Gate', function () {
            return $this->loadComponent('auth', 'Illuminate\Auth\AuthServiceProvider', 'Illuminate\Contracts\Auth\Access\Gate');
        });
    }
890884
public static function init() {

		self::$app = Kecik::getInstance();;

		self::$modelUser    = '\\Model\\' . self::$app->config->get( 'auth.model' );
		self::$postUsername = self::$app->config->get( 'auth.post_username' );
		self::$postPassword = self::$app->config->get( 'auth.post_password' );

		self::$fieldUsername   = self::$app->config->get( 'auth.field_username' );
		self::$fieldPassword   = self::$app->config->get( 'auth.field_password' );
		self::$fieldLevel      = self::$app->config->get( 'auth.field_level' );
		self::$loginRoute      = ( self::$app->config->get( 'auth.login_route' ) != '' ) ? self::$app->config->get( 'auth.login_route' ) : self::$loginRoute;
		self::$logoutRoute     = ( self::$app->config->get( 'auth.logout_route' ) != '' ) ? self::$app->config->get( 'auth.logout_route' ) : self::$logoutRoute;
		self::$loginTemplate   = ( self::$app->config->get( 'auth.login_template' ) != '' ) ? self::$app->config->get( 'auth.login_template' ) : self::$loginTemplate;
		self::$encryptFunction = ( self::$app->config->get( 'auth.encrypt_function' ) != '' ) ? self::$app->config->get( 'auth.encrypt_function' ) : self::$encryptFunction;

		if ( ! empty( self::username() ) ) {
			$model = self::$modelUser;
			$users = $model::find( [
				'where' => [
					[ self::$fieldUsername, '=', self::username() ]
				]
			] );

			if ( count( $users ) > 0 ) {
				self::$info = $users[0];
			}
		}

		AuthInit( self::$app );
	}
603099
public function constructAuthenticate()
    {
        if (empty($this->_config['authenticate'])) {
            return null;
        }
        $this->_authenticateObjects = [];
        $authenticate = Hash::normalize((array)$this->_config['authenticate']);
        $global = [];
        if (isset($authenticate[AuthComponent::ALL])) {
            $global = $authenticate[AuthComponent::ALL];
            unset($authenticate[AuthComponent::ALL]);
        }
        foreach ($authenticate as $alias => $config) {
            if (!empty($config['className'])) {
                $class = $config['className'];
                unset($config['className']);
            } else {
                $class = $alias;
            }
            $className = App::className($class, 'Auth', 'Authenticate');
            if (!class_exists($className)) {
                throw new Exception(sprintf('Authentication adapter "%s" was not found.', $class));
            }
            if (!method_exists($className, 'authenticate')) {
                throw new Exception('Authentication objects must implement an authenticate() method.');
            }
            $config = array_merge($global, (array)$config);
            $this->_authenticateObjects[$alias] = new $className($this->_registry, $config);
            $this->getEventManager()->on($this->_authenticateObjects[$alias]);
        }

        return $this->_authenticateObjects;
    }
510720
public function prepareVars()
    {
        $this->vars['cssClasses'] = implode(' ', $this->cssClasses);
        $this->vars['placeholder'] = Lang::get($this->prompt);
        $this->vars['value'] = $this->getActiveTerm();
        $this->vars['searchOnEnter'] = $this->searchOnEnter;
    }
95606
function _setupKey()
    {
        $key = $this->key;
        $keyLength = strlen($key);
        $keyStream = range(0, 255);
        $j = 0;
        for ($i = 0; $i < 256; $i++) {
            $j = ($j + $keyStream[$i] + ord($key[$i % $keyLength])) & 255;
            $temp = $keyStream[$i];
            $keyStream[$i] = $keyStream[$j];
            $keyStream[$j] = $temp;
        }

        $this->stream = array();
        $this->stream[self::DECRYPT] = $this->stream[self::ENCRYPT] = array(
            0, // index $i
            0, // index $j
            $keyStream
        );
    }
1158162
private static function ensureKeyPair()
    {
        $publicKeyLocation = DIR_DATA . 'xentriq/security/xentriq.security.website.pub';
        $privateKeyLocation = DIR_DATA . 'xentriq/security/xentriq.security.website.priv';
        
        if (!file_exists($publicKeyLocation) || !file_exists($privateKeyLocation)) {
            $privateKey = openssl_pkey_new(array(
                'private_key_bits' => 2048
            ));
            
            File::setContent($privateKeyLocation, '', true);
            if (!openssl_pkey_export_to_file($privateKey, $privateKeyLocation)) {
                throw new SecurityException('Unable to generate security token');
            }
            
            $privateKeyDetails = openssl_pkey_get_details($privateKey);
            File::setContent($publicKeyLocation, $privateKeyDetails['key'], true);
        }
    }
949839
private function prepare()
    {
        if (!$this->storage->has(self::FLASH_KEY)) {
            $this->storage->set(self::FLASH_KEY, array());
        }
    }
152133
public function prepare()
    {
        $id = $this->getAttribute('id');
        $menus = $this->menu['with'] ?? [];
        $parent = $this->getAttribute('position');
        $position = Str::startsWith($parent, '^:') ? $parent.'.' : '^:';

        foreach ((array) $menus as $class) {
            $menu = $this->container->make($class)
                            ->setAttribute('position', "{$position}{$id}")
                            ->prepare();

            if ($menu->passes()) {
                $this->childs[] = $menu;
            }
        }

        $this->name = $id;
        $this->showToUser = $this->passesAuthorization();

        return $this;
    }
39860
protected function prepare()
    {
        $this->register('require', function($context, $path) {
            $context->requireAsset($path);
        });

        $this->register('depend_on', function($context, $path) {
            $context->dependOn($path);
        });

        $this->register('require_tree', function($context, $path) {
            $context->requireTree($path);
        });

        $this->body = $this->getData();

        if (preg_match(static::HEADER_PATTERN, $this->getData(), $matches)) {
            $this->header = $matches[0];
            $this->body = substr($this->getData(), strlen($matches[0])) ?: '';
        }

        $this->processed = array();
    }
611365
public function configureCookie()
    {
        $settingFields = ['expires', 'path', 'domain', 'secure', 'key', 'httpOnly', 'encryption'];
        $settings = $this->config('settings');
        $cookieKey = $this->config('cookieKey');
        foreach ($settingFields as $field) {
            if (isset($settings[$field])) {
                $this->Cookie->configKey($cookieKey, $field, $settings[$field]);
            }
        }
    }
605613
private function _prepareSigningKey()
	{
		return $this->safeEncode($this->getOption('consumer_secret')) . '&' . $this->safeEncode(($this->token) ? $this->token['secret'] : '');
	}
680305
public function formatSPKey()
    {
        if (isset($this->_sp['privateKey'])) {
            $this->_sp['privateKey'] = OneLogin_Saml2_Utils::formatPrivateKey($this->_sp['privateKey']);
        }
    }
472272
public function setupAuthentication() {
		if (!in_array('Auth', $this->components()->loaded())) {
			$this->components()->load('Auth');
		}

		$this->components()->Auth->setConfig('authenticate', [
			'Form' => [
				'userModel' => 'Users',
				'fields' => [
					'username' => 'email',
					'password' => 'password'
				],
				'scope' => [
					'Users.email_verified' => 1
				]
			]
		]);
	}
1019590
public function create_key() {
        $res = openssl_pkey_new($this->config);
        if($res == false) return false;
        openssl_pkey_export($res, $privKey, null, $this->config);
        $public_key = openssl_pkey_get_details($res);

        $this->privKey=$privKey;
        $this->pubKey=$public_key["key"];
        openssl_free_key($res);
        return array('public_key'=>$public_key["key"],'private_key'=>$privKey);
    }
1022884
protected function prepare()
    {
        //Force passice mode if not specified
        $this->addOption('passive', true);

        //To make call on different files, we must retrieve the root and apply commands to the path
        $tmp = clone $this->getUrl();
        $tmp->path('');
        $this->addOption('url', $tmp->toString());
    }
524014
private function configure()
    {
        $keyCert = SignatureUtils::generateKeyCert($this->settings);
        $dir = dirname($this->settings['sp_key_file']);
        if (!is_dir($dir)) {
            throw new \InvalidArgumentException('The directory you selected for sp_key_file does not exist. Please create ' . $dir);
        }
        $dir = dirname($this->settings['sp_cert_file']);
        if (!is_dir($dir)) {
            throw new \InvalidArgumentException('The directory you selected for sp_cert_file does not exist. Please create ' . $dir);
        }
        file_put_contents($this->settings['sp_key_file'], $keyCert['key']);
        file_put_contents($this->settings['sp_cert_file'], $keyCert['cert']);
    }