public XmlRpcResponse XmlRPCGetAvatarAppearance(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            XmlRpcResponse response = new XmlRpcResponse();
            Hashtable requestData = (Hashtable)request.Params[0];
            AvatarAppearance appearance;
            Hashtable responseData;
            if (requestData.Contains("owner"))
            {
                appearance = m_userDataBaseService.GetUserAppearance(new UUID((string)requestData["owner"]));
                if (appearance == null)
                {
                    responseData = new Hashtable();
                    responseData["error_type"] = "no appearance";
                    responseData["error_desc"] = "There was no appearance found for this avatar";
                }
                else
                {
                    responseData = appearance.ToHashTable();
                }
            }
            else
            {
                responseData = new Hashtable();
                responseData["error_type"] = "unknown_avatar";
                responseData["error_desc"] = "The avatar appearance requested is not in the database";
            }

            response.Value = responseData;
            return response;
        }
예제 #2
0
        /// <summary>
        /// Someone wants to link to us
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public XmlRpcResponse LinkRegionRequest(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            Hashtable requestData = (Hashtable)request.Params[0];
            //string host = (string)requestData["host"];
            //string portstr = (string)requestData["port"];
            string name = (string)requestData["region_name"];
            if (name == null)
                name = string.Empty;

            UUID regionID = UUID.Zero;
            string externalName = string.Empty;
            string imageURL = string.Empty;
            ulong regionHandle = 0;
            string reason = string.Empty;

            bool success = m_GatekeeperService.LinkRegion(name, out regionID, out regionHandle, out externalName, out imageURL, out reason);

            Hashtable hash = new Hashtable();
            hash["result"] = success.ToString();
            hash["uuid"] = regionID.ToString();
            hash["handle"] = regionHandle.ToString();
            hash["region_image"] = imageURL;
            hash["external_name"] = externalName;

            XmlRpcResponse response = new XmlRpcResponse();
            response.Value = hash;
            return response;
        }
예제 #3
0
        public XmlRpcResponse GetLandData(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            Hashtable requestData = (Hashtable)request.Params[0];
            ulong regionHandle = Convert.ToUInt64(requestData["region_handle"]);
            uint x = Convert.ToUInt32(requestData["x"]);
            uint y = Convert.ToUInt32(requestData["y"]);
            m_log.DebugFormat("[LAND HANDLER]: Got request for land data at {0}, {1} for region {2}", x, y, regionHandle);

            byte regionAccess;
            LandData landData = m_LocalService.GetLandData(regionHandle, x, y, out regionAccess);
            Hashtable hash = new Hashtable();
            if (landData != null)
            {
                // for now, only push out the data we need for answering a ParcelInfoReqeust
                hash["AABBMax"] = landData.AABBMax.ToString();
                hash["AABBMin"] = landData.AABBMin.ToString();
                hash["Area"] = landData.Area.ToString();
                hash["AuctionID"] = landData.AuctionID.ToString();
                hash["Description"] = landData.Description;
                hash["Flags"] = landData.Flags.ToString();
                hash["GlobalID"] = landData.GlobalID.ToString();
                hash["Name"] = landData.Name;
                hash["OwnerID"] = landData.OwnerID.ToString();
                hash["SalePrice"] = landData.SalePrice.ToString();
                hash["SnapshotID"] = landData.SnapshotID.ToString();
                hash["UserLocation"] = landData.UserLocation.ToString();
                hash["RegionAccess"] = regionAccess.ToString();
            }

            XmlRpcResponse response = new XmlRpcResponse();
            response.Value = hash;
            return response;
        }
        public XmlRpcResponse GetRegion(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            Hashtable requestData = (Hashtable)request.Params[0];
            //string host = (string)requestData["host"];
            //string portstr = (string)requestData["port"];
            string regionID_str = (string)requestData["region_uuid"];
            UUID regionID = UUID.Zero;
            UUID.TryParse(regionID_str, out regionID);

            GridRegion regInfo = m_GatekeeperService.GetHyperlinkRegion(regionID);

            Hashtable hash = new Hashtable();
            if (regInfo == null)
                hash["result"] = "false";
            else
            {
                hash["result"] = "true";
                hash["uuid"] = regInfo.RegionID.ToString();
                hash["x"] = regInfo.RegionLocX.ToString();
                hash["y"] = regInfo.RegionLocY.ToString();
                hash["region_name"] = regInfo.RegionName;
                hash["hostname"] = regInfo.ExternalHostName;
                hash["http_port"] = regInfo.HttpPort.ToString();
                hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString();
            }
            XmlRpcResponse response = new XmlRpcResponse();
            response.Value = hash;
            return response;

        }
