public void Authenticate(ClientConnectionInfo cci, string encryptedCustomerID, string encryptedExtensionNumber, string encryptedPassword)
        {
            string userKey = encryptedCustomerID + " " + encryptedExtensionNumber + " " + encryptedPassword;

            if (IsAuthenticated(userKey) == false)
            {
                RijndaelHelper h = new RijndaelHelper(System.Text.Encoding.ASCII.GetString(cci.Provider.Key));

                int    customerID      = Convert.ToInt32(h.Decrypt(encryptedCustomerID));
                int    extensionNumber = Convert.ToInt32(h.Decrypt(encryptedExtensionNumber));
                string password        = h.Decrypt(encryptedPassword);

                if (OnAuthentication != null)
                {
                    AuthenticationEventArgs args = new AuthenticationEventArgs(customerID, extensionNumber, password);
                    OnAuthentication(this, args);

                    if (args.IsAuthenticated == false)
                    {
                        throw new Exception("Failed to authenticate");
                    }
                    else
                    {
                        lock (AuthUsers.SyncRoot)
                        {
                            AuthUsers.Add(userKey, DateTime.Now);
                        }
                    }
                }
                else
                {
                    throw new Exception("Failed to authenticate");
                }
            }
        }
        public void CheckForManagementAllowed(ClientConnectionInfo cci, string clientIpAddress, string extension)
        {
            RijndaelHelper h = new RijndaelHelper(System.Text.Encoding.ASCII.GetString(cci.Provider.Key));

            string extensionNumber = h.Decrypt(extension);

            if (OnManagementAllowed != null)
            {
                ManagementAllowedEventArgs args = new ManagementAllowedEventArgs(clientIpAddress, extensionNumber);

                OnManagementAllowed(this, args);

                if (args.ManagementAllowed == false)
                {
                    throw new Exception("Remote Management not allowed for : " + clientIpAddress);
                }
            }
            else
            {
                throw new Exception("Remote Management not allowed");
            }
        }
        public void CheckForManagementAllowed(ClientConnectionInfo cci, string clientIpAddress, string extension)
        {
            RijndaelHelper h = new RijndaelHelper(System.Text.Encoding.ASCII.GetString(cci.Provider.Key));

            string extensionNumber = h.Decrypt(extension);
            if (OnManagementAllowed != null)
            {
                ManagementAllowedEventArgs args = new ManagementAllowedEventArgs( clientIpAddress, extensionNumber );

                OnManagementAllowed(this, args);

                if (args.ManagementAllowed == false)
                {
                    throw new Exception("Remote Management not allowed for : " + clientIpAddress);
                }
            }
            else
            {
                throw new Exception("Remote Management not allowed");
            }
        }
        public void Authenticate(ClientConnectionInfo cci, string encryptedCustomerID, string encryptedExtensionNumber, string encryptedPassword)
        {
            string userKey = encryptedCustomerID + " " + encryptedExtensionNumber + " " + encryptedPassword;

            if (IsAuthenticated(userKey) == false)
            {
                RijndaelHelper h = new RijndaelHelper(System.Text.Encoding.ASCII.GetString(cci.Provider.Key));

                int customerID = Convert.ToInt32(h.Decrypt(encryptedCustomerID));
                int extensionNumber = Convert.ToInt32(h.Decrypt(encryptedExtensionNumber));
                string password = h.Decrypt(encryptedPassword);

                if (OnAuthentication != null)
                {
                    AuthenticationEventArgs args = new AuthenticationEventArgs(customerID, extensionNumber, password);
                    OnAuthentication(this, args);

                    if (args.IsAuthenticated == false)
                    {
                        throw new Exception("Failed to authenticate");
                    }
                    else
                    {
                        lock (AuthUsers.SyncRoot)
                        {
                            AuthUsers.Add(userKey, DateTime.Now);
                        }
                    }
                }
                else
                {
                    throw new Exception("Failed to authenticate");
                }
            }
        }