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");
                }
            }
        }
Beispiel #2
0
        private void SendCredentials(ITransportHeaders requestHeaders)
        {
            string         key = System.Text.Encoding.ASCII.GetString(_provider.Key);
            RijndaelHelper rh  = new RijndaelHelper(key);

            if (_sinkProperties != null)
            {
                requestHeaders[CommonHeaders.CustomerID]      = rh.Encrypt(this["customerid"].ToString());
                requestHeaders[CommonHeaders.ExtensionNumber] = rh.Encrypt(this["extensionnumber"].ToString());
                requestHeaders[CommonHeaders.Password]        = rh.Encrypt(this["password"].ToString());
            }
        }
        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");
            }
        }
        private void SendCredentials(ITransportHeaders requestHeaders)
        {
            string key = System.Text.Encoding.ASCII.GetString(_provider.Key);
            RijndaelHelper rh = new RijndaelHelper(key);

            if (_sinkProperties != null)
            {

                requestHeaders[CommonHeaders.CustomerID] = rh.Encrypt(this["customerid"].ToString());
                requestHeaders[CommonHeaders.ExtensionNumber] = rh.Encrypt(this["extensionnumber"].ToString());
                requestHeaders[CommonHeaders.Password] = rh.Encrypt(this["password"].ToString());
            }
        }
        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");
                }
            }
        }