public static XmlRpc.XmlRpcResponse DoXmlRpcRequest(string url, XmlRpc.XmlRpcRequest req, int timeoutms, X509CertificateCollection clientCertificates = null) { byte[] rpcdata = req.Serialize(); using (Stream res = new HttpClient.Post(url, "text/xml", rpcdata.Length, (Stream s) => s.Write(rpcdata, 0, rpcdata.Length)) { TimeoutMs = timeoutms, ClientCertificates = clientCertificates }.ExecuteStreamRequest()) { return(XmlRpc.DeserializeResponse(res)); } }
private static Map DoXmlRpcWithHashResponse(string uri, string method, Map reqparams, int timeoutms) { var req = new XmlRpc.XmlRpcRequest(method); req.Params.Add(reqparams); XmlRpc.XmlRpcResponse res = RPC.DoXmlRpcRequest(uri, req, timeoutms); var hash = (Map)res.ReturnValue; if (hash == null) { throw new InvalidOperationException(); } return hash; }
private XmlRpc.XmlRpcResponse HandleBuyLandPrep(XmlRpc.XmlRpcRequest req) { Map structParam; UUID agentId; UUID secureSessionId; IValue language; IValue currencyBuy; IValue confirm; if (!req.Params.TryGetValue(0, out structParam) || !structParam.TryGetValue("agentId", out agentId) || !structParam.TryGetValue("secureSessionId", out secureSessionId) || !structParam.TryGetValue("language", out language) || !structParam.TryGetValue("currencyBuy", out currencyBuy) || !structParam.TryGetValue("confirm", out confirm)) { throw new XmlRpc.XmlRpcFaultException(4, "Missing parameters"); } bool validated = false; IAgent agent; foreach (SceneInterface scene in m_Scenes.ValuesByKey1) { if (scene.Agents.TryGetValue(agentId, out agent) && agent.Session.SecureSessionID == secureSessionId) { validated = true; break; } } var resdata = new Map(); if (!validated) { resdata.Add("success", false); resdata.Add("errorMessage", this.GetLanguageString(GetLanguageCulture(language.ToString()), "UnableToAuthenticate", "Unable to authenticate.")); resdata.Add("errorURI", string.Empty); } else { resdata.Add("success", true); } return(new XmlRpc.XmlRpcResponse { ReturnValue = resdata }); }
private XmlRpc.XmlRpcResponse HandleBuyLandPrep(XmlRpc.XmlRpcRequest req) { Map structParam; UUID agentId; UUID secureSessionId; IValue language; IValue currencyBuy; IValue confirm; if (!req.Params.TryGetValue(0, out structParam) || !structParam.TryGetValue("agentId", out agentId) || !structParam.TryGetValue("secureSessionId", out secureSessionId) || !structParam.TryGetValue("language", out language) || !structParam.TryGetValue("currencyBuy", out currencyBuy) || !structParam.TryGetValue("confirm", out confirm)) { throw new XmlRpc.XmlRpcFaultException(4, "Missing parameters"); } bool validated = false; UserSessionInfo sessionInfo; if (m_UserSessionService.TryGetSecureValue(secureSessionId, out sessionInfo) && sessionInfo.User.ID == agentId) { validated = true; } var resdata = new Map(); if (!validated) { resdata.Add("success", false); resdata.Add("errorMessage", this.GetLanguageString(GetLanguageCulture(language.ToString()), "UnableToAuthenticate", "Unable to authenticate.")); resdata.Add("errorURI", string.Empty); } else { resdata.Add("success", true); } return(new XmlRpc.XmlRpcResponse { ReturnValue = resdata }); }
private XmlRpc.XmlRpcResponse HandlePreFlightBuyLandPrep(XmlRpc.XmlRpcRequest req) { Map structParam; UUID agentId; UUID secureSessionId; IValue language; IValue currencyBuy; if (!req.Params.TryGetValue(0, out structParam) || !structParam.TryGetValue("agentId", out agentId) || !structParam.TryGetValue("secureSessionId", out secureSessionId) || !structParam.TryGetValue("language", out language) || !structParam.TryGetValue("currencyBuy", out currencyBuy)) { throw new XmlRpc.XmlRpcFaultException(4, "Missing parameters"); } bool validated = false; IAgent agent; foreach (SceneInterface scene in m_Scenes.ValuesByKey1) { if (scene.Agents.TryGetValue(agentId, out agent) && agent.Session.SecureSessionID == secureSessionId) { validated = true; break; } } var resdata = new Map(); if (!validated) { resdata.Add("success", false); resdata.Add("errorMessage", this.GetLanguageString(GetLanguageCulture(language.ToString()), "UnableToAuthenticate", "Unable to authenticate.")); resdata.Add("errorURI", string.Empty); } else { var membership_level = new Map { { "id", UUID.Zero }, { "description", "some level" } }; var membership_levels = new Map { ["level"] = membership_level }; var landUse = new Map { { "upgrade", false }, { "action", m_HttpServer.ServerURI } }; var currency = new Map { { "estimatedCost", currencyBuy } }; var membership = new Map { { "upgrade", false }, { "action", m_HttpServer.ServerURI }, { "levels", membership_levels } }; resdata.Add("success", true); resdata.Add("membership", membership); resdata.Add("landUse", landUse); resdata.Add("currency", currency); if (currency.AsInt != 0) { resdata.Add("confirm", "click"); } else { resdata.Add("confirm", string.Empty); } } return(new XmlRpc.XmlRpcResponse { ReturnValue = resdata }); }
private XmlRpc.XmlRpcResponse HandleGetCurrencyQuote(XmlRpc.XmlRpcRequest req) { Map structParam; UUID agentId; UUID secureSessionId; Integer currencyBuy; IValue language; if (!req.Params.TryGetValue(0, out structParam) || !structParam.TryGetValue("agentId", out agentId) || !structParam.TryGetValue("secureSessionId", out secureSessionId) || !structParam.TryGetValue("currencyBuy", out currencyBuy) || !structParam.TryGetValue("language", out language)) { throw new XmlRpc.XmlRpcFaultException(4, "Missing parameters"); } bool validated = false; IAgent agent = null; foreach (SceneInterface scene in m_Scenes.ValuesByKey1) { if (scene.Agents.TryGetValue(agentId, out agent) && agent.Session.SecureSessionID == secureSessionId) { validated = true; break; } } var resdata = new Map(); if (!validated) { resdata.Add("success", false); resdata.Add("errorMessage", this.GetLanguageString(GetLanguageCulture(language.ToString()), "UnableToAuthenticate", "Unable to authenticate.")); resdata.Add("errorURI", string.Empty); return(new XmlRpc.XmlRpcResponse { ReturnValue = resdata }); } EconomyServiceInterface economyService = agent.EconomyService; if (economyService == null) { resdata.Add("success", false); resdata.Add("errorMessage", this.GetLanguageString(agent.CurrentCulture, "NoEconomyConfigured", "No economy configured.")); resdata.Add("errorURI", string.Empty); return(new XmlRpc.XmlRpcResponse { ReturnValue = resdata }); } EconomyServiceInterface.CurrencyQuote quote; try { quote = economyService.GetCurrencyQuote(agent.Owner, language.ToString(), currencyBuy.AsInt); } catch (EconomyServiceInterface.UrlAttachedErrorException e) { resdata.Add("success", false); resdata.Add("errorMessage", e.Message); resdata.Add("errorURI", e.Uri); return(new XmlRpc.XmlRpcResponse { ReturnValue = resdata }); } catch (Exception e) { resdata.Add("success", false); resdata.Add("errorMessage", "\n\n" + e.Message); resdata.Add("errorURI", string.Empty); return(new XmlRpc.XmlRpcResponse { ReturnValue = resdata }); } resdata.Add("currency", quote.LocalCurrency); resdata.Add("estimatedCost", quote.EstimatedUsCents); resdata.Add("estimatedLocalCost", quote.EstimatedLocalCost); resdata.Add("currencyBuy", quote.CurrencyToBuy); switch (quote.ConfirmType) { case EconomyServiceInterface.ConfirmTypeEnum.None: resdata.Add("confirm", "none"); break; default: resdata.Add("confirm", "click"); break; case EconomyServiceInterface.ConfirmTypeEnum.Password: resdata.Add("confirm", "password"); break; } return(new XmlRpc.XmlRpcResponse { ReturnValue = resdata }); }
private XmlRpc.XmlRpcResponse HandlePreFlightBuyLandPrep(XmlRpc.XmlRpcRequest req) { Map structParam; UUID agentId; UUID secureSessionId; IValue language; if (!req.Params.TryGetValue(0, out structParam) || !structParam.TryGetValue("agentId", out agentId) || !structParam.TryGetValue("secureSessionId", out secureSessionId) || !structParam.TryGetValue("language", out language)) { throw new XmlRpc.XmlRpcFaultException(4, "Missing parameters"); } bool validated = false; UserSessionInfo sessionInfo; if (m_UserSessionService.TryGetSecureValue(secureSessionId, out sessionInfo) && sessionInfo.User.ID == agentId) { validated = true; } var resdata = new Map(); if (!validated) { resdata.Add("success", false); resdata.Add("errorMessage", this.GetLanguageString(GetLanguageCulture(language.ToString()), "UnableToAuthenticate", "Unable to authenticate.")); resdata.Add("errorURI", string.Empty); } else { var membership_level = new Map { { "id", UUID.Zero }, { "description", "some level" } }; var membership_levels = new Map { ["level"] = membership_level }; var landUse = new Map { { "upgrade", false }, { "action", m_HttpServer.ServerURI } }; var currency = new Map { { "estimatedCost", "200.00" } }; var membership = new Map { { "upgrade", false }, { "action", m_HttpServer.ServerURI }, { "levels", membership_levels } }; resdata.Add("success", true); resdata.Add("membership", membership); resdata.Add("landUse", landUse); resdata.Add("currency", currency); resdata.Add("confirm", string.Empty); } return(new XmlRpc.XmlRpcResponse { ReturnValue = resdata }); }
public bool Run() { XmlRpc.XmlRpcRequest req = XmlRpc.DeserializeRequest(new MemoryStream(UTF8NoBOM.GetBytes(ParserInput))); return(true); }