detect if the protocol of current request is secure

@return boolean
779432
static function IsSecureHttp()
	{
		return ( CLib::IsArrayWithKeys( $_SERVER, 'HTTPS' ) &&
			CLib::IsExistingString( $_SERVER[ 'HTTPS' ] ) &&
			(
				0 == strcasecmp( 'ON', $_SERVER[ 'HTTPS' ] ) ||
				0 == strcasecmp( '1', $_SERVER[ 'HTTPS' ] )
			) );
	}
642758
public function authenticate(): bool
    {
        if (isset($_GET['access_token'])) {
            $this->logger->warning('found access_token in query string, you should use a bearer token instead due security reasons https://tools.ietf.org/html/rfc6750#section-2.3', [
                'category' => get_class($this),
            ]);

            return $this->verifyToken($_GET['access_token']);
        }
        if (isset($_SERVER['HTTP_AUTHORIZATION'])) {
            $header = $_SERVER['HTTP_AUTHORIZATION'];
            $parts = explode(' ', $header);

            if ('Bearer' === $parts[0]) {
                $this->logger->debug('found http bearer authorization header', [
                    'category' => get_class($this),
                ]);

                return $this->verifyToken($parts[1]);
            }
            $this->logger->debug('no bearer token provided', [
                    'category' => get_class($this),
                ]);

            return false;
        }

        $this->logger->debug('http authorization header contains no bearer string or invalid authentication string', [
                    'category' => get_class($this),
                ]);

        return false;
    }
45823
public function is_authenticated() {
		$retval = false;
		$parentRes = false;
		
		try {
			if(parent::is_authenticated()) {
				$parentRes = true;
				$retval = $this->is_valid_sid($this->sid);
			}
		}
		catch(Exception $e) {
			$this->exception_handler($e->getMessage());
		}
		
		return ($retval);
	}
806001
protected function isValid()
    {
        if (!$this->request->ajax()) {
            return false;
        }
        $search = $this->request->input('search');
        if (!is_string($search) or strlen($this->request->input('search')) <= 0) {
            return false;
        }
        $token = $this->request->header('search-protection');
        if (!$this->validateToken($token)) {
            return false;
        }
        return true;
    }
845842
public function is_url()
    {
        return ($this->scheme == '' || $this->scheme == 'http' || $this->scheme == 'https' || $this->scheme == 'ftp' || $this->scheme == 'ftps' || $this->scheme == 'file');
    }
1266463
protected function isSecurityException()
    {
        if (!count($this->csrfExceptions))
            return false;
        foreach ($this->csrfExceptions as $route) {
            list($module, $controller, $action) = explode('/', $route);
            if ($module != $this->module) {
                continue;
            }
            if ('*' == $controller)
                return true;

            if ($controller != $this->controller)
                continue;

            if ('*' == $action)
                return true;

            return ($action == $this->action);
        }
        return false;
    }
536372
private boolean isTransportSecure(HttpServletRequest req) {
		String url = req.getRequestURL().toString();
		if (req.getScheme().equals("https")) {
			return true;
		}

		String value = req.getHeader("X-Forwarded-Proto");
		if (value != null && value.toLowerCase().equals("https")) {
			return true;
		}
		return false;
	}
1145778
@Override
    public boolean isSecure() {
        boolean secure = (null != this.connection.getSSLContext());
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "isSecure: " + secure);
        }
        return secure;
    }
