当前位置: 首页>>代码示例>>C#>>正文


C# Util.TokenBasedSet类代码示例

本文整理汇总了C#中System.Security.Util.TokenBasedSet的典型用法代码示例。如果您正苦于以下问题:C# TokenBasedSet类的具体用法?C# TokenBasedSet怎么用?C# TokenBasedSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TokenBasedSet类属于System.Security.Util命名空间,在下文中一共展示了TokenBasedSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TokenBasedSet

 internal TokenBasedSet(TokenBasedSet tbSet)
 {
     this.m_initSize = 0x18;
     this.m_increment = 8;
     if (tbSet == null)
     {
         this.Reset();
     }
     else
     {
         if (tbSet.m_cElt > 1)
         {
             object[] set = tbSet.m_Set;
             int length = set.Length;
             object[] destinationArray = new object[length];
             Array.Copy(set, 0, destinationArray, 0, length);
             this.m_Set = destinationArray;
         }
         else
         {
             this.m_Obj = tbSet.m_Obj;
         }
         this.m_cElt = tbSet.m_cElt;
         this.m_maxIndex = tbSet.m_maxIndex;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:TokenBasedSet.cs

示例2: TokenBasedSet

 public TokenBasedSet(TokenBasedSet tbSet)
 {
     if (tbSet == null)
     {
         Reset(DefaultSize, DefaultIncrement);
         return;
     }
     
     m_objSet = new Object[tbSet.m_objSet.Length];
     System.Array.Copy(tbSet.m_objSet, 0, m_objSet, 0, tbSet.m_objSet.Length);
     
     m_cElt      = tbSet.m_cElt;
     m_initSize  = tbSet.m_initSize;
     m_increment = tbSet.m_increment;
     m_maxIndex  = tbSet.m_maxIndex;
 }
开发者ID:ArildF,项目名称:masters,代码行数:16,代码来源:tokenbasedset.cs

示例3: AppendTokenBasedSets

     private void AppendTokenBasedSets( TokenBasedSet thisSet, TokenBasedSet permSet, int type, bool unrestricted )
     {
         int thisMaxIndex = thisSet.GetMaxUsedIndex();
         int permMaxIndex = permSet == null ? 0 : permSet.GetMaxUsedIndex();
         int maxIndex = thisMaxIndex > permMaxIndex ? thisMaxIndex : permMaxIndex;
         
         // Loop over the relevant indexes...
         for (int i = 0; i <= maxIndex; i++)
         {
             PermissionList plist = (PermissionList)thisSet.GetItem(i);
             CodeAccessPermission cap = permSet == null ? null : (CodeAccessPermission)permSet.GetItem(i);
             
             if (plist == null)
             {
                 if (this.m_unrestricted)
                 {
                     switch (type)
                     {
                     case PermissionList.MatchChecked:
                     case PermissionList.MatchPermitOnly:
                         plist = new PermissionList();
                         plist.AppendPermission(cap, type);
                         thisSet.SetItem( i, plist );
                         break;
                     
                     case PermissionList.MatchDeny:
                     case PermissionList.MatchAssert:
                         if (cap != null)
                         {
                             plist = new PermissionList();
                             plist.AppendPermission(cap, type);
                             thisSet.SetItem( i, plist );
                         }
                         break;
                     
                     default:
                         throw new ArgumentException(Environment.GetResourceString( "Argument_InvalidPermissionListType" ));
                     }
                 }
             }
             else
             {                    
                 // A list already exists. All lists should have at least
                 // one element in them.
 
                 // Normally, only append if the permission is not null.
                 // However, if the type is Checked, then make sure the
                 // list is terminated with a permission, null or not.
                 switch (type)
                 {
                 case PermissionList.MatchChecked:
                 case PermissionList.MatchPermitOnly:
                     plist.AppendPermissionAndCompress(cap, type);
                     break;
                         
                 case PermissionList.MatchDeny:
                 case PermissionList.MatchAssert:
                     if (cap != null)
                         plist.AppendPermissionAndCompress(cap, type);
                     break;
                         
                 default:
                     throw new ArgumentException(Environment.GetResourceString( "Argument_InvalidPermissionListType" ));
                 }
             }
         }
     }
开发者ID:ArildF,项目名称:masters,代码行数:67,代码来源:permissionlistset.cs

示例4: CheckSetDemandInternal

        public bool CheckSetDemandInternal(PermissionSet permSet, out Exception exception, bool bNeedAlteredSet, out PermissionSet alteredSet)
        {
            alteredSet = null;

            BCLDebug.Assert(permSet != null, "permSet != null");
            
            // If the compressed stack is not unrestricted and the demand is
            // then we just throw an exception.
            if (!this.m_unrestricted && permSet.IsUnrestricted())
            {
                exception = new SecurityException(Environment.GetResourceString("Security_GenericNoType") );
                return false;
            }
            
            
            TokenBasedSet normalAlteredSet = null;
            TokenBasedSet unrestrictedAlteredSet = null;

            // Check the "normal" permissions since we always know we have to check them.

            bool normalContinue = CheckTokenBasedSets( this.m_normalPermSet, permSet.m_normalPermSet, false, PermissionListSetState.None, out exception, bNeedAlteredSet, out normalAlteredSet );

            if (exception != null)
            {
                return false;
            }
            
            bool unrestrictedContinue = CheckTokenBasedSets( this.m_unrestrictedPermSet, permSet.m_unrestrictedPermSet, m_unrestricted, m_state, out exception, bNeedAlteredSet, out unrestrictedAlteredSet );

            if (exception != null)
            {
                return false;
            }

            if ((m_state & PermissionListSetState.UnrestrictedAssert) != 0)
            {
                // If we are unrestricted, we want to terminate the stack walk based
                // on us having an unrestricted assert.

                if (bNeedAlteredSet)
                    unrestrictedAlteredSet = new TokenBasedSet( 1, 4 );
                unrestrictedContinue = false;
            }

            if (normalContinue || unrestrictedContinue)
            {
                if (!bNeedAlteredSet)
                    return true;

                // If we need to continue, let's build the altered set.  We only
                // need to do this if 1) our original demand is not unrestricted
                // and 2) if we have altered token based sets.

                if (!permSet.IsUnrestricted())
                {
                    if (normalAlteredSet != null || unrestrictedAlteredSet != null)
                    {
                        alteredSet = new PermissionSet( false );

                        if (normalAlteredSet != null)
                            alteredSet.m_normalPermSet = normalAlteredSet;
                        else
                            alteredSet.m_normalPermSet = CopyTokenBasedSet( permSet.m_normalPermSet );

                        if (unrestrictedAlteredSet != null)
                            alteredSet.m_unrestrictedPermSet = unrestrictedAlteredSet;
                        else
                            alteredSet.m_unrestrictedPermSet = CopyTokenBasedSet( permSet.m_unrestrictedPermSet );

                        if (alteredSet.IsEmpty())
                            return false;
                    }
                }

                return true;
            }
            else
            {
                return false;
            }
        }
开发者ID:ArildF,项目名称:masters,代码行数:81,代码来源:permissionlistset.cs

示例5: Reset

 // Reinitializes all state in PermissionSet.
 public void Reset()
 {
     if (m_unrestrictedPermSet == null)
         m_unrestrictedPermSet = new TokenBasedSet( 12, 4 );
     else
         m_unrestrictedPermSet.Reset();
     
     if (m_normalPermSet == null)
         m_normalPermSet = new TokenBasedSet( 6, 4 );
     else
         m_normalPermSet.Reset();
     
     // By default, the PermissionListSet is unrestricted. Why?
     // At the start, having nothing on the stack should indicate success.
     // Once the first non-unrestricted grant is appended to the set,
     // then the PermissionListSet will become non-unrestricted.
     m_unrestricted = true;
     m_state = PermissionListSetState.None;
 }
开发者ID:ArildF,项目名称:masters,代码行数:20,代码来源:permissionlistset.cs

示例6: TokenBasedSetEnumerator

 public TokenBasedSetEnumerator(TokenBasedSet tb)
 {
     Index = -1;
     Current = null;
     _tb = tb;
 }
开发者ID:ChuangYang,项目名称:coreclr,代码行数:6,代码来源:TokenBasedSetEnumerator.cs

示例7: SpecialSplit

        internal void SpecialSplit(ref TokenBasedSet unrestrictedPermSet, ref TokenBasedSet normalPermSet, bool ignoreTypeLoadFailures)
        {
           int maxIndex = GetMaxUsedIndex();

            for (int i = GetStartingIndex(); i <= maxIndex; ++i)
            {
                Object obj = GetItem( i );
                if (obj != null)
                {
                    IPermission perm = obj as IPermission;
#if FEATURE_CAS_POLICY
                    if (perm == null)
                        perm = PermissionSet.CreatePerm(obj, ignoreTypeLoadFailures);
#endif // FEATURE_CAS_POLICY
                    PermissionToken token = PermissionToken.GetToken(perm);

                    if (perm == null || token == null)
                        continue;

                    if (perm is IUnrestrictedPermission)
                    {
                        // Add to unrestrictedPermSet
                        if (unrestrictedPermSet == null)
                            unrestrictedPermSet = new TokenBasedSet();
                        unrestrictedPermSet.SetItem(token.m_index, perm);
                    }
                    else
                    {
                        // Add to normalPermSet
                        if (normalPermSet == null)
                            normalPermSet = new TokenBasedSet();
                        normalPermSet.SetItem(token.m_index, perm);
                    }

                }

            }
            
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:39,代码来源:TokenBasedSet.cs

示例8: TokenBasedSet

        internal TokenBasedSet(TokenBasedSet tbSet)
        {
            if (tbSet == null)
            {
                Reset();
                return;
            }

            if (tbSet.m_cElt > 1)
            {
                Object[] aObj = tbSet.m_Set;
                int aLen = aObj.Length;
                
                Object[] aNew = new Object[aLen];
                System.Array.Copy(aObj, 0, aNew, 0, aLen);
                
                m_Set = aNew;
            }
            else
            {
                m_Obj = tbSet.m_Obj;
            }

            m_cElt      = tbSet.m_cElt;
            m_maxIndex  = tbSet.m_maxIndex;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:26,代码来源:TokenBasedSet.cs

示例9: SetData

 protected void SetData(TokenBasedSet set)
 {
     m_set = set;
     m_currentIndex = -1;
 }
开发者ID:ArildF,项目名称:masters,代码行数:5,代码来源:tokenbasedsetenumerator.cs

示例10: TokenBasedSetEnumerator

 public TokenBasedSetEnumerator(TokenBasedSet set)
 {
     SetData(set);
 }
开发者ID:ArildF,项目名称:masters,代码行数:4,代码来源:tokenbasedsetenumerator.cs

示例11: FromXml

 internal virtual void FromXml(SecurityElement et, bool allowInternalOnly, bool ignoreTypeLoadFailures)
 {
     if (et == null)
     {
         throw new ArgumentNullException("et");
     }
     if (!et.Tag.Equals("PermissionSet"))
     {
         throw new ArgumentException(string.Format(null, Environment.GetResourceString("Argument_InvalidXMLElement"), new object[] { "PermissionSet", base.GetType().FullName }));
     }
     this.Reset();
     this.m_ignoreTypeLoadFailures = ignoreTypeLoadFailures;
     this.m_allPermissionsDecoded = false;
     this.m_Unrestricted = XMLUtil.IsUnrestricted(et);
     if (et.InternalChildren != null)
     {
         int count = et.InternalChildren.Count;
         for (int i = 0; i < count; i++)
         {
             SecurityElement element = (SecurityElement) et.Children[i];
             if (IsPermissionTag(element.Tag, allowInternalOnly))
             {
                 PermissionToken token;
                 object obj2;
                 string typeStr = element.Attribute("class");
                 if (typeStr != null)
                 {
                     token = PermissionToken.GetToken(typeStr);
                     if (token == null)
                     {
                         obj2 = this.CreatePerm(element);
                         if (obj2 != null)
                         {
                             token = PermissionToken.GetToken((IPermission) obj2);
                         }
                     }
                     else
                     {
                         obj2 = element;
                     }
                 }
                 else
                 {
                     IPermission perm = this.CreatePerm(element);
                     if (perm == null)
                     {
                         token = null;
                         obj2 = null;
                     }
                     else
                     {
                         token = PermissionToken.GetToken(perm);
                         obj2 = perm;
                     }
                 }
                 if ((token != null) && (obj2 != null))
                 {
                     if (this.m_permSet == null)
                     {
                         this.m_permSet = new TokenBasedSet();
                     }
                     if (this.m_permSet.GetItem(token.m_index) != null)
                     {
                         IPermission item;
                         if (this.m_permSet.GetItem(token.m_index) is IPermission)
                         {
                             item = (IPermission) this.m_permSet.GetItem(token.m_index);
                         }
                         else
                         {
                             item = this.CreatePerm((SecurityElement) this.m_permSet.GetItem(token.m_index));
                         }
                         if (obj2 is IPermission)
                         {
                             obj2 = ((IPermission) obj2).Union(item);
                         }
                         else
                         {
                             obj2 = this.CreatePerm((SecurityElement) obj2).Union(item);
                         }
                     }
                     if (this.m_Unrestricted && (obj2 is IPermission))
                     {
                         obj2 = null;
                     }
                     this.m_permSet.SetItem(token.m_index, obj2);
                 }
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:91,代码来源:PermissionSet.cs

示例12: PermissionSet

 public PermissionSet(PermissionSet permSet) : this()
 {
     if (permSet == null)
     {
         this.Reset();
     }
     else
     {
         this.m_Unrestricted = permSet.m_Unrestricted;
         this.m_CheckedForNonCas = permSet.m_CheckedForNonCas;
         this.m_ContainsCas = permSet.m_ContainsCas;
         this.m_ContainsNonCas = permSet.m_ContainsNonCas;
         this.m_ignoreTypeLoadFailures = permSet.m_ignoreTypeLoadFailures;
         if (permSet.m_permSet != null)
         {
             this.m_permSet = new TokenBasedSet(permSet.m_permSet);
             for (int i = this.m_permSet.GetStartingIndex(); i <= this.m_permSet.GetMaxUsedIndex(); i++)
             {
                 object item = this.m_permSet.GetItem(i);
                 IPermission permission = item as IPermission;
                 ISecurityElementFactory factory = item as ISecurityElementFactory;
                 if (permission != null)
                 {
                     this.m_permSet.SetItem(i, permission.Copy());
                 }
                 else if (factory != null)
                 {
                     this.m_permSet.SetItem(i, factory.Copy());
                 }
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:33,代码来源:PermissionSet.cs

示例13: CheckSet

 internal void CheckSet()
 {
     if (this.m_permSet == null)
         this.m_permSet = new TokenBasedSet();
 }
开发者ID:l1183479157,项目名称:coreclr,代码行数:5,代码来源:PermissionSet.cs

示例14: SpecialUnion

        // Used to merge two distinct TokenBasedSets (used currently only in PermissionSet Deserialization)
        internal TokenBasedSet SpecialUnion(TokenBasedSet other)
        {
            // This gets called from PermissionSet.OnDeserialized and it's possible that the TokenBasedSets have 
            // not been subjected to VTS callbacks yet
            OnDeserializedInternal();
            TokenBasedSet unionSet = new TokenBasedSet();
            int maxMax;
            if (other != null)
            {
                other.OnDeserializedInternal();
                maxMax = this.GetMaxUsedIndex() > other.GetMaxUsedIndex() ? this.GetMaxUsedIndex() : other.GetMaxUsedIndex();
            }
            else
                maxMax = this.GetMaxUsedIndex();
        
            for (int i = 0; i <= maxMax; ++i)
            {
                Object thisObj = this.GetItem( i );
                IPermission thisPerm = thisObj as IPermission;
#if FEATURE_CAS_POLICY
                ISecurityElementFactory thisElem = thisObj as ISecurityElementFactory;
#endif // FEATURE_CAS_POLICY

                Object otherObj = (other != null)?other.GetItem( i ):null;
                IPermission otherPerm = otherObj as IPermission;
#if FEATURE_CAS_POLICY
                ISecurityElementFactory otherElem = otherObj as ISecurityElementFactory;
#endif // FEATURE_CAS_POLICY

                if (thisObj == null && otherObj == null)
                    continue;
        
             
                if (thisObj == null)
                {
#if FEATURE_CAS_POLICY
                    if (otherElem != null)
                    {
                        otherPerm = PermissionSet.CreatePerm(otherElem, false);
                    }
#endif // FEATURE_CAS_POLICY

                    PermissionToken token = PermissionToken.GetToken(otherPerm);
                    
                    if (token == null)
                    {
                        throw new SerializationException(Environment.GetResourceString("Serialization_InsufficientState"));
                    }
                    
                    unionSet.SetItem(token.m_index, otherPerm);
                }
                else if (otherObj == null)
                {
#if FEATURE_CAS_POLICY
                    if (thisElem != null)
                    {
                        thisPerm = PermissionSet.CreatePerm(thisElem, false);
                    }
#endif // FEATURE_CAS_POLICY

                    PermissionToken token = PermissionToken.GetToken(thisPerm);
                    if (token == null)
                    {
                        throw new SerializationException(Environment.GetResourceString("Serialization_InsufficientState"));
                    }
                    unionSet.SetItem( token.m_index, thisPerm);
                }
                else
                {
                    Contract.Assert( (thisObj == null || otherObj == null), "Permission cannot be in both TokenBasedSets" );
                }
            }
            return unionSet;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:75,代码来源:TokenBasedSet.cs

示例15: CheckTokenBasedSetHelper

        private static void CheckTokenBasedSetHelper( bool ignoreGrants,
                                                      TokenBasedSet grants,
                                                      TokenBasedSet denied,
                                                      TokenBasedSet demands )
        {
            if (demands == null)
                return;

            TokenBasedSetEnumerator enumerator = (TokenBasedSetEnumerator)demands.GetEnum();
            
            while (enumerator.MoveNext())
            {
                CodeAccessPermission demand = (CodeAccessPermission)enumerator.Current;
                int index = enumerator.GetCurrentIndex();

                if (demand != null)
                {
                    try
                    {
                        // Check to make sure the permission was granted, unless we are supposed
                        // to ignore grants.
                    
                        if (!ignoreGrants)
                        {
                            CodeAccessPermission grant
                                = grants != null ? (CodeAccessPermission)grants.GetItem(index) : null;
                            if (grant != null)
                            {
                                grant.CheckDemand(demand);
                            }
                            else
                            {
                                if (!demand.IsSubsetOf( null ))
                                    throw new SecurityException(String.Format(Environment.GetResourceString("Security_Generic"), demand.GetType().AssemblyQualifiedName), demand.GetType(), demand.ToXml().ToString());
                            }
                        }
                    
                        // Check to make sure our permission was not denied.
                
                        if (denied != null)
                        {
                            CodeAccessPermission deny
                                = (CodeAccessPermission)denied.GetItem(index);
                            if (deny != null && deny.Intersect(demand) != null)
                                throw new SecurityException(String.Format(Environment.GetResourceString("Security_Generic"), demand.GetType().AssemblyQualifiedName), demand.GetType(), demand.ToXml().ToString());
                        }
                    }
                    catch (Exception e)
                    {
                        // Any exception besides a security exception in this code means that
                        // a permission was unable to properly handle what we asked of it.
                        // We will define this to mean that the demand failed.
                        
                        if (e is SecurityException)
                            throw e;
                        else
                            throw new SecurityException(String.Format(Environment.GetResourceString("Security_Generic"), demand.GetType().AssemblyQualifiedName), demand.GetType(), demand.ToXml().ToString());
                    }                                
                }
            }
        }
开发者ID:ArildF,项目名称:masters,代码行数:61,代码来源:codeaccesssecurityengine.cs


注:本文中的System.Security.Util.TokenBasedSet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。