Ejemplo n.º 1
0
        /// <summary>
        /// Returns a response string that we should send to the MonetDB server upon initial connection.
        /// The challenge string is sent from the server in the format (without quotes) "challenge:servertype:protocolversion:"
        ///
        /// For now we only support protocol version 8.
        /// </summary>
        /// <param name="challengeString">initial string sent from server to challenge against</param>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="language"></param>
        /// <param name="database"></param>
        /// <param name="hash">the hash method to use, or null for all supported hashes</param>
        /// <returns></returns>
        private string GetChallengeResponse(
            string challengeString,
            string username, string password,
            string language, string database,
            string hash)
        {
            var tokens = challengeString.Split(':');

            if (tokens.Length <= 4)
            {
                throw new MonetDbException(string.Format(
                                               "Server challenge unusable! Challenge contains too few tokens: {0}",
                                               challengeString));
            }

            int version;

            if (!int.TryParse(tokens[2], out version))
            {
                throw new MonetDbException("Unknown Mapi protocol {0}", tokens[2]);
            }

            // get Mapi protocol instance
            var protocol = MapiProtocolFactory.GetProtocol(version);

            if (protocol == null)
            {
                throw new MonetDbException("Unsupported protocol version {0}", version);
            }

            return(protocol.BuildChallengeResponse(username, password,
                                                   language, tokens,
                                                   database, hash));
        }
Ejemplo n.º 2
0
        public Socket()
        {
            Created = DateTime.Now;

            // register protocols
            MapiProtocolFactory.Register <MapiProtocolVersion8>(8);
            MapiProtocolFactory.Register <MapiProtocolVersion9>(9);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a socket in the given pool
        /// </summary>
        /// <param name="pool"></param>
        public Socket(ConnectionPool pool)
        {
            Created = DateTime.Now;

            this.Pool = pool;

            this.Host     = pool.Host;
            this.Port     = pool.Port;
            this.Username = pool.Username;
            this.Database = pool.Database;

            // register protocols
            MapiProtocolFactory.Register <MapiProtocolVersion8>(8);
            MapiProtocolFactory.Register <MapiProtocolVersion9>(9);
        }