예제 #5
0
        public SimProfile LoadFromGrid(LLUUID UUID, string GridURL, string SendKey, string RecvKey)
        {
            try
            {
                Hashtable GridReqParams = new Hashtable();
                GridReqParams["UUID"] = UUID.ToString();
                GridReqParams["authkey"] = SendKey;
                ArrayList SendParams = new ArrayList();
                SendParams.Add(GridReqParams);
                XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);

                XmlRpcResponse GridResp = GridReq.Send(GridURL, 3000);

                Hashtable RespData = (Hashtable)GridResp.Value;
                this.UUID = new LLUUID((string)RespData["UUID"]);
                this.regionhandle = Helpers.UIntsToLong(((uint)Convert.ToUInt32(RespData["region_locx"]) * 256), ((uint)Convert.ToUInt32(RespData["region_locy"]) * 256));
                this.regionname = (string)RespData["regionname"];
                this.sim_ip = (string)RespData["sim_ip"];
                this.sim_port = (uint)Convert.ToUInt16(RespData["sim_port"]);
                this.caps_url = "http://" + ((string)RespData["sim_ip"]) + ":" + (string)RespData["sim_port"] + "/";
                this.RegionLocX = (uint)Convert.ToUInt32(RespData["region_locx"]);
                this.RegionLocY = (uint)Convert.ToUInt32(RespData["region_locy"]);
                this.sendkey = SendKey;
                this.recvkey = RecvKey;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            return this;
        }
        /// <summary>Static method that parses XML data into a request using the Singleton.</summary>
        /// <param name="xmlData"><c>StreamReader</c> containing an XML-RPC request.</param>
        /// <returns><c>XmlRpcRequest</c> object resulting from the parse.</returns>
        override public Object Deserialize(TextReader xmlData)
        {
            XmlTextReader reader = new XmlTextReader(xmlData);
            XmlRpcRequest request = new XmlRpcRequest();
            bool done = false;

            lock (this)
            {
                Reset();
                while (!done && reader.Read())
                {
                    DeserializeNode(reader); // Parent parse...
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.EndElement:
                            switch (reader.Name)
                            {
                                case METHOD_NAME:
                                    request.MethodName = _text;
                                    break;
                                case METHOD_CALL:
                                    done = true;
                                    break;
                                case PARAM:
                                    request.Params.Add(_value);
                                    _text = null;
                                    break;
                            }
                            break;
                    }
                }
            }
            return request;
        }
예제 #7
0
        public XmlRpcResponse GenerateKeyMethod(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            XmlRpcResponse response = new XmlRpcResponse();

            if (request.Params.Count < 2)
            {
                response.IsFault = true;
                response.SetFault(-1, "Invalid parameters");
                return response;
            }

            // Verify the key of who's calling
            UUID userID = UUID.Zero;
            string authKey = string.Empty;
            UUID.TryParse((string)request.Params[0], out userID);
            authKey = (string)request.Params[1];

            m_log.InfoFormat("[AUTH HANDLER] GenerateKey called with authToken {0}", authKey);
            string newKey = string.Empty;

            newKey = m_LocalService.GetKey(userID, authKey.ToString());
 
            response.Value = (string)newKey;
            return response;
        }
        public virtual void CustomiseResponse(ref Hashtable response, UserProfile theUser)
        {
            //default method set up to act as ogs user server
            SimProfile SimInfo= new SimProfile();
            //get siminfo from grid server
            SimInfo = SimInfo.LoadFromGrid(theUser.homeregionhandle, GridURL, GridSendKey, GridRecvKey);
            Int32 circode = (Int32)Convert.ToUInt32(response["circuit_code"]);
            theUser.AddSimCircuit((uint)circode, SimInfo.UUID);
            response["home"] = "{'region_handle':[r" + (SimInfo.RegionLocX * 256).ToString() + ",r" + (SimInfo.RegionLocY * 256).ToString() + "], 'position':[r" + theUser.homepos.X.ToString() + ",r" + theUser.homepos.Y.ToString() + ",r" + theUser.homepos.Z.ToString() + "], 'look_at':[r" + theUser.homelookat.X.ToString() + ",r" + theUser.homelookat.Y.ToString() + ",r" + theUser.homelookat.Z.ToString() + "]}";
            response["sim_ip"] = SimInfo.sim_ip;
            response["sim_port"] = (Int32)SimInfo.sim_port;
            response["region_y"] = (Int32)SimInfo.RegionLocY * 256;
            response["region_x"] = (Int32)SimInfo.RegionLocX * 256;

            //default is ogs user server, so let the sim know about the user via a XmlRpcRequest
            Console.WriteLine(SimInfo.caps_url);
            Hashtable SimParams = new Hashtable();
            SimParams["session_id"] = theUser.CurrentSessionID.ToString();
            SimParams["secure_session_id"] = theUser.CurrentSecureSessionID.ToString();
            SimParams["firstname"] = theUser.firstname;
            SimParams["lastname"] = theUser.lastname;
            SimParams["agent_id"] = theUser.UUID.ToString();
            SimParams["circuit_code"] = (Int32)circode;
            SimParams["startpos_x"] = theUser.homepos.X.ToString();
            SimParams["startpos_y"] = theUser.homepos.Y.ToString();
            SimParams["startpos_z"] = theUser.homepos.Z.ToString();
            ArrayList SendParams = new ArrayList();
            SendParams.Add(SimParams);

            XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
            XmlRpcResponse GridResp = GridReq.Send(SimInfo.caps_url, 3000);
        }
