예제 #1
0
 public UserInfo[] GetUserInfos(string[] userIDs)
 {
     UserInfo[] us = new UserInfo[userIDs.Length];
     for (int i = 0; i < userIDs.Length; i++)
         us[i] = GetUserInfo(userIDs[i]);
     return us;
 }
예제 #2
0
 public UserInfo GetUserInfo(string userID)
 {
     List<string> urls = m_registry.RequestModuleInterface<IConfigurationService>().FindValueOf(userID, "AgentInfoServerURI");
     foreach (string url in urls)
     {
         try
         {
             OSDMap request = new OSDMap();
             request["userID"] = userID;
             request["Method"] = "GetUserInfo";
             OSDMap result = WebUtils.PostToService(url, request, true, false);
             OSD r = OSDParser.DeserializeJson(result["_RawResult"]);
             if (r is OSDMap)
             {
                 OSDMap innerresult = (OSDMap)r;
                 UserInfo info = new UserInfo();
                 if(innerresult["Result"].AsString() == "null")
                     return null;
                 info.FromOSD((OSDMap)innerresult["Result"]);
                 return info;
             }
         }
         catch(Exception)
         {
         }
     }
     return null;
 }
예제 #3
0
 public virtual UserInfo[] GetUserInfos(string[] userIDs)
 {
     UserInfo[] infos = new UserInfo[userIDs.Length];
     for (int i = 0; i < userIDs.Length; i++)
     {
         infos[i] = GetUserInfo(userIDs[i]);
     }
     return infos;
 }
예제 #4
0
        private void FillOutHomeData(OpenSim.Services.Interfaces.UserInfo pinfo, GridRegion home)
        {
            int x = 1000 * (int)Constants.RegionSize, y = 1000 * (int)Constants.RegionSize;

            if (home != null)
            {
                x = home.RegionLocX;
                y = home.RegionLocY;
            }

            Home = string.Format(
                "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
                x,
                y,
                pinfo.HomePosition.X, pinfo.HomePosition.Y, pinfo.HomePosition.Z,
                pinfo.HomeLookAt.X, pinfo.HomeLookAt.Y, pinfo.HomeLookAt.Z);
        }
예제 #5
0
 public bool Set(UserInfo info)
 {
     object[] values = new object[13];
     values[0] = info.UserID;
     values[1] = info.CurrentRegionID;
     values[2] = Util.ToUnixTime(DateTime.Now); //Convert to binary so that it can be converted easily
     values[3] = info.IsOnline ? 1 : 0;
     values[4] = Util.ToUnixTime(info.LastLogin);
     values[5] = Util.ToUnixTime(info.LastLogout);
     values[6] = OSDParser.SerializeJsonString(info.Info);
     values[7] = info.CurrentRegionID.ToString();
     values[8] = info.CurrentPosition.ToString();
     values[9] = info.CurrentLookAt.ToString();
     values[10] = info.HomeRegionID.ToString();
     values[11] = info.HomePosition.ToString();
     values[12] = info.HomeLookAt.ToString();
     GD.Delete(m_realm, new string[1] { "UserID" }, new object[1] { info.UserID });
     return GD.Insert(m_realm, values);
 }
예제 #6
0
 public bool Set(UserInfo info)
 {
     string[] keys = new string[8];
     keys[0] = "UserID";
     keys[1] = "RegionID";
     keys[2] = "SessionID";
     keys[3] = "LastSeen";
     keys[4] = "IsOnline";
     keys[5] = "LastLogin";
     keys[6] = "LastLogout";
     keys[7] = "Info";
     object[] values = new object[8];
     values[0] = info.UserID;
     values[1] = info.CurrentRegionID;
     values[2] = info.SessionID;
     values[3] =  DateTime.Now.ToBinary(); //Convert to binary so that it can be converted easily
     values[4] = info.IsOnline ? 1 : 0;
     values[5] = info.LastLogin.ToBinary();
     values[6] = info.LastLogout.ToBinary();
     values[7] = OSDParser.SerializeJsonString(info.Info);
     return GD.Replace(m_realm, keys, values);
 }
예제 #7
0
        public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, OpenSim.Services.Interfaces.UserInfo pinfo,
                               GridRegion destination, List <InventoryFolderBase> invSkel, FriendInfo[] friendsList, ILibraryService libService,
                               string where, string startlocation, Vector3 position, Vector3 lookAt, List <InventoryItemBase> gestures,
                               GridRegion home, IPEndPoint clientIP, string AdultMax, string AdultRating,
                               ArrayList eventValues, ArrayList classifiedValues, string seedCap, IConfigSource source, string DisplayName)
            : this()
        {
            m_source       = source;
            SeedCapability = seedCap;

            FillOutInventoryData(invSkel, libService);

            FillOutActiveGestures(gestures);

            CircuitCode          = (int)aCircuit.circuitcode;
            Lastname             = account.LastName;
            Firstname            = account.FirstName;
            this.DisplayName     = DisplayName;
            AgentID              = account.PrincipalID;
            SessionID            = aCircuit.SessionID;
            SecureSessionID      = aCircuit.SecureSessionID;
            BuddList             = ConvertFriendListItem(friendsList);
            StartLocation        = where;
            AgentAccessMax       = AdultMax;
            AgentAccess          = AdultRating;
            eventCategories      = eventValues;
            classifiedCategories = classifiedValues;

            FillOutHomeData(pinfo, home);
            LookAt = String.Format("[r{0},r{1},r{2}]", lookAt.X, lookAt.Y, lookAt.Z);

            FillOutRegionData(destination);
            login        = "******";
            ErrorMessage = "";
            ErrorReason  = LoginResponseEnum.OK;
        }
예제 #8
0
        private OSDMap UserInfo2InfoWebOSD(UserInfo userinfo)
        {
            OSDMap resp = new OSDMap();

            IUserAccountService accountService = m_registry.RequestModuleInterface<IUserAccountService>();
            IGridService gs = m_registry.RequestModuleInterface<IGridService>();
            UserAccount user = accountService.GetUserAccount(UUID.Zero, new UUID(userinfo.UserID));

            GridRegion homeRegion = gs.GetRegionByUUID(UUID.Zero, userinfo.HomeRegionID);
            GridRegion currentRegion = userinfo.CurrentRegionID != UUID.Zero ? gs.GetRegionByUUID(UUID.Zero, userinfo.CurrentRegionID) : null;

            resp["UUID"] = OSD.FromUUID(user.PrincipalID);
            resp["HomeUUID"] = OSD.FromUUID((homeRegion == null) ? UUID.Zero : homeRegion.RegionID);
            resp["HomeName"] = OSD.FromString((homeRegion == null) ? "" : homeRegion.RegionName);
            resp["CurrentRegionUUID"] = OSD.FromUUID((userinfo == null) ? UUID.Zero : userinfo.CurrentRegionID);
            resp["CurrentRegionName"] = OSD.FromString((currentRegion == null) ? "" : currentRegion.RegionName);
            resp["Online"] = OSD.FromBoolean((userinfo == null) ? false : userinfo.IsOnline);
            resp["Email"] = OSD.FromString(user.Email);
            resp["Name"] = OSD.FromString(user.Name);
            resp["FirstName"] = OSD.FromString(user.FirstName);
            resp["LastName"] = OSD.FromString(user.LastName);
            resp["LastLogin"] = userinfo == null ? OSD.FromBoolean(false) : OSD.FromInteger((int)Utils.DateTimeToUnixTime(userinfo.LastLogin));
            resp["LastLogout"] = userinfo == null ? OSD.FromBoolean(false) : OSD.FromInteger((int)Utils.DateTimeToUnixTime(userinfo.LastLogout));

            return resp;
        }
