public static string Serialize(UserProfileData profile)
        {
            StringWriter sw = new StringWriter();
            XmlTextWriter xtw = new XmlTextWriter(sw);
            xtw.Formatting = Formatting.Indented;
            xtw.WriteStartDocument();
            
            xtw.WriteStartElement("user_profile");
            xtw.WriteAttributeString("major_version", MAJOR_VERSION.ToString());
            xtw.WriteAttributeString("minor_version", MINOR_VERSION.ToString());
                       
            xtw.WriteElementString("name", profile.Name);
            xtw.WriteElementString("id", profile.ID.ToString());
            xtw.WriteElementString("about", profile.AboutText);
  
            // Not sure if we're storing this yet, need to take a look
//            xtw.WriteElementString("Url", profile.Url);
            // or, indeed, interests

            xtw.WriteEndElement();
            
            xtw.Close();
            sw.Close();
            
            return sw.ToString();
        }
示例#2
0
            public UserProfileData GetUserProfile(Uri uri)
            {
                UserProfileData userProfile = new UserProfileData();

//                userProfile.ID = new UUID(Util.GetHashGuid(uri.ToString(), AssetCache.AssetInfo.Secret));

                return userProfile;
            }
 public bool IsLocalUser(UserProfileData userData)
 {
     if (userData != null)
     {
         if (userData is ForeignUserProfileData)
             return IsLocalUser(((ForeignUserProfileData)userData).UserServerURI);
         else
             return true;
     }
     else
         // Something fishy; ignore it
         return true;
 }
 public bool IsLocalUser(UserProfileData userData)
 {
     if (userData != null)
     {
         if (userData is ForeignUserProfileData)
         {
             return(IsLocalUser(((ForeignUserProfileData)userData).UserServerURI));
         }
         else
         {
             return(true);
         }
     }
     else
     {
         // Something fishy; ignore it
         return(true);
     }
 }
示例#5
0
        public bool UserHasProductAccess(UserProfileData profile)
        {
            if (ProductAccess == ProductAccessUse.Anyone)
            {
                return(true);
            }

            // Region has access restricted to certain user types, i.e. Plus
            if (ProductAccessAllowed(ProductAccessUse.PlusOnly))
            {
                if (profile != null)
                {
                    if (IsPlusUser(profile.CustomType))
                    {
                        return(true);
                    }
                }
            }

            // no more access options to check
            return(false);
        }
示例#6
0
 protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response, string clientVersion)
 {
     return PrepareLoginToRegion(RegionProfileData.FromRegionInfo(regionInfo), user, response, clientVersion);
 }
示例#7
0
        /***********************************************************************
         *
         *  Convert between ADO.NET <=> OpenSim Objects
         *
         *  These should be database independant
         *
         **********************************************************************/

        /// <summary>
        /// TODO: this doesn't work yet because something more
        /// interesting has to be done to actually get these values
        /// back out.  Not enough time to figure it out yet.
        /// </summary>
        /// <param name="row"></param>
        /// <returns></returns>
        private static UserProfileData buildUserProfile(DataRow row)
        {
            UserProfileData user = new UserProfileData();
            UUID tmp;
            UUID.TryParse((String)row["UUID"], out tmp);
            user.ID = tmp;
            user.FirstName = (String) row["username"];
            user.SurName = (String) row["surname"];
            user.Email = (row.IsNull("email")) ? "" : (String) row["email"];

            user.PasswordHash = (String) row["passwordHash"];
            user.PasswordSalt = (String) row["passwordSalt"];

            user.HomeRegionX = Convert.ToUInt32(row["homeRegionX"]);
            user.HomeRegionY = Convert.ToUInt32(row["homeRegionY"]);
            user.HomeLocation = new Vector3(
                Convert.ToSingle(row["homeLocationX"]),
                Convert.ToSingle(row["homeLocationY"]),
                Convert.ToSingle(row["homeLocationZ"])
                );
            user.HomeLookAt = new Vector3(
                Convert.ToSingle(row["homeLookAtX"]),
                Convert.ToSingle(row["homeLookAtY"]),
                Convert.ToSingle(row["homeLookAtZ"])
                );

            UUID regionID = UUID.Zero;
            UUID.TryParse(row["homeRegionID"].ToString(), out regionID); // it's ok if it doesn't work; just use UUID.Zero
            user.HomeRegionID = regionID;

            user.Created = Convert.ToInt32(row["created"]);
            user.LastLogin = Convert.ToInt32(row["lastLogin"]);
            user.UserInventoryURI = (String) row["userInventoryURI"];
            user.UserAssetURI = (String) row["userAssetURI"];
            user.CanDoMask = Convert.ToUInt32(row["profileCanDoMask"]);
            user.WantDoMask = Convert.ToUInt32(row["profileWantDoMask"]);
            user.AboutText = (String) row["profileAboutText"];
            user.FirstLifeAboutText = (String) row["profileFirstText"];
            UUID.TryParse((String)row["profileImage"], out tmp);
            user.Image = tmp;
            UUID.TryParse((String)row["profileFirstImage"], out tmp);
            user.FirstLifeImage = tmp;
            user.WebLoginKey = new UUID((String) row["webLoginKey"]);
            user.UserFlags = Convert.ToInt32(row["userFlags"]);
            user.GodLevel = Convert.ToInt32(row["godLevel"]);
            user.CustomType = row["customType"].ToString();
            user.Partner = new UUID((String) row["partner"]);

            return user;
        }