예제 #9
0
    public static XmlRpcRequest Parse(StreamReader xmlData)
      {
	XmlTextReader reader = new XmlTextReader(xmlData);
	XmlRpcRequest request = new XmlRpcRequest();
	bool done = false;


	while (!done && reader.Read())
	  {
	    Singleton.ParseNode(reader); // Parent parse...
            switch (reader.NodeType)
	      {
	      case XmlNodeType.EndElement:
		switch (reader.Name)
		  {
		  case METHOD_NAME:
		    request.MethodName = Singleton._text;
		    break;
		  case METHOD_CALL:
		    done = true;
		    break;
		  case PARAM:
		    request.Params.Add(Singleton._value);
		    Singleton._text = null;
		    break;
		  }
		break;
	      default:
		Singleton.ParseNode(reader);
		break;
	      }	
	  }
	return request;
      }
        /// <summary>
        /// Request sim data based on arbitrary key/value
        /// </summary>
        private RegionProfileData RequestSimData(Uri gridserverUrl, string gridserverSendkey, string keyField, string keyValue)
        {
            Hashtable requestData = new Hashtable();
            requestData[keyField] = keyValue;
            requestData["authkey"] = gridserverSendkey;
            ArrayList SendParams = new ArrayList();
            SendParams.Add(requestData);
            XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
            XmlRpcResponse GridResp = GridReq.Send(gridserverUrl.ToString(), 3000);

            Hashtable responseData = (Hashtable) GridResp.Value;

            RegionProfileData simData = null;

            if (!responseData.ContainsKey("error"))
            {
                uint locX = Convert.ToUInt32((string)responseData["region_locx"]);
                uint locY = Convert.ToUInt32((string)responseData["region_locy"]);
                string externalHostName = (string)responseData["sim_ip"];
                uint simPort = Convert.ToUInt32((string)responseData["sim_port"]);
                uint httpPort = Convert.ToUInt32((string)responseData["http_port"]);
                uint remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
                string serverUri = (string)responseData["server_uri"];
                UUID regionID = new UUID((string)responseData["region_UUID"]);
                string regionName = (string)responseData["region_name"];
                byte access = Convert.ToByte((string)responseData["access"]);

                simData = RegionProfileData.Create(regionID, regionName, locX, locY, externalHostName, simPort, httpPort, remotingPort, serverUri, access);
            }

            return simData;
        }
        public XmlRpcResponse GetHomeRegion(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            Hashtable requestData = (Hashtable)request.Params[0];
            //string host = (string)requestData["host"];
            //string portstr = (string)requestData["port"];
            string userID_str = (string)requestData["userID"];
            UUID userID = UUID.Zero;
            UUID.TryParse(userID_str, out userID);

            Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY;
            GridRegion regInfo = m_HomeUsersService.GetHomeRegion(userID, out position, out lookAt);

            Hashtable hash = new Hashtable();
            if (regInfo == null)
                hash["result"] = "false";
            else
            {
                hash["result"] = "true";
                hash["uuid"] = regInfo.RegionID.ToString();
                hash["x"] = regInfo.RegionLocX.ToString();
                hash["y"] = regInfo.RegionLocY.ToString();
                hash["region_name"] = regInfo.RegionName;
                hash["hostname"] = regInfo.ExternalHostName;
                hash["http_port"] = regInfo.HttpPort.ToString();
                hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString();
                hash["position"] = position.ToString();
                hash["lookAt"] = lookAt.ToString();
            }
            XmlRpcResponse response = new XmlRpcResponse();
            response.Value = hash;
            return response;

        }
 public bool Connect(string GridServerURL, string username, string password)
 {
     try
     {
         this.ServerURL=GridServerURL;
         Hashtable LoginParamsHT = new Hashtable();
         LoginParamsHT["username"]=username;
         LoginParamsHT["password"]=password;
         ArrayList LoginParams = new ArrayList();
         LoginParams.Add(LoginParamsHT);
         XmlRpcRequest GridLoginReq = new XmlRpcRequest("manager_login",LoginParams);
         XmlRpcResponse GridResp = GridLoginReq.Send(ServerURL,3000);
         if (GridResp.IsFault)
         {
             connected=false;
             return false;
         }
         else
         {
             Hashtable gridrespData = (Hashtable)GridResp.Value;
             this.SessionID = new LLUUID((string)gridrespData["session_id"]);
             connected=true;
             return true;
         }
     }
     catch(Exception e)
     {
         Console.WriteLine(e.ToString());
         connected=false;
         return false;
     }
 }
