private void HandleAuthChange(MySqlPacket packet)
        {
            packet.ReadByte();
            string arg_3D_0 = packet.ReadString();

            byte[] array = new byte[packet.Length - packet.Position];
            Array.Copy(packet.Buffer, packet.Position, array, 0, array.Length);
            MySqlAuthenticationPlugin.GetPlugin(arg_3D_0, this.driver, array).AuthenticationChange();
        }
        /// <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)
        {
            MySqlAuthenticationPlugin plugin = AuthenticationPluginManager.GetPlugin(method);

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

            plugin.driver   = driver;
            plugin.AuthData = authData;
            return(plugin);
        }
        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(Resources.UnableToCreateAuthPlugin, method), e);
            }
        }
예제 #4
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.AuthenticationChange();
        }
예제 #5
0
        private static MySqlAuthenticationPlugin CreatePlugin(string method)
        {
            PluginInfo pluginInfo = AuthenticationPluginManager.plugins[method];
            MySqlAuthenticationPlugin result;

            try
            {
                Type type = Type.GetType(pluginInfo.Type);
                MySqlAuthenticationPlugin mySqlAuthenticationPlugin = (MySqlAuthenticationPlugin)Activator.CreateInstance(type);
                result = mySqlAuthenticationPlugin;
            }
            catch (Exception ex)
            {
                throw new MySqlException(string.Format(Resources.UnableToCreateAuthPlugin, method), ex);
            }
            return(result);
        }
        internal static MySqlAuthenticationPlugin GetPlugin(string method, NativeDriver driver, byte[] authData)
        {
            if (method == "mysql_old_password")
            {
                driver.Close(true);
                throw new MySqlException(Resources.OldPasswordsNotSupported);
            }
            MySqlAuthenticationPlugin plugin = AuthenticationPluginManager.GetPlugin(method);

            if (plugin == null)
            {
                throw new MySqlException(string.Format(Resources.UnknownAuthenticationMethod, method));
            }
            plugin.driver = driver;
            plugin.SetAuthData(authData);
            return(plugin);
        }
    public void Authenticate(string authMethod, bool reset)
    {
      if (authMethod != null)
      {
        byte[] seedBytes = Encoding.GetBytes(encryptionSeed);

        // Integrated security is a shortcut for windows auth
        if (Settings.IntegratedSecurity)
          authMethod = "authentication_windows_client";

        authPlugin = MySqlAuthenticationPlugin.GetPlugin(authMethod, this, seedBytes);
      }
      authPlugin.Authenticate(reset);
    }