コード例 #1
0
        public DigestEditDialog(IServiceProvider serviceProvider, DigestItem item, AuthenticationFeature feature)
            : base(serviceProvider)
        {
            InitializeComponent();
            txtRealm.Text = item.Realm;
            txtRealm.SelectAll();

            var container = new CompositeDisposable();

            FormClosed += (sender, args) => container.Dispose();

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnOK, "Click")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                item.Realm = txtRealm.Text;
                item.Apply();
                DialogResult = DialogResult.OK;
            }));

            container.Add(
                Observable.FromEventPattern <CancelEventArgs>(this, "HelpButtonClicked")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(EnvironmentVariableTarget =>
            {
                feature.ShowHelp();
            }));
        }
コード例 #2
0
 public AuthenticationListViewItem(AuthenticationFeature feature, AuthenticationPage page)
     : base(feature.Name)
 {
     _page   = page;
     Feature = feature;
     _status = new ListViewSubItem(this, feature.IsEnabled ? "Enabled" : "Disabled");
     SubItems.Add(_status);
     SubItems.Add(new ListViewSubItem(this, GetString(feature.AuthenticationType)));
     feature.AuthenticationSettingsUpdated = AuthenticationSettingsUpdated;
 }
コード例 #3
0
        public CredentialsDialog(IServiceProvider serviceProvider, string name, AuthenticationFeature feature)
            : base(serviceProvider)
        {
            InitializeComponent();
            btnOK.Enabled = false;
            txtName.Text  = name;

            var container = new CompositeDisposable();

            FormClosed += (sender, args) => container.Dispose();

            container.Add(
                Observable.FromEventPattern <EventArgs>(txtName, "TextChanged")
                .Merge(Observable.FromEventPattern <EventArgs>(txtPassword, "TextChanged"))
                .Merge(Observable.FromEventPattern <EventArgs>(txtConfirm, "TextChanged"))
                .Sample(TimeSpan.FromSeconds(0.5))
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                btnOK.Enabled = !string.IsNullOrWhiteSpace(txtName.Text) &&
                                !string.IsNullOrWhiteSpace(txtPassword.Text) &&
                                txtConfirm.Text == txtPassword.Text;
            }));

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnOK, "Click")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                UserName = txtName.Text;
                Password = txtPassword.Text;
                // TODO: verify user
                // DialogResult = DialogResult.Cancel;
                DialogResult = DialogResult.OK;
            }));

            container.Add(
                Observable.FromEventPattern <CancelEventArgs>(this, "HelpButtonClicked")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(EnvironmentVariableTarget =>
            {
                feature.ShowHelp();
            }));
        }
コード例 #4
0
        public FormsEditDialog(IServiceProvider serviceProvider, FormsItem existing, bool readOnly, AuthenticationFeature feature)
            : base(serviceProvider)
        {
            InitializeComponent();

            txtURL.Text     = existing.LoginUrl;
            txtTimeout.Text = TimeSpanExtensions.GetTotalMinutes(existing.Timeout).ToString();

            cbMode.SelectedIndex          = (int)existing.Mode;
            txtName.Text                  = existing.Name;
            cbProtectedMode.SelectedIndex = (int)existing.ProtectedMode;
            cbSSL.Checked                 = existing.RequireSsl;
            cbExpire.Checked              = existing.SlidinngExpiration;
            btnOK.Enabled                 = false;

            gbCookie.Enabled   = !readOnly;
            txtURL.Enabled     = !readOnly;
            txtTimeout.Enabled = !readOnly;

            var container = new CompositeDisposable();

            FormClosed += (sender, args) => container.Dispose();

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnOK, "Click")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                if (string.IsNullOrWhiteSpace(txtURL.Text))
                {
                    ShowMessage(
                        "You must specify a login page URL.",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1);
                    return;
                }

                int minutes;
                if (!int.TryParse(txtTimeout.Text, out minutes))
                {
                    ShowMessage(
                        "You must specify a valid, positive integer for the authentication time-out.",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1);
                    return;
                }

                if (string.IsNullOrWhiteSpace(txtName.Text))
                {
                    ShowMessage(
                        "You must specify a cookie name.",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1);
                    return;
                }

                existing.LoginUrl           = txtURL.Text;
                existing.Timeout            = new TimeSpan(0, 0, minutes, 0);
                existing.Mode               = cbMode.SelectedIndex;
                existing.Name               = txtName.Text;
                existing.ProtectedMode      = cbProtectedMode.SelectedIndex;
                existing.RequireSsl         = cbSSL.Checked;
                existing.SlidinngExpiration = cbExpire.Checked;
                existing.Apply();
                DialogResult = DialogResult.OK;
            }));

            container.Add(
                Observable.FromEventPattern <EventArgs>(cbSSL, "CheckedChanged")
                .Merge(Observable.FromEventPattern <EventArgs>(txtURL, "TextChanged"))
                .Merge(Observable.FromEventPattern <EventArgs>(cbMode, "SelectedIndexChanged"))
                .Sample(TimeSpan.FromSeconds(1))
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                btnOK.Enabled = true;
            }));

            container.Add(
                Observable.FromEventPattern <CancelEventArgs>(this, "HelpButtonClicked")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(EnvironmentVariableTarget =>
            {
                feature.ShowHelp();
            }));
        }
