Login Request Parameters
 private void cmdConnect_Click(object sender, EventArgs e)
 {
     if (cmdConnect.Text == "Connect")
     {
         cmdConnect.Text = "Disconnect";
         txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = false;
         LoginParams lp = new LoginParams();
         lp.FirstName = txtFirstName.Text;
         lp.LastName = txtLastName.Text;
         lp.Password = txtPassword.Text;
         lp.URI = Client.Settings.LOGIN_SERVER;
         lp.Start = "last";
         cmdConnect.Enabled = false;
         Client.Network.BeginLogin(lp);
         return;
     }
     else
     {
         Client.Network.Logout();
         cmdConnect.Text = "Connect";
         txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true;
         DisableUpload();
         InitClient();
     }
 }
Example #2
0
        static void Main(string[] args)
        {
            int ircPort;

            if (args.Length < 7 || !UUID.TryParse(args[3], out _MasterID) || !int.TryParse(args[5], out ircPort) || args[6].IndexOf('#') == -1)
                Console.WriteLine("Usage: ircgateway.exe <firstName> <lastName> <password> <masterUUID> <ircHost> <ircPort> <#channel>");

            else
            {
                _Client = new GridClient();
                _Client.Network.OnLogin += new NetworkManager.LoginCallback(Network_OnLogin);
                _Client.Self.ChatFromSimulator += new EventHandler<ChatEventArgs>(Self_ChatFromSimulator);                
                _Client.Self.IM += Self_IM;
                _ClientLogin = _Client.Network.DefaultLoginParams(args[0], args[1], args[2], "", "IRCGateway");

                _AutoJoinChannel = args[6];
                _IRC = new IRCClient(args[4], ircPort, "SLGateway", "Second Life Gateway");
                _IRC.OnConnected += new IRCClient.ConnectCallback(_IRC_OnConnected);
                _IRC.OnMessage += new IRCClient.MessageCallback(_IRC_OnMessage);

                _IRC.Connect();

                string read = Console.ReadLine();
                while (read != null) read = Console.ReadLine();                
            }
        }
Example #3
0
        public GridConn(LoginParams data)
        {
            client = new GridClient();
            prop_request = new List<UUID>();

            discovered_sims = new List<ulong>();

            agent_properties_recieved = new List<UUID>();
            agent_properties_queue = new Dictionary<UUID, DateTime>();
            agent_properties_wait = new List<UUID>();

            LoginParams login = new LoginParams();
            login = client.Network.DefaultLoginParams(data.FirstName, data.LastName, data.Password, "GridSpider", "1.0");
            login.AgreeToTos = true;
            // login.Start = "home";
            login.URI = data.URI;
            login.Channel = "Test Grid Spider";
            login.Version = "1.0";

            client.Settings.OBJECT_TRACKING = true;
            client.Settings.PARCEL_TRACKING = true;
            client.Settings.ALWAYS_REQUEST_OBJECTS = false;
            client.Settings.SEND_AGENT_UPDATES = true;
            client.Settings.MULTIPLE_SIMS = true; // <-------------- very important indeed

            client.Network.SimDiscovered += new EventHandler<SimDiscoveredEventArgs>(Network_SimDiscovered);
            client.Network.SimConnected += new EventHandler<SimConnectedEventArgs>(Network_SimConnected);
            client.Network.SimConnecting += new EventHandler<SimConnectingEventArgs>(Network_SimConnecting);
            client.Parcels.SimParcelsDownloaded += new EventHandler<SimParcelsDownloadedEventArgs>(Parcels_SimParcelsDownloaded);
            client.Self.TeleportProgress += new EventHandler<TeleportEventArgs>(Self_TeleportProgress);
            client.Network.Disconnected += new EventHandler<DisconnectedEventArgs>(Network_Disconnected);
            client.Network.LoggedOut += new EventHandler<LoggedOutEventArgs>(Network_LoggedOut);
            client.Network.SimDisconnected += new EventHandler<SimDisconnectedEventArgs>(Network_SimDisconnected);
            //client.Grid.GridLayer += new EventHandler<GridLayerEventArgs>(Grid_GridLayer);
            //client.Grid.GridRegion += new EventHandler<GridRegionEventArgs>(Grid_GridRegion);


            client.Self.ChatFromSimulator += HandleClientSelfChatFromSimulator;
            client.Self.IM += HandleClientSelfIM;

            client.Self.Movement.Camera.Far = 512;

            client.Network.Login(login);

            client.Self.Movement.Camera.Far = 512;

            client.Self.Movement.SendUpdate(true);

            if (client.Network.LoginStatusCode == LoginStatus.Success)
            {
                Logger.Log("Login procedure completed", Helpers.LogLevel.Info);
                connected = true;
            }
            Logger.Log("Status is " + client.Network.LoginStatusCode.ToString(), Helpers.LogLevel.Info);
            Logger.Log(client.Network.LoginMessage, Helpers.LogLevel.Info);

        }
Example #4
0
        /// <summary>
        /// Provides a full representation of OpenMetaverse.GUI
        /// </summary>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <param name="password"></param>
        public Dashboard(string firstName, string lastName, string password)
        {
            InitializeComponent();

            //force logout and exit when form is closed
            this.FormClosing += new FormClosingEventHandler(Dashboard_FormClosing);

            //initialize the client object and related controls
            InitializeClient(true);

            //double-click events
            avatarList1.OnAvatarDoubleClick += new AvatarList.AvatarDoubleClickCallback(avatarList1_OnAvatarDoubleClick);
            friendsList1.OnFriendDoubleClick += new FriendList.FriendDoubleClickCallback(friendsList1_OnFriendDoubleClick);
            groupList1.OnGroupDoubleClick += new GroupList.GroupDoubleClickCallback(groupList1_OnGroupDoubleClick);

            //login
            ClientLogin = Client.Network.DefaultLoginParams(firstName, lastName, password, "OpenMetaverse Dashboard", Assembly.GetExecutingAssembly().GetName().Version.ToString());
            ClientLogin.Start = "last";
            Client.Network.BeginLogin(ClientLogin);
        }
