Beispiel #1
0
        internal PermissionSetTriple UpdateAssert(PermissionSet in_a)
        {
            PermissionSetTriple retTriple = null;

            if (in_a != null)
            {
                Debug.Assert((!in_a.IsUnrestricted() || RefusedSet == null), "Cannot be unrestricted or refused must be null");
                // if we're already asserting in_a, nothing to do
                if (in_a.IsSubsetOf(AssertSet))
                {
                    return(null);
                }

                PermissionSet retPs;
                if (GrantSet != null)
                {
                    retPs = in_a.Intersect(GrantSet); // Restrict the assert to what we've already been granted
                }
                else
                {
                    GrantSet = new PermissionSet(true);
                    retPs    = in_a.Copy(); // Currently unrestricted Grant: assert the whole assert set
                }
                bool bFailedToCompress = false;
                // removes anything that is already in the refused set from the assert set
                if (RefusedSet != null)
                {
                    retPs = PermissionSet.RemoveRefusedPermissionSet(retPs, RefusedSet, out bFailedToCompress);
                }
                if (!bFailedToCompress)
                {
                    bFailedToCompress = PermissionSet.IsIntersectingAssertedPermissions(retPs, AssertSet);
                }
                if (bFailedToCompress)
                {
                    retTriple = new PermissionSetTriple(this);
                    this.Reset();
                    this.GrantSet = retTriple.GrantSet.Copy();
                }

                if (AssertSet == null)
                {
                    AssertSet = retPs;
                }
                else
                {
                    AssertSet.InplaceUnion(retPs);
                }
            }
            return(retTriple);
        }
Beispiel #2
0
        internal PermissionSetTriple UpdateAssert(PermissionSet in_a)
        {
            PermissionSetTriple permissionSetTriple = (PermissionSetTriple)null;

            if (in_a != null)
            {
                if (in_a.IsSubsetOf(this.AssertSet))
                {
                    return((PermissionSetTriple)null);
                }
                PermissionSet permissionSet;
                if (this.GrantSet != null)
                {
                    permissionSet = in_a.Intersect(this.GrantSet);
                }
                else
                {
                    this.GrantSet = new PermissionSet(true);
                    permissionSet = in_a.Copy();
                }
                bool bFailedToCompress = false;
                if (this.RefusedSet != null)
                {
                    permissionSet = PermissionSet.RemoveRefusedPermissionSet(permissionSet, this.RefusedSet, out bFailedToCompress);
                }
                if (!bFailedToCompress)
                {
                    bFailedToCompress = PermissionSet.IsIntersectingAssertedPermissions(permissionSet, this.AssertSet);
                }
                if (bFailedToCompress)
                {
                    permissionSetTriple = new PermissionSetTriple(this);
                    this.Reset();
                    this.GrantSet = permissionSetTriple.GrantSet.Copy();
                }
                if (this.AssertSet == null)
                {
                    this.AssertSet = permissionSet;
                }
                else
                {
                    this.AssertSet.InplaceUnion(permissionSet);
                }
            }
            return(permissionSetTriple);
        }
        internal PermissionSetTriple UpdateAssert(PermissionSet in_a)
        {
            PermissionSetTriple triple = null;

            if (in_a != null)
            {
                PermissionSet set;
                bool          flag;
                if (in_a.IsSubsetOf(this.AssertSet))
                {
                    return(null);
                }
                if (this.GrantSet != null)
                {
                    set = in_a.Intersect(this.GrantSet);
                }
                else
                {
                    this.GrantSet = new PermissionSet(true);
                    set           = in_a.Copy();
                }
                set = PermissionSet.RemoveRefusedPermissionSet(set, this.RefusedSet, out flag);
                if (!flag)
                {
                    flag = PermissionSet.IsIntersectingAssertedPermissions(set, this.AssertSet);
                }
                if (flag)
                {
                    triple = new PermissionSetTriple(this);
                    this.Reset();
                    this.GrantSet = triple.GrantSet.Copy();
                }
                if (this.AssertSet == null)
                {
                    this.AssertSet = set;
                    return(triple);
                }
                this.AssertSet.InplaceUnion(set);
            }
            return(triple);
        }