コード例 #1
0
 public PushResponseBuilder(ISession session, PushRequest pushRequest, IAccessControlLists acls)
 {
     this.session = session;
     this.pushRequest = pushRequest;
     this.acls = acls;
     this.metaPopulation = this.session.Database.MetaPopulation;
 }
コード例 #2
0
        public static bool Set(this Step step, IObject @object, IAccessControlLists acls, object value)
        {
            var acl = acls[@object];

            if (step.ExistNext)
            {
                if (acl.CanRead(step.PropertyType))
                {
                    if (step.PropertyType.Get(@object.Strategy) is IObject property)
                    {
                        step.Next.Set(property, acls, value);
                        return(true);
                    }
                }

                return(false);
            }

            if (step.PropertyType is RoleType roleType)
            {
                if (acl.CanWrite(roleType))
                {
                    roleType.Set(@object.Strategy, value);
                    return(true);
                }
            }

            return(false);
        }
コード例 #3
0
 public PullInstantiate(ISession session, Pull pull, IAccessControlLists acls, IFetchService fetchService)
 {
     this.session      = session;
     this.pull         = pull;
     this.fetchService = fetchService;
     this.acls         = acls;
 }
コード例 #4
0
ファイル: PullExtent.cs プロジェクト: Allors/allors2
 public PullExtent(ISession session, Pull pull, IAccessControlLists acls, IExtentService extentService, IFetchService fetchService)
 {
     this.session       = session;
     this.pull          = pull;
     this.extentService = extentService;
     this.fetchService  = fetchService;
     this.acls          = acls;
 }
コード例 #5
0
        internal AccessControlList(IAccessControlLists accessControlLists, IObject @object)
        {
            this.AccessControlLists = accessControlLists;
            this.Object             = (Object)@object;
            this.classId            = this.Object.Strategy.Class.Id;

            this.lazyLoaded = false;
        }
コード例 #6
0
        public PullResponseBuilder(IAccessControlLists acls, ITreeService treeService)
        {
            this.acls        = acls;
            this.treeService = treeService;

            this.objects = new HashSet <IObject>();
            this.accessControlsWriter = new AccessControlsWriter(this.acls);
            this.permissionsWriter    = new PermissionsWriter(this.acls);
        }
コード例 #7
0
        public SyncResponseBuilder(ISession session, SyncRequest syncRequest, IAccessControlLists acls)
        {
            this.session     = session;
            this.syncRequest = syncRequest;
            this.acls        = acls;

            this.accessControlsWriter = new AccessControlsWriter(this.acls);
            this.permissionsWriter    = new PermissionsWriter(this.acls);
        }
コード例 #8
0
        public InvokeResponseBuilder(ISession session, InvokeRequest invokeRequest, IAccessControlLists acls)
        {
            this.session         = session;
            this.invocations     = invokeRequest.i;
            this.isolated        = invokeRequest.o?.i ?? false;
            this.continueOnError = invokeRequest.o?.c ?? false;

            this.acls = acls;
        }
コード例 #9
0
 public static void Resolve(this Node[] treeNodes, IObject @object, IAccessControlLists acls, ISet <IObject> objects)
 {
     if (@object != null)
     {
         foreach (var node in treeNodes)
         {
             node.Resolve(@object, acls, objects);
         }
     }
 }
コード例 #10
0
        public static void Ensure(this Step step, IObject @object, IAccessControlLists acls)
        {
            var acl = acls[@object];

            if (step.PropertyType is RoleType roleType)
            {
                if (roleType.IsMany)
                {
                    throw new NotSupportedException("RoleType with muliplicity many");
                }

                if (roleType.ObjectType.IsComposite)
                {
                    if (acl.CanRead(roleType))
                    {
                        var role = roleType.Get(@object.Strategy);
                        if (role == null)
                        {
                            if (acl.CanWrite(roleType))
                            {
                                role = @object.Strategy.Session.Create((Class)roleType.ObjectType);
                                roleType.Set(@object.Strategy, role);
                            }
                        }

                        if (step.ExistNext)
                        {
                            if (role is IObject next)
                            {
                                step.Next.Ensure(next, acls);
                            }
                        }
                    }
                }
            }
            else
            {
                var associationType = (AssociationType)step.PropertyType;
                if (associationType.IsMany)
                {
                    throw new NotSupportedException("AssociationType with muliplicity many");
                }

                if (acl.CanRead(associationType))
                {
                    if (associationType.Get(@object.Strategy) is IObject association)
                    {
                        if (step.ExistNext)
                        {
                            step.Next.Ensure(association, acls);
                        }
                    }
                }
            }
        }
