internal static void AddEntry(NameValuePermission kvtree, ArrayList entries, DBConnectionString entry)
 {
     if (entry.KeyChain != null)
     {
         for (NameValuePair pair = entry.KeyChain; pair != null; pair = pair.Next)
         {
             NameValuePermission permit = kvtree.CheckKeyForValue(pair.Name);
             if (permit == null)
             {
                 permit = new NameValuePermission(pair.Name);
                 kvtree.Add(permit);
             }
             kvtree = permit;
             permit = kvtree.CheckKeyForValue(pair.Value);
             if (permit == null)
             {
                 DBConnectionString str2 = (pair.Next != null) ? null : entry;
                 permit = new NameValuePermission(pair.Value, str2);
                 kvtree.Add(permit);
                 if (str2 != null)
                 {
                     entries.Add(str2);
                 }
             }
             else if (pair.Next == null)
             {
                 if (permit._entry != null)
                 {
                     entries.Remove(permit._entry);
                     permit._entry = permit._entry.Intersect(entry);
                 }
                 else
                 {
                     permit._entry = entry;
                 }
                 entries.Add(permit._entry);
             }
             kvtree = permit;
         }
     }
     else
     {
         DBConnectionString str = kvtree._entry;
         if (str != null)
         {
             entries.Remove(str);
             kvtree._entry = str.Intersect(entry);
         }
         else
         {
             kvtree._entry = entry;
         }
         entries.Add(kvtree._entry);
     }
 }
        internal void Intersect(ArrayList entries, NameValuePermission target)
        {
            if (null == target)
            {
                _tree  = null;
                _entry = null;
            }
            else
            {
                if (null != _entry)
                {
                    entries.Remove(_entry);
                    _entry = _entry.MergeIntersect(target._entry);
                    entries.Add(_entry);
                }
                else if (null != target._entry)
                {
                    _entry = target._entry.MergeIntersect(null);
                    entries.Add(_entry);
                }

                if (null != _tree)
                {
                    int count = _tree.Length;
                    for (int i = 0; i < _tree.Length; ++i)
                    {
                        NameValuePermission kvtree = target.CheckKeyForValue(_tree[i]._value);
                        if (null != kvtree)   // does target tree contain our value
                        {
                            _tree[i].Intersect(entries, kvtree);
                        }
                        else
                        {
                            _tree[i] = null;
                            --count;
                        }
                    }
                    if (0 == count)
                    {
                        _tree = null;
                    }
                    else if (count < _tree.Length)
                    {
                        NameValuePermission[] kvtree = new NameValuePermission[count];
                        for (int i = 0, j = 0; i < _tree.Length; ++i)
                        {
                            if (null != _tree[i])
                            {
                                kvtree[j++] = _tree[i];
                            }
                        }
                    }
                }
            }
        }
 internal static void AddEntry(NameValuePermission kvtree, ArrayList entries, DBConnectionString entry)
 {
     if (entry.KeyChain != null)
     {
         for (NameValuePair pair = entry.KeyChain; pair != null; pair = pair.Next)
         {
             NameValuePermission permit = kvtree.CheckKeyForValue(pair.Name);
             if (permit == null)
             {
                 permit = new NameValuePermission(pair.Name);
                 kvtree.Add(permit);
             }
             kvtree = permit;
             permit = kvtree.CheckKeyForValue(pair.Value);
             if (permit == null)
             {
                 DBConnectionString str2 = (pair.Next != null) ? null : entry;
                 permit = new NameValuePermission(pair.Value, str2);
                 kvtree.Add(permit);
                 if (str2 != null)
                 {
                     entries.Add(str2);
                 }
             }
             else if (pair.Next == null)
             {
                 if (permit._entry != null)
                 {
                     entries.Remove(permit._entry);
                     permit._entry = permit._entry.Intersect(entry);
                 }
                 else
                 {
                     permit._entry = entry;
                 }
                 entries.Add(permit._entry);
             }
             kvtree = permit;
         }
     }
     else
     {
         DBConnectionString str = kvtree._entry;
         if (str != null)
         {
             entries.Remove(str);
             kvtree._entry = str.Intersect(entry);
         }
         else
         {
             kvtree._entry = entry;
         }
         entries.Add(kvtree._entry);
     }
 }
 /// <include file='doc\OraclePermission.uex' path='docs/doc[@for="OraclePermission.Clear"]/*' />
 /// <internalonly />
 internal void Clear()   // MDAC 83105
 {
     try {
         lock (this) {
             _keyvaluetree = null;
             _keyvalues    = null;
         }
     }
     catch {
         throw;
     }
 }
 private void Add(NameValuePermission permit)
 {
     NameValuePermission[] permissionArray2 = this._tree;
     int index = (permissionArray2 != null) ? permissionArray2.Length : 0;
     NameValuePermission[] array = new NameValuePermission[1 + index];
     for (int i = 0; i < (array.Length - 1); i++)
     {
         array[i] = permissionArray2[i];
     }
     array[index] = permit;
     Array.Sort<NameValuePermission>(array);
     this._tree = array;
 }
        private void Add(NameValuePermission permit)
        {
            NameValuePermission[] permissionArray2 = this._tree;
            int index = (permissionArray2 != null) ? permissionArray2.Length : 0;

            NameValuePermission[] array = new NameValuePermission[1 + index];
            for (int i = 0; i < (array.Length - 1); i++)
            {
                array[i] = permissionArray2[i];
            }
            array[index] = permit;
            Array.Sort <NameValuePermission>(array);
            this._tree = array;
        }
        private void Add(NameValuePermission permit)
        {
            NameValuePermission[] tree = _tree;
            int length = ((null != tree) ? tree.Length : 0);

            NameValuePermission[] newtree = new NameValuePermission[1 + length];
            for (int i = 0; i < length; ++i)
            {
                newtree[i] = tree[i];
            }
            newtree[length] = permit;
            Array.Sort(newtree);
            _tree = newtree;
        }
 private NameValuePermission CheckKeyForValue(string keyInQuestion)
 {
     NameValuePermission[] permissionArray = this._tree;
     if (permissionArray != null)
     {
         for (int i = 0; i < permissionArray.Length; i++)
         {
             NameValuePermission permission = permissionArray[i];
             if (string.Equals(keyInQuestion, permission._value, StringComparison.OrdinalIgnoreCase))
             {
                 return(permission);
             }
         }
     }
     return(null);
 }
 private NameValuePermission(NameValuePermission permit)   // deep-copy
 {
     _value = permit._value;
     _entry = permit._entry;
     _tree  = permit._tree;
     if (null != _tree)
     {
         NameValuePermission[] tree = (_tree.Clone() as NameValuePermission[]);
         int length = tree.Length;
         for (int i = 0; i < length; ++i)
         {
             tree[i] = tree[i].Copy(); // deep copy
         }
         _tree = tree;
     }
 }
        internal bool CheckValueForKeyPermit(DBConnectionString parsetable)
        {
            if (parsetable == null)
            {
                return(false);
            }
            bool isEmpty = false;

            NameValuePermission[] permissionArray = this._tree;
            if (permissionArray != null)
            {
                isEmpty = parsetable.IsEmpty;
                if (!isEmpty)
                {
                    for (int i = 0; i < permissionArray.Length; i++)
                    {
                        NameValuePermission permission = permissionArray[i];
                        if (permission != null)
                        {
                            string keyword = permission._value;
                            if (parsetable.ContainsKey(keyword))
                            {
                                string keyInQuestion            = parsetable[keyword];
                                NameValuePermission permission2 = permission.CheckKeyForValue(keyInQuestion);
                                if ((permission2 != null) && permission2.CheckValueForKeyPermit(parsetable))
                                {
                                    isEmpty = true;
                                }
                                else
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                }
            }
            DBConnectionString str = this._entry;

            if (str != null)
            {
                isEmpty = str.IsSupersetOf(parsetable);
            }
            return(isEmpty);
        }
 private NameValuePermission(NameValuePermission permit)
 {
     this._value = permit._value;
     this._entry = permit._entry;
     this._tree  = permit._tree;
     if (this._tree != null)
     {
         NameValuePermission[] permissionArray = this._tree.Clone() as NameValuePermission[];
         for (int i = 0; i < permissionArray.Length; i++)
         {
             if (permissionArray[i] != null)
             {
                 permissionArray[i] = permissionArray[i].CopyNameValue();
             }
         }
         this._tree = permissionArray;
     }
 }
 private NameValuePermission(NameValuePermission permit)
 {
     this._value = permit._value;
     this._entry = permit._entry;
     this._tree = permit._tree;
     if (this._tree != null)
     {
         NameValuePermission[] permissionArray = this._tree.Clone() as NameValuePermission[];
         for (int i = 0; i < permissionArray.Length; i++)
         {
             if (permissionArray[i] != null)
             {
                 permissionArray[i] = permissionArray[i].CopyNameValue();
             }
         }
         this._tree = permissionArray;
     }
 }
        private NameValuePermission CheckKeyForValue(string keyInQuestion)
        {
            NameValuePermission[] valuetree = _tree; // _tree won't mutate but Add will replace it
            if (null != valuetree)
            {
                for (int i = 0; i < valuetree.Length; ++i)
                {
                    NameValuePermission permitValue = valuetree[i];
#if DATAPERMIT
                    Debug.WriteLine("DBDataPermission value: <" + permitValue._value + ">");
#endif
                    if (0 == ADP.DstCompare(keyInQuestion, permitValue._value))
                    {
                        return(permitValue);
                    }
                }
            }
            return(null);
        }
 internal void Intersect(ArrayList entries, NameValuePermission target)
 {
     if (target == null)
     {
         this._tree = null;
         this._entry = null;
     }
     else
     {
         if (this._entry != null)
         {
             entries.Remove(this._entry);
             this._entry = this._entry.Intersect(target._entry);
             entries.Add(this._entry);
         }
         else if (target._entry != null)
         {
             this._entry = target._entry.Intersect(null);
             entries.Add(this._entry);
         }
         if (this._tree != null)
         {
             int length = this._tree.Length;
             for (int i = 0; i < this._tree.Length; i++)
             {
                 NameValuePermission permission = target.CheckKeyForValue(this._tree[i]._value);
                 if (permission != null)
                 {
                     this._tree[i].Intersect(entries, permission);
                 }
                 else
                 {
                     this._tree[i] = null;
                     length--;
                 }
             }
             if (length == 0)
             {
                 this._tree = null;
             }
             else if (length < this._tree.Length)
             {
                 NameValuePermission[] permissionArray = new NameValuePermission[length];
                 int index = 0;
                 int num4 = 0;
                 while (index < this._tree.Length)
                 {
                     if (this._tree[index] != null)
                     {
                         permissionArray[num4++] = this._tree[index];
                     }
                     index++;
                 }
                 this._tree = permissionArray;
             }
         }
     }
 }
        internal bool CheckValueForKeyPermit(DBConnectionString parsetable)
        {
            if (null == parsetable)
            {
                return(false);
            }

            bool hasMatch = false;

            NameValuePermission[] keytree = _tree; // _tree won't mutate but Add will replace it
            if (null != keytree)
            {
                // which key do we follow the key-value chain on
                for (int i = 0; i < keytree.Length; ++i)
                {
                    NameValuePermission permitKey = keytree[i];
                    string keyword = permitKey._value;
#if DATAPERMIT
                    Debug.WriteLine("DBDataPermission keyword: <" + keyword + ">");
#endif
#if DEBUG
                    Debug.Assert(null == permitKey._entry, "key member has no restrictions");
#endif
                    if (parsetable.Contains(keyword))
                    {
                        string valueInQuestion = (string)parsetable[keyword];

                        // keyword is restricted to certain values
                        NameValuePermission permitValue = permitKey.CheckKeyForValue(valueInQuestion);
                        if (null != permitValue)
                        {
                            //value does match - continue the chain down that branch
                            if (permitValue.CheckValueForKeyPermit(parsetable))
                            {
                                hasMatch = true;
                            }
                            else
                            {
#if DATAPERMIT
                                Debug.WriteLine("DBDataPermission failed branch checking");
#endif
                                return(false);
                            }
                        }
                        else   // value doesn't match to expected values - fail here
                        {
#if DATAPERMIT
                            Debug.WriteLine("DBDataPermission failed to match expected value");
#endif
                            return(false);
                        }
                    }
                    // else try next keyword
                }
                // partial chain match, either leaf-node by shorter chain or fail mid-chain if (null == _restrictions)
            }
#if DATAPERMIT
            else
            {
                Debug.WriteLine("leaf node");
            }
#endif
            DBConnectionString entry = _entry;
            if (null != entry)
            {
                return(entry.IsSubsetOf(parsetable));
            }
#if DATAPERMIT
            Debug.WriteLine("DBDataPermission failed on non-terminal node");
#endif
            return(hasMatch); // mid-chain failure
        }