Example #5
0
        /// <summary>
        /// Handle response from LLSD login replies
        /// </summary>
        /// <param name="client"></param>
        /// <param name="result"></param>
        /// <param name="error"></param>
        private void LoginReplyLLSDHandler(CapsClient client, OSD result, Exception error)
        {
            if (error == null)
            {
                if (result != null && result.Type == OSDType.Map)
                {
                    OSDMap map = (OSDMap)result;
                    OSD osd;

                    LoginResponseData data = new LoginResponseData();
                    data.Parse(map);

                    if (map.TryGetValue("login", out osd))
                    {
                        bool loginSuccess = osd.AsBoolean();
                        bool redirect = (osd.AsString() == "indeterminate");

                        if (redirect)
                        {
                            // Login redirected

                            // Make the next login URL jump
                            UpdateLoginStatus(LoginStatus.Redirecting, data.Message);

                            LoginParams loginParams = CurrentContext;
                            loginParams.URI = LoginResponseData.ParseString("next_url", map);
                            //CurrentContext.Params.MethodName = LoginResponseData.ParseString("next_method", map);

                            // Sleep for some amount of time while the servers work
                            int seconds = (int)LoginResponseData.ParseUInt("next_duration", map);
                            Logger.Log("Sleeping for " + seconds + " seconds during a login redirect",
                                Helpers.LogLevel.Info);
                            Thread.Sleep(seconds * 1000);

                            // Ignore next_options for now
                            CurrentContext = loginParams;

                            BeginLogin();
                        }
                        else if (loginSuccess)
                        {
                            // Login succeeded

                            // Fire the login callback
                            if (OnLoginResponse != null)
                            {
                                try { OnLoginResponse(loginSuccess, redirect, data.Message, data.Reason, data); }
                                catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client, ex); }
                            }

                            // These parameters are stored in NetworkManager, so instead of registering
                            // another callback for them we just set the values here
                            CircuitCode = (uint)data.CircuitCode;
                            LoginSeedCapability = data.SeedCapability;

                            UpdateLoginStatus(LoginStatus.ConnectingToSim, "Connecting to simulator...");

                            ulong handle = Utils.UIntsToLong((uint)data.RegionX, (uint)data.RegionY);

                            if (data.SimIP != null && data.SimPort != 0)
                            {
                                // Connect to the sim given in the login reply
                                if (Connect(data.SimIP, (ushort)data.SimPort, handle, true, LoginSeedCapability) != null)
                                {
                                    // Request the economy data right after login
                                    SendPacket(new EconomyDataRequestPacket());

                                    // Update the login message with the MOTD returned from the server
                                    UpdateLoginStatus(LoginStatus.Success, data.Message);
                                }
                                else
                                {
                                    UpdateLoginStatus(LoginStatus.Failed,
                                        "Unable to establish a UDP connection to the simulator");
                                }
                            }
                            else
                            {
                                UpdateLoginStatus(LoginStatus.Failed,
                                    "Login server did not return a simulator address");
                            }
                        }
                        else
                        {
                            // Login failed

                            // Make sure a usable error key is set
                            if (data.Reason != String.Empty)
                                InternalErrorKey = data.Reason;
                            else
                                InternalErrorKey = "unknown";

                            UpdateLoginStatus(LoginStatus.Failed, data.Message);
                        }
                    }
                    else
                    {
                        // Got an LLSD map but no login value
                        UpdateLoginStatus(LoginStatus.Failed, "login parameter missing in the response");
                    }
                }
                else
                {
                    // No LLSD response
                    InternalErrorKey = "bad response";
                    UpdateLoginStatus(LoginStatus.Failed, "Empty or unparseable login response");
                }
            }
            else
            {
                // Connection error
                InternalErrorKey = "no connection";
                UpdateLoginStatus(LoginStatus.Failed, error.Message);
            }
        }