コード例 #5
0
        public ImpersonationEditDialog(IServiceProvider serviceProvider, ImpersonationItem existing, AuthenticationFeature feature)
            : base(serviceProvider)
        {
            InitializeComponent();

            using (var container = new CompositeDisposable())
            {
                FormClosed += (sender, args) => container.Dispose();

                container.Add(
                    Observable.FromEventPattern <EventArgs>(txtName, "TextChanged")
                    .Sample(TimeSpan.FromSeconds(1))
                    .ObserveOn(System.Threading.SynchronizationContext.Current)
                    .Subscribe(evt =>
                {
                    rbPool.Checked = txtName.Text.Length == 0;
                }));

                container.Add(
                    Observable.FromEventPattern <EventArgs>(btnSet, "Click")
                    .ObserveOn(System.Threading.SynchronizationContext.Current)
                    .Subscribe(evt =>
                {
                    using (var dialog = new CredentialsDialog(ServiceProvider, existing.Name, feature))
                    {
                        if (dialog.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }

                        txtName.Text      = dialog.UserName;
                        existing.Name     = txtName.Text;
                        existing.Password = dialog.Password;
                    }
                    SetButton();
                }));

                container.Add(
                    Observable.FromEventPattern <EventArgs>(btnOK, "Click")
                    .ObserveOn(System.Threading.SynchronizationContext.Current)
                    .Subscribe(evt =>
                {
                    DialogResult = DialogResult.OK;
                    if (rbPool.Checked)
                    {
                        existing.Name = string.Empty;
                        // TODO: reset password.
                        existing.Password = null;
                    }

                    existing.Apply();
                }));

                container.Add(
                    Observable.FromEventPattern <EventArgs>(rbPool, "CheckedChanged")
                    .Merge(Observable.FromEventPattern <EventArgs>(rbSpecific, "CheckedChanged"))
                    .Sample(TimeSpan.FromSeconds(1))
                    .ObserveOn(System.Threading.SynchronizationContext.Current)
                    .Subscribe(evt =>
                {
                    btnSet.Enabled = !rbPool.Checked;
                    SetButton();
                    var toElevate = !rbPool.Checked;
                    if (toElevate)
                    {
                        NativeMethods.TryAddShieldToButton(btnOK);
                    }
                    else
                    {
                        NativeMethods.RemoveShieldFromButton(btnOK);
                    }
                }));

                container.Add(
                    Observable.FromEventPattern <CancelEventArgs>(this, "HelpButtonClicked")
                    .ObserveOn(System.Threading.SynchronizationContext.Current)
                    .Subscribe(EnvironmentVariableTarget =>
                {
                    feature.ShowHelp();
                }));
            }

            txtName.Text = "test"; // IMPORTANT: trigger a change event.
            txtName.Text = existing.Name;
        }