예제 #9
0
        public LoginResponse Login(string Name, string passwd, string startLocation, UUID scopeID,
            string clientVersion, string channel, string mac, string id0, IPEndPoint clientIP, Hashtable requestData, UUID secureSession)
        {
            UUID session = UUID.Random();

            m_log.InfoFormat("[LLOGIN SERVICE]: Login request for {0} from {1} with user agent {2} starting in {3}",
                Name, clientIP.Address.ToString(), clientVersion, startLocation);
            UserAccount account = m_UserAccountService.GetUserAccount (scopeID, Name);
            try
            {
                string DisplayName = account.Name;
                IAgentInfo agent = null;

                IAgentConnector agentData = DataManager.RequestPlugin<IAgentConnector>();
                IProfileConnector profileData = DataManager.RequestPlugin<IProfileConnector>();
                if (agentData != null)
                    agent = agentData.GetAgent(account.PrincipalID);

                requestData["ip"] = clientIP.ToString();
                foreach (ILoginModule module in LoginModules)
                {
                    string message;
                    if (!module.Login(requestData, account.PrincipalID, out message))
                    {
                        LLFailedLoginResponse resp = new LLFailedLoginResponse(LoginResponseEnum.PasswordIncorrect,
                            message, false);
                        return resp;
                    }
                }
                

                //
                // Get the user's inventory
                //
                if (m_RequireInventory && m_InventoryService == null)
                {
                    m_log.WarnFormat("[LLOGIN SERVICE]: Login failed, reason: inventory service not set up");
                    return LLFailedLoginResponse.InventoryProblem;
                }
                List<InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID);
                if (m_RequireInventory && ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0)))
                {
                    m_InventoryService.CreateUserInventory(account.PrincipalID, m_DefaultUserAvatarArchive == "");
                    inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID);
                    if (m_RequireInventory && ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0)))
                    {
                        m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: unable to retrieve user inventory");
                        return LLFailedLoginResponse.InventoryProblem;
                    }
                }
                if (m_InventoryService.CreateUserRootFolder (account.PrincipalID))
                    ///Gotta refetch... since something went wrong
                    inventorySkel = m_InventoryService.GetInventorySkeleton (account.PrincipalID);

                if (profileData != null)
                {
                    IUserProfileInfo UPI = profileData.GetUserProfile(account.PrincipalID);
                    if (UPI == null)
                    {
                        profileData.CreateNewProfile(account.PrincipalID);
                        UPI = profileData.GetUserProfile(account.PrincipalID);
                        UPI.AArchiveName = m_DefaultUserAvatarArchive;
                        UPI.IsNewUser = true;
                        //profileData.UpdateUserProfile(UPI); //It gets hit later by the next thing
                    }
                    //Find which is set, if any
                    string archiveName = (UPI.AArchiveName != "" && UPI.AArchiveName != " ") ? UPI.AArchiveName : m_DefaultUserAvatarArchive;
                    if (UPI.IsNewUser && archiveName != "")
                    {
                        archiver.LoadAvatarArchive(archiveName, account.Name);
                        UPI.AArchiveName = "";
                    }
                    if (UPI.IsNewUser)
                    {
                        UPI.IsNewUser = false;
                        profileData.UpdateUserProfile(UPI);
                    }
                    if(UPI.DisplayName != "")
                        DisplayName = UPI.DisplayName;
                }

                // Get active gestures
                List<InventoryItemBase> gestures = m_InventoryService.GetActiveGestures(account.PrincipalID);
                //m_log.DebugFormat("[LLOGIN SERVICE]: {0} active gestures", gestures.Count);

                //Reset logged in to true if the user was crashed, but don't fire the logged in event yet
                m_agentInfoService.SetLoggedIn (account.PrincipalID.ToString (), true, false, UUID.Zero);
                //Lock it as well
                m_agentInfoService.LockLoggedInStatus (account.PrincipalID.ToString (), true);
                //Now get the logged in status, then below make sure to kill the previous agent if we crashed before
                UserInfo guinfo = m_agentInfoService.GetUserInfo (account.PrincipalID.ToString ());
                //
                // Clear out any existing CAPS the user may have
                //
                if (m_CapsService != null)
                {
                    IAgentProcessing agentProcessor = m_registry.RequestModuleInterface<IAgentProcessing>();
                    if (agentProcessor != null)
                    {
                        IClientCapsService clientCaps = m_CapsService.GetClientCapsService(account.PrincipalID);
                        if (clientCaps != null)
                        {
                            IRegionClientCapsService rootRegionCaps = clientCaps.GetRootCapsService();
                            if (rootRegionCaps != null)
                                agentProcessor.LogoutAgent(rootRegionCaps, !m_AllowDuplicateLogin);
                        }
                    }
                    else
                        m_CapsService.RemoveCAPS(account.PrincipalID);
                }

                //
                // Change Online status and get the home region
                //
                GridRegion home = null;
                if (guinfo != null && (guinfo.HomeRegionID != UUID.Zero) && m_GridService != null)
                {
                    home = m_GridService.GetRegionByUUID(scopeID, guinfo.HomeRegionID);
                }
                bool GridUserInfoFound = true;
                if (guinfo == null)
                {
                    GridUserInfoFound = false;
                    // something went wrong, make something up, so that we don't have to test this anywhere else
                    guinfo = new UserInfo();
                    guinfo.UserID = account.PrincipalID.ToString();
                    guinfo.CurrentPosition = guinfo.HomePosition = new Vector3(128, 128, 30);
                }

                //
                // Find the destination region/grid
                //
                string where = string.Empty;
                Vector3 position = Vector3.Zero;
                Vector3 lookAt = Vector3.Zero;
                TeleportFlags tpFlags = TeleportFlags.ViaLogin;
                GridRegion destination = FindDestination (account, scopeID, guinfo, session, startLocation, home, out tpFlags, out where, out position, out lookAt);
                if (destination == null)
                {
                    m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: destination not found");
                    return LLFailedLoginResponse.DeadRegionProblem;
                }
                if (!GridUserInfoFound || guinfo.HomeRegionID == UUID.Zero) //Give them a default home and last
                {
                    List<GridRegion> DefaultRegions = m_GridService.GetDefaultRegions(account.ScopeID);
                    GridRegion DefaultRegion = null;
                    if (DefaultRegions.Count == 0)
                        DefaultRegion = destination;
                    else
                        DefaultRegion = DefaultRegions[0];

                    if (m_DefaultHomeRegion != "" && guinfo.HomeRegionID == UUID.Zero)
                    {
                        GridRegion newHomeRegion = m_GridService.GetRegionByName(account.ScopeID, m_DefaultHomeRegion);
                        if (newHomeRegion == null)
                            guinfo.HomeRegionID = guinfo.CurrentRegionID = DefaultRegion.RegionID;
                        else
                            guinfo.HomeRegionID = guinfo.CurrentRegionID = newHomeRegion.RegionID;
                    }
                    else if (guinfo.HomeRegionID == UUID.Zero)
                        guinfo.HomeRegionID = guinfo.CurrentRegionID = DefaultRegion.RegionID;

                    //Z = 0 so that it fixes it on the region server and puts it on the ground
                    guinfo.CurrentPosition = guinfo.HomePosition = new Vector3(128, 128, 25);

                    guinfo.HomeLookAt = guinfo.CurrentLookAt = new Vector3(0, 0, 0);

                    m_agentInfoService.SetLastPosition(guinfo.UserID, guinfo.CurrentRegionID, guinfo.CurrentPosition, guinfo.CurrentLookAt);
                    m_agentInfoService.SetHomePosition(guinfo.UserID, guinfo.HomeRegionID, guinfo.HomePosition, guinfo.HomeLookAt);
                }

                //
                // Get the avatar
                //
                AvatarAppearance avappearance = new AvatarAppearance(account.PrincipalID);
                if (m_AvatarService != null)
                {
                    avappearance = m_AvatarService.GetAppearance(account.PrincipalID);
                    if (avappearance == null)
                    {
                        //Create an appearance for the user if one doesn't exist
                        if (m_DefaultUserAvatarArchive != "")
                        {
                            m_log.Error("[LLoginService]: Cannot find an appearance for user " + account.Name +
                                ", loading the default avatar from " + m_DefaultUserAvatarArchive + ".");
                            archiver.LoadAvatarArchive(m_DefaultUserAvatarArchive, account.Name);
                        }
                        else
                        {
                            m_log.Error("[LLoginService]: Cannot find an appearance for user " + account.Name + ", setting to the default avatar.");
                            AvatarAppearance appearance = new AvatarAppearance(account.PrincipalID);
                            m_AvatarService.SetAvatar(account.PrincipalID, new AvatarData(appearance));
                        }
                        avappearance = m_AvatarService.GetAppearance(account.PrincipalID);
                    }
                    else
                    {
                        //Verify that all assets exist now
                        for (int i = 0; i < avappearance.Wearables.Length; i++)
                        {
                            bool messedUp = false;
                            foreach (KeyValuePair<UUID, UUID> item in avappearance.Wearables[i].GetItems())
                            {
                                AssetBase asset = m_AssetService.Get(item.Value.ToString());
                                if (asset == null)
                                {
                                    InventoryItemBase invItem = m_InventoryService.GetItem (new InventoryItemBase (item.Value));
                                    if (invItem == null)
                                    {
                                        m_log.Warn ("Missing avatar appearance asset for user " + account.Name + " for item " + item.Value + ", asset should be " + item.Key + "!");
                                        messedUp = true;
                                    }
                                }
                            }
                            if (messedUp)
                                avappearance.Wearables[i] = AvatarWearable.DefaultWearables[i];
                        }
                        //Also verify that all baked texture indices exist
                        foreach (byte BakedTextureIndex in AvatarAppearance.BAKE_INDICES)
                        {
                            if (BakedTextureIndex == 19) //Skirt isn't used unless you have a skirt
                                continue;
                            if (avappearance.Texture.GetFace(BakedTextureIndex).TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE)
                            {
                                m_log.Warn("Bad texture index for user " + account.Name + " for " + BakedTextureIndex + "!");
                                avappearance = new AvatarAppearance(account.PrincipalID);
                                m_AvatarService.SetAvatar(account.PrincipalID, new AvatarData(avappearance));
                                break;
                            }
                        }
                    }
                }

                //
                // Instantiate/get the simulation interface and launch an agent at the destination
                //
                string reason = string.Empty;
                AgentCircuitData aCircuit = LaunchAgentAtGrid (destination, tpFlags, account, avappearance, session, secureSession, position, where,
                    clientIP, out where, out reason, out destination);

                if (aCircuit == null)
                {
                    m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: {0}", reason);
                    return new LLFailedLoginResponse (LoginResponseEnum.InternalError, reason, false);
                }

                // Get Friends list 
                FriendInfo[] friendsList = new FriendInfo[0];
                if (m_FriendsService != null)
                {
                    friendsList = m_FriendsService.GetFriends(account.PrincipalID);
                    //m_log.DebugFormat("[LLOGIN SERVICE]: Retrieved {0} friends", friendsList.Length);
                }

                //Set them as logged in now, they are ready, and fire the logged in event now, as we're all done
                m_agentInfoService.SetLastPosition (account.PrincipalID.ToString (), destination.RegionID, position, lookAt);
                m_agentInfoService.LockLoggedInStatus (account.PrincipalID.ToString (), false); //Unlock it now
                m_agentInfoService.SetLoggedIn(account.PrincipalID.ToString(), true, true, destination.RegionID);
                
                //
                // Finally, fill out the response and return it
                //
                string MaturityRating = "A";
                string MaxMaturity = "A";
                if (agent != null)
                {
                    if (agent.MaturityRating == 0)
                        MaturityRating = "P";
                    else if (agent.MaturityRating == 1)
                        MaturityRating = "M";
                    else if (agent.MaturityRating == 2)
                        MaturityRating = "A";

                    if (agent.MaxMaturity == 0)
                        MaxMaturity = "P";
                    else if (agent.MaxMaturity == 1)
                        MaxMaturity = "M";
                    else if (agent.MaxMaturity == 2)
                        MaxMaturity = "A";
                }

                LLLoginResponse response = new LLLoginResponse(account, aCircuit, guinfo, destination, inventorySkel, friendsList, m_InventoryService, m_LibraryService,
                    where, startLocation, position, lookAt, gestures, home, clientIP, MaxMaturity, MaturityRating,
                    eventCategories, classifiedCategories, FillOutSeedCap (aCircuit, destination, clientIP, account.PrincipalID), m_config, DisplayName, m_registry);

                m_log.InfoFormat("[LLOGIN SERVICE]: All clear. Sending login response to client to login to region " + destination.RegionName + ", tried to login to " + startLocation + " at " + position.ToString() + ".");
                return response;
            }
            catch (Exception e)
            {
                m_log.WarnFormat ("[LLOGIN SERVICE]: Exception processing login for {0} : {1}", Name, e.ToString ());
                if (account != null)
                {
                    //Revert their logged in status if we got that far
                    m_agentInfoService.LockLoggedInStatus (account.PrincipalID.ToString (), false); //Unlock it now
                    m_agentInfoService.SetLoggedIn (account.PrincipalID.ToString (), false, false, UUID.Zero);
                }
                return LLFailedLoginResponse.InternalError;
            }
            
        }