Example #6
0
        private void BeginLogin()
        {
            LoginParams loginParams = CurrentContext;
            // Generate a random ID to identify this login attempt
            loginParams.LoginID = UUID.Random();
            CurrentContext = loginParams;

            #region Sanity Check loginParams

            if (loginParams.Options == null)
                loginParams.Options = new List<string>().ToArray();

            if (loginParams.Password == null)
                loginParams.Password = String.Empty;

            // Convert the password to MD5 if it isn't already
            if (loginParams.Password.Length != 35 && !loginParams.Password.StartsWith("$1$"))
                loginParams.Password = Utils.MD5(loginParams.Password);

            if (loginParams.ViewerDigest == null)
                loginParams.ViewerDigest = String.Empty;

            if (loginParams.Version == null)
                loginParams.Version = String.Empty;

            if (loginParams.UserAgent == null)
                loginParams.UserAgent = String.Empty;

            if (loginParams.Platform == null)
                loginParams.Platform = String.Empty;

            if (loginParams.MAC == null)
                loginParams.MAC = String.Empty;

            if (string.IsNullOrEmpty(loginParams.Channel))
            {
                Logger.Log("Viewer channel not set. This is a TOS violation on some grids.", Helpers.LogLevel.Warning);
                loginParams.Channel = "libopenmetaverse generic client";
            }

            if (loginParams.Author == null)
                loginParams.Author = String.Empty;

            #endregion

            // TODO: Allow a user callback to be defined for handling the cert
            ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
            // Even though this will compile on Mono 2.4, it throws a runtime exception
            //ServicePointManager.ServerCertificateValidationCallback = TrustAllCertificatePolicy.TrustAllCertificateHandler;

            if (Client.Settings.USE_LLSD_LOGIN)
            {
                #region LLSD Based Login

                // Create the CAPS login structure
                OSDMap loginLLSD = new OSDMap();
                loginLLSD["first"] = OSD.FromString(loginParams.FirstName);
                loginLLSD["last"] = OSD.FromString(loginParams.LastName);
                loginLLSD["passwd"] = OSD.FromString(loginParams.Password);
                loginLLSD["start"] = OSD.FromString(loginParams.Start);
                loginLLSD["channel"] = OSD.FromString(loginParams.Channel);
                loginLLSD["version"] = OSD.FromString(loginParams.Version);
                loginLLSD["platform"] = OSD.FromString(loginParams.Platform);
                loginLLSD["mac"] = OSD.FromString(loginParams.MAC);
                loginLLSD["agree_to_tos"] = OSD.FromBoolean(loginParams.AgreeToTos);
                loginLLSD["read_critical"] = OSD.FromBoolean(loginParams.ReadCritical);
                loginLLSD["viewer_digest"] = OSD.FromString(loginParams.ViewerDigest);
                loginLLSD["id0"] = OSD.FromString(loginParams.ID0);
                loginLLSD["last_exec_event"] = OSD.FromInteger((int)loginParams.LastExecEvent);

                // Create the options LLSD array
                OSDArray optionsOSD = new OSDArray();
                for (int i = 0; i < loginParams.Options.Length; i++)
                    optionsOSD.Add(OSD.FromString(loginParams.Options[i]));

                foreach (string[] callbackOpts in CallbackOptions.Values)
                {
                    if (callbackOpts != null)
                    {
                        for (int i = 0; i < callbackOpts.Length; i++)
                        {
                            if (!optionsOSD.Contains(callbackOpts[i]))
                                optionsOSD.Add(callbackOpts[i]);
                        }
                    }
                }
                loginLLSD["options"] = optionsOSD;

                // Make the CAPS POST for login
                Uri loginUri;
                try
                {
                    loginUri = new Uri(loginParams.URI);
                }
                catch (Exception ex)
                {
                    Logger.Log(String.Format("Failed to parse login URI {0}, {1}", loginParams.URI, ex.Message),
                        Helpers.LogLevel.Error, Client);
                    return;
                }

                CapsClient loginRequest = new CapsClient(loginUri);
                loginRequest.OnComplete += new CapsClient.CompleteCallback(LoginReplyLLSDHandler);
                loginRequest.UserData = CurrentContext;
                UpdateLoginStatus(LoginStatus.ConnectingToLogin, String.Format("Logging in as {0} {1}...", loginParams.FirstName, loginParams.LastName));
                loginRequest.BeginGetResponse(loginLLSD, OSDFormat.Xml, Client.Settings.CAPS_TIMEOUT);

                #endregion
            }
            else
            {
                #region XML-RPC Based Login Code

                // Create the Hashtable for XmlRpcCs
                Hashtable loginXmlRpc = new Hashtable();
                loginXmlRpc["first"] = loginParams.FirstName;
                loginXmlRpc["last"] = loginParams.LastName;
                loginXmlRpc["passwd"] = loginParams.Password;
                loginXmlRpc["start"] = loginParams.Start;
                loginXmlRpc["channel"] = loginParams.Channel;
                loginXmlRpc["version"] = loginParams.Version;
                loginXmlRpc["platform"] = loginParams.Platform;
                loginXmlRpc["mac"] = loginParams.MAC;
                if (loginParams.AgreeToTos)
                    loginXmlRpc["agree_to_tos"] = "true";
                if (loginParams.ReadCritical)
                    loginXmlRpc["read_critical"] = "true";
                loginXmlRpc["id0"] = loginParams.ID0;
                loginXmlRpc["last_exec_event"] = (int)loginParams.LastExecEvent;

                // Create the options array
                ArrayList options = new ArrayList();
                for (int i = 0; i < loginParams.Options.Length; i++)
                    options.Add(loginParams.Options[i]);

                foreach (string[] callbackOpts in CallbackOptions.Values)
                {
                    if (callbackOpts != null)
                    {
                        for (int i = 0; i < callbackOpts.Length; i++)
                        {
                            if (!options.Contains(callbackOpts[i]))
                                options.Add(callbackOpts[i]);
                        }
                    }
                }
                loginXmlRpc["options"] = options;

                try
                {
                    ArrayList loginArray = new ArrayList(1);
                    loginArray.Add(loginXmlRpc);
                    XmlRpcRequest request = new XmlRpcRequest(CurrentContext.MethodName, loginArray);
                    var cc = CurrentContext;
                    // Start the request
                    Thread requestThread = new Thread(
                        delegate()
                        {
                            try
                            {
                                LoginReplyXmlRpcHandler(
                                    request.Send(cc.URI, cc.Timeout),
                                    loginParams);
                            }
                            catch (Exception e)
                            {
                                UpdateLoginStatus(LoginStatus.Failed, "Error opening the login server connection: " + e.Message);
                            }
                        });
                    requestThread.Name = "XML-RPC Login";
                    requestThread.Start();
                }
                catch (Exception e)
                {
                    UpdateLoginStatus(LoginStatus.Failed, "Error opening the login server connection: " + e);
                }

                #endregion
            }
        }
