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


C# IPermission.IsSubsetOf方法代码示例

本文整理汇总了C#中IPermission.IsSubsetOf方法的典型用法代码示例。如果您正苦于以下问题:C# IPermission.IsSubsetOf方法的具体用法?C# IPermission.IsSubsetOf怎么用?C# IPermission.IsSubsetOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPermission的用法示例。


在下文中一共展示了IPermission.IsSubsetOf方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsGranted

		// note: in 2.0 *all* permissions (including identity permissions) support unrestricted
		internal static bool IsGranted (Assembly a, IPermission perm)
		{
			PermissionSet granted = a.GrantedPermissionSet;
			if ((granted != null) && !granted.IsUnrestricted ()) {
				CodeAccessPermission grant = (CodeAccessPermission) granted.GetPermission (perm.GetType ());
				if (!perm.IsSubsetOf (grant)) {
					return false;
				}
			}

			PermissionSet denied = a.DeniedPermissionSet;
			if ((denied != null) && !denied.IsEmpty ()) {
				if (denied.IsUnrestricted ())
					return false;
				CodeAccessPermission refuse = (CodeAccessPermission) a.DeniedPermissionSet.GetPermission (perm.GetType ());
				if ((refuse != null) && perm.IsSubsetOf (refuse))
					return false;
			}
			return true;
		}
开发者ID:shana,项目名称:mono,代码行数:21,代码来源:SecurityManager.cs

示例2: Contains

        // Returns true if perm is contained in this
        internal bool Contains(IPermission perm)
        {
            if (perm == null)
                return true;
            if (m_Unrestricted)
                return true;
            if (FastIsEmpty())
                return false;

            PermissionToken token = PermissionToken.GetToken(perm);
            Object thisObj = this.m_permSet.GetItem( token.m_index );
            if (thisObj == null)
                return perm.IsSubsetOf( null );

            IPermission thisPerm = GetPermission(token.m_index);
            if (thisPerm != null)
                return perm.IsSubsetOf( thisPerm );
            else
                return perm.IsSubsetOf( null );
        }
开发者ID:l1183479157,项目名称:coreclr,代码行数:21,代码来源:PermissionSet.cs

示例3: IsGranted

 public static bool IsGranted(this IRole role, IPermission permission) {
     var permissionSet = new PermissionSet(PermissionState.None);
     role.Permissions.Each(perm => permissionSet.AddPermission(perm));
     var getPermission = permissionSet.GetPermission(typeof(ObjectAccessPermission));
     return getPermission != null && permission.IsSubsetOf(getPermission);
 }
开发者ID:jdraith1,项目名称:eXpand,代码行数:6,代码来源:SecuritySystemExtensions.cs