예제 #10
0
        protected GridRegion FindDestination (UserAccount account, UUID scopeID, UserInfo pinfo, UUID sessionID, string startLocation, GridRegion home, out TeleportFlags tpFlags, out string where, out Vector3 position, out Vector3 lookAt)
        {
            where = "home";
            position = new Vector3(128, 128, 25);
            lookAt = new Vector3(0, 1, 0);
            tpFlags = TeleportFlags.ViaLogin;

            if (m_GridService == null)
                return null;

            if (startLocation.Equals("home"))
            {
                tpFlags |= TeleportFlags.ViaLandmark;
                // logging into home region
                if (pinfo == null)
                    return null;

                GridRegion region = null;

                bool tryDefaults = false;

                if (home == null)
                {
                    m_log.WarnFormat(
                        "[LLOGIN SERVICE]: User {0} {1} tried to login to a 'home' start location but they have none set",
                        account.FirstName, account.LastName);

                    tryDefaults = true;
                }
                else
                {
                    region = home;

                    position = pinfo.HomePosition;
                    lookAt = pinfo.HomeLookAt;
                }

                if (tryDefaults)
                {
                    tpFlags &= ~TeleportFlags.ViaLandmark;
                    List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID);
                    if (defaults != null && defaults.Count > 0)
                    {
                        region = defaults[0];
                        where = "safe";
                    }
                    else
                    {
                        List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.ScopeID, 0, 0);
                        if (fallbacks != null && fallbacks.Count > 0)
                        {
                            region = fallbacks[0];
                            where = "safe";
                        }
                        else
                        {
                            //Try to find any safe region
                            List<GridRegion> safeRegions = m_GridService.GetSafeRegions(account.ScopeID, 0, 0);
                            if (safeRegions != null && safeRegions.Count > 0)
                            {
                                region = safeRegions[0];
                                where = "safe";
                            }
                            else
                            {
                                m_log.WarnFormat("[LLOGIN SERVICE]: User {0} {1} does not have a valid home and this grid does not have default locations. Attempting to find random region",
                                    account.FirstName, account.LastName);
                                defaults = m_GridService.GetRegionsByName(scopeID, "", 1);
                                if (defaults != null && defaults.Count > 0)
                                {
                                    region = defaults[0];
                                    where = "safe";
                                }
                            }
                        }
                    }
                }

                return region;
            }
            else if (startLocation.Equals ("last"))
            {
                tpFlags |= TeleportFlags.ViaLandmark;
                // logging into last visited region
                where = "last";

                if (pinfo == null)
                    return null;

                GridRegion region = null;

                if (pinfo.CurrentRegionID.Equals (UUID.Zero) || (region = m_GridService.GetRegionByUUID (scopeID, pinfo.CurrentRegionID)) == null)
                {
                    tpFlags &= ~TeleportFlags.ViaLandmark;
                    List<GridRegion> defaults = m_GridService.GetDefaultRegions (scopeID);
                    if (defaults != null && defaults.Count > 0)
                    {
                        region = defaults[0];
                        where = "safe";
                    }
                    else
                    {
                        defaults = m_GridService.GetFallbackRegions (scopeID, 0, 0);
                        if (defaults != null && defaults.Count > 0)
                        {
                            region = defaults[0];
                            where = "safe";
                        }
                        else
                        {
                            defaults = m_GridService.GetSafeRegions (scopeID, 0, 0);
                            if (defaults != null && defaults.Count > 0)
                            {
                                region = defaults[0];
                                where = "safe";
                            }
                        }
                    }

                }
                else
                {
                    position = pinfo.CurrentPosition;
                    if (position.X < 0)
                        position.X = 0;
                    if (position.Y < 0)
                        position.Y = 0;
                    if (position.Z < 0)
                        position.Z = 0;
                    if (position.X > region.RegionSizeX)
                        position.X = region.RegionSizeX;
                    if (position.Y > region.RegionSizeY)
                        position.Y = region.RegionSizeY;


                    lookAt = pinfo.CurrentLookAt;
                }

                return region;
            }
            else
            {
                // free uri form
                // e.g. New Moon&135&46  New [email protected]:8002&153&34
                where = "url";
                Regex reURI = new Regex (@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$");
                Match uriMatch = reURI.Match (startLocation);
                if (uriMatch == null)
                {
                    m_log.InfoFormat ("[LLLOGIN SERVICE]: Got Custom Login URI {0}, but can't process it", startLocation);
                    return null;
                }
                else
                {
                    position = new Vector3 (float.Parse (uriMatch.Groups["x"].Value, Culture.NumberFormatInfo),
                                           float.Parse (uriMatch.Groups["y"].Value, Culture.NumberFormatInfo),
                                           float.Parse (uriMatch.Groups["z"].Value, Culture.NumberFormatInfo));

                    string regionName = uriMatch.Groups["region"].ToString ();
                    if (regionName != null)
                    {
                        if (!regionName.Contains ("@"))
                        {
                            List<GridRegion> regions = m_GridService.GetRegionsByName (scopeID, regionName, 1);
                            if ((regions == null) || (regions != null && regions.Count == 0))
                            {
                                m_log.InfoFormat ("[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}. Trying defaults.", startLocation, regionName);
                                regions = m_GridService.GetDefaultRegions (scopeID);
                                if (regions != null && regions.Count > 0)
                                {
                                    where = "safe";
                                    return regions[0];
                                }
                                else
                                {
                                    List<GridRegion> fallbacks = m_GridService.GetFallbackRegions (account.ScopeID, 0, 0);
                                    if (fallbacks != null && fallbacks.Count > 0)
                                    {
                                        where = "safe";
                                        return fallbacks[0];
                                    }
                                    else
                                    {
                                        //Try to find any safe region
                                        List<GridRegion> safeRegions = m_GridService.GetSafeRegions (account.ScopeID, 0, 0);
                                        if (safeRegions != null && safeRegions.Count > 0)
                                        {
                                            where = "safe";
                                            return safeRegions[0];
                                        }
                                        else
                                        {
                                            m_log.InfoFormat ("[LLLOGIN SERVICE]: Got Custom Login URI {0}, Grid does not have any available regions.", startLocation);
                                            return null;
                                        }
                                    }
                                }
                            }
                            return regions[0];
                        }
                        else
                        {
                            //This is so that you can login to other grids via IWC (or HG), example"[email protected]:8002". All this really needs to do is inform the other grid that we have a user who wants to connect. IWC allows users to login by default to other regions (without the host names), but if one is provided and we don't have a link, we need to create one here.
                            string[] parts = regionName.Split (new char[] { '@' });
                            if (parts.Length < 2)
                            {
                                m_log.InfoFormat ("[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}", startLocation, regionName);
                                return null;
                            }
                            // Valid specification of a remote grid

                            regionName = parts[0];
                            string domainLocator = parts[1];

                            //Try now that we removed the domain locator
                            GridRegion region = m_GridService.GetRegionByName (scopeID, regionName);
                            if (region != null && region.RegionName == regionName)//Make sure the region name is right too... it could just be a similar name
                                return region;
                            ICommunicationService service = m_registry.RequestModuleInterface<ICommunicationService> ();
                            if (service != null)
                            {
                                region = service.GetRegionForGrid (regionName, domainLocator);

                                if (region != null)
                                    return region;
                            }
                        }
                    }
                    List<GridRegion> defaults = m_GridService.GetDefaultRegions (scopeID);
                    if (defaults != null && defaults.Count > 0)
                    {
                        where = "safe";
                        return defaults[0];
                    }
                    else
                    {
                        List<GridRegion> fallbacks = m_GridService.GetFallbackRegions (account.ScopeID, 0, 0);
                        if (fallbacks != null && fallbacks.Count > 0)
                        {
                            where = "safe";
                            return fallbacks[0];
                        }
                        else
                        {
                            //Try to find any safe region
                            List<GridRegion> safeRegions = m_GridService.GetSafeRegions (account.ScopeID, 0, 0);
                            if (safeRegions != null && safeRegions.Count > 0)
                            {
                                where = "safe";
                                return safeRegions[0];
                            }
                            else
                            {
                                m_log.InfoFormat ("[LLLOGIN SERVICE]: Got Custom Login URI {0}, Grid does not have any available regions.", startLocation);
                                return null;
                            }
                        }
                    }
                }
            }
        }