예제 #13
0
        public virtual LandData GetLandData(ulong regionHandle, uint x, uint y)
        {
            LandData landData = null;
            Hashtable hash = new Hashtable();
            hash["region_handle"] = regionHandle.ToString();
            hash["x"] = x.ToString();
            hash["y"] = y.ToString();

            IList paramList = new ArrayList();
            paramList.Add(hash);

            try
            {
                uint xpos = 0, ypos = 0;
                Utils.LongToUInts(regionHandle, out xpos, out ypos);
                GridRegion info = m_GridService.GetRegionByPosition(UUID.Zero, (int)xpos, (int)ypos);
                if (info != null) // just to be sure
                {
                    XmlRpcRequest request = new XmlRpcRequest("land_data", paramList);
                    string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/";
                    XmlRpcResponse response = request.Send(uri, 10000);
                    if (response.IsFault)
                    {
                        m_log.ErrorFormat("[LAND CONNECTOR] remote call returned an error: {0}", response.FaultString);
                    }
                    else
                    {
                        hash = (Hashtable)response.Value;
                        try
                        {
                            landData = new LandData();
                            landData.AABBMax = Vector3.Parse((string)hash["AABBMax"]);
                            landData.AABBMin = Vector3.Parse((string)hash["AABBMin"]);
                            landData.Area = Convert.ToInt32(hash["Area"]);
                            landData.AuctionID = Convert.ToUInt32(hash["AuctionID"]);
                            landData.Description = (string)hash["Description"];
                            landData.Flags = Convert.ToUInt32(hash["Flags"]);
                            landData.GlobalID = new UUID((string)hash["GlobalID"]);
                            landData.Name = (string)hash["Name"];
                            landData.OwnerID = new UUID((string)hash["OwnerID"]);
                            landData.SalePrice = Convert.ToInt32(hash["SalePrice"]);
                            landData.SnapshotID = new UUID((string)hash["SnapshotID"]);
                            landData.UserLocation = Vector3.Parse((string)hash["UserLocation"]);
                            m_log.DebugFormat("[OGS1 GRID SERVICES] Got land data for parcel {0}", landData.Name);
                        }
                        catch (Exception e)
                        {
                            m_log.Error("[LAND CONNECTOR] Got exception while parsing land-data:", e);
                        }
                    }
                }
                else m_log.WarnFormat("[LAND CONNECTOR] Couldn't find region with handle {0}", regionHandle);
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[LAND CONNECTOR] Couldn't contact region {0}: {1}", regionHandle, e);
            }
        
            return landData;
        }
예제 #14
0
        public XmlRpcResponse HandleXMLRPCLogin(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            Hashtable requestData = (Hashtable)request.Params[0];
            if (m_Proxy && request.Params[3] != null)
            {
                IPEndPoint ep = Util.GetClientIPFromXFF((string)request.Params[3]);
                if (ep != null)
                    // Bang!
                    remoteClient = ep;
            }

            if (requestData != null)
            {
                if (requestData.ContainsKey("first") && requestData["first"] != null &&
                    requestData.ContainsKey("last") && requestData["last"] != null &&
                    requestData.ContainsKey("passwd") && requestData["passwd"] != null)
                {
                    string first = requestData["first"].ToString();
                    string last = requestData["last"].ToString();
                    string passwd = requestData["passwd"].ToString();
                    string startLocation = string.Empty;
                    UUID scopeID = UUID.Zero;
                    if (requestData["scope_id"] != null)
                        scopeID = new UUID(requestData["scope_id"].ToString());
                    if (requestData.ContainsKey("start"))
                        startLocation = requestData["start"].ToString();

                    string clientVersion = "Unknown";
                    if (requestData.Contains("version") && requestData["version"] != null)
                        clientVersion = requestData["version"].ToString();
                    // We should do something interesting with the client version...

                    string channel = "Unknown";
                    if (requestData.Contains("channel") && requestData["channel"] != null)
                        channel = requestData["channel"].ToString();

                    string mac = "Unknown";
                    if (requestData.Contains("mac") && requestData["mac"] != null)
                        mac = requestData["mac"].ToString();

                    string id0 = "Unknown";
                    if (requestData.Contains("id0") && requestData["id0"] != null)
                        id0 = requestData["id0"].ToString();
                    
                    //m_log.InfoFormat("[LOGIN]: XMLRPC Login Requested for {0} {1}, starting in {2}, using {3}", first, last, startLocation, clientVersion);

                    LoginResponse reply = null;
                    reply = m_LocalService.Login(first, last, passwd, startLocation, scopeID, clientVersion, channel, mac, id0, remoteClient);

                    XmlRpcResponse response = new XmlRpcResponse();
                    response.Value = reply.ToHashtable();
                    return response;

                }
            }

            return FailedXMLRPCResponse();

        }