示例#8
0
        /// <summary>
        /// Creates a new user profile
        /// </summary>
        /// <param name="user">The profile to add to the database</param>
        override public void AddNewUserProfile(UserProfileData user)
        {
            DataTable users = ds.Tables["users"];
            UUID zero = UUID.Zero;
            if (ExistsFirstLastName(user.FirstName, user.SurName) || user.ID == zero)
                return;

            lock (ds)
            {
                DataRow row = users.Rows.Find(user.ID.ToString());
                if (row == null)
                {
                    row = users.NewRow();
                    fillUserRow(row, user);
                    users.Rows.Add(row);

                    m_log.Debug("[USER DB]: Syncing user database: " + ds.Tables["users"].Rows.Count + " users stored");

                    // save changes off to disk
                    da.Update(ds, "users");
                }
                else
                {
                    m_log.WarnFormat("[USER DB]: Ignoring add since user with id {0} already exists", user.ID);
                }
            }
        }
示例#9
0
        public bool UpdateUserProfile(UserProfileData user)
        {
            m_userProfilesByUuid[user.ID] = user;
            m_userProfilesByName[user.FirstName + " " + user.SurName] = user;

            return true;
        }
示例#10
0
 public void AddTemporaryUserProfile(UserProfileData userProfile)
 {
     // Not interested
 }
示例#11
0
 /// <summary>
 /// Creates a new users profile
 /// </summary>
 /// <param name="user">The user profile to create</param>
 override public void AddNewUserProfile(UserProfileData user)
 {
     try
     {
         InsertUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt,
                       user.HomeRegion, user.HomeLocation.X, user.HomeLocation.Y,
                       user.HomeLocation.Z,
                       user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created,
                       user.LastLogin, user.UserInventoryURI, user.UserAssetURI,
                       user.CanDoMask, user.WantDoMask,
                       user.AboutText, user.FirstLifeAboutText, user.Image,
                       user.FirstLifeImage, user.WebLoginKey, user.HomeRegionID,
                       user.GodLevel, user.UserFlags, user.CustomType, user.Partner);
     }
     catch (Exception e)
     {
         m_log.ErrorFormat("[USER DB] Error adding new profile, error: {0}", e.Message);
     }
 }
        private void UpdateAvatarPropertiesHandler(IClientAPI client, UserProfileData profileData)
        {
            OSDMap map = new OSDMap
            {
                { "About", OSD.FromString(profileData.AboutText) },
                { "Image", OSD.FromUUID(profileData.Image) },
                { "FLAbout", OSD.FromString(profileData.FirstLifeAboutText) },
                { "FLImage", OSD.FromUUID(profileData.FirstLifeImage) },
                { "URL", OSD.FromString(profileData.ProfileUrl) }
            };

            AddUserData(client.AgentId, "LLAbout", map);
        }
示例#13
0
        protected bool PrepareNextRegion(LoginResponse response, UserProfileData theUser, List<string> theList, string startLocationRequest, string clientVersion)
        {
            Regex reURI = new Regex(@"^(?<region>[^&]+)/(?<x>\d+)/(?<y>\d+)/(?<z>\d+)$");
            if ((startLocationRequest != "home") && (startLocationRequest != "last"))
                startLocationRequest = "safe";

            foreach (string location in theList)
            {
                if (PrepareLoginToREURI(reURI, response, theUser, location, "safe", "default region", clientVersion))
                    return true;
            }
            return false;
        }
示例#14
0
        protected bool PrepareLoginToREURI(Regex reURI, LoginResponse response, UserProfileData theUser, string startLocationRequest, string StartLocationType, string desc, string clientVersion)
        {
			string region;
			RegionInfo regionInfo = null;
            Match uriMatch = reURI.Match(startLocationRequest);
            if (uriMatch == null)
            {
                m_log.InfoFormat("[LOGIN]: Got {0} {1}, but can't process it", desc, startLocationRequest);
				return false;
            }

            region = uriMatch.Groups["region"].ToString();
            regionInfo = RequestClosestRegion(region);
            if (regionInfo == null)
            {
                m_log.InfoFormat("[LOGIN]: Got {0} {1}, can't locate region {2}", desc, startLocationRequest, region);
				return false;
            }
            theUser.CurrentAgent.Position = new Vector3(float.Parse(uriMatch.Groups["x"].Value),
                                                        float.Parse(uriMatch.Groups["y"].Value), float.Parse(uriMatch.Groups["z"].Value));
            response.LookAt = "[r0,r1,r0]";
            // can be: last, home, safe, url
			response.StartLocation = StartLocationType;
			return PrepareLoginToRegion(regionInfo, theUser, response, clientVersion);
		}