예제 #11
0
 public override IDataTransferable Duplicate()
 {
     UserInfo m = new UserInfo();
     m.FromOSD(ToOSD());
     return m;
 }
예제 #12
0
 public virtual void Save(UserInfo userInfo)
 {
     m_agentInfoConnector.Set(userInfo);
 }
예제 #13
0
 public UserInfo[] GetUserInfos(string[] userIDs)
 {
     List<string> urls =
         m_registry.RequestModuleInterface<IConfigurationService>().FindValueOf("AgentInfoServerURI");
     List<UserInfo> retVal = new List<UserInfo>();
     foreach (string url in urls)
     {
         OSDMap request = new OSDMap();
         OSDArray requestArray = new OSDArray();
         foreach (string t in userIDs)
         {
             requestArray.Add(t);
         }
         request["userIDs"] = requestArray;
         request["Method"] = "GetUserInfos";
         OSDMap result = WebUtils.PostToService(url, request, true, false);
         OSD r = OSDParser.DeserializeJson(result["_RawResult"]);
         if (r is OSDMap)
         {
             OSDMap innerresult = (OSDMap) r;
             OSDArray resultArray = (OSDArray) innerresult["Result"];
             foreach (OSD o in resultArray)
             {
                 UserInfo info = new UserInfo();
                 info.FromOSD((OSDMap) o);
                 retVal.Add(info);
             }
         }
     }
     return retVal.ToArray();
 }
예제 #14
0
        public LLLoginResponse()
        {
            loginFlags = new ArrayList();
            globalTextures = new ArrayList();
            eventCategories = new ArrayList();
            uiConfig = new ArrayList();
            classifiedCategories = new ArrayList();

            uiConfigHash = new Hashtable();

            // defaultXmlRpcResponse = new XmlRpcResponse();
            userProfile = new UserInfo();
            inventoryRoot = new ArrayList();
            initialOutfit = new ArrayList();
            agentInventory = new ArrayList();
            inventoryLibrary = new ArrayList();
            inventoryLibraryOwner = new ArrayList();
            activeGestures = new ArrayList();

            SetDefaultValues();
        }
예제 #15
0
        private void DoNonLocalPresenceUpdateCall(UserInfo u, IScenePresence presence)
        {
            Dictionary<string, object> sendData = new Dictionary<string, object>();
            //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            //sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"] = "status";

            sendData["FromID"] = presence.UUID.ToString();
            sendData["ToID"] = u.UserID;
            sendData["Online"] = u.IsOnline.ToString();
            
            Call(m_scene.GridService.GetRegionByUUID(UUID.Zero, u.CurrentRegionID), sendData);
        }
예제 #16
0
 public UserInfo[] Get(string userID)
 {
     List<string> query = GD.Query("UserID", userID, m_realm, "*");
     UserInfo[] users = new UserInfo[query.Count / 8];
     for (int i = 0; i < query.Count; i += 8)
     {
         //Build each user now
         users[i / 8] = new UserInfo();
         users[i / 8].UserID = query[i];
         users[i / 8].CurrentRegionID = UUID.Parse(query[i+1]);
         users[i / 8].SessionID = UUID.Parse(query[i+2]);
         //Check LastSeen
         if (m_checkLastSeen && (new DateTime(long.Parse(query[i + 3])).AddHours(1) < DateTime.Now))
         {
             m_log.Warn("[UserInfoService]: Found a user (" + users[i / 8].UserID + ") that was not seen within the last hour! Logging them out.");
             return null;
         }
         users[i / 8].IsOnline = query[i+4] == "1" ? true : false;
         users[i / 8].LastLogin = new DateTime(long.Parse(query[i+5]));
         users[i / 8].LastLogout = new DateTime(long.Parse(query[i+6]));
         users[i / 8].Info = (OSDMap)OSDParser.DeserializeJson(query[i+7]);
     }
     return users;
 }
