public override byte[] Handle(string path, Stream requestData, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { string body = GetBodyAsString(requestData); //MainConsole.Instance.DebugFormat("[XXX]: query String: {0}", body); try { IGridRegistrationService urlModule = m_registry.RequestModuleInterface <IGridRegistrationService>(); OSDMap map = WebUtils.GetOSDMap(body); if (map != null) { if (map.ContainsKey("Method")) { if (map["Method"] == "GetUserInfo") { if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, map["Method"], ThreatLevel.None)) { return(FailureResult()); } } return(GetUserInfo(map)); } if (map["Method"] == "GetUserInfos") { if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, map["Method"], ThreatLevel.Low)) { return(FailureResult()); } } return(GetUserInfos(map)); } if (map["Method"] == "GetAgentsLocations") { if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, map["Method"], ThreatLevel.Low)) { return(FailureResult()); } } return(GetAgentsLocations(map)); } } } } catch (Exception e) { MainConsole.Instance.WarnFormat("[AGENT INFO HANDLER]: Exception {0}", e); } return(FailureResult()); }
public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); AssetBase asset = (AssetBase)xs.Deserialize(request); IGridRegistrationService urlModule = m_registry.RequestModuleInterface <IGridRegistrationService>(); if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, "Asset_Update", ThreatLevel.Full)) { return(new byte[0]); } } string[] p = SplitParams(path); if (p.Length > 1) { bool result = m_AssetService.UpdateContent(p[1], asset.Data); xs = new XmlSerializer(typeof(bool)); return(WebUtils.SerializeResult(xs, result)); } string id = m_AssetService.Store(asset); xs = new XmlSerializer(typeof(string)); return(WebUtils.SerializeResult(xs, id)); }
public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { bool result = false; string[] p = SplitParams(path); IGridRegistrationService urlModule = m_registry.RequestModuleInterface <IGridRegistrationService>(); if (m_SessionID != "" && urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, "Asset_Delete", ThreatLevel.High)) { return(new byte[0]); } } if (p.Length > 0 && m_allowDelete) { result = m_AssetService.Delete(UUID.Parse(p[0])); } XmlSerializer xs = new XmlSerializer(typeof(bool)); return(ServerUtils.SerializeResult(xs, result)); }
public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { string body = GetBodyAsString(request); OSDMap map = WebUtils.GetOSDMap(Util.Decompress(body)); IGridRegistrationService urlModule = m_registry.RequestModuleInterface <IGridRegistrationService>(); if (m_SessionID != "" && urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, "Asset_Update", ThreatLevel.High)) { return(new byte[0]); } } UUID newID; if (map.ContainsKey("Method") && map["Method"] == "UpdateContent") { m_AssetService.UpdateContent(map["ID"].AsUUID(), map["Data"].AsBinary(), out newID); } else { AssetBase asset = new AssetBase(); asset = asset.Unpack(map); newID = m_AssetService.Store(asset); } return(Encoding.UTF8.GetBytes(newID.ToString())); }
public override byte[] Handle(string path, Stream requestData, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { StreamReader sr = new StreamReader(requestData); string body = sr.ReadToEnd(); sr.Close(); body = body.Trim(); IGridRegistrationService urlModule = m_registry.RequestModuleInterface <IGridRegistrationService>(); if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, "EQM_Post", ThreatLevel.None)) { return(new byte[0]); } } OSDMap request = WebUtils.GetOSDMap(body); if (request == null) { return(null); } return(ProcessEnqueueEQMMessage(request)); }
public byte[] HandleMap(OSDMap args) { if (args.ContainsKey("Method")) { IGridRegistrationService urlModule = m_registry.RequestModuleInterface <IGridRegistrationService>(); string method = args["Method"].AsString(); MethodImplementation methodInfo; if (GetMethodInfo(method, args.Count - 1, out methodInfo)) { if (m_SessionID == "") { if (methodInfo.Attribute.ThreatLevel != ThreatLevel.None) { return(new byte[0]); } } else if (!urlModule.CheckThreatLevel(m_SessionID, method, methodInfo.Attribute.ThreatLevel)) { return(new byte[0]); } MainConsole.Instance.Debug("[Server]: Method Called: " + method); ParameterInfo[] paramInfo = methodInfo.Method.GetParameters(); object[] parameters = new object[paramInfo.Length]; int paramNum = 0; foreach (ParameterInfo param in paramInfo) { parameters[paramNum++] = Util.OSDToObject(args[param.Name], param.ParameterType); } object o = methodInfo.Method.FastInvoke(paramInfo, methodInfo.Reference, parameters); OSDMap response = new OSDMap(); if (o == null)//void method { response["Value"] = "null"; } else { response["Value"] = Util.MakeOSD(o, methodInfo.Method.ReturnType); } response["Success"] = true; return(Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(response, true))); } } MainConsole.Instance.Warn("[ServerHandler]: Post did not have a method block"); return(new byte[0]); }
public override byte[] Handle(string path, Stream requestData, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { StreamReader sr = new StreamReader(requestData); string body = sr.ReadToEnd(); sr.Close(); body = body.Trim(); OSDMap args = WebUtils.GetOSDMap(body); if (args.ContainsKey("Method")) { IGridRegistrationService urlModule = m_registry.RequestModuleInterface <IGridRegistrationService>(); string method = args["Method"].AsString(); MethodImplementation methodInfo; if (GetMethodInfo(method, args.Count - 1, out methodInfo)) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ((CanBeReflected)Attribute.GetCustomAttribute(methodInfo.Method, typeof(CanBeReflected))).ThreatLevel)) { return(new byte[0]); } ParameterInfo[] paramInfo = methodInfo.Method.GetParameters(); object[] parameters = new object[paramInfo.Length]; int paramNum = 0; foreach (ParameterInfo param in paramInfo) { parameters[paramNum++] = Util.OSDToObject(args[param.Name], param.ParameterType); } object o = methodInfo.Method.Invoke(methodInfo.Reference, parameters); OSDMap response = new OSDMap(); if (o == null)//void method { response["Value"] = true; } else { response["Value"] = Util.MakeOSD(o, methodInfo.Method.ReturnType); } response["Success"] = true; return(Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(response))); } } return(new byte[0]); }
public override byte[] Handle(string path, Stream requestData, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { StreamReader sr = new StreamReader(requestData); string body = sr.ReadToEnd(); sr.Close(); body = body.Trim(); //MainConsole.Instance.DebugFormat("[XXX]: query String: {0}", body); try { Dictionary <string, object> request = WebUtils.ParseQueryString(body); if (!request.ContainsKey("METHOD")) { return(FailureResult()); } string method = request["METHOD"].ToString(); IGridRegistrationService urlModule = m_registry.RequestModuleInterface <IGridRegistrationService>(); switch (method) { case "getfriends": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Low)) { return(FailureResult()); } } return(GetFriends(request)); case "storefriend": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) { return(FailureResult()); } } return(StoreFriend(request)); case "deletefriend": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) { return(FailureResult()); } } return(DeleteFriend(request)); } MainConsole.Instance.DebugFormat("[FRIENDS HANDLER]: unknown method {0} request {1}", method.Length, method); } catch (Exception e) { MainConsole.Instance.DebugFormat("[FRIENDS HANDLER]: Exception {0}", e); } return(FailureResult()); }
public override byte[] Handle(string path, Stream requestData, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { StreamReader sr = new StreamReader(requestData); string body = sr.ReadToEnd(); sr.Close(); body = body.Trim(); // We need to check the authorization header //httpRequest.Headers["authorization"] ... //m_log.DebugFormat("[XXX]: query String: {0}", body); string method = string.Empty; try { Dictionary <string, object> request = WebUtils.ParseQueryString(body); if (!request.ContainsKey("METHOD")) { return(FailureResult()); } method = request["METHOD"].ToString(); IGridRegistrationService urlModule = m_registry.RequestModuleInterface <IGridRegistrationService>(); switch (method) { case "getaccount": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.None)) { return(new byte[0]); } } return(GetAccount(request)); case "getaccounts": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.None)) { return(new byte[0]); } } return(GetAccounts(request)); case "setaccount": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.Full)) { return(new byte[0]); } } return(StoreAccount(request)); } m_log.DebugFormat("[USER SERVICE HANDLER]: unknown method request: {0}", method); } catch (Exception e) { m_log.DebugFormat("[USER SERVICE HANDLER]: Exception in method {0}: {1}", method, e); } return(FailureResult()); }
public override byte[] Handle(string path, Stream requestData, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { StreamReader sr = new StreamReader(requestData); string body = sr.ReadToEnd(); sr.Close(); body = body.Trim(); OSDMap args = WebUtils.GetOSDMap(body); if (args.ContainsKey("Method")) { IGridRegistrationService urlModule = m_registry.RequestModuleInterface <IGridRegistrationService>(); string method = args["Method"].AsString(); ulong handle; switch (method) { #region Profile case "getprofile": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.None)) { return(FailureResult()); } } return(ProfileHandler.GetProfile(args)); case "updateprofile": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) { return(FailureResult()); } } return(ProfileHandler.UpdateProfile(args)); case "updateagent": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) { return(FailureResult()); } } return(ProfileHandler.UpdateAgent(args)); case "getclassified": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) { return(FailureResult()); } } return(ProfileHandler.GetClassifed(args)); case "getclassifieds": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) { return(FailureResult()); } } return(ProfileHandler.GetClassifieds(args)); case "getpick": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) { return(FailureResult()); } } return(ProfileHandler.GetPick(args)); case "getpicks": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) { return(FailureResult()); } } return(ProfileHandler.GetPicks(args)); case "removepick": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) { return(FailureResult()); } } return(ProfileHandler.RemovePick(args)); case "removeclassified": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) { return(FailureResult()); } } return(ProfileHandler.RemoveClassified(args)); case "addclassified": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) { return(FailureResult()); } } return(ProfileHandler.AddClassified(args)); case "addpick": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) { return(FailureResult()); } } return(ProfileHandler.AddPick(args)); #endregion #region Offline Messages case "addofflinemessage": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Low)) { return(FailureResult()); } } return(OfflineMessagesHandler.AddOfflineMessage(args)); case "getofflinemessages": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(OfflineMessagesHandler.GetOfflineMessages(args)); #endregion #region Emails case "insertemail": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Low)) { return(FailureResult()); } } return(EmailHandler.InsertEmail(args)); case "getemails": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(EmailHandler.GetEmails(args)); #endregion #region Directory Messages case "addregion": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Low)) { return(FailureResult()); } } if (ulong.TryParse(m_SessionID, out handle)) { int x, y; Util.UlongToInts(handle, out x, out y); UUID regionID = this.m_registry.RequestModuleInterface <IGridService>().GetRegionByPosition(UUID.Zero, x, y).RegionID; return(DirectoryHandler.AddRegion(args, regionID)); } break; case "clearregion": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Medium)) { return(FailureResult()); } } if (ulong.TryParse(m_SessionID, out handle)) { int x, y; Util.UlongToInts(handle, out x, out y); UUID regionID = this.m_registry.RequestModuleInterface <IGridService>().GetRegionByPosition(UUID.Zero, x, y).RegionID; return(DirectoryHandler.ClearRegion(regionID, args)); } break; case "getparcelinfo": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Low)) { return(FailureResult()); } } return(DirectoryHandler.GetParcelInfo(args)); case "getparcelbyowner": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(DirectoryHandler.GetParcelByOwner(args)); #endregion } } return(FailureResult()); }
public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { byte[] result = new byte[0]; string[] p = SplitParams(path); if (p.Length == 0) { return(result); } IGridRegistrationService urlModule = m_registry.RequestModuleInterface <IGridRegistrationService>(); if (m_SessionID != "" && urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, "Asset_Get", ThreatLevel.Low)) { return(new byte[0]); } } if (p.Length > 1 && p[1] == "data") { result = m_AssetService.GetData(p[0]); if (result == null) { httpResponse.StatusCode = (int)HttpStatusCode.NotFound; httpResponse.ContentType = "text/plain"; result = new byte[0]; } else { httpResponse.StatusCode = (int)HttpStatusCode.OK; httpResponse.ContentType = "application/octet-stream"; } } else if (p.Length > 1 && p[1] == "exists") { try { bool RetVal = m_AssetService.GetExists(p[0]); XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); result = ServerUtils.SerializeResult(xs, RetVal); if (result == null) { httpResponse.StatusCode = (int)HttpStatusCode.NotFound; httpResponse.ContentType = "text/plain"; result = new byte[0]; } else { httpResponse.StatusCode = (int)HttpStatusCode.OK; httpResponse.ContentType = "application/octet-stream"; } } catch (Exception ex) { result = new byte[0]; MainConsole.Instance.Warn("[AssetServerGetHandler]: Error serializing the result for /exists for asset " + p[0] + ", " + ex); } } else { AssetBase asset = m_AssetService.Get(p[0]); if (asset != null) { XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); result = Util.CompressBytes(ServerUtils.SerializeResult(xs, asset)); httpResponse.StatusCode = (int)HttpStatusCode.OK; httpResponse.ContentType = SLUtil.SLAssetTypeToContentType(asset.Type) + "/gzip"; } else { httpResponse.StatusCode = (int)HttpStatusCode.NotFound; httpResponse.ContentType = "text/plain"; result = new byte[0]; } } return(result); }
public override byte[] Handle(string path, Stream requestData, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { StreamReader sr = new StreamReader(requestData); string body = sr.ReadToEnd(); sr.Close(); body = body.Trim(); //MainConsole.Instance.DebugFormat("[XXX]: query String: {0}", body); try { Dictionary <string, object> request = WebUtils.ParseQueryString(body); if (!request.ContainsKey("METHOD")) { return(FailureResult()); } string method = request["METHOD"].ToString(); IGridRegistrationService urlModule = m_registry.RequestModuleInterface <IGridRegistrationService>(); switch (method) { case "getavatar": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Low)) { return(FailureResult()); } } return(GetAvatar(request)); case "setavatar": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) { return(FailureResult()); } } return(SetAvatar(request)); case "resetavatar": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) { return(FailureResult()); } } return(ResetAvatar(request)); case "cachewearabledata": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(CacheWearableData(request)); } MainConsole.Instance.DebugFormat("[AVATAR HANDLER]: unknown method request: {0}", method); } catch (Exception e) { MainConsole.Instance.Debug("[AVATAR HANDLER]: Exception {0}" + e); } return(FailureResult()); }
public override byte[] Handle(string path, Stream requestData, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { StreamReader sr = new StreamReader(requestData); string body = sr.ReadToEnd(); sr.Close(); body = body.Trim(); OSDMap args = WebUtils.GetOSDMap(body); if (args.ContainsKey("Method")) { IGridRegistrationService urlModule = m_registry.RequestModuleInterface <IGridRegistrationService> (); string method = args["Method"].AsString(); switch (method) { #region Profile case "getprofile": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.None)) { return(FailureResult()); } } return(ProfileHandler.GetProfile(args)); case "updateprofile": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.High)) { return(FailureResult()); } } return(ProfileHandler.UpdateProfile(args)); case "getclassified": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.High)) { return(FailureResult()); } } return(ProfileHandler.GetClassifed(args)); case "getclassifieds": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.High)) { return(FailureResult()); } } return(ProfileHandler.GetClassifieds(args)); case "getpick": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.High)) { return(FailureResult()); } } return(ProfileHandler.GetPick(args)); case "getpicks": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.High)) { return(FailureResult()); } } return(ProfileHandler.GetPicks(args)); case "removepick": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.High)) { return(FailureResult()); } } return(ProfileHandler.RemovePick(args)); case "removeclassified": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.High)) { return(FailureResult()); } } return(ProfileHandler.RemoveClassified(args)); case "addclassified": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.High)) { return(FailureResult()); } } return(ProfileHandler.AddClassified(args)); case "addpick": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.High)) { return(FailureResult()); } } return(ProfileHandler.AddPick(args)); #endregion } } return(FailureResult()); }
public override byte[] Handle(string path, Stream requestData, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { StreamReader sr = new StreamReader(requestData); string body = sr.ReadToEnd(); sr.Close(); body = body.Trim(); //MainConsole.Instance.DebugFormat("[XXX]: query String: {0}", body); try { Dictionary <string, object> request = WebUtils.ParseQueryString(body); if (!request.ContainsKey("METHOD")) { //OSD map test OSDMap map = WebUtils.GetOSDMap(body); if (map != null) { if (map.ContainsKey("Method")) { if (map["Method"] == "Register") { return(NewRegister(map)); } else if (!m_secure) { return(null); } if (map["Method"] == "UpdateMap") { return(UpdateMap(map)); } } } else { return(FailureResult()); } } if (!m_secure) { return(null); } string method = request["METHOD"].ToString(); IGridRegistrationService urlModule = m_registry.RequestModuleInterface <IGridRegistrationService>(); switch (method) { case "register": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.None)) { return(FailureResult()); } } return(Register(request)); case "deregister": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.None)) { return(FailureResult()); } } return(Deregister(request)); case "get_region_by_uuid": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Low)) { return(FailureResult()); } } return(GetRegionByUUID(request)); case "get_region_by_position": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Low)) { return(FailureResult()); } } return(GetRegionByPosition(request)); case "get_region_by_name": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Low)) { return(FailureResult()); } } return(GetRegionByName(request)); case "get_regions_by_name": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Low)) { return(FailureResult()); } } return(GetRegionsByName(request)); case "get_region_range": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Low)) { return(FailureResult()); } } return(GetRegionRange(request)); case "get_default_regions": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(GetDefaultRegions(request)); case "get_fallback_regions": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(GetFallbackRegions(request)); case "get_safe_regions": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(GetSafeRegions(request)); case "get_region_flags": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Low)) { return(FailureResult()); } } return(GetRegionFlags(request)); case "getmapitems": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Low)) { return(FailureResult()); } } return(GetMapItems(request)); case "removetelehub": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(RemoveTelehub(request)); case "addtelehub": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(AddTelehub(request)); case "findtelehub": if (urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Low)) { return(FailureResult()); } } return(FindTelehub(request)); } MainConsole.Instance.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method); } catch (Exception e) { MainConsole.Instance.WarnFormat("[GRID HANDLER]: Exception {0}", e); } return(FailureResult()); }
public override byte[] Handle(string path, Stream requestData, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { StreamReader sr = new StreamReader(requestData); string body = sr.ReadToEnd(); sr.Close(); body = body.Trim(); //m_log.DebugFormat("[XXX]: query String: {0}", body); try { Dictionary <string, object> request = WebUtils.ParseQueryString(body); if (!request.ContainsKey("METHOD")) { return(FailureResult()); } string method = request["METHOD"].ToString(); request.Remove("METHOD"); IGridRegistrationService urlModule = m_registry.RequestModuleInterface <IGridRegistrationService>(); switch (method) { case "CREATEUSERINVENTORY": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.Full)) { return(FailureResult()); } } return(HandleCreateUserInventory(request)); case "GETINVENTORYSKELETON": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(HandleGetInventorySkeleton(request)); case "GETROOTFOLDER": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(HandleGetRootFolder(request)); case "GETFOLDERFORTYPE": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(HandleGetFolderForType(request)); case "GETFOLDERCONTENT": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(HandleGetFolderContent(request)); case "GETFOLDERITEMS": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(HandleGetFolderItems(request)); case "ADDFOLDER": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(HandleAddFolder(request)); case "UPDATEFOLDER": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.High)) { return(FailureResult()); } } return(HandleUpdateFolder(request)); case "MOVEFOLDER": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(HandleMoveFolder(request)); case "DELETEFOLDERS": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.High)) { return(FailureResult()); } } return(HandleDeleteFolders(request)); case "PURGEFOLDER": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.High)) { return(FailureResult()); } } return(HandlePurgeFolder(request)); case "ADDITEM": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(HandleAddItem(request)); case "UPDATEITEM": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.High)) { return(FailureResult()); } } return(HandleUpdateItem(request)); case "MOVEITEMS": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(HandleMoveItems(request)); case "DELETEITEMS": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.High)) { return(FailureResult()); } } return(HandleDeleteItems(request)); case "GETITEM": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(HandleGetItem(request)); case "GETFOLDER": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(HandleGetFolder(request)); case "GETACTIVEGESTURES": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(HandleGetActiveGestures(request)); case "GETASSETPERMISSIONS": if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(HandleGetAssetPermissions(request)); } m_log.DebugFormat("[XINVENTORY HANDLER]: unknown method request: {0}", method); } catch (Exception e) { m_log.Debug("[XINVENTORY HANDLER]: Exception {0}", e); } return(FailureResult()); }
public byte[] HandleMap(OSDMap args) { if (args.ContainsKey("Method")) { string method = args["Method"].AsString(); try { MethodImplementation methodInfo; if (GetMethodInfo(method, args.Count - 1, out methodInfo)) { if (m_SessionID == "") { if (methodInfo.Attribute.ThreatLevel != ThreatLevel.None) { return(MainServer.BadRequest); } } else if (!m_urlModule.CheckThreatLevel(m_SessionID, method, methodInfo.Attribute.ThreatLevel)) { return(MainServer.BadRequest); } if (methodInfo.Attribute.UsePassword) { if (!methodInfo.Reference.CheckPassword(args["Password"].AsString())) { return(MainServer.BadRequest); } } if (methodInfo.Attribute.OnlyCallableIfUserInRegion) { UUID userID = args["UserID"].AsUUID(); IClientCapsService clientCaps = m_capsService.GetClientCapsService(userID); if (userID == UUID.Zero || clientCaps == null || clientCaps.GetRootCapsService().RegionHandle != ulong.Parse(m_SessionID)) { return(MainServer.BadRequest); } } ParameterInfo[] paramInfo = methodInfo.Method.GetParameters(); object[] parameters = new object[paramInfo.Length]; int paramNum = 0; foreach (ParameterInfo param in paramInfo) { if (args[param.Name].Type == OSDType.Unknown) { parameters[paramNum++] = null; } else if (param.ParameterType == typeof(OSD)) { parameters[paramNum++] = args[param.Name]; } else { parameters[paramNum++] = Util.OSDToObject(args[param.Name], param.ParameterType); } } object o = methodInfo.Method.FastInvoke(paramInfo, methodInfo.Reference, parameters); OSDMap response = new OSDMap(); if (o == null)//void method { response["Value"] = "null"; } else { response["Value"] = Util.MakeOSD(o, methodInfo.Method.ReturnType); } response["Success"] = true; return(Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(response, true))); } } catch (Exception ex) { MainConsole.Instance.WarnFormat("[ServerHandler]: Error occured for method {0}: {1}", method, ex.ToString()); } } else { MainConsole.Instance.Warn("[ServerHandler]: Post did not have a method block"); } return(MainServer.BadRequest); }
public override byte[] Handle(string path, Stream requestData, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { StreamReader sr = new StreamReader(requestData); string body = sr.ReadToEnd(); sr.Close(); body = body.Trim(); //MainConsole.Instance.DebugFormat("[XXX]: query String: {0}", body); try { Dictionary <string, object> request = WebUtils.ParseQueryString(body); if (!request.ContainsKey("METHOD")) { return(FailureResult()); } string method = request["METHOD"].ToString(); request.Remove("METHOD"); IGridRegistrationService urlModule = m_registry.RequestModuleInterface <IGridRegistrationService>(); switch (method) { case "GETROOTFOLDER": if (m_SessionID != "" && urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(HandleGetRootFolder(request)); case "GETFOLDERFORTYPE": if (m_SessionID != "" && urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(HandleGetFolderForType(request)); case "GETFOLDERCONTENT": if (m_SessionID != "" && urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(HandleGetFolderContent(request)); case "GETFOLDERITEMS": if (m_SessionID != "" && urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(HandleGetFolderItems(request)); case "ADDFOLDER": if (m_SessionID != "" && urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(HandleAddFolder(request)); case "UPDATEFOLDER": if (m_SessionID != "" && urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) { return(FailureResult()); } } return(HandleUpdateFolder(request)); case "MOVEFOLDER": if (m_SessionID != "" && urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(HandleMoveFolder(request)); case "DELETEFOLDERS": if (m_SessionID != "" && urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) { return(FailureResult()); } } return(HandleDeleteFolders(request)); case "PURGEFOLDER": if (m_SessionID != "" && urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) { return(FailureResult()); } } return(HandlePurgeFolder(request)); case "ADDITEM": if (m_SessionID != "" && urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(HandleAddItem(request)); case "UPDATEITEM": if (m_SessionID != "" && urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) { return(FailureResult()); } } return(HandleUpdateItem(request)); case "MOVEITEMS": if (m_SessionID != "" && urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(HandleMoveItems(request)); case "DELETEITEMS": if (m_SessionID != "" && urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.High)) { return(FailureResult()); } } return(HandleDeleteItems(request)); case "GETITEM": if (m_SessionID != "" && urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(HandleGetItem(request)); case "GETFOLDER": if (m_SessionID != "" && urlModule != null) { if (!urlModule.CheckThreatLevel(m_SessionID, method, ThreatLevel.Medium)) { return(FailureResult()); } } return(HandleGetFolder(request)); } MainConsole.Instance.DebugFormat("[XINVENTORY HANDLER]: unknown method request: {0}", method); } catch (Exception e) { MainConsole.Instance.Debug("[XINVENTORY HANDLER]: Exception {0}", e); } return(FailureResult()); }
public override byte[] Handle(string path, Stream requestData, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { StreamReader sr = new StreamReader(requestData); string body = sr.ReadToEnd(); sr.Close(); body = body.Trim(); //m_log.DebugFormat("[XXX]: query String: {0}", body); try { IGridRegistrationService urlModule = m_registry.RequestModuleInterface <IGridRegistrationService>(); OSDMap map = WebUtils.GetOSDMap(body); if (map != null) { if (map.ContainsKey("Method")) { if (map["Method"] == "GetUserInfo") { if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, map["Method"], ThreatLevel.None)) { return(FailureResult()); } } return(GetUserInfo(map)); } if (map["Method"] == "GetUserInfos") { if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, map["Method"], ThreatLevel.Low)) { return(FailureResult()); } } return(GetUserInfos(map)); } if (map["Method"] == "GetAgentsLocations") { if (urlModule != null) { if (!urlModule.CheckThreatLevel("", m_regionHandle, map["Method"], ThreatLevel.Low)) { return(FailureResult()); } } return(GetAgentsLocations(map)); } } } } catch (Exception e) { m_log.WarnFormat("[AGENT INFO HANDLER]: Exception {0}", e); } return(FailureResult()); }