Example #7
0
        private void BeginLogin()
        {
            LoginParams loginParams = CurrentContext.Value;

            // Sanity check
            if (loginParams.Options == null)
            {
                loginParams.Options = new List <string>();
            }

            // Convert the password to MD5 if it isn't already
            if (loginParams.Password.Length != 35 && !loginParams.Password.StartsWith("$1$"))
            {
                loginParams.Password = Utils.MD5(loginParams.Password);
            }

            // Override SSL authentication mechanisms. DO NOT convert this to the
            // .NET 2.0 preferred method, the equivalent function in Mono has a
            // different name and it will break compatibility!
            #pragma warning disable 0618
            ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy();
            // TODO: At some point, maybe we should check the cert?

            // Create the CAPS login structure
            LLSDMap loginLLSD = new LLSDMap();
            loginLLSD["first"]         = LLSD.FromString(loginParams.FirstName);
            loginLLSD["last"]          = LLSD.FromString(loginParams.LastName);
            loginLLSD["passwd"]        = LLSD.FromString(loginParams.Password);
            loginLLSD["start"]         = LLSD.FromString(loginParams.Start);
            loginLLSD["channel"]       = LLSD.FromString(loginParams.Channel);
            loginLLSD["version"]       = LLSD.FromString(loginParams.Version);
            loginLLSD["platform"]      = LLSD.FromString(loginParams.Platform);
            loginLLSD["mac"]           = LLSD.FromString(loginParams.MAC);
            loginLLSD["agree_to_tos"]  = LLSD.FromBoolean(true);
            loginLLSD["read_critical"] = LLSD.FromBoolean(true);
            loginLLSD["viewer_digest"] = LLSD.FromString(loginParams.ViewerDigest);
            loginLLSD["id0"]           = LLSD.FromString(loginParams.id0);

            // Create the options LLSD array
            LLSDArray optionsLLSD = new LLSDArray();
            for (int i = 0; i < loginParams.Options.Count; i++)
            {
                optionsLLSD.Add(LLSD.FromString(loginParams.Options[i]));
            }
            foreach (string[] callbackOpts in CallbackOptions.Values)
            {
                if (callbackOpts != null)
                {
                    for (int i = 0; i < callbackOpts.Length; i++)
                    {
                        if (!optionsLLSD.Contains(callbackOpts[i]))
                        {
                            optionsLLSD.Add(callbackOpts[i]);
                        }
                    }
                }
            }
            loginLLSD["options"] = optionsLLSD;

            // Make the CAPS POST for login
            Uri loginUri;
            try
            {
                loginUri = new Uri(loginParams.URI);
            }
            catch (Exception ex)
            {
                Logger.Log(String.Format("Failed to parse login URI {0}, {1}", loginParams.URI, ex.Message),
                           Helpers.LogLevel.Error, Client);
                return;
            }

            CapsClient loginRequest = new CapsClient(loginUri);
            loginRequest.OnComplete += new CapsClient.CompleteCallback(LoginReplyHandler);
            loginRequest.UserData    = CurrentContext;
            loginRequest.StartRequest(LLSDParser.SerializeXmlBytes(loginLLSD), "application/xml+llsd");
        }
Example #8
0
        /// <summary>
        /// Login that takes a struct of all the values that will be passed to
        /// the login server
        /// </summary>
        /// <param name="loginParams">The values that will be passed to the login
        /// server, all fields must be set even if they are String.Empty</param>
        /// <returns>Whether the login was successful or not. On failure the
        /// LoginErrorKey string will contain the error code and LoginMessage
        /// will contain a description of the error</returns>
        public bool Login(LoginParams loginParams)
        {
            BeginLogin(loginParams);

            LoginEvent.WaitOne(loginParams.Timeout, false);

            if (CurrentContext != null)
            {
                CurrentContext = null; // Will force any pending callbacks to bail out early
                InternalStatusCode = LoginStatus.Failed;
                InternalLoginMessage = "Timed out";
                return false;
            }

            return (InternalStatusCode == LoginStatus.Success);
        }
Example #9
0
        /// <summary>
        /// Handles response from XML-RPC login replies
        /// </summary>
        private void LoginReplyXmlRpcHandler(XmlRpcResponse response, LoginParams context)
        {
            LoginResponseData reply = new LoginResponseData();
            ushort simPort = 0;
            uint regionX = 0;
            uint regionY = 0;

            // Fetch the login response
            if (response == null || !(response.Value is Hashtable))
            {
                UpdateLoginStatus(LoginStatus.Failed, "Invalid or missing login response from the server");
                Logger.Log("Invalid or missing login response from the server", Helpers.LogLevel.Warning);
                return;
            }

            try
            {
                reply.Parse((Hashtable)response.Value);
                if (context.LoginID != CurrentContext.Value.LoginID)
                {
                    Logger.Log("Login response does not match login request. Only one login can be attempted at a time",
                        Helpers.LogLevel.Error);
                    return;
                }
            }
            catch (Exception e)
            {
                UpdateLoginStatus(LoginStatus.Failed, "Error retrieving the login response from the server: " + e.Message);
                Logger.Log("Login response failure: " + e.Message + " " + e.StackTrace, Helpers.LogLevel.Warning);
                return;
            }

            string reason = reply.Reason;
            string message = reply.Message;

            if (reply.Login == "true")
            {
                // Remove the quotes around our first name.
                if (reply.FirstName[0] == '"')
                    reply.FirstName = reply.FirstName.Remove(0, 1);
                if (reply.FirstName[reply.FirstName.Length - 1] == '"')
                    reply.FirstName = reply.FirstName.Remove(reply.FirstName.Length - 1);

                #region Critical Information

                try
                {
                    // Networking
                    Client.Network.CircuitCode = (uint)reply.CircuitCode;
                    regionX = (uint)reply.RegionX;
                    regionY = (uint)reply.RegionY;
                    simPort = (ushort)reply.SimPort;
                    LoginSeedCapability = reply.SeedCapability;
                }
                catch (Exception)
                {
                    UpdateLoginStatus(LoginStatus.Failed, "Login server failed to return critical information");
                    return;
                }

                #endregion Critical Information

                /* Add any blacklisted UDP packets to the blacklist
                 * for exclusion from packet processing */
                if (reply.UDPBlacklist != null)
                    UDPBlacklist.AddRange(reply.UDPBlacklist.Split(','));

                // Misc:
                //uint timestamp = (uint)reply.seconds_since_epoch;
                //DateTime time = Helpers.UnixTimeToDateTime(timestamp); // TODO: Do something with this?

                // Unhandled:
                // reply.gestures
                // reply.event_categories
                // reply.classified_categories
                // reply.event_notifications
                // reply.ui_config
                // reply.login_flags
                // reply.global_textures
                // reply.inventory_lib_root
                // reply.inventory_lib_owner
                // reply.inventory_skeleton
                // reply.inventory_skel_lib
                // reply.initial_outfit
            }

            bool redirect = (reply.Login == "indeterminate");

            try
            {
                if (OnLoginResponse != null)
                {
                    try { OnLoginResponse(reply.Success, redirect, message, reason, reply); }
                    catch (Exception ex) { Logger.Log(ex.ToString(), Helpers.LogLevel.Error); }
                }
            }
            catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, ex); }

            // Make the next network jump, if needed
            if (redirect)
            {
                UpdateLoginStatus(LoginStatus.Redirecting, "Redirecting login...");
                LoginParams loginParams = CurrentContext.Value;
                loginParams.URI = reply.NextUrl;
                loginParams.MethodName = reply.NextMethod;
                loginParams.Options = reply.NextOptions;

                // Sleep for some amount of time while the servers work
                int seconds = reply.NextDuration;
                Logger.Log("Sleeping for " + seconds + " seconds during a login redirect",
                    Helpers.LogLevel.Info);
                Thread.Sleep(seconds * 1000);

                CurrentContext = loginParams;
                BeginLogin();
            }
            else if (reply.Success)
            {
                UpdateLoginStatus(LoginStatus.ConnectingToSim, "Connecting to simulator...");

                ulong handle = Utils.UIntsToLong(regionX, regionY);

                // Connect to the sim given in the login reply
                if (Connect(reply.SimIP, simPort, handle, true, LoginSeedCapability) != null)
                {
                    // Request the economy data right after login
                    SendPacket(new EconomyDataRequestPacket());

                    // Update the login message with the MOTD returned from the server
                    UpdateLoginStatus(LoginStatus.Success, message);
                }
                else
                {
                    UpdateLoginStatus(LoginStatus.Failed, "Unable to connect to simulator");
                }
            }
            else
            {
                // Make sure a usable error key is set

                if (!String.IsNullOrEmpty(reason))
                    InternalErrorKey = reason;
                else
                    InternalErrorKey = "unknown";

                UpdateLoginStatus(LoginStatus.Failed, message);
            }
        }