예제 #17
0
 private bool IsLocal(UserInfo u, IScenePresence presence)
 {
     return presence.Scene.RequestModuleInterface<ISceneManager>().GetAllScenes().Any(scene => scene.GetScenePresence(UUID.Parse(u.UserID)) != null);
 }
예제 #18
0
        protected UserInfo Get(Dictionary<string, object> sendData)
        {
            string reqString = WebUtils.BuildQueryString(sendData);
            // m_log.DebugFormat("[GRID USER CONNECTOR]: queryString = {0}", reqString);
            try
            {
                List<string> urls = m_registry.RequestModuleInterface<IConfigurationService>().FindValueOf("GridUserServerURI");
                foreach (string url in urls)
                {
                    string reply = SynchronousRestFormsRequester.MakeRequest("POST",
                               url,
                               reqString);
                    if (reply != string.Empty)
                    {
                        Dictionary<string, object> replyData = WebUtils.ParseXmlResponse(reply);
                        UserInfo guinfo = null;

                        if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null))
                        {
                            if (replyData["result"] is Dictionary<string, object>)
                            {
                                guinfo = new UserInfo();
                                Dictionary<string, object> kvp = (Dictionary<string, object>)replyData["result"];
                                guinfo.UserID = kvp["UserID"].ToString();
                                guinfo.HomeRegionID = UUID.Parse(kvp["HomeRegionID"].ToString());
                                guinfo.CurrentRegionID = UUID.Parse(kvp["LastRegionID"].ToString());
                                guinfo.CurrentPosition = Vector3.Parse(kvp["LastPosition"].ToString());
                                guinfo.HomePosition = Vector3.Parse(kvp["HomePosition"].ToString());
                                guinfo.IsOnline = bool.Parse(kvp["Online"].ToString());
                                guinfo.LastLogin = DateTime.Parse(kvp["Login"].ToString());
                                guinfo.LastLogout = DateTime.Parse(kvp["Logout"].ToString());
                            }
                        }

                        return guinfo;
                    }
                }
            }
            catch (Exception)
            { }

            return null;
        }
예제 #19
0
        public UserInfo Get(string userID)
        {
            List<string> query = GD.Query("UserID", userID, m_realm, "*");
            if (query.Count == 0)
                return null;
            UserInfo user = new UserInfo();
            user.UserID = query[0];
            user.CurrentRegionID = UUID.Parse(query[1]);
            user.IsOnline = query[3] == "1" ? true : false;
            user.LastLogin = Util.ToDateTime(int.Parse(query[4]));
            user.LastLogout = Util.ToDateTime(int.Parse(query[5]));
            user.Info = (OSDMap)OSDParser.DeserializeJson(query[6]);
            try
            {
                user.CurrentRegionID = UUID.Parse(query[7]);
                if(query[8] != "")
                    user.CurrentPosition = Vector3.Parse(query[8]);
                if (query[9] != "")
                    user.CurrentLookAt = Vector3.Parse(query[9]);
                user.HomeRegionID = UUID.Parse(query[10]);
                if (query[11] != "")
                    user.HomePosition = Vector3.Parse(query[11]);
                if (query[12] != "")
                    user.HomeLookAt = Vector3.Parse(query[12]);
            }
            catch
            {
            }

            //Check LastSeen
            if (m_checkLastSeen && user.IsOnline && (Util.ToDateTime(int.Parse(query[2])).AddHours(1) < DateTime.Now))
            {
                m_log.Warn("[UserInfoService]: Found a user (" + user.UserID + ") that was not seen within the last hour! Logging them out.");
                user.IsOnline = false;
                Set(user);
            }
            return user;
        }