示例#15
0
 public void CreateAgent(UserProfileData profile, OSD request)
 {
     m_userManager.CreateAgent(profile, request);
 }
示例#16
0
        public virtual bool AuthenticateUser(UserProfileData profile, UUID webloginkey)
        {
            bool passwordSuccess = false;
            m_log.InfoFormat("[LOGIN]: Authenticating {0} {1} ({2})", profile.FirstName, profile.SurName, profile.ID);

            // Match web login key unless it's the default weblogin key UUID.Zero
            passwordSuccess = ((profile.WebLoginKey == webloginkey) && profile.WebLoginKey != UUID.Zero);

            return passwordSuccess;
        }
        public override bool UpdateUserProfile(UserProfileData userProfile)
        {
            string url = string.Empty;
            if ((m_localUserServices != null) && (!IsForeignUser(userProfile.ID, out url)))
                return m_localUserServices.UpdateUserProfile(userProfile);

            return base.UpdateUserProfile(userProfile);
        }
示例#18
0
        // For new users' first-time logins
        protected bool PrepareNextDefaultLogin(LoginResponse response, UserProfileData theUser, string startLocationRequest, string clientVersion)
		{
            return PrepareNextRegion(response, theUser, _DefaultLoginsList, startLocationRequest, clientVersion);
		}
示例#19
0
        /// <summary>
        /// Reads a user profile from an active data reader
        /// </summary>
        /// <param name="reader">An active database reader</param>
        /// <returns>A user profile</returns>
        private static UserProfileData ReadUserRow(SqlDataReader reader)
        {
            UserProfileData retval = new UserProfileData();

            if (reader.Read())
            {
                retval.ID = new UUID((Guid)reader["UUID"]);
                retval.FirstName = (string)reader["username"];
                retval.SurName = (string)reader["lastname"];
                if (reader.IsDBNull(reader.GetOrdinal("email")))
                    retval.Email = "";
                else
                    retval.Email = (string)reader["email"];

                retval.PasswordHash = (string)reader["passwordHash"];
                retval.PasswordSalt = (string)reader["passwordSalt"];

                retval.HomeRegion = Convert.ToUInt64(reader["homeRegion"].ToString());
                retval.HomeLocation = new Vector3(
                    Convert.ToSingle(reader["homeLocationX"].ToString()),
                    Convert.ToSingle(reader["homeLocationY"].ToString()),
                    Convert.ToSingle(reader["homeLocationZ"].ToString()));
                retval.HomeLookAt = new Vector3(
                    Convert.ToSingle(reader["homeLookAtX"].ToString()),
                    Convert.ToSingle(reader["homeLookAtY"].ToString()),
                    Convert.ToSingle(reader["homeLookAtZ"].ToString()));

                if (reader.IsDBNull(reader.GetOrdinal("homeRegionID")))
                    retval.HomeRegionID = UUID.Zero;
                else
                    retval.HomeRegionID = new UUID((Guid)reader["homeRegionID"]);       

                retval.Created = Convert.ToInt32(reader["created"].ToString());
                retval.LastLogin = Convert.ToInt32(reader["lastLogin"].ToString());

                if (reader.IsDBNull(reader.GetOrdinal("userInventoryURI")))
                    retval.UserInventoryURI = "";
                else
                    retval.UserInventoryURI = (string)reader["userInventoryURI"];

                if (reader.IsDBNull(reader.GetOrdinal("userAssetURI")))
                    retval.UserAssetURI = "";
                else
                    retval.UserAssetURI = (string)reader["userAssetURI"];

                retval.CanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString());
                retval.WantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString());


                if (reader.IsDBNull(reader.GetOrdinal("profileAboutText")))
                    retval.AboutText = "";
                else
                    retval.AboutText = (string)reader["profileAboutText"];

                if (reader.IsDBNull(reader.GetOrdinal("profileFirstText")))
                    retval.FirstLifeAboutText = "";
                else
                    retval.FirstLifeAboutText = (string)reader["profileFirstText"];

                if (reader.IsDBNull(reader.GetOrdinal("profileImage")))
                    retval.Image = UUID.Zero;
                else
                    retval.Image = new UUID((Guid)reader["profileImage"]);

                if (reader.IsDBNull(reader.GetOrdinal("profileFirstImage")))
                    retval.Image = UUID.Zero;
                else
                    retval.FirstLifeImage = new UUID((Guid)reader["profileFirstImage"]);

                if (reader.IsDBNull(reader.GetOrdinal("webLoginKey")))
                    retval.WebLoginKey = UUID.Zero;
                else
                    retval.WebLoginKey = new UUID((Guid)reader["webLoginKey"]);

                retval.UserFlags = Convert.ToInt32(reader["userFlags"].ToString());
                retval.GodLevel = Convert.ToInt32(reader["godLevel"].ToString());
                if (reader.IsDBNull(reader.GetOrdinal("customType")))
                    retval.CustomType = "";
                else
                    retval.CustomType = reader["customType"].ToString();

                if (reader.IsDBNull(reader.GetOrdinal("partner")))
                    retval.Partner = UUID.Zero;
                else
                    retval.Partner = new UUID((Guid)reader["partner"]);    
            }
            else
            {
                return null;
            }
            return retval;
        }
