Ejemplo n.º 1
0
        protected void BankDD_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (rblMandateModes.SelectedValue == "E_MANDATE")
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("AuthModeText", typeof(string));
                dt.Columns.Add("AuthModeVal", typeof(string));
                JArray MandateAuthModes = (JArray)Session["MandateAuthModes"];

                JArray SelectedAuthModes = (JArray)MandateAuthModes.Where(a => a["BankCode"].ToString() == BankDD.SelectedValue).Select(b => b["AuthModes"]).First();
                foreach (var AuthMode in SelectedAuthModes)
                {
                    dt.Rows.Add(new object[] { AuthMode.ToString().Replace("_", " "), AuthMode });
                }

                rblAuthType.DataSource = dt;
                rblAuthType.DataBind();
                pnlAuthMode.Visible = true;
            }
            else
            {
                rblAuthType.DataSource = null;
                rblAuthType.DataBind();
                pnlAuthMode.Visible = false;
            }

            EnableAccountDetails();
        }
Ejemplo n.º 2
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     writer.WritePropertyName("authMode");
     writer.WriteStringValue(AuthMode.ToString());
     if (Optional.IsDefined(Description))
     {
         if (Description != null)
         {
             writer.WritePropertyName("description");
             writer.WriteStringValue(Description);
         }
         else
         {
             writer.WriteNull("description");
         }
     }
     if (Optional.IsDefined(Keys))
     {
         if (Keys != null)
         {
             writer.WritePropertyName("keys");
             writer.WriteObjectValue(Keys);
         }
         else
         {
             writer.WriteNull("keys");
         }
     }
     if (Optional.IsCollectionDefined(Properties))
     {
         if (Properties != null)
         {
             writer.WritePropertyName("properties");
             writer.WriteStartObject();
             foreach (var item in Properties)
             {
                 writer.WritePropertyName(item.Key);
                 writer.WriteStringValue(item.Value);
             }
             writer.WriteEndObject();
         }
         else
         {
             writer.WriteNull("properties");
         }
     }
     writer.WriteEndObject();
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Joins a wireless network
 /// </summary>
 /// <param name="SSID">The name of the wireless network</param>
 /// <param name="Channel">The channel the AP is listening on (0 for autodetect)</param>
 /// <param name="Authentication">The method for authentication</param>
 /// <param name="Key">The shared key required to join the network (WEP / WPA)</param>
 /// <param name="KeyIndex">The index of the key (WEP only)</param>
 public void JoinNetwork(string SSID, int Channel = 0, AuthMode Authentication = AuthMode.Open, string Key = "", int KeyIndex = 1)
 {
     // Enterring command mode
     this._CommandMode_Start();
     // Configures the network
     if (!this._CommandMode_Exec("set wlan ssid " + SSID))
     {
         throw new SystemException(this._CommandMode_Response);
     }
     if (!this._CommandMode_Exec("set wlan channel " + Channel))
     {
         throw new SystemException(this._CommandMode_Response);
     }
     if (!this._CommandMode_Exec("set wlan auth " + Authentication.ToString()))
     {
         throw new SystemException(this._CommandMode_Response);
     }
     if (Authentication == AuthMode.WEP_128)
     {
         if (!this._CommandMode_Exec("set wlan key " + Key))
         {
             throw new SystemException(this._CommandMode_Response);
         }
         if (!this._CommandMode_Exec("set wlan num " + KeyIndex.ToString()))
         {
             throw new SystemException(this._CommandMode_Response);
         }
     }
     else if (Authentication != AuthMode.Open)
     {
         if (!this._CommandMode_Exec("set wlan phrase " + Key))
         {
             throw new SystemException(this._CommandMode_Response);
         }
     }
     // Actually joins the network
     this._SerialPort_Write("join\r");
     // Closes down command mode
     this._CommandMode_Stop();
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Joins a wireless network
        /// </summary>
        /// <param name="SSID">The name of the wireless network</param>
        /// <param name="Channel">The channel the AP is listening on (0 for autodetect)</param>
        /// <param name="Authentication">The method for authentication</param>
        /// <param name="Key">The shared key required to join the network (WEP / WPA)</param>
        /// <param name="KeyIndex">The index of the key (WEP only)</param>
        public bool JoinNetwork(string SSID, int Channel = 0, AuthMode Authentication = AuthMode.Open, string Key = "", int KeyIndex = 1)
        {
            // Enterring command mode
            this._CommandMode_Start();
            // Configures the network
            if (!this._CommandMode_Exec("set wlan ssid " + SSID)) throw new SystemException(this._CommandMode_Response);
            if (!this._CommandMode_Exec("set wlan channel " + Channel)) throw new SystemException(this._CommandMode_Response);
            if (!this._CommandMode_Exec("set wlan auth " + Authentication.ToString())) throw new SystemException(this._CommandMode_Response);
            if (Authentication == AuthMode.WEP_128)
            {
                if (!this._CommandMode_Exec("set wlan key " + Key)) throw new SystemException(this._CommandMode_Response);
                if (!this._CommandMode_Exec("set wlan num " + KeyIndex.ToString())) throw new SystemException(this._CommandMode_Response);
            }
            else if (Authentication != AuthMode.Open)
            {
                if (!this._CommandMode_Exec("set wlan phrase " + Key)) throw new SystemException(this._CommandMode_Response);
            }

            // Auto-Assoc Rightpoint chan=6 mode=MIXED SCAN OK\r\n
            // Auto-Assoc Rightpoint!! chan=6 mode=NONE FAILED\r\n
            var joinComplete = false;
            var joinSuccessful = false;
            var joinHandler = new Tools.StringEventHandler((text, time) =>
            {
                if (text.IndexOf("AUTH-ERR") >= 0)
                {
                    joinComplete = true;
                    joinSuccessful = false;
                    _DebugPrint('D', "Authentication error");
                }

                if (text.IndexOf("Auto-Assoc") >= 0 && text.IndexOf("NONE FAILED") >= 0)
                {
                    joinComplete = true;
                    joinSuccessful = false;
                    _DebugPrint('D', "Couldn't find network");
                }

                if (text.IndexOf("Associated!") >= 0)
                {
                    joinComplete = true;
                    joinSuccessful = true;
                }
            });

            // Actually joins the network
            this._lineRecieved += joinHandler;
            this._SerialPort_Write("join\r");

            for(var i =0; i< 40 && !joinComplete; i++)
            {
                Thread.Sleep(250);
            }

            this._lineRecieved -= joinHandler;

            // Closes down command mode
            this._CommandMode_Stop();

            return joinSuccessful;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Joins a wireless network
        /// </summary>
        /// <param name="SSID">The name of the wireless network</param>
        /// <param name="Channel">The channel the AP is listening on (0 for autodetect)</param>
        /// <param name="Authentication">The method for authentication</param>
        /// <param name="Key">The shared key required to join the network (WEP / WPA)</param>
        /// <param name="KeyIndex">The index of the key (WEP only)</param>
        public bool JoinNetwork(string SSID, int Channel = 0, AuthMode Authentication = AuthMode.Open, string Key = "", int KeyIndex = 1)
        {
            // Enterring command mode
            this._CommandMode_Start();
            // Configures the network
            if (!this._CommandMode_Exec("set wlan ssid " + SSID))
            {
                throw new SystemException(this._CommandMode_Response);
            }
            if (!this._CommandMode_Exec("set wlan channel " + Channel))
            {
                throw new SystemException(this._CommandMode_Response);
            }
            if (!this._CommandMode_Exec("set wlan auth " + Authentication.ToString()))
            {
                throw new SystemException(this._CommandMode_Response);
            }
            if (Authentication == AuthMode.WEP_128)
            {
                if (!this._CommandMode_Exec("set wlan key " + Key))
                {
                    throw new SystemException(this._CommandMode_Response);
                }
                if (!this._CommandMode_Exec("set wlan num " + KeyIndex.ToString()))
                {
                    throw new SystemException(this._CommandMode_Response);
                }
            }
            else if (Authentication != AuthMode.Open)
            {
                if (!this._CommandMode_Exec("set wlan phrase " + Key))
                {
                    throw new SystemException(this._CommandMode_Response);
                }
            }

            // Auto-Assoc Rightpoint chan=6 mode=MIXED SCAN OK\r\n
            // Auto-Assoc Rightpoint!! chan=6 mode=NONE FAILED\r\n
            var joinComplete   = false;
            var joinSuccessful = false;
            var joinHandler    = new Tools.StringEventHandler((text, time) =>
            {
                if (text.IndexOf("AUTH-ERR") >= 0)
                {
                    joinComplete   = true;
                    joinSuccessful = false;
                    _DebugPrint('D', "Authentication error");
                }

                if (text.IndexOf("Auto-Assoc") >= 0 && text.IndexOf("NONE FAILED") >= 0)
                {
                    joinComplete   = true;
                    joinSuccessful = false;
                    _DebugPrint('D', "Couldn't find network");
                }

                if (text.IndexOf("Associated!") >= 0)
                {
                    joinComplete   = true;
                    joinSuccessful = true;
                }
            });

            // Actually joins the network
            this._lineRecieved += joinHandler;
            this._SerialPort_Write("join\r");

            for (var i = 0; i < 40 && !joinComplete; i++)
            {
                Thread.Sleep(250);
            }

            this._lineRecieved -= joinHandler;

            // Closes down command mode
            this._CommandMode_Stop();

            return(joinSuccessful);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Checks this configuration is valid
        /// </summary>
        /// <param name="throwOnValidationError">Whether to throw an exception on a validation error rather than return false</param>
        /// <returns><c>bool</c> Is the configuration valid</returns>
        public bool IsValid(bool throwOnValidationError = false)
        {
            bool isValid = true;

            if (string.IsNullOrWhiteSpace(ServerHostname))
            {
                if (throwOnValidationError)
                {
                    throw new Exception($"The parameter '{nameof(ServerHostname)}' is invalid");
                }
                isValid = false;
            }

            if (ServerPort > 65535 || ServerPort < 1)
            {
                if (throwOnValidationError)
                {
                    throw new Exception($"The parameter '{nameof(ServerPort)}' is out of range 1-65535");
                }
                isValid = false;
            }

            if (string.IsNullOrWhiteSpace(Nick))
            {
                if (throwOnValidationError)
                {
                    throw new Exception($"The parameter '{nameof(Nick)}' is invalid");
                }
                isValid = false;
            }

            foreach (string nick in AlternativeNicks)
            {
                if (string.IsNullOrWhiteSpace(nick))
                {
                    if (throwOnValidationError)
                    {
                        throw new Exception($"One of the values in the parameter '{nameof(AlternativeNicks)}' is invalid");
                    }
                    isValid = false;
                }
            }

            foreach (string channel in AutoJoinChannels)
            {
                if (string.IsNullOrWhiteSpace(channel) || !IrcChannel.IsValidName(channel))
                {
                    if (throwOnValidationError)
                    {
                        throw new Exception($"One of the values in the parameter '{nameof(AutoJoinChannels)}' is invalid");
                    }
                    isValid = false;
                }
            }

            if (string.IsNullOrWhiteSpace(UserName))
            {
                if (throwOnValidationError)
                {
                    throw new Exception($"The parameter '{nameof(UserName)}' is invalid");
                }
                isValid = false;
            }

            if (string.IsNullOrWhiteSpace(RealName))
            {
                if (throwOnValidationError)
                {
                    throw new Exception($"The parameter '{nameof(RealName)}' is invalid");
                }
                isValid = false;
            }

            if (AuthMode != AuthMode.None && string.IsNullOrWhiteSpace(AuthUsername))
            {
                if (throwOnValidationError)
                {
                    throw new Exception($"The parameter '{nameof(AuthUsername)}' is invalid for AuthMode {AuthMode.ToString()}");
                }
                isValid = false;
            }

            if (AuthMode != AuthMode.None && string.IsNullOrWhiteSpace(AuthPassword))
            {
                if (throwOnValidationError)
                {
                    throw new Exception($"The parameter '{nameof(AuthPassword)}' is invalid for AuthMode {AuthMode.ToString()}");
                }
                isValid = false;
            }

            if (ReconnectAttempts < 0)
            {
                if (throwOnValidationError)
                {
                    throw new Exception($"The parameter '{nameof(ReconnectAttempts)}' is less than 0");
                }
                isValid = false;
            }

            foreach (string capability in DesiredCapabilities)
            {
                if (string.IsNullOrWhiteSpace(capability))
                {
                    if (throwOnValidationError)
                    {
                        throw new Exception($"One of the values in the parameter '{nameof(DesiredCapabilities)}' is invalid");
                    }
                    isValid = false;
                }

                if (capability.ToIrcLower() == "sasl")
                {
                    if (throwOnValidationError)
                    {
                        throw new Exception($"Do not provide SASL as a value in the parameter '{nameof(DesiredCapabilities)}'");
                    }
                    isValid = false;
                }
            }

            return(isValid);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Joins a wireless network
 /// </summary>
 /// <param name="SSID">The name of the wireless network</param>
 /// <param name="Channel">The channel the AP is listening on (0 for autodetect)</param>
 /// <param name="Authentication">The method for authentication</param>
 /// <param name="Key">The shared key required to join the network (WEP / WPA)</param>
 /// <param name="KeyIndex">The index of the key (WEP only)</param>
 public void JoinNetwork(string SSID, int Channel = 0, AuthMode Authentication = AuthMode.Open, string Key = "", int KeyIndex = 1)
 {
     // Enterring command mode
     this._CommandMode_Start();
     // Configures the network
     if (!this._CommandMode_Exec("set wlan ssid " + SSID)) throw new SystemException(this._CommandMode_Response);
     if (!this._CommandMode_Exec("set wlan channel " + Channel)) throw new SystemException(this._CommandMode_Response);
     if (!this._CommandMode_Exec("set wlan auth " + Authentication.ToString())) throw new SystemException(this._CommandMode_Response);
     if (Authentication == AuthMode.WEP_128)
     {
         if (!this._CommandMode_Exec("set wlan key " + Key)) throw new SystemException(this._CommandMode_Response);
         if (!this._CommandMode_Exec("set wlan num " + KeyIndex.ToString())) throw new SystemException(this._CommandMode_Response);
     }
     else if (Authentication != AuthMode.Open)
     {
         if (!this._CommandMode_Exec("set wlan phrase " + Key)) throw new SystemException(this._CommandMode_Response);
     }
     // Actually joins the network
     this._SerialPort_Write("join\r");
     // Closes down command mode
     this._CommandMode_Stop();
 }
Ejemplo n.º 8
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     if (Optional.IsDefined(Compute))
     {
         if (Compute != null)
         {
             writer.WritePropertyName("compute");
             writer.WriteStringValue(Compute);
         }
         else
         {
             writer.WriteNull("compute");
         }
     }
     if (Optional.IsCollectionDefined(MirrorTraffic))
     {
         if (MirrorTraffic != null)
         {
             writer.WritePropertyName("mirrorTraffic");
             writer.WriteStartObject();
             foreach (var item in MirrorTraffic)
             {
                 writer.WritePropertyName(item.Key);
                 writer.WriteNumberValue(item.Value);
             }
             writer.WriteEndObject();
         }
         else
         {
             writer.WriteNull("mirrorTraffic");
         }
     }
     if (Optional.IsDefined(PublicNetworkAccess))
     {
         writer.WritePropertyName("publicNetworkAccess");
         writer.WriteStringValue(PublicNetworkAccess.Value.ToString());
     }
     if (Optional.IsCollectionDefined(Traffic))
     {
         if (Traffic != null)
         {
             writer.WritePropertyName("traffic");
             writer.WriteStartObject();
             foreach (var item in Traffic)
             {
                 writer.WritePropertyName(item.Key);
                 writer.WriteNumberValue(item.Value);
             }
             writer.WriteEndObject();
         }
         else
         {
             writer.WriteNull("traffic");
         }
     }
     writer.WritePropertyName("authMode");
     writer.WriteStringValue(AuthMode.ToString());
     if (Optional.IsDefined(Description))
     {
         if (Description != null)
         {
             writer.WritePropertyName("description");
             writer.WriteStringValue(Description);
         }
         else
         {
             writer.WriteNull("description");
         }
     }
     if (Optional.IsDefined(Keys))
     {
         if (Keys != null)
         {
             writer.WritePropertyName("keys");
             writer.WriteObjectValue(Keys);
         }
         else
         {
             writer.WriteNull("keys");
         }
     }
     if (Optional.IsCollectionDefined(Properties))
     {
         if (Properties != null)
         {
             writer.WritePropertyName("properties");
             writer.WriteStartObject();
             foreach (var item in Properties)
             {
                 writer.WritePropertyName(item.Key);
                 writer.WriteStringValue(item.Value);
             }
             writer.WriteEndObject();
         }
         else
         {
             writer.WriteNull("properties");
         }
     }
     writer.WriteEndObject();
 }