Inheritance: AllScopeIDImpl, BaseCacheAccount
Esempio 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 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;
 }
        //[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);
        }
 public void CacheAccount(UserAccount account)
 {
     if ((account != null) && (account.UserLevel <= -1))
         return;
     m_cache.Cache(account.PrincipalID, account);
 }
 public void Initialise(ICapsService server, UUID agentID)
 {
     m_CapsService = server;
     m_agentID = agentID;
     m_account = Registry.RequestModuleInterface<IUserAccountService>().GetUserAccount(null, agentID);
 }
Esempio n. 7
0
        // event locations
        public static List<Dictionary<string, object>> EventLocations (UserAccount user, IRegistryCore registry, string selParcel)
        {
            // Get current parcels on regions etc
            var regionList = new List<Dictionary<string, object>> ();
            var directoryService = Framework.Utilities.DataManager.RequestPlugin<IDirectoryServiceConnector> ();
            var groupService = registry.RequestModuleInterface<IGroupsModule> ();
            var friendsService = registry.RequestModuleInterface<IFriendsService> ();

            regionList.Add (new Dictionary<string, object> {
                {"Value", "---MY PARCELS---"},
                {"Index","0"},
                {"disabled","disabled"},
                {"selected", ""}
            });

            #region user land
            if (user != null) {
                var myParcels = directoryService.GetParcelByOwner (user.PrincipalID);
                if (myParcels.Count > 0)
                    regionList.AddRange (ParcelLocations (myParcels, selParcel));


                // Group owned parcels
                regionList.Add (new Dictionary<string, object> {
                    {"Value", "---GROUP PARCELS---"},
                    {"Index","0"},
                    {"disabled","disabled"},
                    {"selected", ""}
                });

                if (groupService != null) {
                    var grpmembership = groupService.GetMembershipData (user.PrincipalID);
                    if (grpmembership != null) {
                        foreach (var grp in grpmembership) {
                            var groupParcels = directoryService.GetParcelByOwner (grp.GroupID);
                            if (groupParcels.Count > 0)
                                regionList.AddRange (ParcelLocations (groupParcels, selParcel));
                        }
                    }
                }

                // Private Estate parcels
                regionList.Add (new Dictionary<string, object> {
                    {"Value", "---PRIVATE ESTATE PARCELS---"},
                    {"Index","0"},
                    {"disabled","disabled"},
                    {"selected", ""}
                });

            }
            #endregion

            // Public parcels
            regionList.Add (new Dictionary<string, object> {
                {"Value", "---PUBLIC PARCELS---"},
                {"Index","0"},
                {"disabled","disabled"},
                {"selected", ""}
            });
            var mainlandParcels = directoryService.GetParcelByOwner ((UUID)Constants.RealEstateOwnerUUID);
            if (mainlandParcels.Count > 0)
                regionList.AddRange (ParcelLocations (mainlandParcels, selParcel));

            // Friends parcels
            regionList.Add (new Dictionary<string, object> {
                {"Value", "---MY FRIENDS PARCELS---"},
                {"Index","0"},
                {"disabled","disabled"},
                {"selected", ""}
            });

            if (user != null) {
                var friends = friendsService.GetFriends (user.PrincipalID);
                foreach (var friend in friends) {
                    UUID friendID = UUID.Zero;
                    UUID.TryParse (friend.Friend, out friendID);

                    if (friendID != UUID.Zero) {
                        var friendParcels = directoryService.GetParcelByOwner (friendID);
                        if (friendParcels.Count > 0)
                            regionList.AddRange (ParcelLocations (friendParcels, selParcel));
                    }
                }
            }

            return regionList;

            /*  
                <select>
                <option value = "" disabled = "disabled" > &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ---MY PARCELS-- -</ option >
                < option value = "" disabled = "disabled" > &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ---GROUP - OWNED PARCELS-- -</ option >
                < option value = "" disabled = "disabled" > &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ---PRIVATE ISLAND PARCELS ---</ option >
                < option value = "" disabled = "disabled" > &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ---PUBLIC PARCELS ---</ option >
                < option value = "1020,995,0,0,0,d436261b-7186-42a6-dcd3-b80c1bcafaa4" >(G)Bacchus Island in Baffin / 136 / 180 & nbsp; &nbsp; (25232 m²)</ option >
                < option value = "991,1001,45,15,25,d2522787-9685-1b12-d5d4-2092a104f79c" >(M)Bayjou Theater in Bay City -Rollers / 45 / 15 & nbsp; &nbsp; (3360 m²)</ option >
                < option value = "1137,1052,0,0,0,17c0534e-23e2-5367-6ca0-8a33a834aa42" >(M)Blake Sea Rez Zone in Blake Sea -Haggerty / 228 / 228 & nbsp; &nbsp; (2304 m²)</ option >
                < option value = "995,1008,164,102,26,5e288455-3f06-80a7-e20d-262887bc80eb" >(G)Violet Welcome Area and Infohu in Violet / 164 / 102 & nbsp; &nbsp; (65536 m²)</ option >
                < option value = "1012,989,233,161,85,671a1590-9969-f565-1f37-464c0fe65257" >(G)Voss Lakeside Rez Zone in Voss / 233 / 161 & nbsp; &nbsp; (2816 m²)</ option >
                .... etc ....
                < option value = "" disabled = "disabled" > &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ---FRIEND - OWNED PARCELS-- -</ option >
                </ select >
            */
        }
Esempio n. 8
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;
        }
        /// <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);
            }
        }
        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
            string channel = "Unknown";
            if (request.Contains("channel") && request["channel"] != null)
                channel = request["channel"].ToString();

            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";
                return new LLFailedLoginResponse(LoginResponseEnum.ToSNeedsSent, File.ReadAllText(Path.Combine(Environment.CurrentDirectory, m_TOSLocation)), 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;
        }
        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);
            }
        }
 public static void AddAuthentication(UUID sessionID, UserAccount account)
 {
     _authenticatedUsers.Add(sessionID, account);
 }
        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);
        }
Esempio n. 14
0
        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;
            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;
        }
Esempio n. 15
0
        private 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);
        }
Esempio n. 16
0
        /// <summary>
        ///     Reply to the set display name reply
        /// </summary>
        /// <param name="newDisplayName"></param>
        /// <param name="oldDisplayName"></param>
        /// <param name="m_avatar"></param>
        public void SetDisplayNameReply(string newDisplayName, string oldDisplayName, UserAccount m_avatar)
        {
            if (m_eventQueue != null)
            {
                bool isDefaultName = isDefaultDisplayName(m_avatar.FirstName, m_avatar.LastName, m_avatar.Name,
                                                          newDisplayName);

                OSD item = DisplayNameReply(newDisplayName, oldDisplayName, m_avatar.PrincipalID, isDefaultName,
                                            m_avatar.FirstName, m_avatar.LastName,
                                            m_avatar.FirstName + "." + m_avatar.LastName);
                m_eventQueue.Enqueue(item, m_avatar.PrincipalID, m_service.Region.RegionID);
            }
        }
        private void AddCapsUrls(OSDMap resp, UserAccount account)
        {
            IGenericsConnector generics = Framework.Utilities.DataManager.RequestPlugin<IGenericsConnector>();
            //Check whether they can use the Api
            if ((account.UserFlags & RegApiAllowed) == RegApiAllowed)
            {
                MainConsole.Instance.InfoFormat("[RegAPI]: User {0} {1} is allowed to use the RegAPI", account.FirstName, account.LastName);

                // Remove all the old keys
                generics.RemoveGeneric(UUID.Zero, "RegAPI");

                if ((account.UserFlags & RegApiAddToGroup) == RegApiAddToGroup)
                    resp["add_to_group"] = AddSpecificUrl("add_to_group");
                MainConsole.Instance.InfoFormat("[RegAPI]: User {0} {1} - Add to Group : {2}", account.FirstName, account.LastName, resp["add_to_group"]);
                generics.AddGeneric(account.PrincipalID, "RegAPI", "add_to_group", new OSDWrapper { Info = resp["add_to_group"] }.ToOSD());

                if ((account.UserFlags & RegApiCheckName) == RegApiCheckName)
                    resp["check_name"] = AddSpecificUrl("check_name");
                MainConsole.Instance.InfoFormat("[RegAPI]: User {0} {1} - Check Name : {2}", account.FirstName, account.LastName, resp["check_name"]);
                generics.AddGeneric(account.PrincipalID, "RegAPI", "check_name", new OSDWrapper { Info = resp["check_name"] }.ToOSD());

                if ((account.UserFlags & RegApiCreateUser) == RegApiCreateUser)
                    resp["create_user"] = AddSpecificUrl("create_user");
                MainConsole.Instance.InfoFormat("[RegAPI]: User {0} {1} - Create User : {2}", account.FirstName, account.LastName, resp["create_user"]);
                generics.AddGeneric(account.PrincipalID, "RegAPI", "create_user", new OSDWrapper { Info = resp["create_user"] }.ToOSD());

                if ((account.UserFlags & RegApiGetErrorCodes) == RegApiGetErrorCodes)
                    resp["get_error_codes"] = AddSpecificUrl("get_error_codes");
                MainConsole.Instance.InfoFormat("[RegAPI]: User {0} {1} - Get Error Code : {2}", account.FirstName, account.LastName, resp["get_error_codes"]);
                generics.AddGeneric(account.PrincipalID, "RegAPI", "get_error_codes", new OSDWrapper { Info = resp["get_error_codes"] }.ToOSD());

                if ((account.UserFlags & RegApiGetLastNames) == RegApiGetLastNames)
                    resp["get_last_names"] = AddSpecificUrl("get_last_names");
                MainConsole.Instance.InfoFormat("[RegAPI]: User {0} {1} - Get Last Names : {2}", account.FirstName, account.LastName, resp["get_last_names"]);
                generics.AddGeneric(account.PrincipalID, "RegAPI", "get_last_names", new OSDWrapper { Info = resp["get_last_names"] }.ToOSD());
            }
        }
        /// <summary>
        /// Handles the default inventory save.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        private void HandleDefInvSave( IScene scene, string[] cmd )
        {
            if (!m_enabled)
                return;

            if (m_busy)
                return;

            string fileName = IARName;

            // optional filename
            int el = cmd.Length;
            if (el >= 4)
            {
                fileName = cmd[3];

                // some file sanity checks
                string extension = Path.GetExtension (fileName);

                if (extension == string.Empty)
                {
                    fileName = fileName + ".iar";
                }

            }

            string fileDir = Path.GetDirectoryName (fileName);
            if (fileDir == "")
            {
                fileDir = "./DefaultInventory";
                fileName = fileDir + '/' + fileName;
            }
            if (!Directory.Exists (fileDir))
            {
                MainConsole.Instance.Info ("[LIBDEF]: The folder specified, '" + fileDir + "' does not exist!");
                return;
            }

            // don't try and write to an existing file
            if (File.Exists (fileName))
            {
                if (MainConsole.Instance.Prompt ("[LIBDEF]: The inventory file '" + fileName + "' exists. Overwrite?", "yes") != "yes")
                    return;

                File.Delete (fileName);
            }

            // good to go... do it...
            m_busy = true;
            m_service = m_registry.RequestModuleInterface<ILibraryService>();

            RegionInfo regInfo = new RegionInfo();
            IScene m_MockScene = null;

            //Make the scene for the IAR loader
            if (m_registry is IScene)
                m_MockScene = (IScene)m_registry;
            else
            {
                m_MockScene = new Scene();
                m_MockScene.Initialize(regInfo);
                m_MockScene.AddModuleInterfaces(m_registry.GetInterfaces());
            }

            UserAccount uinfo = m_MockScene.UserAccountService.GetUserAccount(null, m_service.LibraryOwner);
            //Make the user account for the default IAR
            if (uinfo == null)
            {
                uinfo = new UserAccount(m_service.LibraryOwner);
                uinfo.Name = m_service.LibraryOwnerName;
                m_MockScene.InventoryService.CreateUserInventory(m_service.LibraryOwner, false);
            }

            List<AssetBase> assets = new List<AssetBase> ();
            if (m_MockScene.InventoryService != null)
            {
                //Add the folders to the user's inventory
                InventoryCollection i = m_MockScene.InventoryService.GetFolderContent (m_service.LibraryOwner, UUID.Zero);
                if (i != null)
                {
                    foreach (InventoryItemBase item in i.Items)
                    {
                        AssetBase asset = m_MockScene.RequestModuleInterface<IAssetService> ().Get (item.AssetID.ToString ());
                        if (asset != null)
                            assets.Add (asset);
                    }
                }
            }
            InventoryFolderBase rootFolder = null;
            List<InventoryFolderBase> rootFolders = m_MockScene.InventoryService.GetRootFolders (m_service.LibraryOwner);
            foreach (InventoryFolderBase folder in rootFolders)
            {
                if (folder.Name == "My Inventory")
                    continue;

                rootFolder = folder;
                break;
            }
            if (rootFolder != null)
            {
                //Save the IAR of the default assets
                MainConsole.Instance.Info ("[LIBDEF]: Saving default inventory to " + fileName);
                InventoryArchiveWriteRequest write = new InventoryArchiveWriteRequest (Guid.NewGuid (), null, m_MockScene,
                    uinfo, "/", new GZipStream (new FileStream (fileName, FileMode.Create), CompressionMode.Compress), true, rootFolder, assets);
                write.Execute ();
            }

            m_busy = false;
        }
 /// <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);
 }
Esempio 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 = 0;
            AgentCircuitData aCircuit = null;
            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;
            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;
        }
        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 WhiteCore
            //
            // Perhaps a talk with viewer devs to allow more options for this
            //

            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
            );
        }
Esempio 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);
             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;
 }
 /// <summary>
 ///     Create a user
 /// </summary>
 /// <param name="newAccount"></param>
 /// <param name="md5password"></param>
 public string CreateUser (UserAccount newAccount, string md5password)
 {
     return CreateNewUser (newAccount, md5password, "");
 }
        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);
        }
Esempio n. 25
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()
                                     };
 }
 /// <summary>
 /// Creates the user with salt.
 /// </summary>
 /// <returns>The salted user.</returns>
 /// <param name="newAccount">New account.</param>
 /// <param name="passHash">Pass hash.</param>
 /// <param name="passSalt">Pass salt.</param>
 public string CreateSaltedUser (UserAccount newAccount, string passHash, string passSalt)
 {
     return CreateNewUser (newAccount, passHash, passSalt);
 }
Esempio n. 27
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;
                    }
                }
            }
        }
        //[CanBeReflected(ThreatLevel = ThreatLevel.Full)]
        string CreateNewUser (UserAccount newAccount, string passHash, string passSalt)
        {
            /*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 (passSalt != "")
                success = SetSaltedPassword (newAccount.PrincipalID, passHash, passSalt);
            else
                success = SetHashedPassword (newAccount.PrincipalID, passHash);

            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 "";

        }
        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("/") ? 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> ();
        }
        /// <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)
            {
                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);
                    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";
        }