コード例 #11
0
ファイル: AccessControlList.cs プロジェクト: Allors/allors2
        internal AccessControlList(IAccessControlLists accessControlLists, IObject @object, bool isWorkspace)
        {
            this.deniedPermissionFilter = isWorkspace
                ? (Func <Permission, bool>)WorkspaceDeniedPermissionFilter
                : DatabaseDeniedPermissionFilter;

            this.AccessControlLists = accessControlLists;
            this.Object             = (Object)@object;
            this.classId            = this.Object.Strategy.Class.Id;

            this.lazyLoaded = false;
        }
コード例 #12
0
        public static object Get(this Step step, IObject @object, IAccessControlLists acls)
        {
            var acl = acls[@object];

            if (acl.CanRead(step.PropertyType))
            {
                if (step.ExistNext)
                {
                    var currentValue = step.PropertyType.Get(@object.Strategy);

                    if (currentValue != null)
                    {
                        if (currentValue is IObject)
                        {
                            return(step.Next.Get((IObject)currentValue, acls));
                        }

                        var results = new HashSet <object>();
                        foreach (var item in (IEnumerable)currentValue)
                        {
                            var nextValueResult = step.Next.Get((IObject)item, acls);
                            if (nextValueResult is HashSet <object> )
                            {
                                results.UnionWith((HashSet <object>)nextValueResult);
                            }
                            else
                            {
                                results.Add(nextValueResult);
                            }
                        }

                        return(results);
                    }
                }

                return(step.PropertyType.Get(@object.Strategy));
            }

            return(null);
        }
コード例 #13
0
 internal PermissionsWriter(IAccessControlLists acls)
 {
     this.acls = acls;
 }
コード例 #14
0
 public static void Resolve(this Node @this, IObject @object, IAccessControlLists acls, ISet <IObject> objects)
 {
     if (@object != null)
     {
         var acl = acls[@object];
         if (acl.CanRead(@this.PropertyType))
         {
             if (@this.PropertyType is IRoleType roleType)
             {
                 if (roleType.ObjectType.IsComposite)
                 {
                     if (roleType.IsOne)
                     {
                         var role = @object.Strategy.GetCompositeRole(roleType.RelationType);
                         if (role != null)
                         {
                             objects.Add(role);
                             foreach (var node in @this.Nodes)
                             {
                                 node.Resolve(role, acls, objects);
                             }
                         }
                     }
                     else
                     {
                         var roles = @object.Strategy.GetCompositeRoles(roleType.RelationType);
                         foreach (IObject role in roles)
                         {
                             objects.Add(role);
                             foreach (var node in @this.Nodes)
                             {
                                 node.Resolve(role, acls, objects);
                             }
                         }
                     }
                 }
             }
             else if (@this.PropertyType is IAssociationType associationType)
             {
                 if (associationType.IsOne)
                 {
                     var association = @object.Strategy.GetCompositeAssociation(associationType.RelationType);
                     if (association != null)
                     {
                         objects.Add(association);
                         foreach (var node in @this.Nodes)
                         {
                             node.Resolve(association, acls, objects);
                         }
                     }
                 }
                 else
                 {
                     var associations = @object.Strategy.GetCompositeAssociations(associationType.RelationType);
                     foreach (IObject association in associations)
                     {
                         objects.Add(association);
                         foreach (var node in @this.Nodes)
                         {
                             node.Resolve(association, acls, objects);
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #15
0
 public SecurityResponseBuilder(ISession session, SecurityRequest securityRequest, IAccessControlLists acls)
 {
     this.session         = session;
     this.securityRequest = securityRequest;
     this.acls            = acls;
 }
コード例 #16
0
 internal AccessControlsWriter(IAccessControlLists acls)
 {
     this.acls = acls;
 }
コード例 #17
0
 public static void Ensure(this Fetch fetch, IObject allorsObject, IAccessControlLists acls) => fetch.Step.Ensure(allorsObject, acls);
コード例 #18
0
 public static bool Set(this Fetch fetch, IObject allorsObject, IAccessControlLists acls, object value) => fetch.Step != null && fetch.Step.Set(allorsObject, acls, value);
コード例 #19
0
 public static object Get(this Fetch fetch, IObject allorsObject, IAccessControlLists acls) => fetch.Step == null ? allorsObject : fetch.Step.Get(allorsObject, acls);