예제 #15
0
		public override object Execute(out Hashtable outputParams)
		{
			// assign output params
			outputParams = null;
			
			Hashtable outputPlaceholder = null;

			// create new XmlRpcRequest object
			XmlRpcRequest client = new XmlRpcRequest();

			// fill in the concrete method name
			client.MethodName = Call.Renderer.Voc.GetMethodCmp(Call.MethodName, Call.ObjectName);	
			
			// provide the input parameters	
			Uiml.Param[] parameters = Call.Renderer.Voc.GetMethodParams(Call.ObjectName, Call.MethodName);
			
			Type[] tparamTypes = null;
			try
			{
				tparamTypes = CreateInOutParamTypes(parameters, out outputPlaceholder);
			}
			catch(ArgumentOutOfRangeException) 
			{ 
				return null; 
			}
			
			for (int k = 0; k < parameters.Length; k++)
			{
				string propValue = (string) ((Uiml.Executing.Param) Call.Params[k]).Value(Call.Renderer);
				client.Params.Add(Call.Renderer.Decoder.GetArg(propValue, tparamTypes[k]));
			}

			if (m_request == null || !client.ToString().Equals(m_request.ToString()))
			{
				XmlRpcResponse response = client.Send(m_url);
				
				// cache response and request
				m_request = client;
				m_response = response;
			}
			
			if (m_response.IsFault)
			{
				Console.WriteLine("Fault {0}: {1}", m_response.FaultCode, m_response.FaultString);
				return null;
			}
			else
			{
				return m_response.Value;
			}
		}
예제 #16
0
        public XmlRpcResponse Process(XmlRpcRequest request, IPEndPoint client)
        {

            XmlRpcResponse resp = null;
            string clientstring = GetClientString(request, client);
            string endpoint = GetEndPoint(request, client);
            if (_dosProtector.Process(clientstring, endpoint))
                resp = _normalMethod(request, client);
            else
                resp = _throttledMethod(request, client);
            if (_options.MaxConcurrentSessions > 0)
                _dosProtector.ProcessEnd(clientstring, endpoint);
            return resp;
        }
 public static Hashtable SendTransaction(string url, string trans, bool debug)
 {
     Hashtable hashtable = new Hashtable();
     Hashtable hashtable2 = new Hashtable();
     hashtable2["TransID"] = trans;
     XmlRpcRequest xmlRpcRequest = new XmlRpcRequest("grid_store_transaction_message", new ArrayList
     {
         hashtable2
     });
     try
     {
         XmlRpcResponse xmlRpcResponse = xmlRpcRequest.Send(url, 10000);
         Hashtable hashtable3 = (Hashtable)xmlRpcResponse.Value;
         if (hashtable3.ContainsKey("success"))
         {
             if ((string)hashtable3["success"] == "true")
             {
                 string value = (string)hashtable3["result"];
                 hashtable.Add("success", "true");
                 hashtable.Add("result", value);
                 if (debug)
                 {
                     StoreServiceConnector.m_log.DebugFormat("[Web Store Debug] Success", new object[0]);
                 }
             }
             else
             {
                 string value2 = (string)hashtable3["result"];
                 hashtable.Add("success", "false");
                 hashtable.Add("result", value2);
                 if (debug)
                 {
                     StoreServiceConnector.m_log.DebugFormat("[Web Store Debug] Fail", new object[0]);
                 }
             }
         }
         else
         {
             hashtable.Add("success", "false");
             hashtable.Add("result", "The region server did not respond!");
             StoreServiceConnector.m_log.DebugFormat("[Web Store Robust Module]: No response from Region Server! {0}", url);
         }
     }
     catch (WebException ex)
     {
         hashtable.Add("success", "false");
         StoreServiceConnector.m_log.ErrorFormat("[STORE]: Error sending transaction to {0} the host didn't respond " + ex.ToString(), url);
     }
     return hashtable;
 }
