private static MyCatAuthenticationPlugin CreatePlugin(string method)
        {
            PluginInfo pi = plugins[method];

            try
            {
                Type t = Type.GetType(pi.Type);
                MyCatAuthenticationPlugin o = (MyCatAuthenticationPlugin)Activator.CreateInstance(t);
                return(o);
            }
            catch (Exception e)
            {
                throw new MyCatException(String.Format(Resources.UnableToCreateAuthPlugin, method), e);
            }
        }
示例#2
0
        private void HandleAuthChange(MyCatPacket 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);

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

            plugin.AuthenticationChange();
        }
示例#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 MyCatAuthenticationPlugin GetPlugin(string method, NativeDriver driver, byte[] authData)
        {
            if (method == "mysql_old_password")
            {
                driver.Close(true);
                throw new MyCatException(Resources.OldPasswordsNotSupported);
            }
            MyCatAuthenticationPlugin plugin = AuthenticationPluginManager.GetPlugin(method);

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

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