public override void ProcessRequest(HttpContext context)
        {
            // Get the username from the identity of the request (which was set by PKIAuthenticationModule)
            string user = context.User.Identity.Name;
            // Get the info for the user
            JObject userInfo = helper.GetUserInfo(user);

            // If the user doesn't exist, exit with 403 response (Forbidden)
            if (userInfo["error"] != null || ((string)userInfo["level"]) != "2")
            {
                if (userInfo["error"] != null)
                {
                    Global.LogInfo("Status: 403 returned. Specified user does not exist");
                }
                else
                {
                    Global.LogInfo("Status: 403 returned. Specified user does not have the correct permissions for this request");
                }
                context.Response.StatusCode = 403;
                return;
            }

            // Get the username and starting folder from the request parameters
            HttpRequest request  = context.Request;
            string      username = request.QueryString["username"];
            string      folder   = request.QueryString["folder"];

            // If a username is not specified, default to the user who made the request
            if (username == null)
            {
                username = user;
            }
            // If a folder is not specified, default to the root folder
            if (folder == null)
            {
                folder = "";
            }

            JObject items = GetItems(username, folder, true);

            context.Response.ContentType = "application/json";
            Global.LogInfo("Status: 200 returned. Returned user item information for user " + user);
            context.Response.Write(helper.JsonToString(items));
        }
Ejemplo n.º 2
0
        public override void ProcessRequest(HttpContext context)
        {
            // Get the username from the identity of the request (which was set by PKIAuthenticationModule)
            string user = context.User.Identity.Name;
            // Get the info for the user
            JObject userInfo = helper.GetUserInfo(user);

            // If the user doesn't exist, exit with 403 response (Forbidden)
            if (userInfo["error"] != null || ((string)userInfo["level"]) != "2")
            {
                if (userInfo["error"] != null)
                {
                    Global.LogInfo("Status: 403 returned. Specified user does not exist");
                }
                else
                {
                    Global.LogInfo("Status: 403 returned. Specified user does not have the correct permissions for this request");
                }
                context.Response.StatusCode = 403;
                return;
            }

            // GetGroupItems returns null if the user does not belong to any groups, and an empty JObject if no items have been shared to any of the user's groups
            JObject items = GetGroupItems(userInfo);

            if (items == null)
            {
                Global.LogInfo("Status: 400 returned. Specified user does not belong to any groups");
                context.Response.StatusCode = 400;
                return;
            }
            context.Response.ContentType = "application/json";
            Global.LogInfo("Status: 200 returned. Returned group item information for user " + user);
            context.Response.Write(helper.JsonToString(items));
            return;
        }