Пример #1
0
        private static MySqlAuthenticationPlugin CreatePlugin(string method)
        {
            PluginInfo pi = plugins[method];

            try
            {
                Type t = Type.GetType(pi.Type);
                MySqlAuthenticationPlugin o = (MySqlAuthenticationPlugin)Activator.CreateInstance(t);
                return(o);
            }
            catch (Exception e)
            {
                throw new MySqlException(String.Format(MySqlResources.UnableToCreateAuthPlugin, method), e);
            }
        }
Пример #2
0
        private void HandleAuthChange(MySqlPacket packet)
        {
            byte b = packet.ReadByte();

            Debug.Assert(b == 0xfe);

            string method = packet.ReadString();

            byte[] authData = new byte[packet.Length - packet.Position];
            Array.Copy(packet.Buffer, packet.Position, authData, 0, authData.Length);

            MySqlAuthenticationPlugin plugin = MySqlAuthenticationPlugin.GetPlugin(method, driver, authData);

            plugin.ContinueAuthentication();
        }
Пример #3
0
        /// <summary>
        /// This is a factory method that is used only internally.  It creates an auth plugin based on the method type
        /// </summary>
        /// <param name="method"></param>
        /// <param name="flags"></param>
        /// <param name="settings"></param>
        /// <returns></returns>
        internal static MySqlAuthenticationPlugin GetPlugin(string method, NativeDriver driver, byte[] authData)
        {
            if (method == "mysql_old_password")
            {
                driver.Close(true);
                throw new MySqlException(MySqlResources.OldPasswordsNotSupported);
            }
            MySqlAuthenticationPlugin plugin = AuthenticationPluginManager.GetPlugin(method);

            if (plugin == null)
            {
                throw new MySqlException(String.Format(MySqlResources.UnknownAuthenticationMethod, method));
            }

            plugin.driver = driver;
            plugin.SetAuthData(authData);
            return(plugin);
        }