Example #10
0
        public LoginParams getlogin(int gridkey)
        {
            LoginParams data = new LoginParams();

            // Remove any stale login locks, any over 30 minutes are quite dead

            int ProcessID = Process.GetCurrentProcess().Id;

            string sql;
            sql = "LOCK TABLES Logins WRITE, Grid READ; ";
            sql += "UPDATE Logins SET LockID='0', PID='0' WHERE (UNIX_TIMESTAMP(LastScrape)+1800) < UNIX_TIMESTAMP(NOW()); ";
            sql += "UPDATE Logins SET PID='" + ProcessID.ToString() + "', LastScrape=NOW(), LockID='" + myid.ToString() + "' WHERE LockID='0' AND grid='" + gridkey.ToString() + "' LIMIT 1;\n ";
            sql += "SELECT LoginURI, First, Last, Password, grid from Grid,Logins where Grid.PKey=Logins.grid and LockID ='" + myid.ToString() + "';";
            sql += "UNLOCK TABLES; ";

            MySqlDataReader rdr = null;

            try
            {

                MySqlCommand cmd = new MySqlCommand(sql, conn);
                rdr = cmd.ExecuteReader();
            }
            catch (Exception e)
            {
                Logger.Log(e.Message, Helpers.LogLevel.Error);
            }

            if (rdr.Read())
            {
                //Console.WriteLine(rdr[0] + " " + rdr[1] + " " + rdr[2] + " " + rdr[3]);
                data.URI = (string)rdr[0];
                data.FirstName = (string)rdr[1];
                data.LastName = (string)rdr[2];
                data.Password = (string)rdr[3];
                gridKey = (int)rdr[4];
            }
            else
            {
                // There are no free login slots to use on this grid
                Logger.Log("No free login slots left on grid id " + gridkey.ToString(), Helpers.LogLevel.Warning);
                data = null;
            }

            rdr.Close();

            return data;
        }
Example #11
0
        public void BeginLogin(LoginParams loginParams)
        {
            // FIXME: Now that we're using CAPS we could cancel the current login and start a new one
            if (CurrentContext != null)
                throw new Exception("Login already in progress");

            LoginEvent.Reset();
            CurrentContext = loginParams;

            try
            {
                BeginLogin();
            }
            catch (Exception error)
            {
                InternalErrorKey = "no connection";
                UpdateLoginStatus(LoginStatus.Failed, error.Message);
            }
        }
