internal bool CheckDemand(CodeAccessPermission target)
 {
     if (target == null)
     {
         return(false);
     }
     if (target.GetType() != this.GetType())
     {
         return(false);
     }
     return(IsSubsetOf(target));
 }
 internal bool CheckAssert(CodeAccessPermission asserted)
 {
     if (asserted == null)
     {
         return(false);
     }
     if (asserted.GetType() != this.GetType())
     {
         return(false);
     }
     return(IsSubsetOf(asserted));
 }
示例#3
0
        // 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);
        }
        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)));
        }