Esempio n. 1
0
        public void Unrestricted_Add()
        {
            OleDbPermission perm = new OleDbPermission(PermissionState.Unrestricted);

            Check("Unrestricted-NoChild", perm, false, true, 0);
            perm.Add("data source=localhost;", String.Empty, KeyRestrictionBehavior.AllowOnly);
            // note: Lost unrestricted state when children was added
            Check("Unrestricted-WithChild", perm, false, false, 1);
        }
        internal COleDbPermControls(IPermission perm, Object oParent) : base(perm, oParent)
        {
            // If they don't have a permission for this permission set, we will
            // feed our property page a 'none' permission state.

            if (perm == null)
            {
                m_perm = new OleDbPermission(PermissionState.None);
            }
        }// COleDbPermControls
Esempio n. 3
0
        public void Provider()
        {
            OleDbPermission perm = new OleDbPermission(PermissionState.None);

            perm.Provider = String.Empty;
            Assert.AreEqual(String.Empty, perm.Provider, "Empty");
            perm.Provider = "Mono";
            Assert.AreEqual("Mono", perm.Provider, "Mono");
            perm.Provider = null;
            Assert.AreEqual(String.Empty, perm.Provider, "Empty(null)");
        }
        public void CreatePermission_Provider()
        {
            OleDbPermissionAttribute a = new OleDbPermissionAttribute(SecurityAction.Assert);

            a.Provider = "Mono";
            Assert.AreEqual("Mono", a.Provider, "Mono");

            OleDbPermission odp = (OleDbPermission)a.CreatePermission();

            // provider isn't even supplied to permission in fx 2.0
            Assert.AreEqual(String.Empty, odp.Provider, "CreatePermission.Provider");
        }
Esempio n. 5
0
        public void None()
        {
            OleDbPermission perm = new OleDbPermission(PermissionState.None);

            Check("None-1", perm, false, false, 0);
            perm.AllowBlankPassword = true;
            Check("None-2", perm, true, false, 0);

            OleDbPermission copy = (OleDbPermission)perm.Copy();

            Check("Copy_None-1", copy, true, false, 0);
            copy.AllowBlankPassword = false;
            Check("Copy_None-2", copy, false, false, 0);
        }
Esempio n. 6
0
 private void Check(string msg, OleDbPermission perm, bool blank, bool unrestricted, int count)
 {
     Assert.AreEqual(blank, perm.AllowBlankPassword, msg + ".AllowBlankPassword");
     Assert.AreEqual(unrestricted, perm.IsUnrestricted(), msg + ".IsUnrestricted");
     if (count == 0)
     {
         Assert.IsNull(perm.ToXml().Children, msg + ".Count != 0");
     }
     else
     {
         Assert.AreEqual(count, perm.ToXml().Children.Count, msg + ".Count");
     }
     Assert.AreEqual(String.Empty, perm.Provider, "Provider");
 }
        }// CreateDataTable

        protected override void PutValuesinPage()
        {
            // Put in the text for the radio buttons
            m_radUnrestricted.Text             = CResourceStore.GetString("OleDbPermission:GrantUnrestrict");
            m_radGrantFollowingPermission.Text = CResourceStore.GetString("OleDbPermission:GrantFollowing");


            // Adjust some of the UI components on this page (and put in a checkbox)
            System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(COleDbPermControls));
            this.m_chkAllowBlank          = new System.Windows.Forms.CheckBox();
            this.m_btnDeleteRow.Location  = ((System.Drawing.Point)(resources.GetObject("m_btn.Location")));
            this.m_chkAllowBlank.Location = ((System.Drawing.Point)(resources.GetObject("m_chkAllowBlank.Location")));
            this.m_chkAllowBlank.Name     = "m_chkAllowBlank";
            this.m_chkAllowBlank.Size     = ((System.Drawing.Size)(resources.GetObject("m_chkAllowBlank.Size")));
            this.m_chkAllowBlank.TabIndex = ((int)(resources.GetObject("m_chkAllowBlank.TabIndex")));
            this.m_chkAllowBlank.Text     = resources.GetString("m_chkAllowBlank.Text");
            this.m_dg.Size              = ((System.Drawing.Size)(resources.GetObject("m_dg.Size")));
            this.m_chkAllowBlank.Click += new EventHandler(onChange);


            m_ucOptions.Controls.Add(this.m_chkAllowBlank);

            OleDbPermission perm = (OleDbPermission)m_perm;

            CheckUnrestricted(perm);

            if (!perm.IsUnrestricted())
            {
                String[] sProviders = perm.Provider.Split(new char[] { ';' });

                for (int i = 0; i < sProviders.Length; i++)
                {
                    if (sProviders[i].Length > 0)
                    {
                        DataRow newRow = m_dt.NewRow();
                        newRow["Provider"] = sProviders[i];
                        m_dt.Rows.Add(newRow);
                    }
                }

                m_chkAllowBlank.Checked = perm.AllowBlankPassword;
            }

            // We want at least 1 rows so it looks pretty
            while (m_dt.Rows.Count < 1)
            {
                AddEmptyRow(m_dt);
            }
        }// PutValuesinPage
