private function detectAuthMethod()
    {
        $data = $this->executeCommand('PROTOCOLINFO');

        foreach ($data as $info) {
            if ('AUTH METHODS=NULL' === $info['message']) {
                $this->options['authmethod'] = static::AUTH_METHOD_NULL;

                return;
            }

            if ('AUTH METHODS=HASHEDPASSWORD' === $info['message']) {
                $this->options['authmethod'] = static::AUTH_METHOD_HASHEDPASSWORD;

                return;
            }

            if (preg_match('/^AUTH METHODS=(.*) COOKIEFILE="(.*)"/', $info['message'], $matches) === 1) {
                $this->options['authmethod'] = static::AUTH_METHOD_COOKIE;
                $this->options['cookiefile'] = $matches[2];

                return;
            }
        }

        throw new Exception\ProtocolError('Auth method not supported');
    }