Exemplo n.º 1
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.components          = new System.ComponentModel.Container();
     this.listBoxCertificates = new System.Windows.Forms.ListBox();
     this.buttonOK            = new System.Windows.Forms.Button();
     this.label1          = new System.Windows.Forms.Label();
     this.groupBox1       = new System.Windows.Forms.GroupBox();
     this.label2          = new System.Windows.Forms.Label();
     this.buttonCancel    = new System.Windows.Forms.Button();
     this.userPreferences = new MarkThree.UserPreferences(this.components);
     this.groupBox1.SuspendLayout();
     this.SuspendLayout();
     //
     // listBoxCertificates
     //
     this.listBoxCertificates.HorizontalScrollbar = true;
     this.listBoxCertificates.Location            = new System.Drawing.Point(64, 72);
     this.listBoxCertificates.Name         = "listBoxCertificates";
     this.listBoxCertificates.Size         = new System.Drawing.Size(272, 147);
     this.listBoxCertificates.TabIndex     = 0;
     this.listBoxCertificates.DoubleClick += new System.EventHandler(this.listBoxCertificates_DoubleClick);
     //
     // buttonOK
     //
     this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
     this.buttonOK.Location     = new System.Drawing.Point(184, 248);
     this.buttonOK.Name         = "buttonOK";
     this.buttonOK.Size         = new System.Drawing.Size(75, 23);
     this.buttonOK.TabIndex     = 1;
     this.buttonOK.Text         = "OK";
     //
     // label1
     //
     this.label1.Location = new System.Drawing.Point(64, 32);
     this.label1.Name     = "label1";
     this.label1.Size     = new System.Drawing.Size(272, 32);
     this.label1.TabIndex = 2;
     this.label1.Text     = "The Web Site you want to view requires identification.  Select the certificate to" +
                            " use when connecting.";
     //
     // groupBox1
     //
     this.groupBox1.Controls.Add(this.label2);
     this.groupBox1.Location = new System.Drawing.Point(8, 8);
     this.groupBox1.Name     = "groupBox1";
     this.groupBox1.Size     = new System.Drawing.Size(344, 224);
     this.groupBox1.TabIndex = 3;
     this.groupBox1.TabStop  = false;
     this.groupBox1.Text     = "Identification";
     //
     // label2
     //
     this.label2.BackColor = System.Drawing.SystemColors.Control;
     this.label2.Location  = new System.Drawing.Point(16, 24);
     this.label2.Name      = "label2";
     this.label2.Size      = new System.Drawing.Size(32, 32);
     this.label2.TabIndex  = 5;
     //
     // buttonCancel
     //
     this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
     this.buttonCancel.Location     = new System.Drawing.Point(272, 248);
     this.buttonCancel.Name         = "buttonCancel";
     this.buttonCancel.Size         = new System.Drawing.Size(75, 23);
     this.buttonCancel.TabIndex     = 4;
     this.buttonCancel.Text         = "Cancel";
     //
     // FormSelectCertificate
     //
     this.AcceptButton      = this.buttonOK;
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
     this.CancelButton      = this.buttonCancel;
     this.ClientSize        = new System.Drawing.Size(362, 286);
     this.ControlBox        = false;
     this.Controls.Add(this.buttonCancel);
     this.Controls.Add(this.label1);
     this.Controls.Add(this.buttonOK);
     this.Controls.Add(this.listBoxCertificates);
     this.Controls.Add(this.groupBox1);
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
     this.MaximizeBox     = false;
     this.MinimizeBox     = false;
     this.Name            = "FormSelectCertificate";
     this.ShowInTaskbar   = false;
     this.Text            = "Client Authentication";
     this.TransparencyKey = System.Drawing.Color.Cyan;
     this.groupBox1.ResumeLayout(false);
     this.ResumeLayout(false);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.components      = new System.ComponentModel.Container();
     this.labelUserName   = new System.Windows.Forms.Label();
     this.labelPassword   = new System.Windows.Forms.Label();
     this.textBoxUserName = new System.Windows.Forms.TextBox();
     this.textBoxPassword = new System.Windows.Forms.TextBox();
     this.buttonOK        = new System.Windows.Forms.Button();
     this.buttonCancel    = new System.Windows.Forms.Button();
     this.textBoxDomain   = new System.Windows.Forms.TextBox();
     this.labelDomain     = new System.Windows.Forms.Label();
     this.userPreferences = new MarkThree.UserPreferences(this.components);
     this.SuspendLayout();
     //
     // labelUserName
     //
     this.labelUserName.Location  = new System.Drawing.Point(8, 8);
     this.labelUserName.Name      = "labelUserName";
     this.labelUserName.Size      = new System.Drawing.Size(72, 16);
     this.labelUserName.TabIndex  = 0;
     this.labelUserName.Text      = "&User Name:";
     this.labelUserName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
     //
     // labelPassword
     //
     this.labelPassword.Location  = new System.Drawing.Point(8, 40);
     this.labelPassword.Name      = "labelPassword";
     this.labelPassword.Size      = new System.Drawing.Size(72, 16);
     this.labelPassword.TabIndex  = 4;
     this.labelPassword.Text      = "&Password:"******"textBoxUserName";
     this.textBoxUserName.Size     = new System.Drawing.Size(216, 20);
     this.textBoxUserName.TabIndex = 1;
     //
     // textBoxPassword
     //
     this.textBoxPassword.Location = new System.Drawing.Point(88, 40);
     this.textBoxPassword.Name     = "textBoxPassword";
     this.textBoxPassword.Size     = new System.Drawing.Size(216, 20);
     this.textBoxPassword.TabIndex = 2;
     //
     // buttonOK
     //
     this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
     this.buttonOK.Location     = new System.Drawing.Point(144, 104);
     this.buttonOK.Name         = "buttonOK";
     this.buttonOK.Size         = new System.Drawing.Size(75, 23);
     this.buttonOK.TabIndex     = 4;
     this.buttonOK.Text         = "OK";
     //
     // buttonCancel
     //
     this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
     this.buttonCancel.Location     = new System.Drawing.Point(232, 104);
     this.buttonCancel.Name         = "buttonCancel";
     this.buttonCancel.Size         = new System.Drawing.Size(75, 23);
     this.buttonCancel.TabIndex     = 5;
     this.buttonCancel.Text         = "Cancel";
     //
     // textBoxDomain
     //
     this.textBoxDomain.Location = new System.Drawing.Point(88, 72);
     this.textBoxDomain.Name     = "textBoxDomain";
     this.textBoxDomain.Size     = new System.Drawing.Size(216, 20);
     this.textBoxDomain.TabIndex = 3;
     //
     // labelDomain
     //
     this.labelDomain.Location  = new System.Drawing.Point(8, 72);
     this.labelDomain.Name      = "labelDomain";
     this.labelDomain.Size      = new System.Drawing.Size(72, 16);
     this.labelDomain.TabIndex  = 11;
     this.labelDomain.Text      = "&Log on to:";
     this.labelDomain.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
     //
     // FormNetworkCredential
     //
     this.AcceptButton      = this.buttonOK;
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
     this.CancelButton      = this.buttonCancel;
     this.ClientSize        = new System.Drawing.Size(314, 136);
     this.ControlBox        = false;
     this.Controls.Add(this.labelDomain);
     this.Controls.Add(this.textBoxDomain);
     this.Controls.Add(this.textBoxPassword);
     this.Controls.Add(this.textBoxUserName);
     this.Controls.Add(this.buttonCancel);
     this.Controls.Add(this.buttonOK);
     this.Controls.Add(this.labelPassword);
     this.Controls.Add(this.labelUserName);
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
     this.Name            = "FormNetworkCredential";
     this.ShowInTaskbar   = false;
     this.Text            = "Network Credentials";
     this.ResumeLayout(false);
     this.PerformLayout();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes the static elements of a 'WebTransactionProtocol' connection.
        /// </summary>
        static HttpBatchProcessor()
        {
            // We need to reference the user preferences in this static constructor.
            UserPreferences userPreferences = new UserPreferences();

            // Use a default timout for the Http Request if one was specified in the application configuration file.
            string timeoutText = ConfigurationManager.AppSettings["httpTimeout"];

            HttpBatchProcessor.Timeout = timeoutText == null ? defaultTimeout : Convert.ToInt32(timeoutText);

            // Initially, the decision about prompting for a URL is decided by whether there is a recently saved URL to try.
            // After the first WebException, we'll prompt them until a good one is entered.
            HttpBatchProcessor.Url           = (string)UserPreferences.LocalSettings[webServiceMru0Key];
            HttpBatchProcessor.IsUrlPrompted = HttpBatchProcessor.Url == string.Empty;

            // Initially the decision to prompt the user for credentials is made by whether a complete set of information for
            // establishing a session can be collected from the local settings.  If there isn't enough information, the user will
            // be prompted.  After the first time, a 401 error will indicate that the user should be prompted for their credentials
            // again.
            HttpBatchProcessor.IsCredentialPrompted = false;

            // Select the method for authenticating the user when they connect to the web transaction server.  The default is to
            // use certificates.  This can be overridden by configuration settings.
            HttpBatchProcessor.AuthenticationMode = AuthenticationMode.Certificate;
            string authenticationModeText = ConfigurationManager.AppSettings["authenticationMode"];

            if (authenticationModeText != null)
            {
                HttpBatchProcessor.AuthenticationMode = (AuthenticationMode)Enum.Parse(typeof(AuthenticationMode),
                                                                                       authenticationModeText);
            }

            // Set up the details of authentication based on the selected authentication mode.
            switch (HttpBatchProcessor.AuthenticationMode)
            {
            case AuthenticationMode.Certificate:

                // This is a collection of cached certificates used for SSL security.
                HttpBatchProcessor.clientCertificates = new X509CertificateCollection();

                // If a certificate name was stored in the user preferences, then attempt to match it up against the personal
                // certificate store.  If a previosly used certificate was found, then put it in the cache where it can be used the
                // next time a connection is established.
                string certificateName = (string)UserPreferences.LocalSettings[certificateNameKey];
                if (certificateName != null)
                {
                    foreach (X509Certificate x509Certificate in Crypt.GetCertificateStore(myStoreName))
                    {
                        if (x509Certificate.Subject == certificateName)
                        {
                            HttpBatchProcessor.clientCertificates.Add(x509Certificate);
                        }
                    }
                }

                // If the user preferences has a valid certificate, then the prompting can be bypassed.  Otherwise, the first time
                // a request is sent, the user will be asked for a URL and a certificate.
                HttpBatchProcessor.IsCredentialPrompted = HttpBatchProcessor.clientCertificates.Count == 0;

                break;

            case AuthenticationMode.WindowsIntegrated:

                // Integrated Mode uses the current user's security context, there is nothing for which to prompt the user.
                HttpBatchProcessor.IsCredentialPrompted = false;

                break;

            case AuthenticationMode.Basic:

                // Basic authorization over SSL can be used for the web request. See if the user has some saved credentials.
                HttpBatchProcessor.networkCredential          = new NetworkCredential();
                HttpBatchProcessor.networkCredential.UserName = (string)UserPreferences.LocalSettings[usernameKey];
                HttpBatchProcessor.networkCredential.Domain   = (string)UserPreferences.LocalSettings[domainKey];

                // The user must always be prompted for the password in Basic Mode due to an inability to secure the password
                // on the local machine.
                HttpBatchProcessor.IsCredentialPrompted = true;

                break;
            }

            // Since the UserPreferences were used by a static non-component, the resources need to be cleaned up explicitly.  This
            // should balance the books on the UserPreferences component.
            userPreferences.Dispose();
        }