示例4: FrameDescHelper

     private static bool FrameDescHelper(FrameSecurityDescriptor secDesc,
                                            IPermission demand, 
                                            PermissionToken permToken)
     {
         PermissionSet permSet;
         
         // If the demand is null, there is no need to continue
         if (demand == null || demand.IsSubsetOf( null ))
             return StackHalt;
             
         // NOTE: See notes about exceptions and exception handling in FrameDescSetHelper 
         
         // Check Reduction
         
         try
         {
             permSet = secDesc.GetPermitOnly();
             if (permSet != null)
             {
                 IPermission perm = permSet.GetPermission(demand);
 #if _DEBUG
                 if (debug)
                 {
                     DEBUG_OUT("Checking PermitOnly");
                     DEBUG_OUT("permit only set =\n" + permSet.ToXml().ToString() );
                     DEBUG_OUT("demand =\n" + ((CodeAccessPermission)demand).ToXml().ToString() );
                 }
 #endif
         
                 // If the permit only set does not contain the demanded permission, throw a security exception
                 
                 if (perm == null)
                 {
                     if(!(demand is IUnrestrictedPermission && permSet.IsUnrestricted()))
                         throw new SecurityException(String.Format(Environment.GetResourceString("Security_Generic"), demand.GetType().AssemblyQualifiedName), demand.GetType(), demand.ToXml().ToString());
                 }
                 else
                 {
                     if (!demand.IsSubsetOf( perm ))
                         throw new SecurityException(String.Format(Environment.GetResourceString("Security_Generic"), demand.GetType().AssemblyQualifiedName), demand.GetType(), demand.ToXml().ToString());
                 }
             }
         }
         catch (Exception)
         {
             throw new SecurityException(String.Format(Environment.GetResourceString("Security_Generic"), demand.GetType().AssemblyQualifiedName), demand.GetType(), demand.ToXml().ToString());
         }
         
         
         // Check Denials
         
         try
         {
             permSet = secDesc.GetDenials();
             if (permSet != null)
             {
 #if _DEBUG
                 if (debug)
                 {
                     DEBUG_OUT("Checking Denials");
                     DEBUG_OUT("denied set =\n" + permSet.ToXml().ToString() );
                 }
 #endif
                 IPermission perm = permSet.GetPermission(demand);
                 
                 // If the deny set does contain the demanded permission, throw a security exception
         
                 if ((perm != null && perm.Intersect( demand ) != null) || (demand is IUnrestrictedPermission && permSet.IsUnrestricted()))
                     throw new SecurityException(String.Format(Environment.GetResourceString("Security_Generic"), demand.GetType().AssemblyQualifiedName), demand.GetType(), demand.ToXml().ToString());
             }
         }
         catch (Exception)
         {
             throw new SecurityException(String.Format(Environment.GetResourceString("Security_Generic"), demand.GetType().AssemblyQualifiedName), demand.GetType(), demand.ToXml().ToString());
         }                
 
         if (secDesc.GetAssertAllPossible())
         {
             return StackHalt;
         }        
 
         try
         {
             permSet = secDesc.GetAssertions();
             // Check Assertions
             if (permSet != null)
             {
 #if _DEBUG
                 if (debug)
                     DEBUG_OUT("Checking Assertions");
 #endif
         
                 IPermission perm = permSet.GetPermission(demand);
             
                 // If the assert set does contain the demanded permission, halt the stackwalk
         
                 if ((perm != null && (demand.IsSubsetOf( perm )) || (demand is IUnrestrictedPermission && permSet.IsUnrestricted())))
                 {
 #if _DEBUG
                     if (debug)
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:securityruntime.cs

示例5: Contains

 internal bool Contains(IPermission perm)
 {
     if (perm == null)
     {
         return true;
     }
     if (this.m_Unrestricted)
     {
         return true;
     }
     if (this.FastIsEmpty())
     {
         return false;
     }
     PermissionToken token = PermissionToken.GetToken(perm);
     if (this.m_permSet.GetItem(token.m_index) != null)
     {
         IPermission target = this.GetPermission(token.m_index);
         if (target != null)
         {
             return perm.IsSubsetOf(target);
         }
     }
     return perm.IsSubsetOf(null);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:PermissionSet.cs

示例6: Contains

        // Returns true if perm is contained in this
        internal virtual bool Contains(IPermission perm)
        {
            if (perm == null)
                return true;
            
            if (m_Unrestricted && perm is IUnrestrictedPermission)
            {
                return true;
            }
    
            PermissionToken token = PermissionToken.GetToken(perm);
            IPermission p;
            
            if (token.m_isUnrestricted)
            {
                if (m_unrestrictedPermSet == null)
                    return perm.IsSubsetOf( null );

                p = (IPermission)m_unrestrictedPermSet.GetItem( token.m_index );
            }
            else
            {
                if (m_normalPermSet == null)
                    return perm.IsSubsetOf( null );

                p = (IPermission)m_normalPermSet.GetItem( token.m_index );
            }

            return perm.IsSubsetOf(p);
        }
开发者ID:ArildF,项目名称:masters,代码行数:31,代码来源:permissionset.cs

示例7: Union

	public override IPermission Union(IPermission target)
			{
				if(target == null)
				{
					return Copy();
				}
				else if(!(target is StrongNameIdentityPermission))
				{
					throw new ArgumentException(_("Arg_PermissionMismatch"));
				}
				else if(IsSubsetOf(target))
				{
					return target.Copy();
				}
				else if(target.IsSubsetOf(this))
				{
					return Copy();
				}
				else
				{
					return null;
				}
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:23,代码来源:StrongNameIdentityPermission.cs

示例8: Intersect

	public override IPermission Intersect(IPermission target)
			{
				if(target == null)
				{
					return target;
				}
				else if(!(target is PublisherIdentityPermission))
				{
					throw new ArgumentException(_("Arg_PermissionMismatch"));
				}
				else if(IsSubsetOf(target))
				{
					return Copy();
				}
				else if(target.IsSubsetOf(this))
				{
					return target.Copy();
				}
				else
				{
					return null;
				}
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:23,代码来源:PublisherIdentityPermission.cs


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