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); }
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); }
internal unsafe static void ReflectedLinkDemandInvoke(MethodBase mb) { RuntimeDeclSecurityActions runtimeDeclSecurityActions; RuntimeDeclSecurityActions runtimeDeclSecurityActions2; if (!SecurityManager.GetLinkDemandSecurity(mb, &runtimeDeclSecurityActions, &runtimeDeclSecurityActions2)) { return; } PermissionSet permissionSet = null; if (runtimeDeclSecurityActions.cas.size > 0) { permissionSet = SecurityManager.Decode(runtimeDeclSecurityActions.cas.blob, runtimeDeclSecurityActions.cas.size); } if (runtimeDeclSecurityActions.noncas.size > 0) { PermissionSet permissionSet2 = SecurityManager.Decode(runtimeDeclSecurityActions.noncas.blob, runtimeDeclSecurityActions.noncas.size); permissionSet = ((permissionSet != null) ? permissionSet.Union(permissionSet2) : permissionSet2); } if (runtimeDeclSecurityActions2.cas.size > 0) { PermissionSet permissionSet3 = SecurityManager.Decode(runtimeDeclSecurityActions2.cas.blob, runtimeDeclSecurityActions2.cas.size); permissionSet = ((permissionSet != null) ? permissionSet.Union(permissionSet3) : permissionSet3); } if (runtimeDeclSecurityActions2.noncas.size > 0) { PermissionSet permissionSet4 = SecurityManager.Decode(runtimeDeclSecurityActions2.noncas.blob, runtimeDeclSecurityActions2.noncas.size); permissionSet = ((permissionSet != null) ? permissionSet.Union(permissionSet4) : permissionSet4); } if (permissionSet != null) { permissionSet.Demand(); } }
internal void InitFromRuntimeFrame(RuntimeSecurityFrame frame) { this._domain = frame.domain; this._method = frame.method; if (frame.assert.size > 0) { this._assert = SecurityManager.Decode(frame.assert.blob, frame.assert.size); } if (frame.deny.size > 0) { this._deny = SecurityManager.Decode(frame.deny.blob, frame.deny.size); } if (frame.permitonly.size > 0) { this._permitonly = SecurityManager.Decode(frame.permitonly.blob, frame.permitonly.size); } }
// Note: SecurityManager.Decode implements a cache - so not every call // ends up making an icall internal void InitFromRuntimeFrame(RuntimeSecurityFrame frame) { _domain = frame.domain; _method = frame.method; #if !DISABLE_SECURITY if (frame.assert.size > 0) { _assert = SecurityManager.Decode(frame.assert.blob, frame.assert.size); } if (frame.deny.size > 0) { _deny = SecurityManager.Decode(frame.deny.blob, frame.deny.size); } if (frame.permitonly.size > 0) { _permitonly = SecurityManager.Decode(frame.permitonly.blob, frame.permitonly.size); } #endif }
internal static PermissionSet Decode(IntPtr permissions, int length) { PermissionSet permissionSet = null; object lockObject = SecurityManager._lockObject; lock (lockObject) { if (SecurityManager._declsecCache == null) { SecurityManager._declsecCache = new Hashtable(); } object key = (int)permissions; permissionSet = (PermissionSet)SecurityManager._declsecCache[key]; if (permissionSet == null) { byte[] array = new byte[length]; Marshal.Copy(permissions, array, 0, length); permissionSet = SecurityManager.Decode(array); permissionSet.DeclarativeSecurity = true; SecurityManager._declsecCache.Add(key, permissionSet); } } return(permissionSet); }
private static void InternalDemand(IntPtr permissions, int length) { PermissionSet permissionSet = SecurityManager.Decode(permissions, length); permissionSet.Demand(); }