示例#20
0
        // For returning users' where the preferred region is down
        protected bool PrepareNextDefaultRegion(LoginResponse response, UserProfileData theUser, string clientVersion)
		{
            return PrepareNextRegion(response, theUser, _DefaultRegionsList, "safe", clientVersion);
		}
示例#21
0
        /// <summary>
        /// update a user profile
        /// </summary>
        /// <param name="user">the profile to update</param>
        /// <returns></returns>
        override public bool UpdateUserProfile(UserProfileData user)
        {
            string sql = string.Format(@"UPDATE {0} 
                                        SET UUID = @uuid,
                                        username = @username, 
                                        lastname = @lastname,
                                        email = @email,
                                        passwordHash = @passwordHash,
                                        passwordSalt = @passwordSalt,
                                        homeRegion = @homeRegion,
                                        homeLocationX = @homeLocationX,
                                        homeLocationY = @homeLocationY,
                                        homeLocationZ = @homeLocationZ,
                                        homeLookAtX = @homeLookAtX,
                                        homeLookAtY = @homeLookAtY,
                                        homeLookAtZ = @homeLookAtZ,
                                        created = @created,
                                        lastLogin = @lastLogin,
                                        userInventoryURI = @userInventoryURI,
                                        userAssetURI = @userAssetURI,
                                        profileCanDoMask = @profileCanDoMask,
                                        profileWantDoMask = @profileWantDoMask,
                                        profileAboutText = @profileAboutText,
                                        profileFirstText = @profileFirstText,
                                        profileImage = @profileImage,
                                        profileFirstImage = @profileFirstImage, 
                                        webLoginKey = @webLoginKey, 
                                        homeRegionID = @homeRegionID,
                                        userFlags = @userFlags,
                                        godLevel = @godLevel, 
                                        customType = @customType, 
                                        partner = @partner WHERE UUID = @keyUUUID;",m_usersTableName);
            using (AutoClosingSqlCommand command = database.Query(sql))
            {
                command.Parameters.Add(database.CreateParameter("uuid", user.ID));
                command.Parameters.Add(database.CreateParameter("username", user.FirstName));
                command.Parameters.Add(database.CreateParameter("lastname", user.SurName));
                command.Parameters.Add(database.CreateParameter("email", user.Email));
                command.Parameters.Add(database.CreateParameter("passwordHash", user.PasswordHash));
                command.Parameters.Add(database.CreateParameter("passwordSalt", user.PasswordSalt));
                command.Parameters.Add(database.CreateParameter("homeRegion", user.HomeRegion));
                command.Parameters.Add(database.CreateParameter("homeLocationX", user.HomeLocation.X));
                command.Parameters.Add(database.CreateParameter("homeLocationY", user.HomeLocation.Y));
                command.Parameters.Add(database.CreateParameter("homeLocationZ", user.HomeLocation.Z));
                command.Parameters.Add(database.CreateParameter("homeLookAtX", user.HomeLookAt.X));
                command.Parameters.Add(database.CreateParameter("homeLookAtY", user.HomeLookAt.Y));
                command.Parameters.Add(database.CreateParameter("homeLookAtZ", user.HomeLookAt.Z));
                command.Parameters.Add(database.CreateParameter("created", user.Created));
                command.Parameters.Add(database.CreateParameter("lastLogin", user.LastLogin));
                command.Parameters.Add(database.CreateParameter("userInventoryURI", user.UserInventoryURI));
                command.Parameters.Add(database.CreateParameter("userAssetURI", user.UserAssetURI));
                command.Parameters.Add(database.CreateParameter("profileCanDoMask", user.CanDoMask));
                command.Parameters.Add(database.CreateParameter("profileWantDoMask", user.WantDoMask));
                command.Parameters.Add(database.CreateParameter("profileAboutText", user.AboutText));
                command.Parameters.Add(database.CreateParameter("profileFirstText", user.FirstLifeAboutText));
                command.Parameters.Add(database.CreateParameter("profileImage", user.Image));
                command.Parameters.Add(database.CreateParameter("profileFirstImage", user.FirstLifeImage));
                command.Parameters.Add(database.CreateParameter("webLoginKey", user.WebLoginKey));
                command.Parameters.Add(database.CreateParameter("homeRegionID", user.HomeRegionID));
                command.Parameters.Add(database.CreateParameter("userFlags", user.UserFlags));
                command.Parameters.Add(database.CreateParameter("godLevel", user.GodLevel));
                command.Parameters.Add(database.CreateParameter("customType", user.CustomType));
                command.Parameters.Add(database.CreateParameter("partner", user.Partner));
                command.Parameters.Add(database.CreateParameter("keyUUUID", user.ID));

                try
                {
                    int affected = command.ExecuteNonQuery();
                    return (affected != 0);
                }
                catch (Exception e)
                {
                    m_log.ErrorFormat("[USER DB] Error updating profile, error: {0}", e.Message);
                }
            }
            return false;
        }
示例#22
0
        /// <summary>
        /// Customises the login response and fills in missing values.  This method also tells the login region to
        /// expect a client connection.
        /// </summary>
        /// <param name="response">The existing response</param>
        /// <param name="theUser">The user profile</param>
        /// <param name="startLocationRequest">The requested start location</param>
        /// <returns>true on success, false if the region was not successfully told to expect a user connection</returns>
        public bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest, string clientVersion)
        {
            // add active gestures to login-response
            AddActiveGestures(response, theUser);

            // HomeLocation
            RegionInfo homeInfo = null;

            // use the homeRegionID if it is stored already. If not, use the regionHandle as before
            UUID homeRegionId = theUser.HomeRegionID;
            ulong homeRegionHandle = theUser.HomeRegion;
            if (homeRegionId != UUID.Zero)
            {
                homeInfo = GetRegionInfo(homeRegionId);
            }
            else
            {
                homeInfo = GetRegionInfo(homeRegionHandle);
            }

            if (homeInfo != null)
            {
                response.Home =
                    string.Format(
                        "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
                        (homeInfo.RegionLocX * Constants.RegionSize),
                        (homeInfo.RegionLocY * Constants.RegionSize),
                        theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z,
                        theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z);
            }
            else
            {
                m_log.InfoFormat("not found the region at {0} {1}", theUser.HomeRegionX, theUser.HomeRegionY);
                // Emergency mode: Home-region isn't available, so we can't request the region info.
                // Use the stored home regionHandle instead.
                // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again
                ulong regionX = homeRegionHandle >> 32;
                ulong regionY = homeRegionHandle & 0xffffffff;
                response.Home =
                    string.Format(
                        "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
                        regionX, regionY,
                        theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z,
                        theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z);

                m_log.InfoFormat("[LOGIN] Home region of user {0} {1} is not available; using computed region position {2} {3}",
                                 theUser.FirstName, theUser.SurName,
                                 regionX, regionY);
            }

            // StartLocation
            RegionInfo regionInfo = null;
            if (theUser.LastLogin == 0)
            {
                // New user first login
                if (PrepareNextDefaultLogin(response, theUser, startLocationRequest, clientVersion))
                    return true;
            }
            else
            {
                // Returning user login
                if (startLocationRequest == "home")
                {
                    regionInfo = homeInfo;
                    theUser.CurrentAgent.Position = theUser.HomeLocation;
                    response.LookAt = String.Format("[r{0},r{1},r{2}]", theUser.HomeLookAt.X.ToString(),
                                                    theUser.HomeLookAt.Y.ToString(), theUser.HomeLookAt.Z.ToString());
                }
                else if (startLocationRequest == "last")
                {
                    UUID lastRegion = theUser.CurrentAgent.Region;
                    regionInfo = GetRegionInfo(lastRegion);
                    response.LookAt = String.Format("[r{0},r{1},r{2}]", theUser.CurrentAgent.LookAt.X.ToString(),
                                                    theUser.CurrentAgent.LookAt.Y.ToString(), theUser.CurrentAgent.LookAt.Z.ToString());
                }
                else
                {
                    // Logging in to a specific URL... try to find the region
                    Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$");
                    if (PrepareLoginToREURI(reURI, response, theUser, startLocationRequest, "url", "Custom Login URL", clientVersion))
                        return true;
                }

                // Logging in to home or last... try to find the region
                if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response, clientVersion)))
                {
                    return true;
                }

                // StartLocation not available, send him to a nearby region instead
                // regionInfo = m_gridService.RequestClosestRegion("");
                //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName);

                // Normal login failed, try to find a default region from the list
                if (PrepareNextDefaultRegion(response, theUser, clientVersion))
                    return true;
            }

            // No default regions available either.
			// Send him to global default region home location instead (e.g. 1000,1000)
            ulong defaultHandle = (((ulong)m_defaultHomeX * Constants.RegionSize) << 32) |
                                  ((ulong)m_defaultHomeY * Constants.RegionSize);

            if ((regionInfo != null) && (defaultHandle == regionInfo.RegionHandle))
            {
                m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region");
                return false;
            }

            m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead");
            regionInfo = GetRegionInfo(defaultHandle);

            if (regionInfo == null)
            {
                m_log.ErrorFormat("[LOGIN]: No default region available. Aborting.");
                return false;
            }

            theUser.CurrentAgent.Position = new Vector3(128, 128, 0);
            response.StartLocation = "safe";

            return PrepareLoginToRegion(regionInfo, theUser, response, clientVersion);
        }
