internal virtual void MergeDeniedSet(TokenBasedSet denied) { if (denied == null) { return; } int minMaxIndex; if (this.m_maxIndex < denied.m_maxIndex) { minMaxIndex = this.m_maxIndex; for (int i = this.m_maxIndex + 1; i <= denied.m_maxIndex; ++i) { denied.RemoveItem(i); } } else { minMaxIndex = denied.m_maxIndex; } IPermission p1; IPermission p2; for (int i = 0; i <= minMaxIndex; i++) { p1 = (IPermission)this.GetItem(i); p2 = (IPermission)denied.GetItem(i); if (p1 != null) { if (p2 != null && p1.IsSubsetOf(p2)) { // If the permission appears in both sets, we can remove it from both // (i.e. now it's not granted instead of being denied) this.RemoveItem(i); denied.RemoveItem(i); } } else if (p2 != null) { // If we tried to deny it and it wasn't granted, just remove it from the denied set. denied.RemoveItem(i); } } }
private void GenericIntersect(TokenBasedSet target, TokenBasedSet other) { // Note: Assumes target set is large enough and empty. int thisMaxIndex = this.m_maxIndex; int otherMaxIndex = other != null ? other.m_maxIndex : 0; int minMaxIndex = thisMaxIndex < otherMaxIndex ? thisMaxIndex : otherMaxIndex; // We want to save any exceptions that occur and throw them at the end. Exception savedException = null; for (int i = 0; i <= minMaxIndex; i++) { try { IPermission p1 = other != null ? (IPermission)other.m_objSet[i] : null; IPermission p2 = (IPermission)this.m_objSet[i]; if (p1 != null && p2 != null) { target.SetItem(i, p1.Intersect(p2)); } else { target.SetItem(i, null); } } catch (Exception e) { if (savedException == null) { savedException = e; } // Remove the permission from the intersection set target.SetItem(i, null); } } if (minMaxIndex == otherMaxIndex) { for (int i = otherMaxIndex + 1; i <= target.m_maxIndex; ++i) { target.RemoveItem(i); } } if (savedException != null) { throw savedException; } }
internal virtual void MergeDeniedSet( TokenBasedSet denied ) { if (denied == null) return; int minMaxIndex; if (this.m_maxIndex < denied.m_maxIndex) { minMaxIndex = this.m_maxIndex; for (int i = this.m_maxIndex + 1; i <= denied.m_maxIndex; ++i) { denied.RemoveItem(i); } } else { minMaxIndex = denied.m_maxIndex; } IPermission p1; IPermission p2; for (int i = 0; i<=minMaxIndex ; i++) { p1 = (IPermission)this.GetItem(i); p2 = (IPermission)denied.GetItem(i); if (p1 != null) { if (p2 != null && p1.IsSubsetOf(p2)) { // If the permission appears in both sets, we can remove it from both // (i.e. now it's not granted instead of being denied) this.RemoveItem(i); denied.RemoveItem(i); } } else if (p2 != null) { // If we tried to deny it and it wasn't granted, just remove it from the denied set. denied.RemoveItem(i); } } }
private void GenericIntersect( TokenBasedSet target, TokenBasedSet other ) { // Note: Assumes target set is large enough and empty. int thisMaxIndex = this.m_maxIndex; int otherMaxIndex = other != null ? other.m_maxIndex : 0; int minMaxIndex = thisMaxIndex < otherMaxIndex ? thisMaxIndex : otherMaxIndex; // We want to save any exceptions that occur and throw them at the end. Exception savedException = null; for (int i = 0; i <= minMaxIndex; i++) { try { IPermission p1 = other != null ? (IPermission)other.m_objSet[i] : null; IPermission p2 = (IPermission)this.m_objSet[i]; if (p1 != null && p2 != null) { target.SetItem( i, p1.Intersect(p2) ); } else { target.SetItem( i, null ); } } catch (Exception e) { if (savedException == null) savedException = e; // Remove the permission from the intersection set target.SetItem( i, null ); } } if (minMaxIndex == otherMaxIndex) { for (int i = otherMaxIndex+1; i <= target.m_maxIndex; ++i) { target.RemoveItem( i ); } } if (savedException != null) throw savedException; }