Exemple #1
0
        private unsafe static bool InheritanceDemand(AppDomain ad, Assembly a, RuntimeDeclSecurityActions *actions)
        {
            bool result;

            try
            {
                bool flag = true;
                if (actions->cas.size > 0)
                {
                    PermissionSet ps = SecurityManager.Decode(actions->cas.blob, actions->cas.size);
                    flag = (SecurityManager.CheckPermissionSet(a, ps, false) == null);
                    if (flag)
                    {
                        flag = (SecurityManager.CheckPermissionSet(ad, ps) == null);
                    }
                }
                if (actions->noncas.size > 0)
                {
                    PermissionSet ps = SecurityManager.Decode(actions->noncas.blob, actions->noncas.size);
                    flag = (SecurityManager.CheckPermissionSet(a, ps, true) == null);
                    if (flag)
                    {
                        flag = (SecurityManager.CheckPermissionSet(ad, ps) == null);
                    }
                }
                result = flag;
            }
            catch (SecurityException)
            {
                result = false;
            }
            return(result);
        }
Exemple #2
0
        private unsafe static bool LinkDemand(Assembly a, RuntimeDeclSecurityActions *klass, RuntimeDeclSecurityActions *method)
        {
            bool result;

            try
            {
                bool flag = true;
                if (klass->cas.size > 0)
                {
                    PermissionSet ps = SecurityManager.Decode(klass->cas.blob, klass->cas.size);
                    flag = (SecurityManager.CheckPermissionSet(a, ps, false) == null);
                }
                if (flag && klass->noncas.size > 0)
                {
                    PermissionSet ps = SecurityManager.Decode(klass->noncas.blob, klass->noncas.size);
                    flag = (SecurityManager.CheckPermissionSet(a, ps, true) == null);
                }
                if (flag && method->cas.size > 0)
                {
                    PermissionSet ps = SecurityManager.Decode(method->cas.blob, method->cas.size);
                    flag = (SecurityManager.CheckPermissionSet(a, ps, false) == null);
                }
                if (flag && method->noncas.size > 0)
                {
                    PermissionSet ps = SecurityManager.Decode(method->noncas.blob, method->noncas.size);
                    flag = (SecurityManager.CheckPermissionSet(a, ps, true) == null);
                }
                result = flag;
            }
            catch (SecurityException)
            {
                result = false;
            }
            return(result);
        }
Exemple #3
0
        // internal - get called by the class loader

        // Called when
        // - class inheritance
        // - method overrides
        private unsafe static bool InheritanceDemand(AppDomain ad, Assembly a, RuntimeDeclSecurityActions *actions)
        {
            try
            {
                PermissionSet ps     = null;
                bool          result = true;
                if (actions->cas.size > 0)
                {
                    ps     = Decode(actions->cas.blob, actions->cas.size);
                    result = (SecurityManager.CheckPermissionSet(a, ps, false) == null);
                    if (result)
                    {
                        // also check appdomain
                        result = (SecurityManager.CheckPermissionSet(ad, ps) == null);
                    }
                }
                if (actions->noncas.size > 0)
                {
                    ps     = Decode(actions->noncas.blob, actions->noncas.size);
                    result = (SecurityManager.CheckPermissionSet(a, ps, true) == null);
                    if (result)
                    {
                        // also check appdomain
                        result = (SecurityManager.CheckPermissionSet(ad, ps) == null);
                    }
                }
                return(result);
            }
            catch (SecurityException)
            {
                return(false);
            }
        }
Exemple #4
0
        private unsafe static bool LinkDemand(Assembly a, RuntimeDeclSecurityActions *klass, RuntimeDeclSecurityActions *method)
        {
            try
            {
                PermissionSet ps     = null;
                bool          result = true;
                if (klass->cas.size > 0)
                {
                    ps     = Decode(klass->cas.blob, klass->cas.size);
                    result = (SecurityManager.CheckPermissionSet(a, ps, false) == null);
                }
                if (result && (klass->noncas.size > 0))
                {
                    ps     = Decode(klass->noncas.blob, klass->noncas.size);
                    result = (SecurityManager.CheckPermissionSet(a, ps, true) == null);
                }

                if (result && (method->cas.size > 0))
                {
                    ps     = Decode(method->cas.blob, method->cas.size);
                    result = (SecurityManager.CheckPermissionSet(a, ps, false) == null);
                }
                if (result && (method->noncas.size > 0))
                {
                    ps     = Decode(method->noncas.blob, method->noncas.size);
                    result = (SecurityManager.CheckPermissionSet(a, ps, true) == null);
                }
                return(result);
            }
            catch (SecurityException)
            {
                return(false);
            }
        }
Exemple #5
0
        internal void CheckAppDomain(AppDomain domain, SecurityFrame frame)
        {
            IPermission p = SecurityManager.CheckPermissionSet(domain, this);

            if (p != null)
            {
                CodeAccessPermission.ThrowSecurityException(this, "Demand failed appdomain permissions checks.",
                                                            frame, SecurityAction.Demand, p);
            }
        }
Exemple #6
0
        internal void CheckAssembly(Assembly a, SecurityFrame frame)
        {
            IPermission p = SecurityManager.CheckPermissionSet(a, this, false);

            if (p != null)
            {
                CodeAccessPermission.ThrowSecurityException(this, "Demand failed assembly permissions checks.",
                                                            frame, SecurityAction.Demand, p);
            }
        }