示例#1
0
        /// <summary>
        /// Selects and loads security for the given UniqueName into a SplxRecordManager
        /// </summary>
        /// <param name="uniqueName"></param>
        /// <returns>A loaded and resolved SplxRecordManager</returns>
        SplxSecureManagerBase GetSecureManagerSecurity(string userName, AceType aceType, string uniqueName, SecurityLoadParameters slp)
        {
            SplxSecureManagerBase sm = new SplxRecordManager()
            {
                UniqueName = uniqueName
            };

            if (aceType == AceType.FileSystem)
            {
                sm = new SplxFileSystemManager()
                {
                    UniqueName = uniqueName
                };
            }

            if (slp == null)
            {
                slp = new SecurityLoadParameters()
                {
                    ExternalGroupInfo = new ExternalGroupInfo(LdapRoot, true, GlobalExternalGroupsCsv),
                    User = this.GetSuplexUser(userName)
                };
            }

            DataSet securityCache = IsFileStore ?
                                    sm.Security.Load(_splxStore, slp) :
                                    sm.Security.Load(_splxApi, slp);

            return(sm);
        }
示例#2
0
        /// <summary>
        /// Selects and loads security for the given UniqueName into a SplxRecordManager
        /// </summary>
        /// <param name="uniqueName"></param>
        /// <returns>A loaded and resolved SplxRecordManager</returns>
        SplxSecureManagerBase GetSecureManagerSecurityRecurseUp(string userName, AceType aceType, string uniqueName, SecurityLoadParameters slp)
        {
            string          rootUniqueName = ContainerRootUniqueName;
            SecureContainer root           = new SecureContainer()
            {
                UniqueName = rootUniqueName
            };

            #region setup SecurityLoadParameters, load ExternalGroupInfo
            if (slp == null)
            {
                slp = new SecurityLoadParameters()
                {
                    ExternalGroupInfo = new ExternalGroupInfo(LdapRoot, true, GlobalExternalGroupsCsv),
                    User = this.GetSuplexUser(userName)
                }
            }
            ;

            ExternalGroupInfo egi =
                new ExternalGroupInfo(LdapRoot, true, GlobalExternalGroupsCsv);
            egi.BuildGroupsList(slp.User.Name);
            #endregion

            SecureContainer       ctrl    = root;
            SplxSecureManagerBase context = null;

            #region IsFileStore = true
            if (IsFileStore)
            {
                context = new SplxRecordManager()
                {
                    UniqueName = uniqueName
                };
                if (aceType == AceType.FileSystem)
                {
                    context = new SplxFileSystemManager()
                    {
                        UniqueName = uniqueName
                    }
                }
                ;

                splxApi.UIElement uie = _splxStore.UIElements.GetByUniqueNameRecursiveIgnoreCase(uniqueName);
                if (uie == null)
                {
                    throw new SecurityException($"Could not find security element [{uniqueName}] in the permissione configuration.");
                }


                ISecureControl curr      = context;
                IObjectModel   parentObj = uie.ParentObject;
                while (parentObj != null)
                {
                    SecureContainer par = new SecureContainer()
                    {
                        UniqueName = ((splxApi.UIElement)parentObj).UniqueName
                    };
                    par.Children.Add(curr);
                    curr = par;

                    parentObj = parentObj.ParentObject;
                }

                curr.Security.Load(_splxStore, slp);
            }
            #endregion
            #region IsFileStore = false
            else
            {
                DataSet ds = _da.GetDataSet("splx.splx_dal_sel_security_byuserbyuie_up",
                                            new System.Collections.sSortedList(
                                                "@UIE_UNIQUE_NAME", uniqueName,
                                                "@SPLX_USER_ID", slp.User.Id,
                                                "@EXTERNAL_GROUP_LIST", egi.GroupsList));

                _da.NameTablesFromCompositeSelect(ref ds);

                //todo, when suplex is ready
                //DataSet ds = _splxApi.GetSecurity( rootUniqueName, slp.User, slp.ExternalGroupInfo, future:recurseUp );

                DataTable acl  = ds.Tables["AclInfo"];
                DataRow[] rows = acl.Select(string.Format("UIE_UNIQUE_NAME = '{0}'", rootUniqueName));
                if (rows.Length > 0)
                {
                    rows = acl.Select(string.Format("UIE_PARENT_ID = '{0}'", rows[0]["SPLX_UI_ELEMENT_ID"]));
                }

                while (rows.Length > 0)
                {
                    string un = rows[0]["UIE_UNIQUE_NAME"].ToString();
                    if (un.StartsWith(ContainerUniqueNamePrefix))
                    {
                        context = new SplxRecordManager()
                        {
                            UniqueName = un
                        };
                        if (aceType == AceType.FileSystem)
                        {
                            context = new SplxFileSystemManager()
                            {
                                UniqueName = un
                            }
                        }
                        ;

                        ctrl.Children.Add(context);
                    }
                    else
                    {
                        SecureContainer child = new SecureContainer()
                        {
                            UniqueName = un
                        };
                        ctrl.Children.Add(child);
                        ctrl = child;
                    }

                    rows = acl.Select(string.Format("UIE_PARENT_ID = '{0}'", rows[0]["SPLX_UI_ELEMENT_ID"]));
                }

                root.Security.Load(ds, slp);
            }
            #endregion


            return(context);
        }