public function getHost()
    {
        $host = '';

        if (isset($_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME'] !== '0.0.0.0') {
            $host = $_SERVER['SERVER_NAME'];
            if (!$this->_validateHost($host)) {
                $host = '';
            }

            // Add the port
            if ($host && isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT']) {
                $port = $_SERVER['SERVER_PORT'];
                if (ctype_digit($port)) {
                    $host .= ':' . $port;
                }
            }
        }

        if (!$host && isset($_SERVER['HTTP_HOST'])) {
            $host = $_SERVER['HTTP_HOST'];
            if (!$this->_validateHost($host)) {
                $host = '';
            }
        }
        if (!$host) {
            throw new SecurityException('Host could not be detected', 1394796366);
        }

        return $host;
    }