-static gboolean
-mono_secman_inheritance_check (MonoClass *klass, MonoDeclSecurityActions *demands)
-{
- MonoSecurityManager* secman = mono_security_manager_get_methods ();
- MonoDomain *domain = mono_domain_get ();
- MonoAssembly *assembly = mono_image_get_assembly (klass->image);
- MonoReflectionAssembly *refass = mono_assembly_get_object (domain, assembly);
- MonoObject *res;
- gpointer args [3];
-
- args [0] = domain->domain;
- args [1] = refass;
- args [2] = demands;
-
- res = mono_runtime_invoke (secman->inheritancedemand, NULL, args, NULL);
- return (*(MonoBoolean *) mono_object_unbox (res));
-}
-
-void
-mono_secman_inheritancedemand_class (MonoClass *klass, MonoClass *parent)
-{
- MonoDeclSecurityActions demands;
-
- /* don't hide previous results -and- don't calc everything for nothing */
- if (klass->exception_type != 0)
- return;
-
- /* short-circuit corlib as it is fully trusted (within itself)
- * and because this cause major recursion headaches */
- if ((klass->image == mono_defaults.corlib) && (parent->image == mono_defaults.corlib))
- return;
-
- /* Check if there are an InheritanceDemand on the parent class */
- if (mono_declsec_get_inheritdemands_class (parent, &demands)) {
- /* If so check the demands on the klass (inheritor) */
- if (!mono_secman_inheritance_check (klass, &demands)) {
- /* Keep flags in MonoClass to be able to throw a SecurityException later (if required) */
- mono_class_set_failure (klass, MONO_EXCEPTION_SECURITY_INHERITANCEDEMAND, NULL);
- }
- }
-}
-
-void
-mono_secman_inheritancedemand_method (MonoMethod *override, MonoMethod *base)
-{
- MonoDeclSecurityActions demands;
-
- /* don't hide previous results -and- don't calc everything for nothing */
- if (override->klass->exception_type != 0)
- return;
-
- /* short-circuit corlib as it is fully trusted (within itself)
- * and because this cause major recursion headaches */
- if ((override->klass->image == mono_defaults.corlib) && (base->klass->image == mono_defaults.corlib))
- return;
-
- /* Check if there are an InheritanceDemand on the base (virtual) method */
- if (mono_declsec_get_inheritdemands_method (base, &demands)) {
- /* If so check the demands on the overriding method */
- if (!mono_secman_inheritance_check (override->klass, &demands)) {
- /* Keep flags in MonoClass to be able to throw a SecurityException later (if required) */
- mono_class_set_failure (override->klass, MONO_EXCEPTION_SECURITY_INHERITANCEDEMAND, base);
- }
- }
-}
-