Example #12
0
        private string Get3DiChallengeCode(LoginParams loginParams)
        {
            string challengeCode = null;
            // Try to get challenge code
            try
            {
                string loginServerVersion = GetLoginServerVersion(loginParams.URI);
                if (loginServerVersion == "3Di OpenSim LoginService 1.0")
                {
                    // we are connecting to 3Di login server; use custom password routine
                    string baseLoginServerUri = loginParams.URI;
                    if (baseLoginServerUri[baseLoginServerUri.Length - 1] == '/')
                        baseLoginServerUri.Remove(baseLoginServerUri.Length - 1, 1);

                    string getChallengeCodeUri = baseLoginServerUri
                        + "/" + "ChallengeCode"
                        + "/" + loginParams.FirstName + "&" + loginParams.LastName;

                    // get XML from challenge code response
                    XmlReader reader = XmlReader.Create(getChallengeCodeUri);
                    XPathDocument xpathDoc = new XPathDocument(reader);
                    XPathNavigator xpathnav = xpathDoc.CreateNavigator();
                    string xpathQuery = "/code";
                    XPathExpression xpathExpr = xpathnav.Compile(xpathQuery);
                    XPathNodeIterator xpathIter = xpathnav.Select(xpathExpr);
                    if (xpathIter.MoveNext())
                    {
                        // got the challenge code
                        challengeCode = xpathIter.Current.Value;
                    }
                    else
                    {
                        // did not get challenge code (e.g. invalid user name)
                    }
                }
            }
            catch
            {
            }

            return challengeCode;
        }
        protected virtual void OnButton1Clicked(object sender, System.EventArgs e)
        {
            MainClass.userlogout = true;

            oncleanuptime();
            Logger.Log("button 1 clicked "+button_login.Label,Helpers.LogLevel.Debug);
            if(this.loginbut==true)
            {
                this.button_login.Sensitive=false;
                GLib.Timeout.Add(1000,debounce);

                this.disablebuttons();
                trying=true;
                GLib.Timeout.Add(100,OnPulseProgress);

                this.textview_loginmsg.Buffer.Text="Connecting to login server...";
                this.textview_loginmsg.QueueDraw();
                //LoginParams login;

                MainClass.getMeANewClient();

                login=MainClass.client.Network.DefaultLoginParams(entry_first.Text,entry_last.Text,entry_pass.Text,"omvviewer","2.0");
                StreamReader s=null;

                 if(File.Exists(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory,"MyMac.txt")))
                     s = File.OpenText(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory,"MyMac.txt"));
                 if(s==null)
                    if(File.Exists("~/.MyMac.txt"))
                        s = File.OpenText("~/.MyMac.txt");
                  if(s==null)
                    if(File.Exists("MyMac.txt"))
                        s = File.OpenText("MyMac.txt");

                if(s!=null)
                {
                    try
                    {
                        login.MAC = s.ReadLine();
                    }
                    catch(Exception ee)
                    {
                        Logger.Log(ee.ToString(),Helpers.LogLevel.Debug);
                    }
                }

                if (this.radiobutton1.Active)
                {
                    login.Start = "home";
                    MainClass.appsettings.LoginLocationSetting="home";
                }
                if (this.radiobutton2.Active)
                {
                    login.Start = "last";
                    MainClass.appsettings.LoginLocationSetting="last";
                }

                if (this.radiobutton3.Active)
                {
                    login.Start = "uri:"+this.entry_location.Text+"&128&128&0";
                    MainClass.appsettings.LoginLocationSetting="location";
                    MainClass.appsettings.LoginLocation=entry_location.Text;
                }

                this.textview_log.Buffer.Clear();
                button_login.Label="Logout";
                this.loginbut=false;
                button_login.Image=new Gtk.Image(Stetic.IconLoader.LoadIcon(this, "gtk-disconnect", Gtk.IconSize.Menu, 16));

                login.URI=entry_loginuri.Text;

                Thread loginRunner= new Thread(new ThreadStart(this.loginthread));
                loginRunner.Start();

            }
            else
            {
                Logger.Log("Trying to logout user request",Helpers.LogLevel.Debug);
                this.button_login.Sensitive = false;
                trying = true;
                progressbar2.Fraction=0.1;
                GLib.Timeout.Add(100, OnPulseProgress);

                Logger.Log("Running logout tasks first",Helpers.LogLevel.Debug);
                if (MainClass.client.Inventory.Store != null)
                    MainClass.client.Inventory.Store.SaveToDisk(MainClass.client.Settings.ASSET_CACHE_DIR + System.IO.Path.DirectorySeparatorChar + MainClass.client.Inventory.Store.RootFolder.UUID.ToString() + ".osl");

                Logger.Log("Done",Helpers.LogLevel.Debug);
                MainClass.userlogout = true;
                MainClass.client.Network.Logout();
                this.trying=false;
            }
        }
Example #14
0
        /// <summary>
        /// Generate sane default values for a login request
        /// </summary>
        /// <param name="firstName">Account first name</param>
        /// <param name="lastName">Account last name</param>
        /// <param name="password">Account password</param>
        /// <param name="userAgent">Client application name</param>
        /// <param name="userVersion">Client application version</param>
        /// <returns>A populated <seealso cref="LoginParams"/> struct containing
        /// sane defaults</returns>
        public LoginParams DefaultLoginParams(string firstName, string lastName, string password,
            string userAgent, string userVersion)
        {
            List<string> options = new List<string>(15);
            options.Add("inventory-root");
            options.Add("inventory-skeleton");
            options.Add("inventory-lib-root");
            options.Add("inventory-lib-owner");
            options.Add("inventory-skel-lib");
            options.Add("initial-outfit");
            options.Add("gestures");
            options.Add("event_categories");
            options.Add("event_notifications");
            options.Add("classified_categories");
            options.Add("buddy-list");
            options.Add("ui-config");
            options.Add("tutorial_settings");
            options.Add("login-flags");
            options.Add("global-textures");

            LoginParams loginParams = new LoginParams();
            

            loginParams.URI = LoginServer;
            loginParams.Timeout = LoginTimeout;
            loginParams.MethodName = "login_to_simulator";
            loginParams.FirstName = firstName;
            loginParams.LastName = lastName;
            loginParams.Password = password;
            loginParams.Start = "last";
            loginParams.Channel = userAgent + " (OpenMetaverse)";
            loginParams.Version = userVersion;
            loginParams.Platform = GetPlatform();
            loginParams.MAC = GetMAC();
            loginParams.ViewerDigest = String.Empty;
            loginParams.Options = options.ToArray();
            loginParams.ID0 = GetMAC();

            return loginParams;
        }
Example #15
0
        /// <summary>
        /// Handles response from XML-RPC login replies
        /// </summary>
        private void LoginReplyXmlRpcHandler(XmlRpcResponse response, LoginParams context)
        {
            LoginResponseData reply = new LoginResponseData();
            // Fetch the login response
            if (response == null || !(response.Value is Hashtable))
            {
                UpdateLoginStatus(LoginStatus.Failed, "Invalid or missing login response from the server");
                Logger.Log("Invalid or missing login response from the server", Helpers.LogLevel.Warning);
                return;
            }

            try
            {
                reply.Parse((Hashtable)response.Value);
                if (context.LoginID != CurrentContext.LoginID)
                {
                    Logger.Log("Login response does not match login request. Only one login can be attempted at a time",
                        Helpers.LogLevel.Error);
                    return;
                }
            }
            catch (Exception e)
            {
                UpdateLoginStatus(LoginStatus.Failed, "Error retrieving the login response from the server: " + e.Message);
                Logger.Log("Login response failure: " + e.Message + " " + e.StackTrace, Helpers.LogLevel.Warning);
                return;
            }
            LoginReplyXmlRpcHandler(reply, context);
        }