コード例 #6
0
        public WindowsAdvancedDialog(IServiceProvider serviceProvider, WindowsItem item, AuthenticationFeature feature)
            : base(serviceProvider)
        {
            InitializeComponent();
            btnOK.Enabled            = false;
            cbExtended.SelectedIndex = item.TokenChecking;
            cbKernelMode.Checked     = item.UseKernelMode;

            var container = new CompositeDisposable();

            FormClosed += (sender, args) => container.Dispose();

            container.Add(
                Observable.FromEventPattern <EventArgs>(cbExtended, "SelectedIndexChanged")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                btnOK.Enabled = true;
            }));

            container.Add(
                Observable.FromEventPattern <EventArgs>(cbKernelMode, "CheckedChanged")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                btnOK.Enabled = true;
            }));

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnOK, "Click")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                item.TokenChecking = cbExtended.SelectedIndex;
                item.UseKernelMode = cbKernelMode.Checked;
                item.Apply();
                DialogResult = DialogResult.OK;
            }));

            container.Add(
                Observable.FromEventPattern <CancelEventArgs>(this, "HelpButtonClicked")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(EnvironmentVariableTarget =>
            {
                feature.ShowHelp();
            }));
        }
コード例 #7
0
        public ProvidersDialog(IServiceProvider serviceProvider, WindowsItem item, AuthenticationFeature feature)
            : base(serviceProvider)
        {
            InitializeComponent();
            foreach (var provider in item.Providers)
            {
                lbProviders.Items.Add(provider.Value);
            }

            foreach (var each in _allProviders)
            {
                if (!lbProviders.Items.Contains(each))
                {
                    cbAvailable.Items.Add(each);
                }
            }

            btnOK.Enabled = false;

            var container = new CompositeDisposable();

            FormClosed += (sender, args) => container.Dispose();

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnRemove, "Click")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                cbAvailable.Items.Add(lbProviders.SelectedItem);
                lbProviders.Items.Remove(lbProviders.SelectedItem);
                cbAvailable.Enabled = true;
                btnOK.Enabled       = true;
            }));

            var add  = Observable.FromEventPattern <EventArgs>(btnAdd, "Click");
            var load = Observable.FromEventPattern <EventArgs>(this, "Load");

            container.Add(
                add.ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                var selected = cbAvailable.Text;
                lbProviders.Items.Add(selected);
                cbAvailable.Items.RemoveAt(cbAvailable.SelectedIndex);
                cbAvailable.SelectedIndex = -1;
                btnOK.Enabled             = true;
            }));

            container.Add(
                Observable.FromEventPattern <EventArgs>(cbAvailable, "SelectedIndexChanged")
                .Merge(load)
                .Merge(add)
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                btnAdd.Enabled = cbAvailable.SelectedIndex > -1;
                if (cbAvailable.Items.Count == 0)
                {
                    cbAvailable.Enabled = false;
                }
            }));

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnOK, "Click")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                item.Providers.Clear();
                foreach (string provider in lbProviders.Items)
                {
                    item.Providers.Add(new ProviderItem(null)
                    {
                        Value = provider
                    });
                }

                item.Apply();
                DialogResult = DialogResult.OK;
            }));

            container.Add(
                Observable.FromEventPattern <EventArgs>(lbProviders, "SelectedIndexChanged")
                .Merge(load)
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                btnRemove.Enabled = lbProviders.SelectedIndex > -1;
                btnUp.Enabled     = lbProviders.SelectedIndex > 0;
                btnDown.Enabled   = lbProviders.SelectedIndex > -1 && lbProviders.SelectedIndex < lbProviders.Items.Count - 1;
            }));

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnUp, "Click")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                var current = lbProviders.SelectedItem;
                var up      = lbProviders.SelectedIndex - 1;
                lbProviders.Items.RemoveAt(lbProviders.SelectedIndex);
                lbProviders.Items.Insert(up, current);
                lbProviders.SelectedIndex = up;
                btnOK.Enabled             = true;
            }));

            container.Add(
                Observable.FromEventPattern <EventArgs>(btnDown, "Click")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(evt =>
            {
                var current = lbProviders.SelectedItem;
                var down    = lbProviders.SelectedIndex + 1;
                lbProviders.Items.RemoveAt(lbProviders.SelectedIndex);
                lbProviders.Items.Insert(down, current);
                lbProviders.SelectedIndex = down;
                btnOK.Enabled             = true;
            }));

            container.Add(
                Observable.FromEventPattern <CancelEventArgs>(this, "HelpButtonClicked")
                .ObserveOn(System.Threading.SynchronizationContext.Current)
                .Subscribe(EnvironmentVariableTarget =>
            {
                feature.ShowHelp();
            }));
        }