예제 #20
0
        public LoginResponse Login(UUID AgentID, string Name, string authType, string passwd, string startLocation, UUID scopeID,
            string clientVersion, string channel, string mac, string id0, IPEndPoint clientIP, Hashtable requestData)
        {
            LoginResponse response;
            UUID session = UUID.Random();
            UUID secureSession = UUID.Zero;

            UserAccount account = AgentID != UUID.Zero ? m_UserAccountService.GetUserAccount(scopeID, AgentID) : m_UserAccountService.GetUserAccount(scopeID, Name);
            if (account == null && m_AllowAnonymousLogin)
            {
                m_UserAccountService.CreateUser(Name, passwd.StartsWith("$1$") ? passwd.Remove(0, 3):passwd, "");
                account = m_UserAccountService.GetUserAccount(scopeID, Name);
            }
            if (account == null)
            {
                MainConsole.Instance.InfoFormat("[LLOGIN SERVICE]: Login failed for user {0}: no account found", Name);
                return LLFailedLoginResponse.AccountProblem;
            }

            if (account.UserLevel < 0)//No allowing anyone less than 0
                return LLFailedLoginResponse.PermanentBannedProblem;

            if (account.UserLevel < m_MinLoginLevel)
            {
                MainConsole.Instance.InfoFormat("[LLOGIN SERVICE]: Login failed for user {1}, reason: login is blocked for user level {0}", account.UserLevel, account.Name);
                return LLFailedLoginResponse.LoginBlockedProblem;
            }

            IAgentInfo agent = null;
            IAgentConnector agentData = DataManager.RequestPlugin<IAgentConnector>();
            if (agentData != null)
                agent = agentData.GetAgent(account.PrincipalID);
            if (agent == null)
            {
                agentData.CreateNewAgent(account.PrincipalID);
                agent = agentData.GetAgent(account.PrincipalID);
            }

            requestData["ip"] = clientIP.ToString();
            foreach (ILoginModule module in LoginModules)
            {
                object data;
                if ((response = module.Login(requestData, account, agent, authType, passwd, out data)) != null)
                    return response;
                if (data != null)
                    secureSession = (UUID)data;//TODO: NEED TO FIND BETTER WAY TO GET THIS DATA
            }

            MainConsole.Instance.InfoFormat("[LLOGIN SERVICE]: Login request for {0} from {1} with user agent {2} starting in {3}",
                Name, clientIP.Address, clientVersion, startLocation);
            try
            {
                string DisplayName = account.Name;
                AvatarAppearance avappearance = null;
                bool newAvatar = false;
                IProfileConnector profileData = DataManager.RequestPlugin<IProfileConnector>();

                //
                // Get the user's inventory
                //
                if (m_RequireInventory && m_InventoryService == null)
                {
                    MainConsole.Instance.WarnFormat("[LLOGIN SERVICE]: Login failed for user {0}, reason: inventory service not set up", account.Name);
                    return LLFailedLoginResponse.InventoryProblem;
                }
                List<InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID);
                if (m_RequireInventory && ((inventorySkel == null) || (inventorySkel.Count == 0)))
                {
                    List<InventoryItemBase> defaultItems;
                    m_InventoryService.CreateUserInventory(account.PrincipalID, m_DefaultUserAvatarArchive == "", out defaultItems);
                    inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID);
                    if (m_RequireInventory && ((inventorySkel == null) || (inventorySkel.Count == 0)))
                    {
                        MainConsole.Instance.InfoFormat("[LLOGIN SERVICE]: Login failed for user {0}, reason: unable to retrieve user inventory", account.Name);
                        return LLFailedLoginResponse.InventoryProblem;
                    }
                    if (defaultItems.Count > 0)
                    {
                        avappearance = new AvatarAppearance(account.PrincipalID);
                        avappearance.SetWearable((int)WearableType.Shape, new AvatarWearable(defaultItems[0].ID, defaultItems[0].AssetID));
                        avappearance.SetWearable((int)WearableType.Skin, new AvatarWearable(defaultItems[1].ID, defaultItems[1].AssetID));
                        avappearance.SetWearable((int)WearableType.Hair, new AvatarWearable(defaultItems[2].ID, defaultItems[2].AssetID));
                        avappearance.SetWearable((int)WearableType.Eyes, new AvatarWearable(defaultItems[3].ID, defaultItems[3].AssetID));
                        avappearance.SetWearable((int)WearableType.Shirt, new AvatarWearable(defaultItems[4].ID, defaultItems[4].AssetID));
                        avappearance.SetWearable((int)WearableType.Pants, new AvatarWearable(defaultItems[5].ID, defaultItems[5].AssetID));
                        m_AvatarService.SetAvatar(account.PrincipalID, new AvatarData(avappearance));
                        newAvatar = true;
                    }
                }

                if (profileData != null)
                {
                    IUserProfileInfo UPI = profileData.GetUserProfile(account.PrincipalID);
                    if (UPI == null)
                    {
                        profileData.CreateNewProfile(account.PrincipalID);
                        UPI = profileData.GetUserProfile(account.PrincipalID);
                        UPI.AArchiveName = m_DefaultUserAvatarArchive;
                        UPI.IsNewUser = true;
                        //profileData.UpdateUserProfile(UPI); //It gets hit later by the next thing
                    }
                    //Find which is set, if any
                    string archiveName = (UPI.AArchiveName != "" && UPI.AArchiveName != " ") ? UPI.AArchiveName : m_DefaultUserAvatarArchive;
                    if (UPI.IsNewUser && archiveName != "")
                    {
                        AvatarAppearance appearance = m_ArchiveService.LoadAvatarArchive(archiveName, account.Name);
                        UPI.AArchiveName = "";
                        AvatarData adata = new AvatarData(appearance);
                        m_AvatarService.SetAppearance(account.PrincipalID, appearance);
                    }
                    if (UPI.IsNewUser)
                    {
                        UPI.IsNewUser = false;
                        profileData.UpdateUserProfile(UPI);
                    }
                    if (UPI.DisplayName != "")
                        DisplayName = UPI.DisplayName;
                }

                // Get active gestures
                List<InventoryItemBase> gestures = m_InventoryService.GetActiveGestures(account.PrincipalID);
                //MainConsole.Instance.DebugFormat("[LLOGIN SERVICE]: {0} active gestures", gestures.Count);

                //Reset logged in to true if the user was crashed, but don't fire the logged in event yet
                m_agentInfoService.SetLoggedIn(account.PrincipalID.ToString(), true, false, UUID.Zero);
                //Lock it as well
                m_agentInfoService.LockLoggedInStatus(account.PrincipalID.ToString(), true);
                //Now get the logged in status, then below make sure to kill the previous agent if we crashed before
                UserInfo guinfo = m_agentInfoService.GetUserInfo(account.PrincipalID.ToString());
                //
                // Clear out any existing CAPS the user may have
                //
                if (m_CapsService != null)
                {
                    IAgentProcessing agentProcessor = m_registry.RequestModuleInterface<IAgentProcessing>();
                    if (agentProcessor != null)
                    {
                        IClientCapsService clientCaps = m_CapsService.GetClientCapsService(account.PrincipalID);
                        if (clientCaps != null)
                        {
                            IRegionClientCapsService rootRegionCaps = clientCaps.GetRootCapsService();
                            if (rootRegionCaps != null)
                                agentProcessor.LogoutAgent(rootRegionCaps, !m_AllowDuplicateLogin);
                        }
                    }
                    else
                        m_CapsService.RemoveCAPS(account.PrincipalID);
                }

                //
                // Change Online status and get the home region
                //
                GridRegion home = null;
                if (guinfo != null && (guinfo.HomeRegionID != UUID.Zero) && m_GridService != null)
                    home = m_GridService.GetRegionByUUID(scopeID, guinfo.HomeRegionID);

                if (guinfo == null || guinfo.HomeRegionID == UUID.Zero) //Give them a default home and last
                {
                    if(guinfo == null)
                        guinfo = new UserInfo { UserID = account.PrincipalID.ToString() };
                    GridRegion DefaultRegion = null;
                    if (m_GridService != null)
                    {
                        if (m_DefaultHomeRegion != "")
                        {
                            DefaultRegion = m_GridService.GetRegionByName(account.ScopeID, m_DefaultHomeRegion);
                            if (DefaultRegion != null)
                                guinfo.HomeRegionID = guinfo.CurrentRegionID = DefaultRegion.RegionID;
                        }
                        if (guinfo.HomeRegionID == UUID.Zero)
                        {
                            List<GridRegion> DefaultRegions = m_GridService.GetDefaultRegions(account.ScopeID);
                            DefaultRegion = DefaultRegions.Count == 0 ? null : DefaultRegions[0];

                            if (DefaultRegion != null)
                                guinfo.HomeRegionID = guinfo.CurrentRegionID = DefaultRegion.RegionID;
                        }
                    }

                    guinfo.CurrentPosition = guinfo.HomePosition = new Vector3(128, 128, 25);
                    guinfo.HomeLookAt = guinfo.CurrentLookAt = new Vector3(0, 0, 0);

                    m_agentInfoService.SetLastPosition(guinfo.UserID, guinfo.CurrentRegionID, guinfo.CurrentPosition, guinfo.CurrentLookAt);
                    m_agentInfoService.SetHomePosition(guinfo.UserID, guinfo.HomeRegionID, guinfo.HomePosition, guinfo.HomeLookAt);

                    MainConsole.Instance.Info("[LLLoginService]: User did not have a home, set to " +
                        (DefaultRegion == null ? "(no region found)" : DefaultRegion.RegionName));
                }

                //
                // Find the destination region/grid
                //
                string where = string.Empty;
                Vector3 position = Vector3.Zero;
                Vector3 lookAt = Vector3.Zero;
                TeleportFlags tpFlags = TeleportFlags.ViaLogin;
                GridRegion destination = FindDestination(account, scopeID, guinfo, session, startLocation, home, out tpFlags, out where, out position, out lookAt);
                if (destination == null)
                {
                    MainConsole.Instance.InfoFormat("[LLOGIN SERVICE]: Login failed for user {0}, reason: destination not found", account.Name);
                    return LLFailedLoginResponse.DeadRegionProblem;
                }

                //
                // Get the avatar
                //
                if (m_AvatarService != null)
                {
                    if(avappearance == null)
                        avappearance = m_AvatarService.GetAppearance(account.PrincipalID);
                    if (avappearance == null)
                    {
                        //Create an appearance for the user if one doesn't exist
                        if (m_DefaultUserAvatarArchive != "")
                        {
                            MainConsole.Instance.Error("[LLoginService]: Cannot find an appearance for user " + account.Name +
                                ", loading the default avatar from " + m_DefaultUserAvatarArchive + ".");
                            avappearance = m_ArchiveService.LoadAvatarArchive(m_DefaultUserAvatarArchive, account.Name);
                            m_AvatarService.SetAvatar(account.PrincipalID, new AvatarData(avappearance));
                        }
                        else
                        {
                            MainConsole.Instance.Error("[LLoginService]: Cannot find an appearance for user " + account.Name + ", setting to the default avatar.");
                            avappearance = new AvatarAppearance(account.PrincipalID);
                            m_AvatarService.SetAvatar(account.PrincipalID, new AvatarData(avappearance));
                        }
                    }
                    else
                    {
                        //Verify that all assets exist now
                        for (int i = 0; i < avappearance.Wearables.Length; i++)
                        {
                            bool messedUp = false;
                            foreach (KeyValuePair<UUID, UUID> item in avappearance.Wearables[i].GetItems())
                            {
                                AssetBase asset = m_AssetService.Get(item.Value.ToString());
                                if (asset == null)
                                {
                                    InventoryItemBase invItem = m_InventoryService.GetItem(new InventoryItemBase(item.Value));
                                    if (invItem == null)
                                    {
                                        MainConsole.Instance.Warn("[LLOGIN SERVICE]: Missing avatar appearance asset for user " + account.Name + " for item " + item.Value + ", asset should be " + item.Key + "!");
                                        messedUp = true;
                                    }
                                }
                            }
                            if (messedUp)
                                avappearance.Wearables[i] = AvatarWearable.DefaultWearables[i];
                        }
                        if (!newAvatar)
                        {
                            //Also verify that all baked texture indices exist
                            foreach (byte BakedTextureIndex in AvatarAppearance.BAKE_INDICES)
                            {
                                if (BakedTextureIndex == 19) //Skirt isn't used unless you have a skirt
                                    continue;
                                if (avappearance.Texture.GetFace(BakedTextureIndex).TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE)
                                {
                                    MainConsole.Instance.Warn("[LLOGIN SERVICE]: Bad texture index for user " + account.Name + " for " + BakedTextureIndex + "!");
                                    avappearance = new AvatarAppearance(account.PrincipalID);
                                    m_AvatarService.SetAvatar(account.PrincipalID, new AvatarData(avappearance));
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                    avappearance = new AvatarAppearance(account.PrincipalID);

                if ((m_forceUserToWearFolderName != "") && (m_forceUserToWearFolderOwnerUUID.Length == 36))
                {
                    UUID userThatOwnersFolder;
                    if (UUID.TryParse(m_forceUserToWearFolderOwnerUUID, out userThatOwnersFolder))
                    {
                        avappearance = WearFolder(avappearance, account.PrincipalID, userThatOwnersFolder);
                    }
                }

                avappearance = FixCurrentOutFitFolder(account.PrincipalID, avappearance);
                
                //
                // Instantiate/get the simulation interface and launch an agent at the destination
                //
                string reason = string.Empty;
                AgentCircuitData aCircuit = LaunchAgentAtGrid(destination, tpFlags, account, avappearance, session, secureSession, position, where,
                    clientIP, out where, out reason, out destination);

                if (aCircuit == null)
                {
                    MainConsole.Instance.InfoFormat("[LLOGIN SERVICE]: Login failed for user {1}, reason: {0}", reason, account.Name);
                    return new LLFailedLoginResponse(LoginResponseEnum.InternalError, reason, false);
                }

                // Get Friends list 
                List<FriendInfo> friendsList = new List<FriendInfo>();
                if (m_FriendsService != null)
                    friendsList = m_FriendsService.GetFriends(account.PrincipalID);

                //Set them as logged in now, they are ready, and fire the logged in event now, as we're all done
                m_agentInfoService.SetLastPosition(account.PrincipalID.ToString(), destination.RegionID, position, lookAt);
                m_agentInfoService.LockLoggedInStatus(account.PrincipalID.ToString(), false); //Unlock it now
                m_agentInfoService.SetLoggedIn(account.PrincipalID.ToString(), true, true, destination.RegionID);

                //
                // Finally, fill out the response and return it
                //
                string MaturityRating = "A";
                string MaxMaturity = "A";
                if (agent != null)
                {
                    MaturityRating = agent.MaturityRating == 0 ? "P" :
                        agent.MaturityRating == 1 ? "M" : "A";
                    MaxMaturity = agent.MaxMaturity == 0 ? "P" :
                        agent.MaxMaturity == 1 ? "M" : "A";
                }

                response = new LLLoginResponse(account, aCircuit, guinfo, destination, inventorySkel, friendsList.ToArray(), m_InventoryService, m_LibraryService,
                    where, startLocation, position, lookAt, gestures, home, clientIP, MaxMaturity, MaturityRating,
                    eventCategories, classifiedCategories, FillOutSeedCap(aCircuit, destination, clientIP, account.PrincipalID), m_config, DisplayName, m_registry);

                MainConsole.Instance.InfoFormat("[LLOGIN SERVICE]: All clear. Sending login response to client to login to region " + destination.RegionName + ", tried to login to " + startLocation + " at " + position.ToString() + ".");
                AddLoginSuccessNotification(account);
                return response;
            }
            catch (Exception e)
            {
                MainConsole.Instance.WarnFormat("[LLOGIN SERVICE]: Exception processing login for {0} : {1}", Name, e);
                if (account != null)
                {
                    //Revert their logged in status if we got that far
                    m_agentInfoService.LockLoggedInStatus(account.PrincipalID.ToString(), false); //Unlock it now
                    m_agentInfoService.SetLoggedIn(account.PrincipalID.ToString(), false, false, UUID.Zero);
                }
                return LLFailedLoginResponse.InternalError;
            }
        }
예제 #21
0
        public void SetLoggedIn(string userID, bool loggingIn, bool fireLoggedInEvent)
        {
            if (m_lockedUsers.Contains (userID))
                return; //User is locked, leave them alone
            UserInfo userInfo = GetUserInfo(userID);
            if (userInfo == null)
            {
                userInfo = new UserInfo();
                userInfo.UserID = userID;
            }
            userInfo.IsOnline = loggingIn;
            if (loggingIn)
                userInfo.LastLogin = DateTime.Now;
            else
                userInfo.LastLogout = DateTime.Now;
            Save(userInfo);

            if (fireLoggedInEvent)
            {
                //Trigger an event so listeners know
                m_registry.RequestModuleInterface<ISimulationBase>().EventManager.FireGenericEventHandler("UserStatusChange", userInfo);
            }
        }
        public UserInfo Get (string userID, bool checkOnlineStatus, out bool onlineStatusChanged)
        {
            onlineStatusChanged = false;
            List<string> query = GD.Query("UserID", userID, m_realm, "*");
            if (query.Count == 0)
                return null;
            UserInfo user = new UserInfo();
            user.UserID = query[0];
            user.CurrentRegionID = UUID.Parse(query[1]);
            user.IsOnline = query[3] == "1" ? true : false;
            user.LastLogin = Util.ToDateTime(int.Parse(query[4]));
            user.LastLogout = Util.ToDateTime(int.Parse(query[5]));
            user.Info = (OSDMap)OSDParser.DeserializeJson(query[6]);
            try
            {
                user.CurrentRegionID = UUID.Parse(query[7]);
                if(query[8] != "")
                    user.CurrentPosition = Vector3.Parse(query[8]);
                if (query[9] != "")
                    user.CurrentLookAt = Vector3.Parse(query[9]);
                user.HomeRegionID = UUID.Parse(query[10]);
                if (query[11] != "")
                    user.HomePosition = Vector3.Parse(query[11]);
                if (query[12] != "")
                    user.HomeLookAt = Vector3.Parse(query[12]);
            }
            catch
            {
            }

            //Check LastSeen
            DateTime timeLastSeen = Util.ToDateTime (int.Parse (query[2]));
            DateTime timeNow = DateTime.Now.ToUniversalTime ();
            if (checkOnlineStatus && m_checkLastSeen && user.IsOnline && (timeLastSeen.AddHours (1) < timeNow))
            {
                if (user.CurrentRegionID != AgentInfoHelpers.LOGIN_STATUS_LOCKED)//The login status can be locked with this so that it cannot be changed with this method
                {
                    m_log.Warn ("[UserInfoService]: Found a user (" + user.UserID + ") that was not seen within the last hour " +
                        "(since " + timeLastSeen.ToLocalTime ().ToString () + ", time elapsed " + (timeNow - timeLastSeen).Days + " days, " + (timeNow - timeLastSeen).Hours + " hours)! Logging them out.");
                    user.IsOnline = false;
                    Set (user);
                    onlineStatusChanged = true;
                }
            }
            return user;
        }
        private static List<UserInfo> ParseQuery(List<string> query)
        {
            List<UserInfo> users = new List<UserInfo>();

            if (query.Count % 13 == 0)
            {
                for (int i = 0; i < query.Count; i += 13)
                {

                    UserInfo user = new UserInfo
                    {
                        UserID = query[i],
                        CurrentRegionID = UUID.Parse(query[i + 1]),
                        IsOnline = query[i + 3] == "1",
                        LastLogin = Util.ToDateTime(int.Parse(query[i + 4])),
                        LastLogout = Util.ToDateTime(int.Parse(query[i + 5])),
                        Info = (OSDMap)OSDParser.DeserializeJson(query[i + 6])
                    };
                    try
                    {
                        user.CurrentRegionID = UUID.Parse(query[i + 7]);
                        if (query[i + 8] != "")
                            user.CurrentPosition = Vector3.Parse(query[i + 8]);
                        if (query[i + 9] != "")
                            user.CurrentLookAt = Vector3.Parse(query[i + 9]);
                        user.HomeRegionID = UUID.Parse(query[i + 10]);
                        if (query[i + 11] != "")
                            user.HomePosition = Vector3.Parse(query[i + 11]);
                        if (query[i + 12] != "")
                            user.HomeLookAt = Vector3.Parse(query[i + 12]);
                    }
                    catch
                    {
                    }

                    users.Add(user);
                }
            }

            return users;
        }
예제 #24
0
        private bool IsLocal(UserInfo u, IScenePresence presence)
        {
#if (!ISWIN)
            foreach (IScene scene in presence.Scene.RequestModuleInterface<SceneManager>().Scenes)
            {
                if (scene.GetScenePresence(UUID.Parse(u.UserID)) != null) return true;
            }
            return false;
#else
            return presence.Scene.RequestModuleInterface<SceneManager>().Scenes.Any(scene => scene.GetScenePresence(UUID.Parse(u.UserID)) != null);
#endif
        }
예제 #25
0
        private bool OnAllowedIncomingAgent(IScene scene, AgentCircuitData agent, bool isRootAgent, out string reason)
        {
            #region Incoming Agent Checks

            UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, agent.AgentID);

            IScenePresence Sp = scene.GetScenePresence(agent.AgentID);
            if (account == null)
            {
                reason = "Failed authentication.";
                return(false); //NO!
            }

            if (LoginsDisabled)
            {
                reason = "Logins Disabled";
                return(false);
            }

            //Check how long its been since the last TP
            if (m_enabledBlockTeleportSeconds && Sp != null && !Sp.IsChildAgent)
            {
                if (TimeSinceLastTeleport.ContainsKey(Sp.Scene.RegionInfo.RegionID))
                {
                    if (TimeSinceLastTeleport[Sp.Scene.RegionInfo.RegionID] > Util.UnixTimeSinceEpoch())
                    {
                        reason = "Too many teleports. Please try again soon.";
                        return(false); // Too soon since the last TP
                    }
                }
                TimeSinceLastTeleport[Sp.Scene.RegionInfo.RegionID] = Util.UnixTimeSinceEpoch() + ((int)(SecondsBeforeNextTeleport));
            }

            //Gods tp freely
            if ((Sp != null && Sp.GodLevel != 0) || account.UserLevel != 0)
            {
                reason = "";
                return(true);
            }

            //Check whether they fit any ban criteria
            if (Sp != null)
            {
                foreach (string banstr in BanCriteria)
                {
                    if (Sp.Name.Contains(banstr))
                    {
                        reason = "You have been banned from this region.";
                        return(false);
                    }
                    else if (((System.Net.IPEndPoint)Sp.ControllingClient.GetClientEP()).Address.ToString().Contains(banstr))
                    {
                        reason = "You have been banned from this region.";
                        return(false);
                    }
                }
                //Make sure they exist in the grid right now
                OpenSim.Services.Interfaces.IAgentInfoService presence = scene.RequestModuleInterface <IAgentInfoService>();
                if (presence == null)
                {
                    reason = String.Format("Failed to verify user presence in the grid for {0} in region {1}. Presence service does not exist.", account.Name, scene.RegionInfo.RegionName);
                    return(false);
                }

                OpenSim.Services.Interfaces.UserInfo pinfo = presence.GetUserInfo(agent.AgentID.ToString());

                if (pinfo == null || (!pinfo.IsOnline && ((agent.teleportFlags & (uint)TeleportFlags.ViaLogin) == 0)))
                {
                    reason = String.Format("Failed to verify user presence in the grid for {0}, access denied to region {1}.", account.Name, scene.RegionInfo.RegionName);
                    return(false);
                }
            }

            EstateSettings ES = scene.RegionInfo.EstateSettings;

            IEntityCountModule entityCountModule = scene.RequestModuleInterface <IEntityCountModule>();
            if (entityCountModule != null && scene.RegionInfo.RegionSettings.AgentLimit
                < entityCountModule.RootAgents + 1)
            {
                reason = "Too many agents at this time. Please come back later.";
                return(false);
            }

            List <EstateBan> EstateBans = new List <EstateBan>(ES.EstateBans);
            int i = 0;
            //Check bans
            foreach (EstateBan ban in EstateBans)
            {
                if (ban.BannedUserID == agent.AgentID)
                {
                    if (Sp != null)
                    {
                        string banIP = ((System.Net.IPEndPoint)Sp.ControllingClient.GetClientEP()).Address.ToString();

                        if (ban.BannedHostIPMask != banIP) //If it changed, ban them again
                        {
                            //Add the ban with the new hostname
                            ES.AddBan(new EstateBan()
                            {
                                BannedHostIPMask   = banIP,
                                BannedUserID       = ban.BannedUserID,
                                EstateID           = ban.EstateID,
                                BannedHostAddress  = ban.BannedHostAddress,
                                BannedHostNameMask = ban.BannedHostNameMask
                            });
                            //Update the database
                            ES.Save();
                        }
                    }

                    reason = "Banned from this region.";
                    return(false);
                }
                if (Sp != null)
                {
                    IPAddress   end  = Sp.ControllingClient.EndPoint;
                    IPHostEntry rDNS = null;
                    try
                    {
                        rDNS = Dns.GetHostEntry(end);
                    }
                    catch (System.Net.Sockets.SocketException)
                    {
                        m_log.WarnFormat("[IPBAN] IP address \"{0}\" cannot be resolved via DNS", end);
                        rDNS = null;
                    }
                    if (ban.BannedHostIPMask == agent.IPAddress ||
                        (rDNS != null && rDNS.HostName.Contains(ban.BannedHostIPMask)) ||
                        end.ToString().StartsWith(ban.BannedHostIPMask))
                    {
                        //Ban the new user
                        ES.AddBan(new EstateBan()
                        {
                            EstateID           = ES.EstateID,
                            BannedHostIPMask   = agent.IPAddress,
                            BannedUserID       = agent.AgentID,
                            BannedHostAddress  = agent.IPAddress,
                            BannedHostNameMask = agent.IPAddress
                        });
                        ES.Save();

                        reason = "Banned from this region.";
                        return(false);
                    }
                }
                i++;
            }

            //Estate owners/managers/access list people/access groups tp freely as well
            if (ES.EstateOwner == agent.AgentID ||
                new List <UUID>(ES.EstateManagers).Contains(agent.AgentID) ||
                new List <UUID>(ES.EstateAccess).Contains(agent.AgentID) ||
                (Sp != null && new List <UUID>(ES.EstateGroups).Contains(Sp.ControllingClient.ActiveGroupId)))
            {
                reason = "";
                return(true);
            }

            if (ES.DenyAnonymous && ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile) == (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile))
            {
                reason = "You may not enter this region.";
                return(false);
            }

            if (ES.DenyIdentified && ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.PaymentInfoOnFile) == (int)IUserProfileInfo.ProfileFlags.PaymentInfoOnFile))
            {
                reason = "You may not enter this region.";
                return(false);
            }

            if (ES.DenyTransacted && ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.PaymentInfoInUse) == (int)IUserProfileInfo.ProfileFlags.PaymentInfoInUse))
            {
                reason = "You may not enter this region.";
                return(false);
            }

            long m_Day = 25 * 60 * 60; //Find out day length in seconds
            if (scene.RegionInfo.RegionSettings.MinimumAge != 0 && (account.Created - Util.UnixTimeSinceEpoch()) < (scene.RegionInfo.RegionSettings.MinimumAge * m_Day))
            {
                reason = "You may not enter this region.";
                return(false);
            }

            if (!ES.PublicAccess)
            {
                reason = "You may not enter this region.";
                return(false);
            }

            IAgentConnector AgentConnector = DataManager.DataManager.RequestPlugin <IAgentConnector>();
            IAgentInfo      agentInfo      = null;
            if (AgentConnector != null)
            {
                agentInfo = AgentConnector.GetAgent(agent.AgentID);
                if (agentInfo == null)
                {
                    AgentConnector.CreateNewAgent(agent.AgentID);
                    agentInfo = AgentConnector.GetAgent(agent.AgentID);
                }
            }


            if (agentInfo != null && scene.RegionInfo.AccessLevel > Util.ConvertMaturityToAccessLevel((uint)agentInfo.MaturityRating))
            {
                reason = "The region has too high of a maturity level. Blocking teleport.";
                return(false);
            }

            if (agentInfo != null && ES.DenyMinors && (agentInfo.Flags & IAgentFlags.Minor) == IAgentFlags.Minor)
            {
                reason = "The region has too high of a maturity level. Blocking teleport.";
                return(false);
            }

            #endregion

            reason = "";
            return(true);
        }