Exemple #1
0
        /// <summary>
        /// The constructor for creating a new AccessControlObject with certain rights.
        /// </summary>
        /// <param name="myObjectLocation">the location of the AccessControlObject (constisting of the ObjectPath and ObjectName) within the file system</param>
        /// <param name="myDefaultRule">This property defines the priority of allowing and denying.</param>
        /// <param name="myAllowACL">The dictionary of rights with corresponding ACLs that allow the access to an object in the GraphFS.</param>
        /// <param name="myDenyACL">The dictionary of rights with corresponding ACLs that denies the access to an object in the GraphFS.</param>
        /// <param name="myNotificationHandling">the NotificationHandling bitfield</param>
        public AccessControlObject(ObjectLocation myObjectLocation, DefaultRuleTypes myDefaultRule, Dictionary<RightUUID, HashSet<EntityUUID>> myAllowACL, Dictionary<RightUUID, HashSet<EntityUUID>> myDenyACL, NHAccessControlObject myNotificationHandling)
        {
            if (myAllowACL == null)
                throw new ArgumentNullException("Invalid AllowACL!");

            if (myDenyACL == null)
                throw new ArgumentNullException("Invalid DenyACL!");

            _AllowACL               = myAllowACL;
            _DenyACL                = myDenyACL;
            _DefaultRule            = myDefaultRule;
            _NotificationHandling   = myNotificationHandling;

            #region calc estimated size

            #region AllowACL

            _estimatedSize += CalcACLSize(myAllowACL);

            #endregion

            #region DenyACL

            _estimatedSize += CalcACLSize(myDenyACL);

            #endregion

            _estimatedSize += EstimatedSizeConstants.EnumByte + EstimatedSizeConstants.EnumUInt64 + GetClassDefaultSize();

            #endregion
        }
Exemple #2
0
        /// <summary>
        /// The constructor for creating a new AccessControlObject with certain rights.
        /// </summary>
        /// <param name="myObjectLocation">the location of the AccessControlObject (constisting of the ObjectPath and ObjectName) within the file system</param>
        /// <param name="myDefaultRule">This property defines the priority of allowing and denying.</param>
        /// <param name="myAllowACL">The dictionary of rights with corresponding ACLs that allow the access to an object in the GraphFS.</param>
        /// <param name="myDenyACL">The dictionary of rights with corresponding ACLs that denies the access to an object in the GraphFS.</param>
        /// <param name="myNotificationHandling">the NotificationHandling bitfield</param>
        public AccessControlObject(ObjectLocation myObjectLocation, DefaultRuleTypes myDefaultRule, Dictionary<RightUUID, HashSet<EntityUUID>> myAllowACL, Dictionary<RightUUID, HashSet<EntityUUID>> myDenyACL, NHAccessControlObject myNotificationHandling)
        {
            if (myAllowACL == null)
                throw new ArgumentNullException("Invalid AllowACL!");

            if (myDenyACL == null)
                throw new ArgumentNullException("Invalid DenyACL!");

            _AllowACL               = myAllowACL;
            _DenyACL                = myDenyACL;
            _DefaultRule            = myDefaultRule;
            _NotificationHandling   = myNotificationHandling;
        }
Exemple #3
0
        public override void Deserialize(ref SerializationReader mySerializationReader)
        {
            #region Data

            UInt64               _NumberOfACLs;
            RightUUID            _RightUUID;
            EntityUUID           _EntityUUID;
            UInt64               _NumberOfEntityUUIDs;
            HashSet<EntityUUID>  _EntityUUIDHashSet;

            #endregion

            try
            {

                #region NotificationHandling

                _NotificationHandling = (NHAccessControlObject)mySerializationReader.ReadOptimizedByte();

                #endregion

                #region DefaultRule

                _DefaultRule = (DefaultRuleTypes)mySerializationReader.ReadOptimizedByte();

                #endregion

                #region AllowACL

                _AllowACL = new Dictionary<RightUUID, HashSet<EntityUUID>>();

                _NumberOfACLs = mySerializationReader.ReadUInt64();

                for (UInt64 i=0; i<_NumberOfACLs; i++)
                {

                    #region KEY

                    _RightUUID = new RightUUID(mySerializationReader.ReadByteArray());

                    #endregion

                    #region VALUE

                    _EntityUUIDHashSet = new HashSet<EntityUUID>();

                    _NumberOfEntityUUIDs = mySerializationReader.ReadUInt64();

                    for (UInt64 j=0; j<_NumberOfEntityUUIDs; j++)
                    {
                        _EntityUUID = new EntityUUID(mySerializationReader.ReadByteArray());
                        _EntityUUIDHashSet.Add(_EntityUUID);
                    }

                    // Finally... add it to the AllowACL!
                    _AllowACL.Add(_RightUUID, _EntityUUIDHashSet);

                    #endregion

                }

                #endregion

                #region DenyACL

                _DenyACL = new Dictionary<RightUUID, HashSet<EntityUUID>>();

                _NumberOfACLs = mySerializationReader.ReadUInt64();

                for (UInt64 i=0; i<_NumberOfACLs; i++)
                {

                    #region KEY

                    _RightUUID = new RightUUID(mySerializationReader.ReadByteArray());

                    #endregion

                    #region VALUE

                    _EntityUUIDHashSet = new HashSet<EntityUUID>();

                    _NumberOfEntityUUIDs = mySerializationReader.ReadUInt64();

                    for (UInt64 j=0; j<_NumberOfEntityUUIDs; j++)
                    {
                        _EntityUUID = new EntityUUID(mySerializationReader.ReadByteArray());
                        _EntityUUIDHashSet.Add(_EntityUUID);
                    }

                    // Finally... add it to the DenyACL!
                    _DenyACL.Add(_RightUUID, _EntityUUIDHashSet);

                    #endregion

                }

                #endregion

            }

            catch (Exception e)
            {
                throw new GraphFSException_AccessControlObjectCouldNotBeDeserialized("AccessControlObject could not be deserialized!\n\n" + e);
            }
        }