Example #16
0
        private void UpdateLoginStatus(LoginStatus status, string message)
        {
            InternalStatusCode = status;
            InternalLoginMessage = message;

            Logger.DebugLog("Login status: " + status.ToString() + ": " + message, Client);

            // If we reached a login resolution trigger the event
            if (status == LoginStatus.Success || status == LoginStatus.Failed)
            {
                CurrentContext = null;
                LoginEvent.Set();
            }

            // Fire the login status callback
            if (m_LoginProgress != null)
            {
                OnLoginProgress(new LoginProgressEventArgs(status, message, InternalErrorKey));
            }
        }
Example #17
0
 public bool Login(LoginParams loginParams)
 {
     _Connected = true;
     OnLogin(LoginStatus.Success, "Testing");
     OnConnected(null);
     return true;
 }
Example #18
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="firstName">Account first name</param>
        /// <param name="lastName">Account last name</param>
        /// <param name="password">Account password</param>
        /// <param name="userAgent">Client application name</param>
        /// <param name="userVersion">Client application version</param>
        /// <returns></returns>
        public LoginParams DefaultLoginParams(string firstName, string lastName, string password,
            string userAgent, string userVersion)
        {
            List<string> options = new List<string>();
            //options.Add("gestures");
            //options.Add("event_categories");
            //options.Add("event_notifications");
            //options.Add("classified_categories");
            //options.Add("ui-config");
            //options.Add("login-flags");
            //options.Add("global-textures");
            //options.Add("initial-outfit");

            LoginParams loginParams = new LoginParams();

            loginParams.URI = Client.Settings.LOGIN_SERVER;
            loginParams.Timeout = Client.Settings.LOGIN_TIMEOUT;
            loginParams.MethodName = "login_to_simulator";
            loginParams.FirstName = firstName;
            loginParams.LastName = lastName;
            loginParams.Password = password;
            loginParams.Start = "last";
            loginParams.Channel = userAgent + " (OpenMetaverse)";
            loginParams.Version = userVersion;
            loginParams.Platform = GetPlatform();
            loginParams.MAC = GetMAC();
            loginParams.ViewerDigest = String.Empty;
            loginParams.Options = options;
			// workaround for bots being caught up in a global ban
			// This *should* be the hash of the first hard drive, 
			// but any unique identifier works.
            loginParams.id0 = GetMAC();

            return loginParams;
        }
Example #19
0
        public void UseNetworkDefaults(LoginParams defaults)
        {
            if (!string.IsNullOrEmpty(loginParams.URI))
                defaults.URI = loginParams.URI;
            else
                loginParams.URI = defaults.URI;

            if (string.IsNullOrEmpty(FirstName))
                FirstName = defaults.FirstName;
            if (string.IsNullOrEmpty(LastName))
                LastName = defaults.LastName;
            if (string.IsNullOrEmpty(loginParams.Start))
                loginParams.Start = defaults.Start;
            if (string.IsNullOrEmpty(loginParams.Password))
                loginParams.Password = defaults.Password;
            if (string.IsNullOrEmpty(loginParams.Version))
                loginParams.Version = defaults.Version;
            if (string.IsNullOrEmpty(loginParams.ViewerDigest))
                loginParams.ViewerDigest = defaults.ViewerDigest;
            if (string.IsNullOrEmpty(loginParams.MAC))
                loginParams.MAC = defaults.MAC;
            if (string.IsNullOrEmpty(loginParams.Channel))
                loginParams.Channel = defaults.Channel;

            AgreeToTos = defaults.AgreeToTos;
            Timeout = defaults.Timeout;
            Status = LoginStatus.None;
        }
Example #20
0
        public void Login(string first, string last, string pass, string uri)
        {
            if (client != null)
                Logout();

            Setup();

            loginCurrentParam = client.Network.DefaultLoginParams(first, last, pass, Default.LOGIN_USER_AGENT, Default.LOGIN_USER_VERSION);
            if (string.IsNullOrEmpty(uri))
            {
                client.Network.Login(loginCurrentParam);
            }
            else
            {
                loginCurrentParam.URI = uri;
                client.Network.Login3Di(loginCurrentParam);
            }
        }
Example #21
0
 public void AbortLogin()
 {
     LoginParams loginParams = CurrentContext;
     CurrentContext = null; // Will force any pending callbacks to bail out early
     // FIXME: Now that we're using CAPS we could cancel the current login and start a new one
     if (loginParams == null)
     {
         Logger.DebugLog("No Login was in progress: " + CurrentContext, Client);
     }
     else
     {
         InternalStatusCode = LoginStatus.Failed;
         InternalLoginMessage = "Aborted";
     }
     UpdateLoginStatus(LoginStatus.Failed, "Abort Requested");
 }
Example #22
0
        /// <summary>
        /// Generate sane default values for a login request
        /// </summary>
        /// <param name="firstName">Account first name</param>
        /// <param name="lastName">Account last name</param>
        /// <param name="password">Account password</param>
        /// <param name="userAgent">Client application name</param>
        /// <param name="userVersion">Client application version</param>
        /// <returns>A populated <seealso cref="LoginParams"/> struct containing
        /// sane defaults</returns>
        public LoginParams DefaultLoginParams(string firstName, string lastName, string password,
            string userAgent, string userVersion)
        {
            List<string> options = new List<string>(16);
            options.Add("inventory-root");
            options.Add("inventory-skeleton");
            options.Add("inventory-lib-root");
            options.Add("inventory-lib-owner");
            options.Add("inventory-skel-lib");
            options.Add("initial-outfit");
            options.Add("gestures");
            options.Add("event_categories");
            options.Add("event_notifications");
            options.Add("classified_categories");
            options.Add("buddy-list");
            options.Add("ui-config");
            options.Add("tutorial_settings");
            options.Add("login-flags");
            options.Add("global-textures");
            options.Add("adult_compliant");

            LoginParams loginParams = new LoginParams();
            if (Client == null)
                throw new NullReferenceException("GridClient must be instantiated before calling DefaultLoginParams()");

            loginParams.URI = Client.Settings.LOGIN_SERVER;
            loginParams.Timeout = Client.Settings.LOGIN_TIMEOUT;
            loginParams.MethodName = "login_to_simulator";
            loginParams.FirstName = firstName;
            loginParams.LastName = lastName;
            loginParams.Password = password;
            loginParams.Start = "last";
            loginParams.Channel = userAgent;
            loginParams.Version = userVersion;
            loginParams.Platform = GetPlatform();
            loginParams.MAC = GetMAC();
            loginParams.ViewerDigest = String.Empty;
            loginParams.Options = options.ToArray();
            loginParams.ID0 = GetMAC();
            loginParams.AgreeToTos = true;
            loginParams.ReadCritical = true;
            return loginParams;
        }