Esempio n. 8
0
        public void Unrestricted()
        {
            OleDbPermission perm = new OleDbPermission(PermissionState.Unrestricted);

            Check("Unrestricted-1", perm, false, true, 0);
            perm.AllowBlankPassword = true;
            Check("Unrestricted-2", perm, true, true, 0);

            OleDbPermission copy = (OleDbPermission)perm.Copy();

            // note: Unrestricted is always created with default values (so AllowBlankPassword is false)
            Check("Copy_Unrestricted-1", copy, false, true, 0);
            copy.AllowBlankPassword = true;
            Check("Copy_Unrestricted-2", copy, true, true, 0);
        }
Esempio n. 9
0
        public void None_Childs()
        {
            OleDbPermission perm = new OleDbPermission(PermissionState.None);

            perm.Add("data source=localhost;", String.Empty, KeyRestrictionBehavior.AllowOnly);
            perm.Add("data source=127.0.0.1;", "password=;", KeyRestrictionBehavior.PreventUsage);

            Check("None-Childs-1", perm, false, false, 2);
            perm.AllowBlankPassword = true;
            Check("None-Childs-2", perm, true, false, 2);

            OleDbPermission copy = (OleDbPermission)perm.Copy();

            Check("Copy_None-Childs-1", copy, true, false, 2);
            copy.AllowBlankPassword = false;
            Check("Copy_None-Childs-2", copy, false, false, 2);
        }
Esempio n. 10
0
        public void Unrestricted()
        {
            OleDbPermissionAttribute a = new OleDbPermissionAttribute(SecurityAction.Assert);

            a.Unrestricted = true;
            OleDbPermission odp = (OleDbPermission)a.CreatePermission();

            Assert.IsTrue(odp.IsUnrestricted(), "IsUnrestricted");
            Assert.IsFalse(a.AllowBlankPassword, "AllowBlankPassword");
            Assert.AreEqual(String.Empty, a.ConnectionString, "ConnectionString");
            Assert.AreEqual(KeyRestrictionBehavior.AllowOnly, a.KeyRestrictionBehavior, "KeyRestrictionBehavior");
            Assert.AreEqual(String.Empty, a.KeyRestrictions, "KeyRestrictions");

            a.Unrestricted = false;
            odp            = (OleDbPermission)a.CreatePermission();
            Assert.IsFalse(odp.IsUnrestricted(), "!IsUnrestricted");
        }
        public void Default()
        {
            OleDbPermissionAttribute a = new OleDbPermissionAttribute(SecurityAction.Assert);

            Assert.AreEqual(a.ToString(), a.TypeId.ToString(), "TypeId");
            Assert.IsFalse(a.Unrestricted, "Unrestricted");
            Assert.IsFalse(a.AllowBlankPassword, "AllowBlankPassword");
            Assert.AreEqual(String.Empty, a.ConnectionString, "ConnectionString");
            Assert.AreEqual(KeyRestrictionBehavior.AllowOnly, a.KeyRestrictionBehavior, "KeyRestrictionBehavior");
            Assert.AreEqual(String.Empty, a.KeyRestrictions, "KeyRestrictions");
            Assert.AreEqual(String.Empty, a.Provider, "Provider");
            Assert.IsFalse(a.ShouldSerializeConnectionString(), "ShouldSerializeConnectionString");
            Assert.IsFalse(a.ShouldSerializeKeyRestrictions(), "ShouldSerializeConnectionString");
            OleDbPermission odp = (OleDbPermission)a.CreatePermission();

            Assert.IsFalse(odp.IsUnrestricted(), "IsUnrestricted");
        }
        }// AddEmptyRow

        internal override IPermission GetCurrentPermission()
        {
            // Change cells so we get data committed to the grid
            m_dg.CurrentCell = new DataGridCell(1, 0);
            m_dg.CurrentCell = new DataGridCell(0, 0);

            OleDbPermission perm = null;

            if (m_radUnrestricted.Checked == true)
            {
                perm = new OleDbPermission(PermissionState.Unrestricted);
            }
            else
            {
                perm = new OleDbPermission(PermissionState.None);
                String sProviders = "";
                for (int i = 0; i < m_dt.Rows.Count; i++)
                {
                    // Make sure we have an file permission to add
                    if (m_dg[i, 0] is String && ((String)m_dg[i, 0]).Length > 0)
                    {
                        sProviders += (String)m_dg[i, 0] + ";";
                    }
                }

                // Strip off the last ';'
                if (sProviders.Length > 0)
                {
                    sProviders = sProviders.Substring(0, sProviders.Length - 1);
                }


                perm.Provider           = sProviders;
                perm.AllowBlankPassword = m_chkAllowBlank.Checked;
            }
            return(perm);
        } // GetCurrentPermission
Esempio n. 13
0
 public void PermissionState_Invalid()
 {
     PermissionState ps   = (PermissionState)Int32.MinValue;
     OleDbPermission perm = new OleDbPermission(ps);
 }
 internal COleDbPermDialog(OleDbPermission perm)
 {
     this.Text      = CResourceStore.GetString("OleDbPermission:PermName");
     m_PermControls = new COleDbPermControls(perm, this);
     Init();
 } // COleDbPermDialog(OleDbPermission)