684147
public static function isSSLNow()
    {
        $ini = eZINI::instance();
        $sslPort = $ini->variable( 'SiteSettings', 'SSLPort' );
        if ( !$sslPort )
            $sslPort = eZSSLZone::DEFAULT_SSL_PORT;
        // $nowSSl is true if current access mode is HTTPS.
        $nowSSL = ( self::serverPort() == $sslPort );

        if ( !$nowSSL )
        {
            // Check if this request might be driven through a ssl proxy
            if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) )
            {
                $nowSSL = ( $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' );
            }
            else if ( isset( $_SERVER['HTTP_X_FORWARDED_PORT'] ) )
            {
                $sslPort = $ini->variable( 'SiteSettings', 'SSLPort' );
                $nowSSL = ( $_SERVER['HTTP_X_FORWARDED_PORT'] == $sslPort );
            }
            else if ( isset( $_SERVER['HTTP_X_FORWARDED_SERVER'] ) )
            {
                $sslProxyServerName = $ini->variable( 'SiteSettings', 'SSLProxyServerName' );
                $nowSSL = ( $sslProxyServerName == $_SERVER['HTTP_X_FORWARDED_SERVER'] );
            }
        }
        return $nowSSL;
    }
142804
public static function EnableSSL () {
		return static::LasyClassVarConstAccessCallback('enable_ssl', function () {
			return (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') || (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off');
		});
	}
1238525
public static function GetCurrentProtocol () {
		$https_flag = (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') || (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off');
		return $https_flag ? 'https' : 'http';
	}
815359
protected function detectSsl()
    {
        $serverHttps = $this->serverValue('HTTPS');
        $fwdProto    = $this->serverValue('HTTP_X_FORWARDED_PROTO');
        $fwdSsl      = $this->serverValue('HTTP_X_FORWARDED_SSL');

        $this->ssl = false;

        if (!empty($serverHttps) && $serverHttps !== 'off') {
            $this->ssl = true;
        } elseif (!empty($fwdProto) && $fwdProto === 'https') {
            $this->ssl = true;
        } elseif (!empty($fwdSsl) && $fwdSsl === 'on') {
            $this->ssl = true;
        }
    }
151066
protected function checkSecurity()
    {
        if (!$this->levelSecure || $this->levelSecure === self::BOTH) {
            return true;
        }

        $secure = Request::is('secure');

        return ($this->levelSecure === self::SECURE && $secure) ||
               ($this->levelSecure === self::NONSECURE && !$secure);
    }
980887
public function _isSsl() {
        $server = $_SERVER;
        if (isset($server['HTTPS']) && ('1' == $server['HTTPS'] || 'on' == strtolower($server['HTTPS']))) {
            return true;
        }
        elseif (isset($server['REQUEST_SCHEME']) && 'https' == $server['REQUEST_SCHEME']) {
            return true;
        }
        elseif (isset($server['SERVER_PORT']) && ('443' == $server['SERVER_PORT'])) {
            return true;
        }
        elseif (isset($server['HTTP_X_FORWARDED_PROTO']) && 'https' == $server['HTTP_X_FORWARDED_PROTO']) {
            return true;
        }
        return false;
    }
42832
final public function isAuthenticated()
    {

        $self = $this;
        $auth = $self->get("handler", "auth");

        if (is_a($auth, Authenticate::class)) {
            if (isset($auth->authenticated)) {
                return (bool)$auth->authenticated;
            }
        }

        return false;
    }
300666
public function valid() {
        $echoStr = app('request')->get('echostr');
        if (!is_null($echoStr)) {
            if ($this->checkSignature()) {
                exit($echoStr);
            }
            throw new \Exception('no access');
        }
        $encryptStr = '';
        if (app('request')->isPost()) {
            $data = (array)Xml::decode($this->xml, false);
            if ($this->encryptType != 'aes') {
                return $data;
            }
            $encryptStr = $data['Encrypt'];
        }
        if (!$this->checkSignature($encryptStr)) {
            throw new \Exception('no access');
        }
        return true;
    }
723125
public function isValid()
    {
        $hashedBody = strtoupper(hash_hmac('sha512', $this->webhookJson, $this->signature));
        return (isset($this->headers['X-ANET-SIGNATURE']) && strtoupper(explode('=', $this->headers['X-ANET-SIGNATURE'])[1]) === $hashedBody);
    }