Пример #1
0
        public virtual IDictionary DetermineUserCapabilities(WebPartManager webPartManager)
        {
            if (webPartManager == null)
            {
                throw new ArgumentNullException("webPartManager");
            }
            Page page = webPartManager.Page;

            if (page == null)
            {
                throw new ArgumentException(System.Web.SR.GetString("PropertyCannotBeNull", new object[] { "Page" }), "webPartManager");
            }
            HttpRequest requestInternal = page.RequestInternal;

            if (requestInternal == null)
            {
                throw new ArgumentException(System.Web.SR.GetString("PropertyCannotBeNull", new object[] { "Page.Request" }), "webPartManager");
            }
            IPrincipal user = null;

            if (requestInternal.IsAuthenticated)
            {
                user = page.User;
            }
            if (user != null)
            {
                if (this._supportedUserCapabilities == null)
                {
                    this._supportedUserCapabilities = this.CreateSupportedUserCapabilities();
                }
                if ((this._supportedUserCapabilities != null) && (this._supportedUserCapabilities.Count != 0))
                {
                    WebPartsSection webParts = RuntimeConfig.GetConfig().WebParts;
                    if (webParts != null)
                    {
                        WebPartsPersonalizationAuthorization authorization = webParts.Personalization.Authorization;
                        if (authorization != null)
                        {
                            IDictionary dictionary = new HybridDictionary();
                            foreach (WebPartUserCapability capability in this._supportedUserCapabilities)
                            {
                                if (authorization.IsUserAllowed(user, capability.Name))
                                {
                                    dictionary[capability] = capability;
                                }
                            }
                            return(dictionary);
                        }
                    }
                }
            }
            return(new HybridDictionary());
        }
Пример #2
0
        /// <devdoc>
        /// </devdoc>
        public virtual IDictionary DetermineUserCapabilities(WebPartManager webPartManager)
        {
            if (webPartManager == null)
            {
                throw new ArgumentNullException("webPartManager");
            }

            Page page = webPartManager.Page;

            if (page == null)
            {
                throw new ArgumentException(SR.GetString(SR.PropertyCannotBeNull, "Page"),
                                            "webPartManager");
            }

            HttpRequest request = page.RequestInternal;

            if (request == null)
            {
                throw new ArgumentException(SR.GetString(SR.PropertyCannotBeNull, "Page.Request"),
                                            "webPartManager");
            }

            IPrincipal user = null;

            if (request.IsAuthenticated)
            {
                user = page.User;
            }

            if (user != null)
            {
                if (_supportedUserCapabilities == null)
                {
                    _supportedUserCapabilities = CreateSupportedUserCapabilities();
                }

                if ((_supportedUserCapabilities != null) && (_supportedUserCapabilities.Count != 0))
                {
                    WebPartsSection configSection = RuntimeConfig.GetConfig().WebParts;
                    if (configSection != null)
                    {
                        WebPartsPersonalizationAuthorization authConfig = configSection.Personalization.Authorization;
                        if (authConfig != null)
                        {
                            IDictionary capabilities = new HybridDictionary();

                            foreach (WebPartUserCapability capability in _supportedUserCapabilities)
                            {
                                if (authConfig.IsUserAllowed(user, capability.Name))
                                {
                                    capabilities[capability] = capability;
                                }
                            }
                            return(capabilities);
                        }
                    }
                }
            }

            return(new HybridDictionary());
        }