Example #1
0
        /// <summary>
        /// 메뉴중 사용자가 권한이 있는 루트메뉴목록
        /// </summary>
        /// <param name="productId">제품Id</param>
        /// <param name="identity">요청자 정보</param>
        /// <returns>메뉴목록</returns>
        public override IEnumerable<MenuItem> GetRootMenu(string productId, IAccessIdentity identity)
        {
            if(IsDebugEnabled)
                log.Debug("==>> S productId={0}, identity={1}", productId, identity);

            productId.ShouldNotBeWhiteSpace("값이 없습니다.");
            //identity.ShouldNotBeNull("사용자 정보가 없습니다.");

            if(identity == null)
                return null;

            var provider = SiteMap.Providers[productId];

            if(IsDebugEnabled)
                log.Debug("productId={0}, identity={1}, provider={2}", productId, identity, provider);

            var menus = new List<MenuItem>();

            if(provider != null)
            {
                if(IsDebugEnabled)
                    log.Debug("provider.RootNode={0}", provider.RootNode);

                if(provider.RootNode != null)
                {
                    var nodes = GetAuthMenus(provider.RootNode.ChildNodes, identity);

                    foreach(SiteMapNode node in nodes)
                    {
                        var menu = new MenuItem(node.Title, node.Title, node.Url);
                        menu.NodePosition.Level = 0;
                        menu.NodePosition.Order = 0;
                        menu.Parent = null;
                        AddNode(node, menu, 1);
                        menus.Add(menu);
                    }
                }
            }
            if(IsDebugEnabled)
                log.Debug("==>> E menus={0}", menus.CollectionToString());

            return menus;
        }
Example #2
0
        private bool ValidateConnectionConfig(ConnectionConfig config)
        {
            var context = new ValidationContext(config, null, null);
            var results = new List<ValidationResult>();
            bool result = Validator.TryValidateObject(config, context, results);

            if (!result)
                Authenticated(this, new AuthenticationEventArgs(ConnectionErrorKind.InvalidConfig,
                                                                results.CollectionToString(i => i.ErrorMessage)));

            return result;
        }