예제 #18
0
 private string GetClientString(XmlRpcRequest request, IPEndPoint client)
 {
     string clientstring;
     if (_options.AllowXForwardedFor && request.Params.Count > 3)
     {
         object headerstr = request.Params[3];
         if (headerstr != null && !string.IsNullOrEmpty(headerstr.ToString()))
             clientstring = request.Params[3].ToString();
         else
             clientstring = client.Address.ToString();
     }
     else
         clientstring = client.Address.ToString();
     return clientstring;
 }
        public XmlRpcResponse AgentIsComingHome(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            Hashtable requestData = (Hashtable)request.Params[0];
            //string host = (string)requestData["host"];
            //string portstr = (string)requestData["port"];
            string sessionID_str = (string)requestData["sessionID"];
            UUID sessionID = UUID.Zero;
            UUID.TryParse (sessionID_str, out sessionID);
            string gridName = (string)requestData["externalName"];

            bool success = m_HomeUsersService.AgentIsComingHome (sessionID, gridName);

            Hashtable hash = new Hashtable ();
            hash["result"] = success.ToString ();
            XmlRpcResponse response = new XmlRpcResponse {Value = hash};
            return response;
        }
예제 #20
0
        public XmlRpcResponse GetRegion(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            Hashtable requestData = (Hashtable)request.Params[0];
            //string host = (string)requestData["host"];
            //string portstr = (string)requestData["port"];
            string regionID_str = (string)requestData["region_uuid"];
            UUID regionID = UUID.Zero;
            UUID.TryParse(regionID_str, out regionID);

            UUID agentID = UUID.Zero;
            string agentHomeURI = null;
            if (requestData.ContainsKey("agent_id"))
                agentID = UUID.Parse((string)requestData["agent_id"]);
            if (requestData.ContainsKey("agent_home_uri"))
                agentHomeURI = (string)requestData["agent_home_uri"];

            string message;
            GridRegion regInfo = m_GatekeeperService.GetHyperlinkRegion(regionID, agentID, agentHomeURI, out message);

            Hashtable hash = new Hashtable();
            if (regInfo == null)
            {
                hash["result"] = "false";
            }
            else
            {
                hash["result"] = "true";
                hash["uuid"] = regInfo.RegionID.ToString();
                hash["x"] = regInfo.RegionLocX.ToString();
                hash["y"] = regInfo.RegionLocY.ToString();
                hash["size_x"] = regInfo.RegionSizeX.ToString();
                hash["size_y"] = regInfo.RegionSizeY.ToString();
                hash["region_name"] = regInfo.RegionName;
                hash["hostname"] = regInfo.ExternalHostName;
                hash["http_port"] = regInfo.HttpPort.ToString();
                hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString();
            }

            if (message != null)
                hash["message"] = message;

            XmlRpcResponse response = new XmlRpcResponse();
            response.Value = hash;
            return response;

        }
      public void Request()
      {
	ArrayList parms = new ArrayList();

	parms.Add(1);
	parms.Add("two");
	parms.Add(3.0);

	XmlRpcRequest reqIn = new XmlRpcRequest("object.method", parms);
	String str = (new XmlRpcRequestSerializer()).Serialize(reqIn);
	XmlRpcRequest reqOut = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(str);
	
	Assertion.AssertEquals("method name", reqIn.MethodName, reqOut.MethodName);
	Assertion.AssertEquals("Param count", reqIn.Params.Count, reqOut.Params.Count);
	
	for (int x = 0; x < 3; x++)
	  Assertion.AssertEquals("Param " + x, reqIn.Params[x], reqOut.Params[x]);
      }
예제 #22
0
    static public void Serialize(XmlTextWriter output, XmlRpcRequest req)
      {
	output.WriteStartDocument();
	output.WriteStartElement(METHOD_CALL);
	output.WriteElementString(METHOD_NAME,req.MethodName);
	output.WriteStartElement(PARAMS);
	foreach (Object param in req.Params)
	  {
	    output.WriteStartElement(PARAM);
	    output.WriteStartElement(VALUE);
	    SerializeObject(output, param);
	    output.WriteEndElement();
	    output.WriteEndElement();
	  }

	output.WriteEndElement();
	output.WriteEndElement();
      }
예제 #23
0
        public XmlRpcResponse XmlRpcLoginMethodSwitch(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            Hashtable requestData = (Hashtable)request.Params[0];

            bool RexXML = (requestData.Contains("account") && requestData.Contains("sessionhash"));
            if (RexXML) { return this.m_RealXtendLogin.XmlRpcLoginMethod(request, remoteClient); }

            XmlRpcResponse response = m_UserLoginService.XmlRpcLoginMethod(request, remoteClient);

            if (requestData.Contains("version"))
            {
                if (((string)requestData["version"]).StartsWith("realXtend"))
                {
                    ((Hashtable)response.Value)["rex"] = "running rex mode";
                }
            }

            return response;
        }
 public XmlRpcResponse BuyFunc(XmlRpcRequest request, IPEndPoint ep)
 {
     Hashtable requestData = (Hashtable)request.Params[0];
     bool success = false;
     if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy") &&
         m_connector.GetConfig().CanBuyCurrencyInworld)
     {
         UUID agentId;
         if (UUID.TryParse((string)requestData["agentId"], out agentId))
         {
             uint amountBuying = uint.Parse(requestData["currencyBuy"].ToString());
             success = m_connector.InworldCurrencyBuyTransaction(agentId, amountBuying, ep);
         }
     }
     XmlRpcResponse returnval = new XmlRpcResponse();
     Hashtable returnresp = new Hashtable { { "success", success } };
     returnval.Value = returnresp;
     return returnval;
 }