示例#23
0
 public void AddNewUserProfile(UserProfileData user)
 {
     UpdateUserProfile(user);
 }
示例#24
0
 //public abstract UserAgentData GetAgentProfileURL(UUID agentID, string profileURL);
 public abstract void AddNewUserProfile(UserProfileData user);
示例#25
0
        /// <summary>
        /// Persist user profile data
        /// </summary>
        /// <param name="row"></param>
        /// <param name="user"></param>
        private void fillUserRow(DataRow row, UserProfileData user)
        {
            row["UUID"] = user.ID.ToString();
            row["username"] = user.FirstName;
            row["surname"] = user.SurName;
            row["email"] = user.Email;
            row["passwordHash"] = user.PasswordHash;
            row["passwordSalt"] = user.PasswordSalt;

            row["homeRegionX"] = user.HomeRegionX;
            row["homeRegionY"] = user.HomeRegionY;
            row["homeRegionID"] = user.HomeRegionID.ToString();
            row["homeLocationX"] = user.HomeLocation.X;
            row["homeLocationY"] = user.HomeLocation.Y;
            row["homeLocationZ"] = user.HomeLocation.Z;
            row["homeLookAtX"] = user.HomeLookAt.X;
            row["homeLookAtY"] = user.HomeLookAt.Y;
            row["homeLookAtZ"] = user.HomeLookAt.Z;

            row["created"] = user.Created;
            row["lastLogin"] = user.LastLogin;
            //TODO: Get rid of rootInventoryFolderID in a safe way.
            row["rootInventoryFolderID"] = UUID.Zero.ToString();
            row["userInventoryURI"] = user.UserInventoryURI;
            row["userAssetURI"] = user.UserAssetURI;
            row["profileCanDoMask"] = user.CanDoMask;
            row["profileWantDoMask"] = user.WantDoMask;
            row["profileAboutText"] = user.AboutText;
            row["profileFirstText"] = user.FirstLifeAboutText;
            row["profileImage"] = user.Image.ToString();
            row["profileFirstImage"] = user.FirstLifeImage.ToString();
            row["webLoginKey"] = user.WebLoginKey.ToString();
            row["userFlags"] = user.UserFlags;
            row["godLevel"] = user.GodLevel;
            row["customType"] = user.CustomType == null ? "" : user.CustomType;
            row["partner"] = user.Partner.ToString();

            // ADO.NET doesn't handle NULL very well
            foreach (DataColumn col in ds.Tables["users"].Columns)
            {
                if (row[col] == null)
                {
                    row[col] = String.Empty;
                }
            }
        }
