Example #1
0
        public async Task <XElement> Page(long pageId, string sessionKey, long requestId)
        {
            #region Заглушка
            var hubConn  = new HubConnection(Settings.Default.ResponseHubUrl);
            var hubProxy = hubConn.CreateHubProxy("ResponseHub");
            await hubConn.Start();

            ObjectAccessResult access = new ObjectAccessResult()
            {
                Id     = pageId,
                Access = new CheckAccessResult()
                {
                    Read           = true,
                    Update         = true,
                    InsertChildren = true,
                    Delete         = true
                }
            };

            hubProxy.Invoke("OperationCallback", sessionKey, requestId,
                            ReturnCodes.BuildRcAnswer(0, "Успешно", ObjectAccessResult.ToXElement(access)));
            return(ReturnCodes.BuildRcAnswer(0, "Успешно"));

            #endregion
        }
Example #2
0
        /// <summary>
        /// Проверяет права доступа к запрашиваемому действию
        /// </summary>
        /// <param name="filterContext">Контекст запроса</param>
        /// <returns>true - доступ разрешен, false - иначе</returns>
        private bool CheckAccess(AuthorizationContext filterContext)
        {
            var actionName = filterContext.ActionDescriptor.ActionName;
            var methodInfo = filterContext.Controller.GetType().GetMethod(actionName);
            var attr       = Attribute.GetCustomAttribute(methodInfo, typeof(PageIDAttribute)) as PageIDAttribute;

            long pageId = -1;

            if (attr != null)
            {
                pageId = attr.PageID;
            }

            ObjectAccessResult AccessInfo = Authentificate.checkAuthorization(this.session, pageId);
            bool readAccess = AccessInfo.Access.Read;

            return(readAccess);
        }
Example #3
0
        /// <summary>
        /// Проверяет права доступа к запрашиваемому действию
        /// </summary>
        /// <param name="actionContext">Контекст запроса</param>
        /// <param name="sessionKey">Ключ сессии</param>
        /// <returns>true - доступ разрешен, false - иначе</returns>
        private bool CheckPageAccess(HttpActionContext actionContext, Guid sessionKey)
        {
            var actionName = actionContext.ActionDescriptor.ActionName;

            var methodInfo = actionContext.ControllerContext.Controller.GetType().GetMethod(actionName);
            var attr       = Attribute.GetCustomAttribute(methodInfo, typeof(PageIDAttribute)) as PageIDAttribute;

            long pageId = -1;

            if (attr != null)
            {
                pageId = attr.PageID;
            }
            var resp = WebApiSync.Current.GetResponse <XElement>(@"api/Access/PageTransfer?pageId=" + pageId + "&sessionKey=" + sessionKey);

            var access = ObjectAccessResult.FromXElement(resp.Element("ObjectAccessResult"));

            return(access.Access.Read);
        }
Example #4
0
        public XElement PageTransfer(string sessionKey, long pageId)
        {
            #region Заглушка

            ObjectAccessResult access = new ObjectAccessResult()
            {
                Id     = pageId,
                Access = new CheckAccessResult()
                {
                    Read           = true,
                    Update         = true,
                    InsertChildren = true,
                    Delete         = true
                }
            };

            return(ReturnCodes.BuildRcAnswer(0, "Успешно", ObjectAccessResult.ToXElement(access)));

            #endregion
        }