예제 #25
0
        public static bool VerifyKey(string authurl, UUID userID, string authKey)
        {
            List<string> SendParams = new List<string>();
            SendParams.Add(userID.ToString());
            SendParams.Add(authKey);

            System.Console.WriteLine("[HGrid]: Verifying user key with authority " + authurl);

            string methodName = "hg_verify_auth_key";
            XmlRpcRequest request = new XmlRpcRequest(methodName, SendParams);
            XmlRpcResponse reply;
            try
            {
                reply = request.Send(Util.XmlRpcRequestURI(authurl, methodName), 10000);
            }
            catch (Exception e)
            {
                System.Console.WriteLine("[HGrid]: Failed to verify key. Reason: " + e.Message);
                return false;
            }

            if (reply != null)
            {
                if (!reply.IsFault)
                {
                    bool success = false;
                    if (reply.Value != null)
                        success = (bool)reply.Value;

                    return success;
                }
                else
                {
                    System.Console.WriteLine("[HGrid]: XmlRpc request to verify key failed with message {0}" + reply.FaultString + ", code " + reply.FaultCode);
                    return false;
                }
            }
            else
            {
                System.Console.WriteLine("[HGrid]: XmlRpc request to verify key returned null reply");
                return false;
            }
        }
예제 #26
0
        public string RegionManagementBroadcastPostRequest(AuroraWeb.Environment env, string message)
        {
            Request request = env.Request;

            SessionInfo sinfo;
            if (TryGetSessionInfo(request, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                env.Session = sinfo;

                string url = m_WebApp.LoginURL;
                Hashtable hash = new Hashtable();
                if (m_ServerAdminPassword == null)
                {
                    m_log.Debug("[RegionManagementBroadcastPostRequest] No remote admin password was set in .ini file");
                }

                hash["password"] = m_ServerAdminPassword;
                hash["message"] = message;
                IList paramList = new ArrayList();
                paramList.Add(hash);
                XmlRpcRequest xmlrpcReq = new XmlRpcRequest("admin_broadcast", paramList);

                XmlRpcResponse response = null;
                try
                {
                    response = xmlrpcReq.Send(url, 10000);
                    env.Flags = Flags.IsAdmin | Flags.IsLoggedIn;
                    env.State = State.RegionManagementSuccessful;
                }
                catch (Exception e)
                {
                    m_log.Debug("[AuroraWeb]: Exception " + e.Message);
                    env.Flags = Flags.IsAdmin | Flags.IsLoggedIn;
                    env.State = State.RegionManagementUnsuccessful;
                }

                return PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html"));
            }

            return m_WebApp.ReadFile(env, "index.html");
        }
        /// <summary>
        /// This actually does the XMLRPC Request
        /// </summary>
        /// <param name="url">URL we pull the data out of to send the request to</param>
        /// <param name="im">The Instant Message </param>
        /// <returns>Bool if the message was successfully delivered at the other side.</returns>
        public static bool SendInstantMessage(string url, GridInstantMessage im)
        {
            Hashtable xmlrpcdata = ConvertGridInstantMessageToXMLRPC(im);
            xmlrpcdata["region_handle"] = 0;

            ArrayList SendParams = new ArrayList();
            SendParams.Add(xmlrpcdata);
            XmlRpcRequest GridReq = new XmlRpcRequest("grid_instant_message", SendParams);
            try
            {

                XmlRpcResponse GridResp = GridReq.Send(url, 10000);

                Hashtable responseData = (Hashtable)GridResp.Value;

                if (responseData.ContainsKey("success"))
                {
                    if ((string)responseData["success"] == "TRUE")
                    {
                        //m_log.DebugFormat("[XXX] Success");
                        return true;
                    }
                    else
                    {
                        //m_log.DebugFormat("[XXX] Fail");
                        return false;
                    }
                }
                else
                {
                    m_log.DebugFormat("[GRID INSTANT MESSAGE]: No response from {0}", url);
                    return false;
                }
            }
            catch (WebException e)
            {
                m_log.ErrorFormat("[GRID INSTANT MESSAGE]: Error sending message to {0} the host didn't respond " + e.ToString(), url);
            }

            return false;
        }
예제 #28
0
        public XmlRpcResponse HandleXMLRPCLogin(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            Hashtable requestData = (Hashtable)request.Params[0];

            if (requestData != null)
            {
                if (requestData.ContainsKey("first") && requestData["first"] != null &&
                    requestData.ContainsKey("last") && requestData["last"] != null &&
                    requestData.ContainsKey("passwd") && requestData["passwd"] != null)
                {
                    string first = requestData["first"].ToString();
                    string last = requestData["last"].ToString();
                    string passwd = requestData["passwd"].ToString();
                    string startLocation = string.Empty;
                    UUID scopeID = UUID.Zero;
                    if (requestData["scope_id"] != null)
                        scopeID = new UUID(requestData["scope_id"].ToString());
                    if (requestData.ContainsKey("start"))
                        startLocation = requestData["start"].ToString();

                    string clientVersion = "Unknown";
                    if (requestData.Contains("version"))
                        clientVersion = requestData["version"].ToString();
                    // We should do something interesting with the client version...

                    m_log.InfoFormat("[LOGIN]: XMLRPC Login Requested for {0} {1}, starting in {2}, using {3}", first, last, startLocation, clientVersion);

                    LoginResponse reply = null;
                    reply = m_LocalService.Login(first, last, passwd, startLocation, scopeID, clientVersion, remoteClient);

                    XmlRpcResponse response = new XmlRpcResponse();
                    response.Value = reply.ToHashtable();
                    return response;

                }
            }

            return FailedXMLRPCResponse();

        }
예제 #29
0
        public XmlRpcResponse LandBuyFunc(XmlRpcRequest request, IPEndPoint ep)
        {
            Hashtable requestData = (Hashtable) request.Params[0];

            bool success = false;
            if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy") &&
                m_connector.GetConfig().CanBuyCurrencyInworld)
            {
                UUID agentId;
                if (UUID.TryParse((string) requestData["agentId"], out agentId))
                {
                    uint amountBuying = uint.Parse(requestData["currencyBuy"].ToString());
                    m_connector.UserCurrencyTransfer(agentId, UUID.Zero, UUID.Zero, UUID.Zero, amountBuying,
                                                     "Inworld purchase", TransactionType.SystemGenerated, UUID.Zero);
                    success = true;
                }
            }
            XmlRpcResponse returnval = new XmlRpcResponse();
            Hashtable returnresp = new Hashtable {{"success", success}};
            returnval.Value = returnresp;
            return returnval;
        }
