Пример #1
0
        private void HandleUserAccountDelete(HttpRequest req, Map jsondata)
        {
            UUID id;

            if (!jsondata.TryGetValue("id", out id))
            {
                m_WebIF.ErrorResponse(req, AdminWebIfErrorResult.InvalidRequest);
                return;
            }

            if (!m_UserAccountService.ContainsKey(id))
            {
                m_WebIF.ErrorResponse(req, AdminWebIfErrorResult.NotFound);
            }
            else
            {
                foreach (var delService in m_AccountDeleteServices)
                {
                    try
                    {
                        delService.Remove(id);
                    }
                    catch
                    {
                        /* intentionally ignored */
                    }
                }
                m_WebIF.SuccessResponse(req, new Map());
            }
        }
Пример #2
0
        private void CreateUserCommand(List <string> args, Common.CmdIO.TTY io, UUID limitedToScene)
        {
            if (args[0] == "help" || args.Count != 4)
            {
                io.Write("create user <firstname> <lastname>");
            }
            else if (limitedToScene != UUID.Zero)
            {
                io.Write("create user not allowed on limited console");
            }
            else if (!IsNameValid(args[1]) || !IsNameValid(args[2]))
            {
                io.Write("name can only contains letters or digits");
            }
            else if (m_UserAccountService.ContainsKey(args[1], args[2]))
            {
                io.Write("user already created");
            }
            else
            {
                var account = new UserAccount
                {
                    IsLocalToGrid = true
                };
                account.Principal.ID        = UUID.Random;
                account.Principal.FirstName = args[2];
                account.Principal.LastName  = args[3];
                account.UserLevel           = 0;

                var authInfo = new UserAuthInfo
                {
                    ID       = account.Principal.ID,
                    Password = io.GetPass("Password")
                };
                try
                {
                    m_UserAccountService.Add(account);
                }
                catch
                {
                    io.WriteFormatted("Could not add user account");
                }

                try
                {
                    m_AuthInfoService.Store(authInfo);
                }
                catch
                {
                    m_UserAccountService.Remove(account.Principal.ID);
                    io.WriteFormatted("Could not add user account");
                }
            }
        }
        private void CapsHandler(HttpRequest req)
        {
            string[] splitquery = req.RawUrl.Split('?');
            string[] elements   = splitquery[0].Substring(1).Split('/');

            if (elements.Length < 3)
            {
                req.ErrorResponse(HttpStatusCode.NotFound, "Not found");
                return;
            }

            UUID sessionid;

            if (!UUID.TryParse(elements[2], out sessionid))
            {
                req.ErrorResponse(HttpStatusCode.NotFound, "Not found");
                return;
            }

            bool            foundIP = false;
            UUID            agent   = UUID.Zero;
            UserSessionInfo userSession;

            if (m_UserSessionService.TryGetValue(sessionid, out userSession) && userSession.ClientIPAddress == req.CallerIP)
            {
                agent   = userSession.User.ID;
                foundIP = true;
            }

            if (!foundIP || !m_UserAccountService.ContainsKey(agent))
            {
                req.ErrorResponse(HttpStatusCode.NotFound, "Not found");
                return;
            }

            string rawPrefixUrl = "/UserCAPS/InventoryAPIv3/" + sessionid;
            string serverURI    = req.IsSsl ? m_HttpsServer.ServerURI : m_HttpServer.ServerURI;

            serverURI = serverURI.Substring(0, serverURI.Length - 1);

            AISv3Handler.MainHandler(new AISv3Handler.Request(
                                         req,
                                         m_InventoryService,
                                         new UGUI(agent),
                                         false,
                                         rawPrefixUrl,
                                         serverURI + rawPrefixUrl));
        }
        private void CapsHandler(HttpRequest req)
        {
            string[] splitquery = req.RawUrl.Split('?');
            string[] elements   = splitquery[0].Substring(1).Split('/');

            if (elements.Length < 3)
            {
                req.ErrorResponse(HttpStatusCode.NotFound, "Not found");
                return;
            }

            UUID sessionid;

            if (!UUID.TryParse(elements[2], out sessionid))
            {
                req.ErrorResponse(HttpStatusCode.NotFound, "Not found");
                return;
            }

            bool foundIP = false;
            UUID agent   = UUID.Zero;

            try
            {
                UserSessionInfo trv = m_UserSessionService[sessionid];
                if (trv.ClientIPAddress == req.CallerIP)
                {
                    agent   = trv.User.ID;
                    foundIP = true;
                }
            }
            catch
            {
                /* entry not found */
            }

            if (!foundIP || !m_UserAccountService.ContainsKey(agent))
            {
                req.ErrorResponse(HttpStatusCode.NotFound, "Not found");
                return;
            }

            HandleHttpRequest(req, m_InventoryService, agent, agent);
        }