/// <summary>
        /// This Method is a javascript callable method.
        /// </summary>
        /// <param name="e">A parameter from javascript.</param>
        /// <param name="y">A callback to javascript.</param>
        public void WebMethod2()
        {


            var x = new SecureString();

            x.AppendChar('p');
            x.AppendChar('a');
            x.AppendChar('s');
            x.AppendChar('s');
            x.AppendChar('w');
            x.AppendChar('o');
            x.AppendChar('r');
            x.AppendChar('d');

            // SecureString seems to be one way PKI. no way to read it?
            var xx = x.ToString();

        }
Exemple #2
0
		public void DefaultConstructor ()
		{
			try {
				SecureString ss = new SecureString ();
				Assert.IsFalse (ss.IsReadOnly (), "IsReadOnly");
				Assert.AreEqual (0, ss.Length, "0");
				ss.AppendChar ('a');
				Assert.AreEqual (1, ss.Length, "1");
				ss.Clear ();
				Assert.AreEqual (0, ss.Length, "0b");
				ss.InsertAt (0, 'b');
				Assert.AreEqual (1, ss.Length, "1b");
				ss.SetAt (0, 'c');
				Assert.AreEqual (1, ss.Length, "1c");
				Assert.AreEqual ("System.Security.SecureString", ss.ToString (), "ToString");
				ss.RemoveAt (0);
				Assert.AreEqual (0, ss.Length, "0c");
				ss.Dispose ();
			}
			catch (NotSupportedException) {
				Assert.Ignore (NotSupported);
			}
		}
Exemple #3
0
        public static bool StartOpenVPN(string _config, string _serviceName, string _userName, SecureString _password)
        {
            string command = $"openvpn --config {_config} --service {_serviceName} 0";

            Process process = null;
            ProcessStartInfo processInfo = null;

            Debug.WriteLine("Command = " + command);
            Debug.WriteLine("");

            Console.WriteLine(Divider);
            Console.WriteLine("OpenVPN" + Divider);
            Console.WriteLine(Divider);
            Console.WriteLine("Username: "******"Password: "******"Trying...");

            bool success = false;
            try
            {
                processInfo = new ProcessStartInfo("cmd.exe", "/C " + command);
                processInfo.UseShellExecute = false;
                processInfo.RedirectStandardInput = true;
                processInfo.RedirectStandardOutput = true;

                process = new Process();
                process.StartInfo = processInfo;
                process.Start();

                process.StandardInput.WriteLine(_userName);
                Thread.Sleep(20);

                process.StandardInput.WriteLine(_password.ToString());
                Thread.Sleep(20);

                int ticks = 0;
                while (!success && !process.HasExited && ticks < 100)
                {
                    string line = process.StandardOutput.ReadLine();

                    Debug.WriteLine($">>{line}");

                    if (line.Contains("Initialization Sequence Completed"))
                    {
                        success = true;
                    }

                    ticks++;
                }

                if (success)
                {
                    Console.WriteLine("...Success");
                }
                else
                {
                    Console.WriteLine("...Failed");
                }

                Console.WriteLine(Divider);
                Console.WriteLine(Divider);
                Console.WriteLine(Divider);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error Opening : " + e.Message);
                Console.WriteLine(e.StackTrace);
            }
            finally
            {
                process.Close();
                process = null;
            }

            return success;
        }
Exemple #4
0
 public static User Create(string userName, SecureString password)
 {
     var user = new User(userName, string.Empty, DateTime.Now);
     user.PasswordHash = GetPasswordHash(password.ToString(), GetPasswordSalt(user.CreatedOn));
     return user;
 }