示例#26
0
 //public abstract UserInterestsData GetUserInterests(UUID user);
 
 public virtual void AddTemporaryUserProfile(UserProfileData userProfile)
 {
     // Temporary profiles are optional for database plugins.
 }
示例#27
0
        /// <summary>
        /// Creates a new user profile
        /// </summary>
        /// <param name="user">The profile to add to the database</param>
        /// <returns>True on success, false on error</returns>
        override public bool UpdateUserProfile(UserProfileData user)
        {
            DataTable users = ds.Tables["users"];
            lock (ds)
            {
                DataRow row = users.Rows.Find(user.ID.ToString());
                if (row == null)
                {
                    return false;
                }
                else
                {
                    fillUserRow(row, user);
                    da.Update(ds, "users");
                }
            }

            //AddNewUserProfile(user);
            return true;
        }
示例#28
0
 public abstract bool UpdateUserProfile(UserProfileData user);
示例#29
0
        public override void LogOffUser(UserProfileData theUser, string message)
        {
            RegionProfileData SimInfo;
            try
            {
                SimInfo = m_regionProfileService.RequestSimProfileData(
                    theUser.CurrentAgent.Handle, m_config.GridServerURL,
                    m_config.GridSendKey, m_config.GridRecvKey);

                if (SimInfo == null)
                {
                    m_log.Error("[GRID]: Region user was in isn't currently logged in");
                    return;
                }
            }
            catch (Exception)
            {
                m_log.Error("[GRID]: Unable to look up region to log user off");
                return;
            }

            // Prepare notification
            Hashtable SimParams = new Hashtable();
            SimParams["agent_id"] = theUser.ID.ToString();
            SimParams["region_secret"] = theUser.CurrentAgent.SecureSessionID.ToString();
            SimParams["region_secret2"] = SimInfo.regionSecret;
            //m_log.Info(SimInfo.regionSecret);
            SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString();
            SimParams["message"] = message;
            ArrayList SendParams = new ArrayList();
            SendParams.Add(SimParams);

            m_log.InfoFormat(
                "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}",
                SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI,
                theUser.FirstName + " " + theUser.SurName);

            try
            {
                string methodName = "logoff_user";
                XmlRpcRequest GridReq = new XmlRpcRequest(methodName, SendParams);
                XmlRpcResponse GridResp = GridReq.Send(Util.XmlRpcRequestURI(SimInfo.httpServerURI, methodName), 6000);

                if (GridResp.IsFault)
                {
                    m_log.ErrorFormat(
                        "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.",
                        SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString);
                }
            }
            catch (Exception)
            {
                m_log.Error("[LOGIN]: Error telling region to logout user!");
            }

            // Prepare notification
            SimParams = new Hashtable();
            SimParams["agent_id"] = theUser.ID.ToString();
            SimParams["region_secret"] = SimInfo.regionSecret;
            //m_log.Info(SimInfo.regionSecret);
            SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString();
            SimParams["message"] = message;
            SendParams = new ArrayList();
            SendParams.Add(SimParams);

            m_log.InfoFormat(
                "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}",
                SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI,
                theUser.FirstName + " " + theUser.SurName);

            try
            {
                string methodName = "logoff_user";
                XmlRpcRequest GridReq = new XmlRpcRequest(methodName, SendParams);
                XmlRpcResponse GridResp = GridReq.Send(Util.XmlRpcRequestURI(SimInfo.httpServerURI, methodName), 6000);

                if (GridResp.IsFault)
                {
                    m_log.ErrorFormat(
                        "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.",
                        SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString);
                }
            }
            catch (Exception)
            {
                m_log.Error("[LOGIN]: Error telling region to logout user!");
            }
            //base.LogOffUser(theUser);
        }