예제 #30
0
        /// <summary>
        /// Request sim data based on arbitrary key/value
        /// </summary>
        private RegionProfileData RequestSimData(Uri gridserverUrl, string gridserverSendkey, string keyField, string keyValue)
        {
            Hashtable requestData = new Hashtable();
            requestData[keyField] = keyValue;
            requestData["authkey"] = gridserverSendkey;
            ArrayList SendParams = new ArrayList();
            SendParams.Add(requestData);

            string methodName = "simulator_data_request";
            XmlRpcRequest GridReq = new XmlRpcRequest(methodName, SendParams);
            XmlRpcResponse GridResp = GridReq.Send(Util.XmlRpcRequestURI(gridserverUrl.ToString(), methodName), 5000);

            Hashtable responseData = (Hashtable) GridResp.Value;

            RegionProfileData simData = null;

            if (!responseData.ContainsKey("error"))
            {
                uint locX = Convert.ToUInt32((string)responseData["region_locx"]);
                uint locY = Convert.ToUInt32((string)responseData["region_locy"]);
                string externalHostName = (string)responseData["sim_ip"];
                uint simPort = Convert.ToUInt32((string)responseData["sim_port"]);
                uint httpPort = Convert.ToUInt32((string)responseData["http_port"]);
                uint remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
                UUID regionID = new UUID((string)responseData["region_UUID"]);
                string regionName = (string)responseData["region_name"];
                byte access = Convert.ToByte((string)responseData["access"]);
                ProductRulesUse product = (ProductRulesUse)Convert.ToInt32(responseData["product"]);

                string outsideIp = null;
                if (responseData.ContainsKey("outside_ip"))
                    outsideIp = (string)responseData["outside_ip"];

                simData = RegionProfileData.Create(regionID, regionName, locX, locY, externalHostName, simPort, httpPort, remotingPort, access, product, outsideIp);
            }

            return simData;
        }
예제 #31
0
 ///<summary>Invoke a method described in a request.</summary>
 ///<param name="req"><c>XmlRpcRequest</c> containing a method descriptions.</param>
 /// <seealso cref="XmlRpcSystemObject.Invoke"/>
 /// <seealso cref="XmlRpcServer.Invoke(String,String,IList)"/>
 public Object Invoke(XmlRpcRequest req)
 {
     return(Invoke(req.MethodNameObject, req.MethodNameMethod, req.Params));
 }