public IEnumerable<AzRecord> GetAcesWithInherits(Guid subjectId, Guid actionId, ISecurityObjectId objectId, ISecurityObjectProvider secObjProvider)
        {
            if (objectId == null)
            {
                return GetAces(subjectId, actionId, null);
            }

            var result = new List<AzRecord>();
            var aces = service.GetAces(CoreContext.TenantManager.GetCurrentTenant().TenantId, default(DateTime));
            result.AddRange(FilterAces(aces, subjectId, actionId, objectId));

            var inherits = new List<AzRecord>();
            var secObjProviderHelper = new AzObjectSecurityProviderHelper(objectId, secObjProvider);
            while (secObjProviderHelper.NextInherit())
            {
                inherits.AddRange(FilterAces(aces, subjectId, actionId, secObjProviderHelper.CurrentObjectId));
            }

            inherits.AddRange(FilterAces(aces, subjectId, actionId, null));

            result.AddRange(DistinctAces(inherits));
            return result;
        }
Example #2
0
 internal IEnumerable<ISubject> GetSubjects(ISubject subject, ISecurityObjectId objectId, ISecurityObjectProvider securityObjProvider)
 {
     var subjects = new List<ISubject>();
     subjects.Add(subject);
     subjects.AddRange(
         roleProvider.GetRoles(subject)
             .ConvertAll(r => { return (ISubject)r; })
         );
     if (objectId != null)
     {
         var secObjProviderHelper = new AzObjectSecurityProviderHelper(objectId, securityObjProvider);
         do
         {
             if (!secObjProviderHelper.ObjectRolesSupported) continue;
             foreach (IRole role in secObjProviderHelper.GetObjectRoles(subject))
             {
                 if (!subjects.Contains(role)) subjects.Add(role);
             }
         } while (secObjProviderHelper.NextInherit());
     }
     return subjects;
 }