示例#30
0
        override public void AddNewUserProfile(UserProfileData profile)
        {
            if (profile.ID == UUID.Zero)
            {
                m_log.ErrorFormat("[NHIBERNATE] Attempted to add User {0} {1} with zero UUID, throwintg exception as this is programming error ", profile.FirstName, profile.SurName);
                return;
            }

            if (!ExistsUser(profile.ID))
            {
                m_log.InfoFormat("[NHIBERNATE] AddNewUserProfile {0}", profile.ID);
                manager.Insert(profile);
                // Agent should not be saved according to BasicUserTest.T015_UserPersistency()
                // SetAgentData(profile.ID, profile.CurrentAgent);

            }
            else
            {
                m_log.ErrorFormat("[NHIBERNATE] Attempted to add User {0} {1} that already exists, updating instead", profile.FirstName, profile.SurName);
                UpdateUserProfile(profile);
            }
        }
示例#31
0
        /// <summary>
        /// Prepare a login to the given region.  This involves both telling the region to expect a connection
        /// and appropriately customising the response to the user.
        /// </summary>
        /// <param name="regionInfo"></param>
        /// <param name="user"></param>
        /// <param name="response"></param>
        /// <returns>true if the region was successfully contacted, false otherwise</returns>
        private bool PrepareLoginToRegion(RegionProfileData regionInfo, UserProfileData user, LoginResponse response, string clientVersion)
        {
            string regionName = regionInfo.regionName;
            bool success = false;

            try
            {
                lock (_LastRegionFailure)
                {
                    if (_LastRegionFailure.ContainsKey(regionName))
                    {
                        // region failed previously
                        RegionLoginFailure failure = _LastRegionFailure[regionName];
                        if (failure.IsExpired())
                        {
                            // failure has expired, retry this region again
                            _LastRegionFailure.Remove(regionName);
//                            m_log.WarnFormat("[LOGIN]: Region '{0}' was previously down, retrying.", regionName);
                        }
                        else
                        {
                            if (failure.IsFailed())
                            {
//                                m_log.WarnFormat("[LOGIN]: Region '{0}' was recently down, skipping.", regionName);
                                return false;   // within 5 minutes, don't repeat attempt
                            }
//                            m_log.WarnFormat("[LOGIN]: Region '{0}' was recently down but under threshold, retrying.", regionName);
                        }
                    }
                }

                response.SimAddress = regionInfo.OutsideIpOrResolvedHostname;
                response.SimPort = regionInfo.serverPort;
                response.RegionX = regionInfo.regionLocX;
                response.RegionY = regionInfo.regionLocY;

                string capsPath = CapsUtil.GetRandomCapsObjectPath();

                response.SeedCapability = CapsUtil.GetFullCapsSeedURL(regionInfo.httpServerURI, capsPath);

                // Notify the target of an incoming user
                m_log.InfoFormat(
                    "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection",
                    regionInfo.regionName, response.RegionX, response.RegionY, response.SeedCapability);

                // Update agent with target sim
                user.CurrentAgent.Region = regionInfo.UUID;
                user.CurrentAgent.Handle = regionInfo.regionHandle;

                // Prepare notification
                Hashtable loginParams = new Hashtable();
                loginParams["session_id"] = user.CurrentAgent.SessionID.ToString();
                loginParams["secure_session_id"] = user.CurrentAgent.SecureSessionID.ToString();
                loginParams["firstname"] = user.FirstName;
                loginParams["lastname"] = user.SurName;
                loginParams["agent_id"] = user.ID.ToString();
                loginParams["circuit_code"] = (Int32)Convert.ToUInt32(response.CircuitCode);
                loginParams["startpos_x"] = user.CurrentAgent.Position.X.ToString();
                loginParams["startpos_y"] = user.CurrentAgent.Position.Y.ToString();
                loginParams["startpos_z"] = user.CurrentAgent.Position.Z.ToString();
                loginParams["regionhandle"] = user.CurrentAgent.Handle.ToString();
                loginParams["caps_path"] = capsPath;
                loginParams["client_version"] = clientVersion;

                // Get appearance
                AvatarAppearance appearance = m_userManager.GetUserAppearance(user.ID);
                if (appearance != null)
                {
                    loginParams["appearance"] = appearance.ToHashTable();
                    m_log.DebugFormat("[LOGIN]: Found appearance version {0} for {1} {2}", appearance.Serial, user.FirstName, user.SurName);
                }
                else
                {
                    m_log.DebugFormat("[LOGIN]: Appearance not for {0} {1}. Creating default.", user.FirstName, user.SurName);
                    appearance = new AvatarAppearance(user.ID);
                }

                // Tell the client the COF version so it can use cached appearance if it matches.
                response.CofVersion = appearance.Serial.ToString();
                loginParams["cof_version"] = response.CofVersion;

                ArrayList SendParams = new ArrayList();
                SendParams.Add(loginParams);
                SendParams.Add(m_config.GridSendKey);

                // Send
                const string METHOD_NAME = "expect_user";
                XmlRpcRequest GridReq = new XmlRpcRequest(METHOD_NAME, SendParams);
                XmlRpcResponse GridResp = GridReq.Send(Util.XmlRpcRequestURI(regionInfo.httpServerURI, METHOD_NAME), 6000);

                if (!GridResp.IsFault)
                {
                    bool responseSuccess = true;

                    if (GridResp.Value != null)
                    {
                        Hashtable resp = (Hashtable)GridResp.Value;
                        if (resp.ContainsKey("success"))
                        {
                            if ((string)resp["success"] == "FALSE")
                            {
                                responseSuccess = false;
                            }
                        }
                        if (!responseSuccess)
                        {
                            if (resp.ContainsKey("reason"))
                            {
                                response.ErrorMessage = resp["reason"].ToString();
                            }
                        }
                    }
                    
                    if (responseSuccess)
                    {
                        handlerUserLoggedInAtLocation = OnUserLoggedInAtLocation;
                        if (handlerUserLoggedInAtLocation != null)
                        {
                            handlerUserLoggedInAtLocation(user.ID, user.CurrentAgent.SessionID,
                                                          user.CurrentAgent.Region,
                                                          user.CurrentAgent.Handle,
                                                          user.CurrentAgent.Position.X,
                                                          user.CurrentAgent.Position.Y,
                                                          user.CurrentAgent.Position.Z,
                                                          user.FirstName, user.SurName);
                        }
                        success = true;
                    }
                    else
                    {
                        m_log.ErrorFormat("[LOGIN]: Region responded that it is not available to receive clients");
                    }
                }
                else
                {
                    m_log.ErrorFormat("[LOGIN]: XmlRpc request to region failed with message {0}, code {1} ", GridResp.FaultString, GridResp.FaultCode);
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[LOGIN]: Region not available for login, {0}", e);
            }

            lock (_LastRegionFailure)
            {
                if (_LastRegionFailure.ContainsKey(regionName))
                {
                    RegionLoginFailure failure = _LastRegionFailure[regionName];
                    if (success)
                    {   // Success, so if we've been storing this as a failed region, remove that from the failed list.
                        m_log.WarnFormat("[LOGIN]: Region '{0}' recently down, is available again.", regionName);
                        _LastRegionFailure.Remove(regionName);
                    }
                    else
                    {
                        // Region not available, update cache with incremented count.
                        failure.AddFailure();
//                        m_log.WarnFormat("[LOGIN]: Region '{0}' is still down ({1}).", regionName, failure.Count);
                    }
                }
                else
                {
                    if (!success)
                    {
                        // Region not available, cache that temporarily.
                        m_log.WarnFormat("[LOGIN]: Region '{0}' is down, marking.", regionName);
                        _LastRegionFailure[regionName] = new RegionLoginFailure();
                    }
                }
            }
            return success;
        }
示例#32
0
 /*
 private void SetAgentData(UUID uuid, UserAgentData agent)
 {
     UserAgentData old = (UserAgentData)manager.Load(typeof(UserAgentData), uuid);
     if (old != null)
     {
         m_log.InfoFormat("[NHIBERNATE] SetAgentData deleting old: {0} ",uuid);
         manager.Delete(old);
     }
     if (agent != null)
     {
         m_log.InfoFormat("[NHIBERNATE] SetAgentData: {0} ", agent.ProfileID);
         manager.Save(agent);
     }
 }
 */
 
 override public bool UpdateUserProfile(UserProfileData profile)
 {
     if (ExistsUser(profile.ID))
     {
         manager.Update(profile);
         // Agent should not be saved according to BasicUserTest.T015_UserPersistency()
         // SetAgentData(profile.ID, profile.CurrentAgent);
         return true;
     }
     else
     {
         m_log.ErrorFormat("[NHIBERNATE] Attempted to update User {0} {1} that doesn't exist, updating instead", profile.FirstName, profile.SurName);
         AddNewUserProfile(profile);
         return true;
     }
 }