internal virtual void CheckImmediate(PermissionSet permSet, ref StackCrawlMark stackMark)
        {
            if (PreCheck(null, permSet, CHECK_SET, ref stackMark, PermissionType.DefaultFlag) == true)
            {
                return;
            }

            CheckSet(permSet,
                     ref stackMark,
                     ImmediateCheckCount,
                     permSet.CanUnrestrictedOverride());
        }
        private static void LazyCheckSetHelper(PermissionSet demands, IntPtr asmSecDesc)
        {
            if (demands.CanUnrestrictedOverride() == 1)
            {
                return;
            }

            PermissionSet grants;
            PermissionSet denied;

            _GetGrantedPermissionSet(asmSecDesc, out grants, out denied);

            CheckSetHelper(grants, denied, demands);
        }
        private static void LazyCheckSetHelper(PermissionSet demands,
                                               IntPtr asmSecDesc,
                                               RuntimeMethodHandle rmh,
                                               Assembly assembly,
                                               SecurityAction action)
        {
            if (demands.CanUnrestrictedOverride())
            {
                return;
            }

            PermissionSet grants;
            PermissionSet refused;

            _GetGrantedPermissionSet(asmSecDesc, out grants, out refused);

            CheckSetHelper(grants, refused, demands, rmh, (Object)assembly, action, true);
        }
Exemplo n.º 4
0
        internal virtual void CheckImmediate(PermissionSet permSet, ref StackCrawlMark stackMark)
        {
            if (PreCheck(null, permSet, CHECK_SET, ref stackMark, PermissionType.DefaultFlag) == true)
                return;

            CheckSet(permSet,
                     ref stackMark,
                     ImmediateCheckCount,
                     permSet.CanUnrestrictedOverride() );
        }
Exemplo n.º 5
0
        // true - Check passes
        // false - Check may fail, do a stackwalk
		// It may look like we dont need three arguments here, but this is being done to 
		// avoid "is instance of" checks and casting
        private bool PreCheck(  CodeAccessPermission permObj, 
                                PermissionSet permSetObj, 
                                int capOrSet, 
                                ref StackCrawlMark stackMark,
                                PermissionType permType)
        {
            //return false;
            int status=0;
            PermissionListSet psl;
            if (capOrSet == CHECK_CAP)
                psl = GetDomainPermissionListSet(out status, permObj, capOrSet, permType);
            else
                psl = GetDomainPermissionListSet(out status, permSetObj, capOrSet, permType);

            if (status == NEED_UPDATED_PLS)
                psl = UpdateDomainPermissionListSet(out status);

			if (status == DEMAND_PASSES || status == SECURITY_OFF)
				return true;

            if (status == FULLY_TRUSTED)
            {
                if (capOrSet == CHECK_CAP)
                {
                    if (permObj is IUnrestrictedPermission)
                        return true;
                }
                else
                {
                    if (permSetObj.CanUnrestrictedOverride() == 1)
                        return true;
                }
            }

            if (status == CONTINUE || status == FULLY_TRUSTED)
			{
                if (capOrSet == CHECK_CAP)
                    return psl.CheckDemandNoThrow( permObj );
                else
                    return psl.CheckSetDemandNoThrow( permSetObj );
			}

            if (status == PLS_IS_BUSY)
                return false;

            if (status == BELOW_THRESHOLD) 
                return false;

            if (status == MULTIPLE_DOMAINS)
                return false;

            if (status == OVERRIDES_FOUND)
            {
                UpdateOverridesCount(ref stackMark); 
                return false;
            }

            if (status == NEED_STACKWALK)
                return false;
                
            BCLDebug.Assert(false,"Unexpected status from GetDomainPermissionListSet");
            return false;
        }
Exemplo n.º 6
0
        private static void LazyCheckSetHelper( PermissionSet demands, IntPtr asmSecDesc )
        {
            if (demands.CanUnrestrictedOverride() == 1)
                return;

            PermissionSet grants;
            PermissionSet denied;

            _GetGrantedPermissionSet( asmSecDesc, out grants, out denied );

            CheckSetHelper( grants, denied, demands );
        }
        // true - Check passes
        // false - Check may fail, do a stackwalk
        // It may look like we dont need three arguments here, but this is being done to
        // avoid "is instance of" checks and casting
        private bool PreCheck(CodeAccessPermission permObj,
                              PermissionSet permSetObj,
                              int capOrSet,
                              ref StackCrawlMark stackMark,
                              PermissionType permType)
        {
            //return false;
            int status = 0;
            PermissionListSet psl;

            if (capOrSet == CHECK_CAP)
            {
                psl = GetDomainPermissionListSet(out status, permObj, capOrSet, permType);
            }
            else
            {
                psl = GetDomainPermissionListSet(out status, permSetObj, capOrSet, permType);
            }

            if (status == NEED_UPDATED_PLS)
            {
                psl = UpdateDomainPermissionListSet(out status);
            }

            if (status == DEMAND_PASSES || status == SECURITY_OFF)
            {
                return(true);
            }

            if (status == FULLY_TRUSTED)
            {
                if (capOrSet == CHECK_CAP)
                {
                    if (permObj is IUnrestrictedPermission)
                    {
                        return(true);
                    }
                }
                else
                {
                    if (permSetObj.CanUnrestrictedOverride() == 1)
                    {
                        return(true);
                    }
                }
            }

            if (status == CONTINUE || status == FULLY_TRUSTED)
            {
                if (capOrSet == CHECK_CAP)
                {
                    return(psl.CheckDemandNoThrow(permObj));
                }
                else
                {
                    return(psl.CheckSetDemandNoThrow(permSetObj));
                }
            }

            if (status == PLS_IS_BUSY)
            {
                return(false);
            }

            if (status == BELOW_THRESHOLD)
            {
                return(false);
            }

            if (status == MULTIPLE_DOMAINS)
            {
                return(false);
            }

            if (status == OVERRIDES_FOUND)
            {
                UpdateOverridesCount(ref stackMark);
                return(false);
            }

            if (status == NEED_STACKWALK)
            {
                return(false);
            }

            BCLDebug.Assert(false, "Unexpected status from GetDomainPermissionListSet");
            return(false);
        }
        private static void LazyCheckSetHelper(PermissionSet demands,
                                               IntPtr asmSecDesc,
                                               RuntimeMethodHandle rmh,
                                               Assembly assembly,
                                               SecurityAction action)
        {
            if (demands.CanUnrestrictedOverride())
                return;

            PermissionSet grants;
            PermissionSet refused;

            _GetGrantedPermissionSet( asmSecDesc, out grants, out refused );

            CheckSetHelper( grants, refused, demands, rmh, (Object)assembly, action, true );
        }