Exemple #1
0
        public override bool Equals(object obj)
        {
            var other = obj as SecurityObjectId;

            return(other != null &&
                   Equals(AzObjectIdHelper.GetFullObjectId(other), AzObjectIdHelper.GetFullObjectId(this)));
        }
        private IEnumerable <AzRecord> FilterAces(IEnumerable <AzRecord> aces, Guid subjectId, Guid actionId, ISecurityObjectId objectId)
        {
            var objId = AzObjectIdHelper.GetFullObjectId(objectId);

            return(aces is AzRecordStore store?
                   store.Get(objId).Where(a => (a.SubjectId == subjectId || subjectId == Guid.Empty) && (a.ActionId == actionId || actionId == Guid.Empty)) :
                       aces.Where(a => (a.SubjectId == subjectId || subjectId == Guid.Empty) && (a.ActionId == actionId || actionId == Guid.Empty) && a.ObjectId == objId));
        }
Exemple #3
0
        public IEnumerable <Ace> GetAcl(ISubject subject, IAction action, ISecurityObjectId objectId, ISecurityObjectProvider secObjProvider)
        {
            if (subject == null)
            {
                throw new ArgumentNullException("subject");
            }
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }
            if (objectId == null)
            {
                throw new ArgumentNullException("objectId");
            }

            var allAces      = new List <Ace>();
            var fullObjectId = AzObjectIdHelper.GetFullObjectId(objectId);

            allAces.AddRange(GetAcl(subject, action, fullObjectId));

            bool inherit = GetObjectAcesInheritance(objectId);

            if (inherit)
            {
                var providerHelper = new AzObjectSecurityProviderHelper(objectId, secObjProvider);
                while (providerHelper.NextInherit())
                {
                    allAces.AddRange(GetAcl(subject, action, AzObjectIdHelper.GetFullObjectId(providerHelper.CurrentObjectId)));
                }
                allAces.AddRange(GetAcl(subject, action));
            }

            var aces    = new List <Ace>();
            var aclKeys = new List <string>();

            foreach (var ace in allAces)
            {
                var key = string.Format("{0}{1:D}", ace.ActionId, ace.Reaction);
                if (!aclKeys.Contains(key))
                {
                    aces.Add(ace);
                    aclKeys.Add(key);
                }
            }

            return(aces);
        }
Exemple #4
0
        public void RemoveAce <T>(ISubject subject, IAction action, ISecurityObjectId objectId, AceType reaction)
        {
            if (subject == null)
            {
                throw new ArgumentNullException("subject");
            }
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            var r = new PermissionRecord(subject.ID, action.ID, AzObjectIdHelper.GetFullObjectId(objectId), reaction);

            if (permRecords.ContainsKey(r.Id))
            {
                permRecords.Remove(r.Id);
            }
        }
Exemple #5
0
 public override int GetHashCode()
 {
     return(AzObjectIdHelper.GetFullObjectId(this).GetHashCode());
 }
Exemple #6
0
 public override bool Equals(object obj)
 {
     return(obj is SecurityObjectId other &&
            Equals(AzObjectIdHelper.GetFullObjectId(other), AzObjectIdHelper.GetFullObjectId(this)));
 }
Exemple #7
0
 public AzRecord(Guid subjectId, Guid actionId, AceType reaction, ISecurityObjectId objectId)
     : this(subjectId, actionId, reaction, AzObjectIdHelper.GetFullObjectId(objectId))
 {
 }
Exemple #8
0
        public bool GetObjectAcesInheritance(ISecurityObjectId objectId)
        {
            var fullObjectId = AzObjectIdHelper.GetFullObjectId(objectId);

            return(inheritAces.ContainsKey(fullObjectId) ? inheritAces[fullObjectId] : true);
        }
Exemple #9
0
        public void SetObjectAcesInheritance(ISecurityObjectId objectId, bool inherit)
        {
            var fullObjectId = AzObjectIdHelper.GetFullObjectId(objectId);

            inheritAces[fullObjectId] = inherit;
        }