Exemplo n.º 4
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.components      = new System.ComponentModel.Container();
     this.userPreferences = new MarkThree.UserPreferences(this.components);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with theCode editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.components      = new System.ComponentModel.Container();
     this.comboBoxUrl     = new System.Windows.Forms.ComboBox();
     this.label1          = new System.Windows.Forms.Label();
     this.buttonOK        = new System.Windows.Forms.Button();
     this.buttonCancel    = new System.Windows.Forms.Button();
     this.buttonHelp      = new System.Windows.Forms.Button();
     this.userPreferences = new MarkThree.UserPreferences(this.components);
     this.SuspendLayout();
     //
     // comboBoxUrl
     //
     this.comboBoxUrl.Location    = new System.Drawing.Point(8, 32);
     this.comboBoxUrl.Name        = "comboBoxUrl";
     this.comboBoxUrl.Size        = new System.Drawing.Size(488, 21);
     this.comboBoxUrl.TabIndex    = 0;
     this.comboBoxUrl.Validating += new System.ComponentModel.CancelEventHandler(this.comboBoxUrl_Validating);
     //
     // label1
     //
     this.label1.Location = new System.Drawing.Point(8, 8);
     this.label1.Name     = "label1";
     this.label1.Size     = new System.Drawing.Size(184, 16);
     this.label1.TabIndex = 1;
     this.label1.Text     = "Please select a Web Server:";
     //
     // buttonOK
     //
     this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
     this.buttonOK.Location     = new System.Drawing.Point(248, 64);
     this.buttonOK.Name         = "buttonOK";
     this.buttonOK.Size         = new System.Drawing.Size(75, 23);
     this.buttonOK.TabIndex     = 2;
     this.buttonOK.Text         = "OK";
     //
     // buttonCancel
     //
     this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
     this.buttonCancel.Location     = new System.Drawing.Point(336, 64);
     this.buttonCancel.Name         = "buttonCancel";
     this.buttonCancel.Size         = new System.Drawing.Size(75, 23);
     this.buttonCancel.TabIndex     = 3;
     this.buttonCancel.Text         = "Cancel";
     //
     // buttonHelp
     //
     this.buttonHelp.Location = new System.Drawing.Point(424, 64);
     this.buttonHelp.Name     = "buttonHelp";
     this.buttonHelp.Size     = new System.Drawing.Size(75, 23);
     this.buttonHelp.TabIndex = 4;
     this.buttonHelp.Text     = "Help";
     //
     // FormUrl
     //
     this.AcceptButton      = this.buttonOK;
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
     this.CancelButton      = this.buttonCancel;
     this.ClientSize        = new System.Drawing.Size(506, 96);
     this.ControlBox        = false;
     this.Controls.Add(this.buttonHelp);
     this.Controls.Add(this.buttonCancel);
     this.Controls.Add(this.buttonOK);
     this.Controls.Add(this.label1);
     this.Controls.Add(this.comboBoxUrl);
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
     this.HelpButton      = true;
     this.MaximizeBox     = false;
     this.MinimizeBox     = false;
     this.Name            = "FormUrl";
     this.ShowInTaskbar   = false;
     this.Text            = "Client Connect";
     this.ResumeLayout(false);
 }