• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Security.CodeAccessPermission类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: CheckAssembly

 internal static void CheckAssembly(RuntimeAssembly asm, CodeAccessPermission demand)
 {
     PermissionSet set;
     PermissionSet set2;
     asm.GetGrantSet(out set, out set2);
     CheckHelper(set, set2, demand, PermissionToken.GetToken(demand), RuntimeMethodHandleInternal.EmptyHandle, asm, SecurityAction.Demand, true);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:CodeAccessSecurityEngine.cs


示例2: CheckDemand

		internal bool CheckDemand (CodeAccessPermission target)
		{
			if (target == null)
				return false;
			if (target.GetType () != this.GetType ())
				return false;
			return IsSubsetOf (target);
		}
开发者ID:runefs,项目名称:Marvin,代码行数:8,代码来源:CodeAccessPermission.cs


示例3: CheckAssert

		internal bool CheckAssert (CodeAccessPermission asserted)
		{
			if (asserted == null)
				return false;
			if (asserted.GetType () != this.GetType ())
				return false;
			return IsSubsetOf (asserted);
		}
开发者ID:runefs,项目名称:Marvin,代码行数:8,代码来源:CodeAccessPermission.cs


示例4: CheckDemand

 internal bool CheckDemand(CodeAccessPermission demand, PermissionToken permToken, RuntimeMethodHandleInternal rmh)
 {
     if (!CheckAssert(this.AssertSet, demand, permToken))
     {
         return false;
     }
     CodeAccessSecurityEngine.CheckHelper(this.GrantSet, this.RefusedSet, demand, permToken, rmh, null, SecurityAction.Demand, true);
     return true;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:PermissionSetTriple.cs


示例5: CheckDemand

 internal bool CheckDemand(CodeAccessPermission demand, PermissionToken permToken, RuntimeMethodHandle rmh)
 {
     this.CompleteConstruction(null);
     if (this.PLS != null)
     {
         this.PLS.CheckDemand(demand, permToken, rmh);
     }
     return false;
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:9,代码来源:CompressedStack.cs


示例6: CheckDemandNoThrow

 internal bool CheckDemandNoThrow(CodeAccessPermission demand)
 {
     PermissionToken permToken = null;
     if (demand != null)
     {
         permToken = PermissionToken.GetToken(demand);
     }
     return this.m_firstPermSetTriple.CheckDemandNoThrow(demand, permToken);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:PermissionListSet.cs


示例7: CheckDemand

 internal bool CheckDemand(CodeAccessPermission demand, PermissionToken permToken, RuntimeMethodHandleInternal rmh)
 {
     bool flag = this.CheckDemand2(demand, permToken, rmh, false);
     if (flag)
     {
         flag = this.CheckDemand2(demand, permToken, rmh, true);
     }
     return flag;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:FrameSecurityDescriptor.cs


示例8: CheckDeny

 internal bool CheckDeny(CodeAccessPermission denied)
 {
     IPermission permission = this.Intersect(denied);
     if (permission != null)
     {
         return permission.IsSubsetOf(null);
     }
     return true;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:CodeAccessPermission.cs


示例9: IsPermissionGranted

 internal static bool IsPermissionGranted(CodeAccessPermission requestedPermission)
 {
     try
     {
         // Try and get this permission
         requestedPermission.Demand();
         return true;
     }
     catch
     {
         return false;
     }
 }
开发者ID:mdjabirov,项目名称:C1Decompiled,代码行数:13,代码来源:MainWindow.xaml.cs


示例10: CheckUnrestricted

     // Returns true if OK to return from check, or false if
     // permission-specific information must be checked.
     internal static bool CheckUnrestricted(IUnrestrictedPermission grant, CodeAccessPermission demand)
     {
         // We return true here because we're defining a demand of null to
         // automatically pass.
         if (demand == null)
             return true;
 
         if (demand.GetType() != grant.GetType())
             return false;
         if (grant.IsUnrestricted())
             return true;
         if (((IUnrestrictedPermission)demand).IsUnrestricted())
             throw new SecurityException(String.Format(Environment.GetResourceString("Security_Generic"), demand.GetType().FullName), demand.GetType(), demand.ToXml().ToString());
         return false;
     } 
开发者ID:ArildF,项目名称:masters,代码行数:17,代码来源:unrestrictedpermission.cs


示例11: CheckDeny

		internal bool CheckDeny (CodeAccessPermission denied)
		{
			if (denied == null)
				return true;
			Type t = denied.GetType ();
			if (t != this.GetType ())
				return true;
			IPermission inter = Intersect (denied);
			if (inter == null)
				return true;
			// sadly that's not enough :( at this stage we must also check
			// if an empty (PermissionState.None) is a subset of the denied
			// (which is like a empty intersection looks like for flag based
			// permissions, e.g. AspNetHostingPermission).
			return denied.IsSubsetOf (PermissionBuilder.Create (t));
		}
开发者ID:runefs,项目名称:Marvin,代码行数:16,代码来源:CodeAccessPermission.cs


示例12: CheckDemand

 internal bool CheckDemand(CodeAccessPermission demand, PermissionToken permToken, RuntimeMethodHandleInternal rmh)
 {
     bool flag = true;
     if (this.m_permSetTriples != null)
     {
         for (int i = 0; (i < this.m_permSetTriples.Count) && flag; i++)
         {
             flag = ((PermissionSetTriple) this.m_permSetTriples[i]).CheckDemand(demand, permToken, rmh);
         }
     }
     else if (this.m_firstPermSetTriple != null)
     {
         flag = this.m_firstPermSetTriple.CheckDemand(demand, permToken, rmh);
     }
     return false;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:16,代码来源:PermissionListSet.cs


示例13: Assert

 internal static void Assert(CodeAccessPermission cap, ref StackCrawlMark stackMark)
 {
     FrameSecurityDescriptor descriptor = CheckNReturnSO(AssertPermissionToken, AssertPermission, ref stackMark, 1);
     if (descriptor == null)
     {
         Environment.FailFast(Environment.GetResourceString("ExecutionEngine_MissingSecurityDescriptor"));
     }
     else
     {
         if (descriptor.HasImperativeAsserts())
         {
             throw new SecurityException(Environment.GetResourceString("Security_MustRevertOverride"));
         }
         descriptor.SetAssert(cap);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:16,代码来源:CodeAccessSecurityEngine.cs


示例14: CheckAssert

 private static bool CheckAssert(PermissionSet pSet, CodeAccessPermission demand, PermissionToken permToken)
 {
     if (pSet != null)
     {
         pSet.CheckDecoded(demand, permToken);
         CodeAccessPermission asserted = (CodeAccessPermission) pSet.GetPermission(demand);
         try
         {
             if (pSet.IsUnrestricted() || demand.CheckAssert(asserted))
             {
                 return false;
             }
         }
         catch (ArgumentException)
         {
         }
     }
     return true;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:19,代码来源:PermissionSetTriple.cs


示例15: CheckDemandNoThrow

        [System.Security.SecurityCritical]  // auto-generated
        internal bool CheckDemandNoThrow(CodeAccessPermission demand) 
        {
            // AppDomain permissions - no asserts. So there should only be one triple to work with 
            Contract.Assert(m_permSetTriples == null && m_firstPermSetTriple != null, "More than one PermissionSetTriple encountered in AD PermissionListSet"); 

 

            PermissionToken permToken = null;
            if (demand != null)
                permToken = PermissionToken.GetToken(demand); 

            return m_firstPermSetTriple.CheckDemandNoThrow(demand, permToken); 
 

        } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:16,代码来源:PermissionListSet.cs


示例16: AddPermission

 public void AddPermission(CodeAccessPermission perm, int type)
 {
     //BCLDebug.Assert(type == MatchAssert || type == MatchDeny, "type == MatchAssert || type == MatchDeny");
     
     // can't get token if perm is null
     if (perm == null)
         return;
     
     PermissionToken permToken = PermissionToken.GetToken(perm);
     PermissionList plist = GetListForToken(permToken, true);
     plist.AppendPermission(perm, type);
 }
开发者ID:ArildF,项目名称:masters,代码行数:12,代码来源:permissionlistset.cs


示例17: CheckDemandNoThrow

        internal bool CheckDemandNoThrow(CodeAccessPermission demand, PermissionToken permToken)
        {
            Exception exception;

            CheckDemandInternal( demand, permToken, out exception );

            return (exception == null);
        }
开发者ID:ArildF,项目名称:masters,代码行数:8,代码来源:permissionlistset.cs


示例18: CheckDemand

        internal bool CheckDemand(CodeAccessPermission demand, PermissionToken permToken)
        {
            Exception exception;

            bool cont = CheckDemandInternal( demand, permToken, out exception );

            if (exception != null)
            {
                throw exception;
            }

            return cont;
        }
开发者ID:ArildF,项目名称:masters,代码行数:13,代码来源:permissionlistset.cs


示例19: CheckHelper

        [System.Security.SecurityCritical]  // auto-generated
#pragma warning disable 618
        internal static bool CheckHelper(PermissionSet grantedSet,
#pragma warning restore 618
                                        PermissionSet refusedSet,
                                        CodeAccessPermission demand, 
                                        PermissionToken permToken,
                                        RuntimeMethodHandleInternal rmh,
                                        Object assemblyOrString,
                                        SecurityAction action,
                                        bool throwException)
        {
            // We should never get here with a null demand
            Contract.Assert(demand != null, "Should not reach here with a null demand");
            
#if _DEBUG && FEATURE_CAS_POLICY
            if (debug)
            {
                DEBUG_OUT("Granted: ");
                DEBUG_OUT(grantedSet.ToXml().ToString());
                DEBUG_OUT("Refused: ");
                DEBUG_OUT(refusedSet != null ? refusedSet.ToXml().ToString() : "<null>");
                DEBUG_OUT("Demanded: ");
                DEBUG_OUT(demand.ToString());
            }
#endif // _DEBUG && FEATURE_CAS_POLICY

            if (permToken == null)
                permToken = PermissionToken.GetToken(demand);

            if (grantedSet != null)
                grantedSet.CheckDecoded(permToken.m_index);
            if (refusedSet != null)
                refusedSet.CheckDecoded(permToken.m_index);

            // If PermissionSet is null, then module does not have Permissions... Fail check.

            bool bThreadSecurity = SecurityManager._SetThreadSecurity(false);

            try
            {
                if (grantedSet == null)
                {
                    if (throwException)
                        ThrowSecurityException(assemblyOrString, grantedSet, refusedSet, rmh, action, demand, demand);
                    else
                        return false;
                }
                
                else if (!grantedSet.IsUnrestricted())
                {
                    // If we aren't unrestricted, there is a refused set, or our permission is not of the unrestricted
                    // variety, we need to do the proper callback.

                    Contract.Assert(demand != null,"demand != null");

                    // Find the permission of matching type in the permission set.

                    CodeAccessPermission grantedPerm = 
                                (CodeAccessPermission)grantedSet.GetPermission(permToken);

                    // Make sure the demand has been granted
                    if (!demand.CheckDemand( grantedPerm ))
                    {
                        if (throwException)
                            ThrowSecurityException(assemblyOrString, grantedSet, refusedSet, rmh, action, demand, demand);
                        else
                            return false;
                    }
                }

                // Make the sure the permission is not refused.

                if (refusedSet != null)
                {
                    CodeAccessPermission refusedPerm = 
                        (CodeAccessPermission)refusedSet.GetPermission(permToken);
                    if (refusedPerm != null)
                    {
                        if (!refusedPerm.CheckDeny(demand))
                        {
        #if _DEBUG
                            if (debug)
                                DEBUG_OUT( "Permission found in refused set" );
        #endif
                                if (throwException)
                                    ThrowSecurityException(assemblyOrString, grantedSet, refusedSet, rmh, action, demand, demand);
                                else
                                    return false;

                        }
                    }

                    if (refusedSet.IsUnrestricted())
                    {
                        if (throwException)
                            ThrowSecurityException(assemblyOrString, grantedSet, refusedSet, rmh, action, demand, demand);
                        else
                            return false;
                    }
//.........这里部分代码省略.........
开发者ID:uQr,项目名称:referencesource,代码行数:101,代码来源:codeaccesssecurityengine.cs


示例20: PermitOnly

        [System.Security.SecurityCritical]  // auto-generated
        internal static void PermitOnly(CodeAccessPermission cap, ref StackCrawlMark stackMark)
        {
            FrameSecurityDescriptor secObj =
                SecurityRuntime.GetSecurityObjectForFrame(ref stackMark, true);
            if (secObj == null)
            {
                // Security: REQ_SQ flag is missing. Bad compiler ?
                // This can happen when you create delegates over functions that need the REQ_SQ 
                System.Environment.FailFast(Environment.GetResourceString("ExecutionEngine_MissingSecurityDescriptor"));
            }
            else
            {
                if (secObj.HasImperativeRestrictions())
                    throw new SecurityException( Environment.GetResourceString( "Security_MustRevertOverride" ) );

                secObj.SetPermitOnly(cap);
            }
        }
开发者ID:uQr,项目名称:referencesource,代码行数:19,代码来源:codeaccesssecurityengine.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Security.NamedPermissionSet类代码示例发布时间:2022-05-26
下一篇:
C# Json.XmlObjectSerializerReadContextComplexJson类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap