Inheritance: AllScopeIDImpl, BaseCacheAccount
Ejemplo n.º 1
0
        public LoginResponse Login (Hashtable request, UserAccount account, IAgentInfo agentInfo, string authType,
                                   string password, out object data)
        {
            data = null;

            string ip = "";
            string version = "";
            string platform = "";
            string mac = "";
            string id0 = "";

            if (request != null) {
                ip = request.ContainsKey ("ip") ? (string)request ["ip"] : "";
                version = request.ContainsKey ("version") ? (string)request ["version"] : "";
                platform = request.ContainsKey ("platform") ? (string)request ["platform"] : "";
                mac = request.ContainsKey ("mac") ? (string)request ["mac"] : "";
                id0 = request.ContainsKey ("id0") ? (string)request ["id0"] : "";
            }

            string message;
            if (!m_module.CheckUser (account.PrincipalID, ip,
                    version,
                    platform,
                    mac,
                    id0, out message)) {
                return new LLFailedLoginResponse (LoginResponseEnum.Indeterminant, message, false);
            }
            return null;
        }
        public override void FromOSD(OSDMap map)
        {
            AgentInfo = new IAgentInfo();
            AgentInfo.FromOSD((OSDMap) (map["AgentInfo"]));
            UserAccount = new UserAccount();
            UserAccount.FromOSD((OSDMap)(map["UserAccount"]));
            if (!map.ContainsKey("ActiveGroup"))
                ActiveGroup = null;
            else
            {
                ActiveGroup = new GroupMembershipData();
                ActiveGroup.FromOSD((OSDMap)(map["ActiveGroup"]));
            }

            GroupMemberships = ((OSDArray) map["GroupMemberships"]).ConvertAll<GroupMembershipData>((o) =>
                                                                                                        {
                                                                                                            GroupMembershipData
                                                                                                                group =
                                                                                                                    new GroupMembershipData
                                                                                                                        ();
                                                                                                            group
                                                                                                                .FromOSD
                                                                                                                ((OSDMap
                                                                                                                 ) o);
                                                                                                            return group;
                                                                                                        });
            OfflineMessages = ((OSDArray) map["OfflineMessages"]).ConvertAll<GridInstantMessage>((o) =>
                                                                                                     {
                                                                                                         GridInstantMessage
                                                                                                             group =
                                                                                                                 new GridInstantMessage
                                                                                                                     ();
                                                                                                         group.FromOSD(
                                                                                                             (OSDMap) o);
                                                                                                         return group;
                                                                                                     });
            MuteList = ((OSDArray) map["MuteList"]).ConvertAll<MuteList>((o) =>
                                                                             {
                                                                                 MuteList group = new MuteList();
                                                                                 group.FromOSD((OSDMap) o);
                                                                                 return group;
                                                                             });

            if (map.ContainsKey("Appearance"))
            {
                Appearance = new AvatarAppearance();
                Appearance.FromOSD((OSDMap)map["Appearance"]);
            }

            if (map.ContainsKey("FriendOnlineStatuses"))
                FriendOnlineStatuses = ((OSDArray)map["FriendOnlineStatuses"]).ConvertAll<UUID>((o) => { return o; });

            if (map.ContainsKey("Friends"))
                Friends = ((OSDArray)map["Friends"]).ConvertAll<FriendInfo>((o) =>
                { 
                    FriendInfo f = new FriendInfo();
                    f.FromOSD((OSDMap)o);
                    return f; 
                });
        }
 public static void ChangeAuthentication(OSHttpRequest request, UserAccount account)
 {
     if (request.Cookies["SessionID"] != null)
     {
         UUID sessionID = UUID.Parse(request.Cookies["SessionID"].Value);
         if (_authenticatedUsers.ContainsKey(sessionID))
             _authenticatedUsers[sessionID] = account;
         if (_authenticatedAdminUsers.ContainsKey(sessionID))
             _authenticatedAdminUsers[sessionID] = account;
     }
 }
        public LoginResponse Login (Hashtable request, UserAccount account, IAgentInfo agentInfo, string authType,
                                   string password, out object data)
        {
            data = null;

            // Authenticate this user
            if (authType == "UserAccount") {
                password = password.StartsWith ("$1$", System.StringComparison.Ordinal) ? password.Remove (0, 3) : Util.Md5Hash (password); //remove $1$
            }
            string token = m_AuthenticationService.Authenticate (account.PrincipalID, authType, password, 30);
            UUID secureSession = UUID.Zero;
            if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse (token, out secureSession))) {
                data = "Incorrect password";
                return LLFailedLoginResponse.AuthenticationProblem;
            }
            data = secureSession;
            return null;
        }
        void SaveIARConsoleCommandCompleted(
            Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
            Exception reportedException)

        {
            lock (m_pendingConsoleSaves)
            {
                if (m_pendingConsoleSaves.Contains(id))
                    m_pendingConsoleSaves.Remove(id);
                else
                    return;
            }

            if (succeeded)
            {
                MainConsole.Instance.InfoFormat("[Inventory Archiver]: Saved archive for {0} {1}", userInfo.FirstName,
                                                userInfo.LastName);
            }
            else
            {
                MainConsole.Instance.ErrorFormat(
                    "[Inventory Archiver]: Archive save for {0} {1} failed - {2}",
                    userInfo.FirstName, userInfo.LastName, reportedException.Message);
            }
        }
        void SendProfile (IClientAPI remoteClient, IUserProfileInfo Profile, UserAccount account,
                         uint agentOnline)
        {
            byte [] charterMember;
            if (Profile.MembershipGroup == "") {
                charterMember = new byte [1];
                if (account != null)
                    charterMember [0] = (byte)((account.UserFlags & Constants.USER_FLAG_CHARTERMEMBER) >> 8);   // CharterMember == 0xf00
            } else
                charterMember = Utils.StringToBytes (Profile.MembershipGroup);

            // 19-06-2015 Fly-Man-
            // When charterMember set this character └ the viewer recognizes it
            // as a Grid Master. Not sure what we want to do with that in Universe
            //
            // Perhaps a talk with viewer devs to allow more options for this
            //

            if (Utilities.IsSystemUser (Profile.PrincipalID)) {
                charterMember = Utils.StringToBytes ("Universe System User");
            }

            uint membershipGroupINT = 0;
            if (Profile.MembershipGroup != "")
                membershipGroupINT = 4;

            uint flags = Convert.ToUInt32 (Profile.AllowPublish) + Convert.ToUInt32 (Profile.MaturePublish) +
                         membershipGroupINT + agentOnline + (uint)(account != null ? account.UserFlags : 0);

            remoteClient.SendAvatarInterestsReply (
                Profile.PrincipalID,
                Convert.ToUInt32 (Profile.Interests.WantToMask),
                Profile.Interests.WantToText,
                Convert.ToUInt32 (Profile.Interests.CanDoMask),
                Profile.Interests.CanDoText,
                Profile.Interests.Languages
            );

            remoteClient.SendAvatarProperties (
                Profile.PrincipalID,
                Profile.AboutText,
                Util.ToDateTime (Profile.Created).ToString ("M/d/yyyy", CultureInfo.InvariantCulture),
                charterMember,
                Profile.FirstLifeAboutText,
                flags,
                Profile.FirstLifeImage,
                Profile.Image,
                Profile.WebURL,
                Profile.Partner
            );
        }
        //[CanBeReflected(ThreatLevel = ThreatLevel.Full)]
        public bool StoreUserAccount(UserAccount data)
        {
            /*object remoteValue = DoRemoteByURL("UserAccountServerURI", data);
            if (remoteValue != null || m_doRemoteOnly)
                return remoteValue == null ? false : (bool)remoteValue;*/

            m_registry.RequestModuleInterface<ISimulationBase>()
                      .EventManager.FireGenericEventHandler("UpdateUserInformation", data.PrincipalID);
            return m_Database.Store(data);
        }
Ejemplo n.º 8
0
        protected GridRegion FindDestination(UserAccount account, 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)
                {
                    MainConsole.Instance.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(account.AllScopeIDs);
                    if (defaults != null && defaults.Count > 0)
                    {
                        region = defaults[0];
                        where = "safe";
                    }
                    else
                    {
                        List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.AllScopeIDs, 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.AllScopeIDs, 0, 0);
                            if (safeRegions != null && safeRegions.Count > 0)
                            {
                                region = safeRegions[0];
                                where = "safe";
                            }
                            else
                            {
                                MainConsole.Instance.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(account.AllScopeIDs, "", 0, 1);
                                if (defaults != null && defaults.Count > 0)
                                {
                                    region = defaults[0];
                                    where = "safe";
                                }
                            }
                        }
                    }
                }

                return region;
            }
            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(account.AllScopeIDs, pinfo.CurrentRegionID)) == null)
                {
                    tpFlags &= ~TeleportFlags.ViaLandmark;
                    List<GridRegion> defaults = m_GridService.GetDefaultRegions(account.AllScopeIDs);
                    if (defaults != null && defaults.Count > 0)
                    {
                        region = defaults[0];
                        where = "safe";
                    }
                    else
                    {
                        defaults = m_GridService.GetFallbackRegions(account.AllScopeIDs, 0, 0);
                        if (defaults != null && defaults.Count > 0)
                        {
                            region = defaults[0];
                            where = "safe";
                        }
                        else
                        {
                            defaults = m_GridService.GetSafeRegions(account.AllScopeIDs, 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);
                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.Contains("@"))
                {
                    List<GridRegion> regions = m_GridService.GetRegionsByName(account.AllScopeIDs, regionName, 0, 1);
                    if ((regions == null) || (regions.Count == 0))
                    {
                        MainConsole.Instance.InfoFormat(
                            "[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}. Trying defaults.",
                            startLocation, regionName);
                        regions = m_GridService.GetDefaultRegions(account.AllScopeIDs);
                        if (regions != null && regions.Count > 0)
                        {
                            where = "safe";
                            return regions[0];
                        }
                        List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.AllScopeIDs, 0, 0);
                        if (fallbacks != null && fallbacks.Count > 0)
                        {
                            where = "safe";
                            return fallbacks[0];
                        }
                        //Try to find any safe region
                        List<GridRegion> safeRegions = m_GridService.GetSafeRegions(account.AllScopeIDs, 0, 0);
                        if (safeRegions != null && safeRegions.Count > 0)
                        {
                            where = "safe";
                            return safeRegions[0];
                        }
                        MainConsole.Instance.InfoFormat(
                            "[LLLOGIN SERVICE]: Got Custom Login URI {0}, Grid does not have any available regions.",
                            startLocation);
                        return null;
                    }
                    return regions[0];
                }
                //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)
                {
                    MainConsole.Instance.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];
                //Try now that we removed the domain locator
                GridRegion region = m_GridService.GetRegionByName(account.AllScopeIDs, regionName);
                if (region != null && region.RegionName == regionName)
                    //Make sure the region name is right too... it could just be a similar name
                    return region;

                List<GridRegion> defaults = m_GridService.GetDefaultRegions(account.AllScopeIDs);
                if (defaults != null && defaults.Count > 0)
                {
                    where = "safe";
                    return defaults[0];
                }
                else
                {
                    List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.AllScopeIDs, 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.AllScopeIDs, 0, 0);
                        if (safeRegions != null && safeRegions.Count > 0)
                        {
                            where = "safe";
                            return safeRegions[0];
                        }
                        MainConsole.Instance.InfoFormat(
                            "[LLLOGIN SERVICE]: Got Custom Login URI {0}, Grid does not have any available regions.",
                            startLocation);
                        return null;
                    }
                }
            }
        }
Ejemplo n.º 9
0
 protected AgentCircuitData MakeAgent(GridRegion region, UserAccount account,
                                      UUID session, UUID secureSession, uint circuit,
                                      Vector3 position, IPEndPoint clientIP)
 {
     return new AgentCircuitData
                                     {
                                         AgentID = account.PrincipalID,
                                         IsChildAgent = false,
                                         CircuitCode = circuit,
                                         SecureSessionID = secureSession,
                                         SessionID = session,
                                         StartingPosition = position,
                                         IPAddress = clientIP.Address.ToString()
                                     };
 }
        private List<UserAccount> ParseQuery(List<UUID> scopeIDs, List<string> query)
        {
            List<UserAccount> list = new List<UserAccount>();
            for (int i = 0; i < query.Count; i += 9)
            {
                UserAccount data = new UserAccount
                                       {
                                           PrincipalID = UUID.Parse(query[i + 0]),
                                           ScopeID = UUID.Parse(query[i + 1])
                                       };
                //We keep these even though we don't always use them because we might need to create the "Name" from them
                string FirstName = query[i + 2];
                string LastName = query[i + 3];
                data.Email = query[i + 4];
                data.Created = Int32.Parse(query[i + 5]);
                data.UserLevel = Int32.Parse(query[i + 6]);
                data.UserFlags = Int32.Parse(query[i + 7]);
                data.Name = query[i + 8];
                if (string.IsNullOrEmpty(data.Name))
                {
                    data.Name = FirstName + " " + LastName;
                    //Save the change!
                    Store(data);
                }
                list.Add(data);
            }

            return AllScopeIDImpl.CheckScopeIDs(scopeIDs, list);
        }
        /// <summary>
        ///     Constructor
        /// </summary>
        public InventoryArchiveWriteRequest(
            Guid id, InventoryArchiverModule module, IRegistryCore registry,
            UserAccount userInfo, string invPath, Stream saveStream, bool UseAssets, InventoryFolderBase folderBase,
            List<AssetBase> assetsToAdd, string checkPermissions)
        {
            m_id = id;
            m_module = module;
            m_registry = registry;
            m_userInfo = userInfo;
            m_invPath = invPath;
            m_saveStream = saveStream;
            m_saveAssets = UseAssets;
            m_defaultFolderToSave = folderBase;
            m_assetsToAdd = assetsToAdd;

            // Set Permission filter if available
            if (checkPermissions != null)
                FilterContent = checkPermissions.ToUpper();

            // some necessary services
            m_inventoryService = m_registry.RequestModuleInterface<IInventoryService> ();
            m_assetService = m_registry.RequestModuleInterface<IAssetService> ();
            m_accountService = m_registry.RequestModuleInterface<IUserAccountService> ();

            // lastly as it is dependant
            m_assetGatherer = new UuidGatherer(m_assetService);
        }
 public static void AddAuthentication(UUID sessionID, UserAccount account)
 {
     _authenticatedUsers.Add(sessionID, account);
 }
        private void SendProfile(IClientAPI remoteClient, IUserProfileInfo Profile, UserAccount account,
            uint agentOnline)
        {
            Byte[] charterMember;
            if (Profile.MembershipGroup == "")
            {
                charterMember = new Byte[1];
                if (account != null)
                    charterMember[0] = (Byte) ((account.UserFlags & Constants.USER_FLAG_CHARTERMEMBER) >> 8);   // CharterMember == 0xf00
            }
            else
                charterMember = Utils.StringToBytes(Profile.MembershipGroup);
            // When ChaterMember set this character └ the viewer recognizes it
            // as a Grid Master Not sure what we will be doing with this in
            // in Virtual Universe.

            // Perhaps the Viewer Development Work Group on the Second Galaxy Development Team
            // will shed some light on this regarding future viewer planning.

            if (Utilities.IsSystemUser(Profile.PrincipalID))
            {
                charterMember = Utils.StringToBytes("└");
            }

            uint membershipGroupINT = 0;
            if (Profile.MembershipGroup != "")
                membershipGroupINT = 4;

            uint flags = Convert.ToUInt32(Profile.AllowPublish) + Convert.ToUInt32(Profile.MaturePublish) +
                         membershipGroupINT + agentOnline + (uint) (account != null ? account.UserFlags : 0);
            remoteClient.SendAvatarInterestsReply(Profile.PrincipalID, Convert.ToUInt32(Profile.Interests.WantToMask),
                                                  Profile.Interests.WantToText,
                                                  Convert.ToUInt32(Profile.Interests.CanDoMask),
                                                  Profile.Interests.CanDoText, Profile.Interests.Languages);
            remoteClient.SendAvatarProperties(Profile.PrincipalID, Profile.AboutText,
                                              Util.ToDateTime(Profile.Created).ToString("M/d/yyyy",
                                                                                        CultureInfo.InvariantCulture),
                                              charterMember, Profile.FirstLifeAboutText, flags,
                                              Profile.FirstLifeImage, Profile.Image, Profile.WebURL,
                                              Profile.Partner);
        }
Ejemplo n.º 14
0
 public LoginResponse Login(Hashtable request, UserAccount account, IAgentInfo agentInfo, string authType,
     string password, out object data)
 {
     data = null;
     string ip = request != null && request.ContainsKey("ip") ? (string) request["ip"] : "127.0.0.1";
     ip = ip.Split(':')[0]; //Remove the port
     IPAddress userIP = IPAddress.Parse(ip);
     if (IPBans.Contains(userIP))
         return new LLFailedLoginResponse(LoginResponseEnum.Indeterminant,
                                          "Your account cannot be accessed on this computer.", false);
     foreach (string ipRange in IPRangeBans)
     {
         string[] split = ipRange.Split('-');
         if (split.Length != 2)
             continue;
         IPAddress low = IPAddress.Parse(ip);
         IPAddress high = IPAddress.Parse(ip);
         NetworkUtils.IPAddressRange range = new NetworkUtils.IPAddressRange(low, high);
         if (range.IsInRange(userIP))
             return new LLFailedLoginResponse(LoginResponseEnum.Indeterminant,
                                              "Your account cannot be accessed on this computer.", false);
     }
     return null;
 }
        public LoginResponse Login(Hashtable request, UserAccount account, IAgentInfo agentInfo, string authType,
            string password, out object data)
        {
            IAgentConnector agentData = Framework.Utilities.DataManager.RequestPlugin<IAgentConnector>();
            data = null;

            if (request == null)
                return null; //If its null, its just a verification request, allow them to see things even if they are banned

            bool tosExists = false;
            string tosAccepted = "";
            if (request.ContainsKey("agree_to_tos"))
            {
                tosExists = true;
                tosAccepted = request["agree_to_tos"].ToString();
            }

            //MAC BANNING START
            string mac = (string) request["mac"];
            if (mac == "")
            {
                data = "Bad Viewer Connection";
                return new LLFailedLoginResponse(LoginResponseEnum.Indeterminant, data.ToString(), false);
            }

            // TODO: Some TPV's now send their version in the Channel

            bool AcceptedNewTOS = false;
            //This gets if the viewer has accepted the new TOS
            if (!agentInfo.AcceptTOS && tosExists)
            {
                if (tosAccepted == "0")
                    AcceptedNewTOS = false;
                else if (tosAccepted == "1")
                    AcceptedNewTOS = true;
                else
                    AcceptedNewTOS = bool.Parse(tosAccepted);

                if (agentInfo.AcceptTOS != AcceptedNewTOS)
                {
                    agentInfo.AcceptTOS = AcceptedNewTOS;
                    agentData.UpdateAgent(agentInfo);
                }
            }
            if (!AcceptedNewTOS && !agentInfo.AcceptTOS && m_UseTOS)
            {
                data = "TOS not accepted";
                if (m_TOSLocation.ToLower().StartsWith("http://"))
                    return new LLFailedLoginResponse(LoginResponseEnum.ToSNeedsSent, m_TOSLocation, false);

                // Text file
                var ToSText = File.ReadAllText (Path.Combine (Environment.CurrentDirectory, m_TOSLocation));
                return new LLFailedLoginResponse(LoginResponseEnum.ToSNeedsSent, ToSText, false);
            }
            if ((agentInfo.Flags & IAgentFlags.PermBan) == IAgentFlags.PermBan)
            {
                MainConsole.Instance.InfoFormat(
                    "[LLOGIN SERVICE]: Login failed for user {0}, reason: user is permanently banned.", account.Name);
                data = "Permanently banned";
                return LLFailedLoginResponse.PermanentBannedProblem;
            }

            if ((agentInfo.Flags & IAgentFlags.TempBan) == IAgentFlags.TempBan)
            {
                bool IsBanned = true;
                string until = "";

                if (agentInfo.OtherAgentInformation.ContainsKey("TemperaryBanInfo"))
                {
                    DateTime bannedTime = agentInfo.OtherAgentInformation["TemperaryBanInfo"].AsDate();
                    until = string.Format(" until {0} {1}", bannedTime.ToLocalTime().ToShortDateString(),
                                          bannedTime.ToLocalTime().ToLongTimeString());

                    //Check to make sure the time hasn't expired
                    if (bannedTime.Ticks < DateTime.Now.ToUniversalTime().Ticks)
                    {
                        //The banned time is less than now, let the user in.
                        IsBanned = false;
                    }
                }

                if (IsBanned)
                {
                    MainConsole.Instance.InfoFormat(
                        "[LLOGIN SERVICE]: Login failed for user {0}, reason: user is temporarily banned {1}.",
                        account.Name, until);
                    data =  string.Format("You are blocked from connecting to this service{0}.", until);
                    return new LLFailedLoginResponse(LoginResponseEnum.Indeterminant,
                                                    data.ToString(), false);
                }
            }
            return null;
        }
 /// <summary>
 ///     Constructor
 /// </summary>
 public InventoryArchiveWriteRequest(
     Guid id, InventoryArchiverModule module, IRegistryCore registry,
     UserAccount userInfo, string invPath, string savePath, bool UseAssets, string checkPermissions)
     : this(id,
         module,
         registry,
         userInfo,
         invPath,
         new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress),
         UseAssets,
         null,
         new List<AssetBase>(),
         checkPermissions)
 {
 }
        /// <summary>
        ///     Create a user
        /// </summary>
        /// <param name="newAccount"></param>
        /// <param name="password"></param>
        public string CreateUser(UserAccount newAccount, string password)
        {
            UserAccount account = GetUserAccount(null, newAccount.PrincipalID);
            UserAccount nameaccount = GetUserAccount(null, newAccount.Name);
            if (account == null && nameaccount == null)
            {
                if (StoreUserAccount(newAccount))
                {
                    bool success;
                    if (m_AuthenticationService != null && password != "")
                    {
                        success = m_AuthenticationService.SetPasswordHashed(newAccount.PrincipalID, "UserAccount", password);
                        if (!success)
                        {
                            MainConsole.Instance.WarnFormat(
                                "[USER ACCOUNT SERVICE]: Unable to set password for account {0}.",
                                newAccount.Name);
                            return "Unable to set password";
                        }
                    }

                    MainConsole.Instance.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} created successfully",
                                                    newAccount.Name);
                    //Cache it as well
                    CacheAccount(newAccount);
                    m_registry.RequestModuleInterface<ISimulationBase>()
                              .EventManager.FireGenericEventHandler("CreateUserInformation", newAccount.PrincipalID);

                    // create a profile for the new user as well
                    if (m_profileConnector != null)
                    {
                        m_profileConnector.CreateNewProfile (newAccount.PrincipalID);
                        IUserProfileInfo profile = m_profileConnector.GetUserProfile (newAccount.PrincipalID);

                        profile.MembershipGroup = "Resident";
                        profile.IsNewUser = true;
                        m_profileConnector.UpdateUserProfile (profile);
                    }

                    return "";
                }

                MainConsole.Instance.ErrorFormat("[USER ACCOUNT SERVICE]: Account creation failed for account {0}", newAccount.Name);
                return "Unable to save account";

            }

            MainConsole.Instance.ErrorFormat("[USER ACCOUNT SERVICE]: A user with the name {0} already exists!", newAccount.Name);
            return "A user with the same name already exists";
        }
        public bool Store(UserAccount data)
        {
            Dictionary<string, object> row = new Dictionary<string, object>(9);
            row["PrincipalID"] = data.PrincipalID;
            row["ScopeID"] = data.ScopeID;
            row["FirstName"] = data.FirstName;
            row["LastName"] = data.LastName;
            row["Email"] = data.Email;
            row["Created"] = data.Created;
            row["UserLevel"] = data.UserLevel;
            row["UserFlags"] = data.UserFlags;
            row["Name"] = data.Name;

            return GD.Replace(m_realm, row);
        }
 public bool StoreUserAccount(UserAccount data)
 {
     m_registry.RequestModuleInterface<ISimulationBase>()
               .EventManager.FireGenericEventHandler("UpdateUserInformation", data.PrincipalID);
     return m_Database.Store(data);
 }
Ejemplo n.º 20
0
        protected AgentCircuitData LaunchAgentAtGrid(GridRegion destination, TeleportFlags tpFlags, UserAccount account,
                                                     UUID session, UUID secureSession, Vector3 position,
                                                     string currentWhere,
                                                     IPEndPoint clientIP, List<UUID> friendsToInform, out string where, out string reason,
                                                     out string seedCap, out GridRegion dest)
        {
            where = currentWhere;
            reason = string.Empty;
            uint circuitCode;
            AgentCircuitData aCircuit;
            dest = destination;

            #region Launch Agent

            circuitCode = (uint) Util.RandomClass.Next();
            aCircuit = MakeAgent(destination, account, session, secureSession, circuitCode, position,
                                 clientIP);
            aCircuit.TeleportFlags = (uint) tpFlags;
            MainConsole.Instance.DebugFormat("[LoginService]: Attempting to log {0} into {1} at {2}...", account.Name, destination.RegionName, destination.ServerURI);
            LoginAgentArgs args = m_registry.RequestModuleInterface<IAgentProcessing>().LoginAgent(destination, aCircuit, friendsToInform);
            aCircuit.CachedUserInfo = args.CircuitData.CachedUserInfo;
            aCircuit.RegionUDPPort = args.CircuitData.RegionUDPPort;

            reason = args.Reason;
            seedCap = args.SeedCap;
            bool success = args.Success;
            if (!success && m_GridService != null)
            {
                MainConsole.Instance.DebugFormat("[LoginService]: Failed to log {0} into {1} at {2}...", account.Name, destination.RegionName, destination.ServerURI);
                //Remove the landmark flag (landmark is used for ignoring the landing points in the region)
                aCircuit.TeleportFlags &= ~(uint) TeleportFlags.ViaLandmark;
                m_GridService.SetRegionUnsafe(destination.RegionID);

                // Make sure the client knows this isn't where they wanted to land
                where = "safe";

                // Try the default regions
                List<GridRegion> defaultRegions = m_GridService.GetDefaultRegions(account.AllScopeIDs);
                if (defaultRegions != null)
                {
                    success = TryFindGridRegionForAgentLogin(defaultRegions, account,
                                                             session, secureSession, circuitCode, position,
                                                             clientIP, aCircuit, friendsToInform,
                                                             out seedCap, out reason, out dest);
                }
                if (!success)
                {
                    // Try the fallback regions
                    List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.AllScopeIDs,
                                                                                  destination.RegionLocX,
                                                                                  destination.RegionLocY);
                    if (fallbacks != null)
                    {
                        success = TryFindGridRegionForAgentLogin(fallbacks, account,
                                                                 session, secureSession, circuitCode,
                                                                 position,
                                                                 clientIP, aCircuit, friendsToInform,
                                                                 out seedCap, out reason, out dest);
                    }
                    if (!success)
                    {
                        //Try to find any safe region
                        List<GridRegion> safeRegions = m_GridService.GetSafeRegions(account.AllScopeIDs,
                                                                                    destination.RegionLocX,
                                                                                    destination.RegionLocY);
                        if (safeRegions != null)
                        {
                            success = TryFindGridRegionForAgentLogin(safeRegions, account,
                                                                     session, secureSession, circuitCode,
                                                                     position, clientIP, aCircuit, friendsToInform,
                                                                     out seedCap, out reason, out dest);
                            if (!success)
                                reason = "No Region Found";
                        }
                    }
                }
            }

            #endregion

            if (success)
            {
                MainConsole.Instance.DebugFormat("[LoginService]: Successfully logged {0} into {1} at {2}...", account.Name, destination.RegionName, destination.ServerURI);
                //Set the region to safe since we got there
                m_GridService.SetRegionSafe(destination.RegionID);
                return aCircuit;
            }
            return null;
        }
        public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, Framework.Services.UserInfo pinfo,
            GridRegion destination, List<InventoryFolderBase> invSkel, FriendInfo[] friendsList,
            IInventoryService invService, ILibraryService libService,
            string where, string startlocation, Vector3 position, Vector3 lookAt,
            List<InventoryItemBase> gestures,
            GridRegion home, IPEndPoint clientIP, string AdultMax, string AdultRating,
            ArrayList eventValues, ArrayList eventNotificationValues, ArrayList classifiedValues,
            string seedCap, IConfigSource source,
            string DisplayName, string cofversion, IGridInfo info)
            : this()
        {
            m_source = source;
            m_gridInfo = info;
            SeedCapability = seedCap;

            FillOutInventoryData(invSkel, libService, invService);

            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;
            AgentRegionAccess = AgentRegionAccess;
            AOTransition = AOTransition;
            AgentFlag = AgentFlag;
            eventCategories = eventValues;
            eventNotifications = eventNotificationValues;
            classifiedCategories = classifiedValues;
            COFVersion = cofversion;

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

            FillOutRegionData(aCircuit, destination);
            login = "******";
            ErrorMessage = "";
            ErrorReason = LoginResponseEnum.OK;
        }
Ejemplo n.º 22
0
 protected bool TryFindGridRegionForAgentLogin(List<GridRegion> regions, UserAccount account,
                                               UUID session, UUID secureSession,
                                               uint circuitCode, Vector3 position,
                                               IPEndPoint clientIP, AgentCircuitData aCircuit, List<UUID> friendsToInform,
                                               out string seedCap, out string reason, out GridRegion destination)
 {
     LoginAgentArgs args = null;
     foreach (GridRegion r in regions)
     {
         if (r == null)
             continue;
         MainConsole.Instance.DebugFormat("[LoginService]: Attempting to log {0} into {1} at {2}...", account.Name, r.RegionName, r.ServerURI);
         args = m_registry.RequestModuleInterface<IAgentProcessing>().
                           LoginAgent(r, aCircuit, friendsToInform);
         if (args.Success)
         {
             //aCircuit = MakeAgent(r, account, session, secureSession, circuitCode, position, clientIP);
             MakeAgent(r, account, session, secureSession, circuitCode, position, clientIP);
             destination = r;
             reason = args.Reason;
             seedCap = args.SeedCap;
             return true;
         }
         m_GridService.SetRegionUnsafe(r.RegionID);
     }
     if (args != null)
     {
         seedCap = args.SeedCap;
         reason = args.Reason;
     }
     else
     {
         seedCap = "";
         reason = "";
     }
     destination = null;
     return false;
 }
        void PackUserInfo(IUserProfileInfo info, UserAccount account, ref OSDArray agents)
        {
            OSDMap agentMap = new OSDMap();
            agentMap["username"] = account.Name;
            agentMap["display_name"] = (info == null || info.DisplayName == "") ? account.Name : info.DisplayName;
            agentMap["display_name_next_update"] =
                OSD.FromDate(DateTime.ParseExact("1970-01-01 00:00:00 +0", "yyyy-MM-dd hh:mm:ss z", DateTimeFormatInfo.InvariantInfo).ToUniversalTime());
            agentMap["legacy_first_name"] = account.FirstName;
            agentMap["legacy_last_name"] = account.LastName;
            agentMap["id"] = account.PrincipalID;
            agentMap["is_display_name_default"] = isDefaultDisplayName(account.FirstName, account.LastName, account.Name, info == null ? account.Name : info.DisplayName);

            agents.Add(agentMap);
        }
 public void CacheAccount(UserAccount account)
 {
     if ((account == null) || (account.UserLevel <= -1))
         return;
     
     m_cache.Cache(account.PrincipalID, account);
 }
        /// <summary>
        ///     Send the user a display name update
        /// </summary>
        /// <param name="newDisplayName"></param>
        /// <param name="oldDisplayName"></param>
        /// <param name="infoFromAv"></param>
        /// <param name="toAgentID"></param>
        public void DisplayNameUpdate(string newDisplayName, string oldDisplayName, UserAccount infoFromAv, UUID toAgentID)
        {
            if (m_eventQueue != null)
            {
                //If the DisplayName is blank, the client refuses to do anything, so we send the name by default
                if (newDisplayName == "")
                    newDisplayName = infoFromAv.Name;

                bool isDefaultName = isDefaultDisplayName(infoFromAv.FirstName, infoFromAv.LastName, infoFromAv.Name, newDisplayName);

                OSD item = DisplayNameUpdate(newDisplayName, oldDisplayName, infoFromAv.PrincipalID, isDefaultName,
                                             infoFromAv.FirstName, infoFromAv.LastName,
                                             infoFromAv.FirstName + "." + infoFromAv.LastName);
                m_eventQueue.Enqueue(item, toAgentID, m_service.Region.RegionID);
            }
        }
        /// <summary>
        ///     Create a user
        /// </summary>
        /// <param name="newAccount"></param>
        /// <param name="password"></param>
        //[CanBeReflected(ThreatLevel = ThreatLevel.Full)]
        public string CreateUser(UserAccount newAccount, string password)
        {
            /*object remoteValue = DoRemoteByURL("UserAccountServerURI", newAcc, password);
            if (remoteValue != null || m_doRemoteOnly)
                return remoteValue == null ? "" : remoteValue.ToString();*/

            UserAccount account = GetUserAccount(null, newAccount.PrincipalID);
            UserAccount nameaccount = GetUserAccount(null, newAccount.Name);
            if (account != null || nameaccount != null)
            {
                MainConsole.Instance.ErrorFormat ("[User account service]: A user with the name {0} already exists!", newAccount.Name);
                return "A user with the same name already exists";
            }

            // This one is available...
            if (!StoreUserAccount (newAccount))
            {
                MainConsole.Instance.ErrorFormat ("[User account service]: Account creation failed for account {0}", newAccount.Name);
                return "Unable to save account";
            }
        
            bool success;
            if (m_AuthenticationService != null && password != "")
            {
                success = m_AuthenticationService.SetPasswordHashed (newAccount.PrincipalID, "UserAccount", password);
                if (!success)
                {
                    MainConsole.Instance.WarnFormat (
                        "[User account service]: Unable to set password for account {0}.", newAccount.Name);
                    return "Unable to set password";
                }
            }

            MainConsole.Instance.InfoFormat ("[User account service]: Account {0} created successfully", newAccount.Name);
            //Cache it as well
            CacheAccount (newAccount);
            m_registry.RequestModuleInterface<ISimulationBase> ()
                              .EventManager.FireGenericEventHandler ("CreateUserInformation", newAccount.PrincipalID);

            // create a profile for the new user
            if (m_profileConnector != null)
            {
                m_profileConnector.CreateNewProfile (newAccount.PrincipalID);
                IUserProfileInfo profile = m_profileConnector.GetUserProfile (newAccount.PrincipalID);

                // if (AvatarArchive != "")
                //    profile.AArchiveName = AvatarArchive;
                profile.MembershipGroup = "Resident";
                profile.IsNewUser = true;
                m_profileConnector.UpdateUserProfile (profile);
            }

            // top up the wallet?
            if ((m_newUserStipend > 0) && !Utilities.IsSystemUser (newAccount.PrincipalID))
            {
                IMoneyModule money = m_registry.RequestModuleInterface<IMoneyModule> ();
                if (money != null)
                {
                    money.Transfer (
                        newAccount.PrincipalID,
                        (UUID)Constants.BankerUUID,            
                        m_newUserStipend,
                        "New user stipend",
                        TransactionType.SystemGenerated
                    );
                }
            }
            return "";


        }
        /// <summary>
        ///     Reply to the set display name reply
        /// </summary>
        /// <param name="newDisplayName"></param>
        /// <param name="oldDisplayName"></param>
        /// <param name="mAvatar"></param>
        public void SetDisplayNameReply(string newDisplayName, string oldDisplayName, UserAccount mAvatar)
        {
            if (m_eventQueue != null)
            {
                bool isDefaultName = isDefaultDisplayName(mAvatar.FirstName, mAvatar.LastName, mAvatar.Name, newDisplayName);

                OSD item = DisplayNameReply(newDisplayName, oldDisplayName, mAvatar.PrincipalID, isDefaultName,
                                            mAvatar.FirstName, mAvatar.LastName,
                                            mAvatar.FirstName + "." + mAvatar.LastName);
                m_eventQueue.Enqueue(item, mAvatar.PrincipalID, m_service.Region.RegionID);
            }
        }
 /// <summary>
 ///     Trigger the inventory archive saved event.
 /// </summary>
 protected internal void TriggerInventoryArchiveSaved(
     Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
     Exception reportedException)
 {
     InventoryArchiveSaved handlerInventoryArchiveSaved = OnInventoryArchiveSaved;
     if (handlerInventoryArchiveSaved != null)
         handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException);
 }
        public InventoryArchiveReadRequest (
            IRegistryCore registry, UserAccount userInfo, string invPath, string loadPath, bool merge,
            UUID overwriteCreator)
        {
            Stream str = ArchiveHelpers.GetStream (loadPath);
            if (str == null)
                return;

            m_registry = registry;
            m_merge = merge;
            m_userInfo = userInfo;
            m_invPath = invPath.StartsWith ("/", StringComparison.Ordinal) ? invPath.Remove (0, 1) : invPath;
            m_loadStream = new GZipStream (str, CompressionMode.Decompress);
            m_overridecreator = overwriteCreator;

            // we will need these at some time
            m_assetService = m_registry.RequestModuleInterface<IAssetService> ();
            m_assetData = Framework.Utilities.DataManager.RequestPlugin<IAssetDataPlugin> ();
            m_inventoryService = m_registry.RequestModuleInterface<IInventoryService> ();
            m_accountService = m_registry.RequestModuleInterface<IUserAccountService> ();
        }
 public void Initialise(ICapsService server, UUID agentID)
 {
     m_CapsService = server;
     m_agentID = agentID;
     m_account = Registry.RequestModuleInterface<IUserAccountService>().GetUserAccount(null, agentID);
 }
        public override void FromOSD(OSDMap map)
        {
            AgentInfo = new IAgentInfo();
            AgentInfo.FromOSD((OSDMap)(map["AgentInfo"]));
            UserAccount = new UserAccount();
            UserAccount.FromOSD((OSDMap)(map["UserAccount"]));
            if (!map.ContainsKey("ActiveGroup"))
            {
                ActiveGroup = null;
            }
            else
            {
                ActiveGroup = new GroupMembershipData();
                ActiveGroup.FromOSD((OSDMap)(map["ActiveGroup"]));
            }
            GroupMemberships = ((OSDArray)map["GroupMemberships"]).ConvertAll <GroupMembershipData>((o) =>
            {
                GroupMembershipData
                group =
                    new GroupMembershipData
                        ();
                group
                .FromOSD
                    ((OSDMap
                      )o);
                return(group);
            });
            OfflineMessages = ((OSDArray)map["OfflineMessages"]).ConvertAll <GridInstantMessage>((o) =>
            {
                GridInstantMessage
                group =
                    new GridInstantMessage
                        ();
                group.FromOSD(
                    (OSDMap)o);
                return(group);
            });
            MuteList = ((OSDArray)map["MuteList"]).ConvertAll <MuteList>((o) =>
            {
                MuteList group = new MuteList();
                group.FromOSD((OSDMap)o);
                return(group);
            });

            if (map.ContainsKey("Appearance"))
            {
                Appearance = new AvatarAppearance();
                Appearance.FromOSD((OSDMap)map["Appearance"]);
            }
            if (map.ContainsKey("FriendOnlineStatuses"))
            {
                FriendOnlineStatuses = ((OSDArray)map["FriendOnlineStatuses"]).ConvertAll <UUID>((o) => { return(o); });
            }
            if (map.ContainsKey("Friends"))
            {
                Friends = ((OSDArray)map["Friends"]).ConvertAll <FriendInfo>((o) =>
                {
                    FriendInfo f = new FriendInfo();
                    f.FromOSD((OSDMap)o);
                    return(f);
                });
            }
        }