示例#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;
        }
示例#2
0
 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 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"]);
            }
        }
 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$") ? 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)))
         return LLFailedLoginResponse.AuthenticationProblem;
     data = secureSession;
     return null;
 }
示例#5
0
 public static void AddAuthentication(UUID sessionID, UserAccount account)
 {
     _authenticatedUsers.Add(sessionID, account);
 }
        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;
        }
        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;
            m_loadStream = new GZipStream(str, CompressionMode.Decompress);
            m_overridecreator = overwriteCreator;
        }
 /// <summary>
 ///     Constructor
 /// </summary>
 public InventoryArchiveWriteRequest(
     Guid id, InventoryArchiverModule module, IRegistryCore registry,
     UserAccount userInfo, string invPath, string savePath, bool UseAssets)
     : this(
         id,
         module,
         registry,
         userInfo,
         invPath,
         new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress),
         UseAssets, null, new List<AssetBase>())
 {
 }
示例#9
0
 protected bool TryFindGridRegionForAgentLogin(List<GridRegion> regions, UserAccount account,
     UUID session, UUID secureSession,
     uint circuitCode, Vector3 position,
     IPEndPoint clientIP, AgentCircuitData aCircuit, out string seedCap,
     out string reason, out GridRegion destination)
 {
     LoginAgentArgs args = null;
     foreach (GridRegion r in regions)
     {
         args = m_registry.RequestModuleInterface<IAgentProcessing>().
                           LoginAgent(r, aCircuit);
         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;
 }
示例#10
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()
                                     };
 }
示例#11
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;
                    }
                }
            }
        }
        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 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 == "")
                return new LLFailedLoginResponse(LoginResponseEnum.Indeterminant, "Bad Viewer Connection", false);

            /*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)
                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);
                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);
                    return new LLFailedLoginResponse(LoginResponseEnum.Indeterminant,
                                                     string.Format(
                                                         "You are blocked from connecting to this service{0}.", until),
                                                     false);
                }
            }
            return null;
        }
示例#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;
 }
 /// <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);
 }
        /// <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 (null == account && 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 "";
                }
                else
                {
                    MainConsole.Instance.ErrorFormat("[USER ACCOUNT SERVICE]: Account creation failed for account {0}",
                                                     newAccount.Name);
                    return "Unable to save account";
                }
            }
            else
            {
                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";
            }
        }
        //[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);
 }
示例#19
0
        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 & 0xf00) >> 8);
            }
            else
                charterMember = Utils.StringToBytes(Profile.MembershipGroup);

            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);
        }
        private void SaveInvConsoleCommandCompleted(
            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 void Initialise(ICapsService server, UUID agentID)
 {
     m_CapsService = server;
     m_agentID = agentID;
     m_account = Registry.RequestModuleInterface<IUserAccountService>().GetUserAccount(null, agentID);
 }
        private void AddCapsUrls(OSDMap resp, UserAccount account)
        {
            //Check whether they can use the Api
            if ((account.UserFlags & RegApiAllowed) == RegApiAllowed)
            {
                if ((account.UserFlags & RegApiAddToGroup) == RegApiAddToGroup)
                    resp["add_to_group"] = AddSpecificUrl("add_to_group");

                if ((account.UserFlags & RegApiCheckName) == RegApiCheckName)
                    resp["check_name"] = AddSpecificUrl("check_name");

                if ((account.UserFlags & RegApiCreateUser) == RegApiCreateUser)
                    resp["create_user"] = AddSpecificUrl("create_user");

                if ((account.UserFlags & RegApiGetErrorCodes) == RegApiGetErrorCodes)
                    resp["get_error_codes"] = AddSpecificUrl("get_error_codes");

                if ((account.UserFlags & RegApiGetLastNames) == RegApiGetLastNames)
                    resp["get_last_names"] = AddSpecificUrl("get_last_names");
            }
        }
        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>
        ///     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);
            }
        }
示例#25
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;
        }
        /// <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);
            }
        }
示例#27
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;
 }
        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);
        }
        public void FinishedStartup()
        {
            string IARName = "DefaultInventory.iar";
            IniConfigSource iniSource = null;
            try
            {
                iniSource = new IniConfigSource("DefaultInventory/Inventory.ini", Nini.Ini.IniFileType.AuroraStyle);
            }
            catch
            {
            }
            IConfig libConfig = m_config.Configs["DefaultAssetsIARCreator"];
            if (libConfig == null)
                libConfig = iniSource.Configs["DefaultAssetsIARCreator"];
            if (libConfig != null)
            {
                if (!libConfig.GetBoolean("Enabled", false))
                    return;
                IARName = libConfig.GetString("NameOfIAR", IARName);
            }
            else
                return;
            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);
                MainConsole.Instance.InfoFormat("[DefaultInventoryToIARConverter]: 1,1");
                InventoryFolderBase newFolder = new InventoryFolderBase
                                                    {
                                                    Name = "My Inventory",
                                                    Type = 9,
                                                    Version = 1,
                                                    ID = new UUID("00000112-000f-0000-0000-000100bba000"),
                                                    Owner = m_service.LibraryOwner,
                                                    ParentID = UUID.Zero
                                                    };
                MainConsole.Instance.InfoFormat("[DefaultInventoryToIARConverter]: 1,3");
            }

            MainConsole.Instance.InfoFormat("[DefaultInventoryToIARConverter]: 1,4");
            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
                InventoryArchiveWriteRequest write = new InventoryArchiveWriteRequest (Guid.NewGuid (), null, m_MockScene,
                    uinfo, "/", new GZipStream (new FileStream (IARName, FileMode.Create), CompressionMode.Compress), true, rootFolder, assets);
                write.Execute ();
            }
        }
 /// <summary>
 ///     Constructor
 /// </summary>
 public InventoryArchiveWriteRequest(
     Guid id, InventoryArchiverModule module, IRegistryCore registry,
     UserAccount userInfo, string invPath, Stream saveStream, bool UseAssets, InventoryFolderBase folderBase,
     List<AssetBase> assetsToAdd)
 {
     m_id = id;
     m_module = module;
     m_registry = registry;
     m_userInfo = userInfo;
     m_invPath = invPath;
     m_saveStream = saveStream;
     m_assetGatherer = new UuidGatherer(m_registry.RequestModuleInterface<IAssetService>());
     m_saveAssets = UseAssets;
     m_defaultFolderToSave = folderBase;
     m_assetsToAdd = assetsToAdd;
 }