[System.Security.SecurityCritical]  // auto-generated
        private void LoadAllPermissionSets()
        {
            // This function loads all the permission sets held in the m_permSetElement member.
            // This is useful when you know that an arbitrary permission set loaded from
            // the config file could be accessed so you just want to forego the lazy load
            // and play it safe.

            if (m_permSetElement != null && m_permSetElement.InternalChildren != null) {
                lock (InternalSyncObject) {
                    while (m_permSetElement != null && m_permSetElement.InternalChildren.Count != 0) {
                        SecurityElement elPermSet = (SecurityElement)m_permSetElement.Children[m_permSetElement.InternalChildren.Count-1];
                        m_permSetElement.InternalChildren.RemoveAt(m_permSetElement.InternalChildren.Count-1);

                        if (elPermSet.Tag.Equals("PermissionSet") && elPermSet.Attribute("class").Equals("System.Security.NamedPermissionSet")) {
                            NamedPermissionSet permSet = new NamedPermissionSet();
                            permSet.FromXmlNameOnly(elPermSet);

                            if (permSet.Name != null) {
                                m_namedPermissionSets.Add(permSet);
                                try {
                                    permSet.FromXml(elPermSet, false, true);
                                }
                                catch {
                                    m_namedPermissionSets.Remove(permSet);
                                }
                            }
                        }
                    }

                    m_permSetElement = null;
                }
            }
        }
Beispiel #2
0
        private void LoadAllPermissionSets()
        {
            // This function loads all the permission sets held in the m_permSetElement member.
            // This is useful when you know that an arbitrary permission set loaded from
            // the config file could be accessed so you just want to forego the lazy load
            // and play it safe.
        
            if (m_permSetElement != null && m_permSetElement.m_lChildren != null)
            {
                Type type = typeof( PolicyLevel );

                lock (type)
                {
                    while (m_permSetElement != null && m_permSetElement.m_lChildren.Count != 0)
                    {
                        SecurityElement elPermSet = (SecurityElement)m_permSetElement.m_lChildren[m_permSetElement.m_lChildren.Count-1];
                        m_permSetElement.m_lChildren.RemoveAt( m_permSetElement.m_lChildren.Count-1 );
                
                        if (elPermSet.Tag.Equals( "PermissionSet" ) && elPermSet.Attribute( "class" ).Equals( "System.Security.NamedPermissionSet" ))
                        {
                            NamedPermissionSet permSet = new NamedPermissionSet();
                            permSet.FromXmlNameOnly( elPermSet );

                            if (permSet.Name != null)
                            {
                                m_namedPermissionSets.Add( permSet );
                                try
                                {
                                    // We play it conservative here and just say that we are loading policy
                                    // anytime we have to decode a permission set.
                                    bool fullyLoaded;
                                    permSet.FromXml( elPermSet, true, out fullyLoaded );
                                }
                                catch (Exception)
                                {
                                    m_namedPermissionSets.Remove( permSet );
                                }
                            }
                        }
                    }
        
                    m_permSetElement = null;
                }
            }
        }