Example #23
0
 /// <summary>
 /// LoginParams and the initial login XmlRpcRequest were made on a remote machine.
 /// This method now initializes libomv with the results.
 /// </summary>
 public void RemoteLoginHandler(LoginResponseData response, LoginParams newContext)
 {
     CurrentContext = newContext;
     LoginReplyXmlRpcHandler(response, newContext);
 }
Example #24
0
        public void BeginLogin(LoginParams loginParams)
        {
            // FIXME: Now that we're using CAPS we could cancel the current login and start a new one
            if (CurrentContext != null)
                throw new Exception("Login already in progress");

            LoginEvent.Reset();
            CurrentContext = loginParams;

            BeginLogin();
        }
Example #25
0
        private void LoginReplyHandler(CapsClient client, LLSD result, Exception error)
        {
            if (error == null)
            {
                if (result != null && result.Type == LLSDType.Map)
                {
                    LLSDMap map = (LLSDMap)result;

                    LLSD   llsd;
                    string reason, message;

                    if (map.TryGetValue("reason", out llsd))
                    {
                        reason = llsd.AsString();
                    }
                    else
                    {
                        reason = String.Empty;
                    }

                    if (map.TryGetValue("message", out llsd))
                    {
                        message = llsd.AsString();
                    }
                    else
                    {
                        message = String.Empty;
                    }

                    if (map.TryGetValue("login", out llsd))
                    {
                        bool loginSuccess      = llsd.AsBoolean();
                        bool redirect          = (llsd.AsString() == "indeterminate");
                        LoginResponseData data = new LoginResponseData();
                        data.Reason  = reason;
                        data.Message = message;

                        if (redirect)
                        {
                            // Login redirected

                            // Make the next login URL jump
                            UpdateLoginStatus(LoginStatus.Redirecting, message);

                            LoginParams loginParams = CurrentContext.Value;
                            loginParams.URI = LoginResponseData.ParseString("next_url", map);
                            //CurrentContext.Params.MethodName = LoginResponseData.ParseString("next_method", map);

                            // Sleep for some amount of time while the servers work
                            int seconds = (int)LoginResponseData.ParseUInt("next_duration", map);
                            Logger.Log("Sleeping for " + seconds + " seconds during a login redirect",
                                       Helpers.LogLevel.Info);
                            Thread.Sleep(seconds * 1000);

                            // Ignore next_options for now
                            CurrentContext = loginParams;

                            BeginLogin();
                        }
                        else if (loginSuccess)
                        {
                            // Login succeeded

                            // Parse successful login replies into LoginResponseData structs
                            data.Parse(map);

                            // Fire the login callback
                            if (OnLoginResponse != null)
                            {
                                try { OnLoginResponse(loginSuccess, redirect, message, reason, data); }
                                catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client, ex); }
                            }

                            // These parameters are stored in NetworkManager, so instead of registering
                            // another callback for them we just set the values here
                            CircuitCode         = data.CircuitCode;
                            LoginSeedCapability = data.SeedCapability;

                            UpdateLoginStatus(LoginStatus.ConnectingToSim, "Connecting to simulator...");

                            ulong handle = Utils.UIntsToLong(data.RegionX, data.RegionY);

                            if (data.SimIP != null && data.SimPort != 0)
                            {
                                // Connect to the sim given in the login reply
                                if (Connect(data.SimIP, data.SimPort, handle, true, LoginSeedCapability) != null)
                                {
                                    // Request the economy data right after login
                                    SendPacket(new EconomyDataRequestPacket());

                                    // Update the login message with the MOTD returned from the server
                                    UpdateLoginStatus(LoginStatus.Success, message);

                                    // Fire an event for connecting to the grid
                                    if (OnConnected != null)
                                    {
                                        try { OnConnected(this.Client); }
                                        catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
                                    }
                                }
                                else
                                {
                                    UpdateLoginStatus(LoginStatus.Failed,
                                                      "Unable to establish a UDP connection to the simulator");
                                }
                            }
                            else
                            {
                                UpdateLoginStatus(LoginStatus.Failed,
                                                  "Login server did not return a simulator address");
                            }
                        }
                        else
                        {
                            // Login failed

                            // Make sure a usable error key is set
                            if (reason != String.Empty)
                            {
                                InternalErrorKey = reason;
                            }
                            else
                            {
                                InternalErrorKey = "unknown";
                            }

                            UpdateLoginStatus(LoginStatus.Failed, message);
                        }
                    }
                    else
                    {
                        // Got an LLSD map but no login value
                        UpdateLoginStatus(LoginStatus.Failed, "login parameter missing in the response");
                    }
                }
                else
                {
                    // No LLSD response
                    InternalErrorKey = "bad response";
                    UpdateLoginStatus(LoginStatus.Failed, "Empty or unparseable login response");
                }
            }
            else
            {
                // Connection error
                InternalErrorKey = "no connection";
                UpdateLoginStatus(LoginStatus.Failed, error.Message);
            }
        }