public bool Get(UUID userID, out UserAccount account)
        {
            if (m_UUIDCache.TryGetValue(userID, out account))
                return true;

            return false;
        }
示例#2
1
 public RexLoginResponse(UserAccount account, AgentCircuitData aCircuit, GridUserInfo pinfo,
     GridRegion destination, List<InventoryFolderBase> invSkel, FriendInfo[] friendsList, ILibraryService libService,
     string where, string startlocation, Vector3 position, Vector3 lookAt, List<InventoryItemBase> gestures, string message,
     GridRegion home, IPEndPoint clientIP, string mapTileURL, string searchURL)
     : base(account, aCircuit, pinfo, destination, invSkel, friendsList, libService, where, startlocation,
     position, lookAt, gestures, message, home, clientIP, mapTileURL, searchURL)
 {
 }
        public UserAccountWithMappingData(UserAccount accountData, UserMappingData mappingData)
        {
            PrincipalID = accountData.PrincipalID;
            FirstName = accountData.FirstName;
            LastName = accountData.LastName;
            Email = accountData.Email;
            ScopeID = accountData.ScopeID;
            UserLevel = accountData.UserLevel;
            UserFlags = accountData.UserFlags;
            UserTitle = accountData.UserTitle;

            ServiceURLs = accountData.ServiceURLs;
            Created = accountData.Created;

            if (mappingData != null)
            {
                RealFirstName = mappingData.RealFirstName;
                RealLastName = mappingData.RealLastName;
                Institution = mappingData.Institution;
                ConnectID = mappingData.ConnectID;
            }
            else
            {
                RealFirstName = string.Empty;
                RealLastName = string.Empty;
                Institution = string.Empty;
                ConnectID = string.Empty;
            }
        }
示例#4
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;
        }
        private void ParseQuery(List<string> query, ref List<UserAccount> list)
        {
            for (int i = 0; i < query.Count; i += 10)
            {
                UserAccount data = new UserAccount();

                data.PrincipalID = UUID.Parse(query[i + 0]);
                data.ScopeID = UUID.Parse(query[i + 1]);
                data.FirstName = query[i + 2];
                data.LastName = query[i + 3];
                data.Email = query[i + 4];

                string[] URLs = query[i + 5].Split(new char[] { ' ' });
                data.ServiceURLs = new Dictionary<string, object>();

                foreach (string url in URLs)
                {
                    string[] parts = url.Split(new char[] { '=' });

                    if (parts.Length != 2)
                        continue;

                    string name = System.Web.HttpUtility.UrlDecode(parts[0]);
                    string val = System.Web.HttpUtility.UrlDecode(parts[1]);

                    data.ServiceURLs[name] = val;
                }
                data.Created = Int32.Parse(query[i + 6]);
                data.UserLevel = Int32.Parse(query[i + 7]);
                data.UserFlags = Int32.Parse(query[i + 8]);
                data.UserTitle = query[i + 9];
                list.Add(data);
            }
        }
 /// <summary>
 /// Trigger the inventory archive saved event.
 /// </summary>
 protected internal void TriggerInventoryArchiveSaved(
     Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, 
     Exception reportedException)
 {
     InventoryArchiveSaved handlerInventoryArchiveSaved = OnInventoryArchiveSaved;
     if (handlerInventoryArchiveSaved != null)
         handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException);
 }
 public InventoryArchiveReadRequest(
     Scene scene, UserAccount userInfo, string invPath, Stream loadStream)
 {
     m_scene = scene;
     m_userInfo = userInfo;
     m_invPath = invPath;
     m_loadStream = loadStream;
 }
 public InventoryArchiveReadRequest(
     Scene scene, UserAccount userInfo, string invPath, string loadPath)
     : this(
         scene,
         userInfo,
         invPath,
         new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress))
 {
 }
        public void Cache(UUID userID, UserAccount account)
        {
            // Cache even null accounts
            m_UUIDCache.AddOrUpdate(userID, account, DateTime.Now + TimeSpan.FromMinutes(2.0d));
            if (account != null)
                m_NameCache.AddOrUpdate(account.Name, account.PrincipalID, DateTime.Now + TimeSpan.FromMinutes(2.0d));

            m_log.DebugFormat("[USER CACHE]: cached user {0}", userID);
        }
 public InventoryArchiveReadRequest(
     IRegistryCore registry, UserAccount userInfo, string invPath, Stream loadStream, bool merge)
 {
     m_registry = registry;
     m_merge = merge;
     m_userInfo = userInfo;
     m_invPath = invPath;
     m_loadStream = loadStream;
 }
 public InventoryArchiveReadRequest(
     Scene scene, UserAccount userInfo, string invPath, string loadPath)
     : this(
         scene,
         userInfo,
         invPath,
         new GZipStream(new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress))
 {
 }
示例#12
0
        public bool Get(UUID userID, out UserAccount account)
        {
            if (m_UUIDCache.TryGetValue(userID, out account))
            {
                //m_log.DebugFormat("[USER CACHE]: Account {0} {1} found in cache", account.FirstName, account.LastName);
                return true;
            }

            return false;
        }
 public InventoryArchiveReadRequest(
     IRegistryCore registry, UserAccount userInfo, string invPath, string loadPath, bool merge)
     : this(
         registry,
         userInfo,
         invPath,
         new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress),
         merge)
 {
 }
示例#14
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;
     }
 }
示例#15
0
        public bool Get(string name, out UserAccount account)
        {
            account = null;

            UUID uuid = UUID.Zero;
            if (m_NameCache.TryGetValue(name, out uuid))
                if (m_UUIDCache.TryGetValue(uuid, out account))
                    return true;

            return false;
        }
 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;
 }
示例#17
0
        private void ParseQuery(List<string> query, ref List<UserAccount> list)
        {
            for (int i = 0; i < query.Count; i += 11)
            {
                UserAccount data = new UserAccount();

                data.PrincipalID = UUID.Parse(query[i + 0]);
                data.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.ServiceURLs = new Dictionary<string, object>();
                if (query[i + 5] != null)
                {
                    string[] URLs = query[i + 5].Split(new char[] { ' ' });

                    foreach (string url in URLs)
                    {
                        string[] parts = url.Split(new char[] { '=' });

                        if (parts.Length != 2)
                            continue;

                        string name = System.Web.HttpUtility.UrlDecode(parts[0]);
                        string val = System.Web.HttpUtility.UrlDecode(parts[1]);

                        data.ServiceURLs[name] = val;
                    }
                }
                data.Created = Int32.Parse(query[i + 6]);
                data.UserLevel = Int32.Parse(query[i + 7]);
                data.UserFlags = Int32.Parse(query[i + 8]);
                data.UserTitle = query[i + 9];
                data.Name = query[i + 10];
                if (data.Name == null || data.Name == "")
                {
                    data.Name = FirstName + " " + LastName;
                    //Save the change!
                    Store(data);
                }
                list.Add(data);
            }
        }
示例#18
0
 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;
         });
 }
        public bool Store(UserAccount data)
        {
            if (data.UserTitle == null)
                data.UserTitle = "";

            string serviceUrls = string.Join(" ", (from kvp in data.ServiceURLs let key = HttpUtility.UrlEncode(kvp.Key) let val = HttpUtility.UrlEncode(kvp.Value.ToString()) select key + "=" + val).ToArray());

            return GD.Replace(m_realm, new[]
                                           {
                                               "PrincipalID", "ScopeID", "FirstName",
                                               "LastName", "Email", "ServiceURLs", "Created", "UserLevel", "UserFlags",
                                               "UserTitle", "Name"
                                           }, new object[]
                                                  {
                                                      data.PrincipalID, data.ScopeID, data.FirstName, data.LastName,
                                                      data.Email,
                                                      serviceUrls, data.Created, data.UserLevel, data.UserFlags,
                                                      data.UserTitle, data.Name
                                                  });
        }
示例#20
0
        public void Cache(UUID userID, UserAccount account)
        {
            if (!m_allowNullCaching && account == null)
                return;
            if (account == null)
            {
                if (!m_nullCacheTimes.ContainsKey (userID))
                    m_nullCacheTimes[userID] = 0;
                else
                    m_nullCacheTimes[userID]++;
                if (m_nullCacheTimes[userID] < 5)
                    return;
            }
            else if (m_nullCacheTimes.ContainsKey (userID))
                m_nullCacheTimes.Remove (userID);
            // Cache even null accounts
            m_UUIDCache.AddOrUpdate(userID, account, CACHE_EXPIRATION_SECONDS);
            if (account != null)
                m_NameCache.AddOrUpdate(account.Name, account.PrincipalID, CACHE_EXPIRATION_SECONDS);

            //m_log.DebugFormat("[USER CACHE]: cached user {0}", userID);
        }
示例#21
0
        public void UserAccounts_001()
        {
            UserAccountServicesConnector m_Connector = new UserAccountServicesConnector(DemonServer.Address);

            string first = "Completely";
            string last = "Clueless";
            string email = "*****@*****.**";

            UserAccount account = m_Connector.CreateUser(first, last, "123", email, UUID.Zero);
            Assert.IsNotNull(account, "Failed to create account " + first + " " + last);
            UUID user1 = account.PrincipalID;

            account = m_Connector.GetUserAccount(UUID.Zero, user1);
            Assert.NotNull(account, "Failed to retrieve account for user id " + user1);
            Assert.AreEqual(account.FirstName, first, "First name does not match");
            Assert.AreEqual(account.LastName, last, "Last name does not match");

            account = m_Connector.GetUserAccount(UUID.Zero, first, last);
            Assert.IsNotNull(account, "Failed to retrieve account for user " + first + " " + last);
            Assert.AreEqual(account.FirstName, first, "First name does not match (bis)");
            Assert.AreEqual(account.LastName, last, "Last name does not match (bis)");

            account.Email = "*****@*****.**";
            bool success = m_Connector.StoreUserAccount(account);
            Assert.IsTrue(success, "Failed to store existing account");

            account = m_Connector.GetUserAccount(UUID.Zero, user1);
            Assert.NotNull(account, "Failed to retrieve account for user id " + user1);
            Assert.AreEqual(account.Email, "*****@*****.**", "Incorrect email");

            account = new UserAccount(UUID.Zero, "DoesNot", "Exist", "*****@*****.**");
            success = m_Connector.StoreUserAccount(account);
            Assert.IsFalse(success, "Storing a non-existing account must fail");

            account = m_Connector.GetUserAccount(UUID.Zero, "DoesNot", "Exist");
            Assert.IsNull(account, "Account DoesNot Exist must not be there");

        }
示例#22
0
        /// <summary>
        /// Create a user
        /// </summary>
        /// <param name="scopeID"></param>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <param name="password"></param>
        /// <param name="email"></param>
        private UserAccount CreateUser(UUID scopeID, string firstName, string lastName, string password, string email)
        {
            Scene scene = m_application.SceneManager.CurrentOrFirstScene;
            IUserAccountService userAccountService = scene.UserAccountService;
            IGridService gridService = scene.GridService;
            IAuthenticationService authenticationService = scene.AuthenticationService;
            IGridUserService gridUserService = scene.GridUserService;
            IInventoryService inventoryService = scene.InventoryService;

            UserAccount account = userAccountService.GetUserAccount(scopeID, firstName, lastName);
            if (null == account)
            {
                account = new UserAccount(scopeID, firstName, lastName, email);
                if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0))
                {
                    account.ServiceURLs = new Dictionary<string, object>();
                    account.ServiceURLs["HomeURI"] = string.Empty;
                    account.ServiceURLs["GatekeeperURI"] = string.Empty;
                    account.ServiceURLs["InventoryServerURI"] = string.Empty;
                    account.ServiceURLs["AssetServerURI"] = string.Empty;
                }

                if (userAccountService.StoreUserAccount(account))
                {
                    bool success;
                    if (authenticationService != null)
                    {
                        success = authenticationService.SetPassword(account.PrincipalID, password);
                        if (!success)
                            m_log.WarnFormat("[RADMIN]: Unable to set password for account {0} {1}.",
                                firstName, lastName);
                    }

                    GridRegion home = null;
                    if (gridService != null)
                    {
                        List<GridRegion> defaultRegions = gridService.GetDefaultRegions(UUID.Zero);
                        if (defaultRegions != null && defaultRegions.Count >= 1)
                            home = defaultRegions[0];

                        if (gridUserService != null && home != null)
                            gridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
                        else
                            m_log.WarnFormat("[RADMIN]: Unable to set home for account {0} {1}.",
                               firstName, lastName);
                    }
                    else
                        m_log.WarnFormat("[RADMIN]: Unable to retrieve home region for account {0} {1}.",
                           firstName, lastName);

                    if (inventoryService != null)
                    {
                        success = inventoryService.CreateUserInventory(account.PrincipalID);
                        if (!success)
                            m_log.WarnFormat("[RADMIN]: Unable to create inventory for account {0} {1}.",
                                firstName, lastName);
                    }

                    m_log.InfoFormat("[RADMIN]: Account {0} {1} created successfully", firstName, lastName);
                    return account;
                 } else {
                    m_log.ErrorFormat("[RADMIN]: Account creation failed for account {0} {1}", firstName, lastName);
                }
            }
            else
            {
                m_log.ErrorFormat("[RADMIN]: A user with the name {0} {1} already exists!", firstName, lastName);
            }
            return null;
        }
 protected void SaveCompleted(
     Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, 
     Exception reportedException)
 {
     mre.Set();
 }        
示例#24
0
        private void SetServiceURLs(AgentCircuitData aCircuit, UserAccount account)
        {
            aCircuit.ServiceURLs = new Dictionary<string, object>();
            if (account.ServiceURLs == null)
                return;

            // Old style: get the service keys from the DB 
            foreach (KeyValuePair<string, object> kvp in account.ServiceURLs)
            {
                if (kvp.Value != null)
                {
                    aCircuit.ServiceURLs[kvp.Key] = kvp.Value;

                    if (!aCircuit.ServiceURLs[kvp.Key].ToString().EndsWith("/"))
                        aCircuit.ServiceURLs[kvp.Key] = aCircuit.ServiceURLs[kvp.Key] + "/";
                }
            }

            // New style: service keys  start with SRV_; override the previous
            string[] keys = m_LoginServerConfig.GetKeys();

            if (keys.Length > 0)
            {
                bool newUrls = false;
                IEnumerable<string> serviceKeys = keys.Where(value => value.StartsWith("SRV_"));
                foreach (string serviceKey in serviceKeys)
                {
                    string keyName = serviceKey.Replace("SRV_", "");
                    string keyValue = m_LoginServerConfig.GetString(serviceKey, string.Empty);
                    if (!keyValue.EndsWith("/"))
                        keyValue = keyValue + "/";

                    if (!account.ServiceURLs.ContainsKey(keyName) || (account.ServiceURLs.ContainsKey(keyName) && (string)account.ServiceURLs[keyName] != keyValue))
                    {
                        account.ServiceURLs[keyName] = keyValue;
                        newUrls = true;
                    }
                    aCircuit.ServiceURLs[keyName] = keyValue;

                    m_log.DebugFormat("[LLLOGIN SERVICE]: found new key {0} {1}", keyName, aCircuit.ServiceURLs[keyName]);
                }

                // The grid operator decided to override the defaults in the
                // [LoginService] configuration. Let's store the correct ones.
                if (newUrls)
                    m_UserAccountService.StoreUserAccount(account);
            }

        }
示例#25
0
        private AgentCircuitData MakeAgent(GridRegion region, UserAccount account, 
            AvatarAppearance avatar, UUID session, UUID secureSession, uint circuit, Vector3 position, 
            string ipaddress, string viewer, string channel, string mac, string id0)
        {
            AgentCircuitData aCircuit = new AgentCircuitData();

            aCircuit.AgentID = account.PrincipalID;
            if (avatar != null)
                aCircuit.Appearance = new AvatarAppearance(avatar);
            else
                aCircuit.Appearance = new AvatarAppearance();

            //aCircuit.BaseFolder = irrelevant
            aCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
            aCircuit.child = false; // the first login agent is root
            aCircuit.ChildrenCapSeeds = new Dictionary<ulong, string>();
            aCircuit.circuitcode = circuit;
            aCircuit.firstname = account.FirstName;
            //aCircuit.InventoryFolder = irrelevant
            aCircuit.lastname = account.LastName;
            aCircuit.SecureSessionID = secureSession;
            aCircuit.SessionID = session;
            aCircuit.startpos = position;
            aCircuit.IPAddress = ipaddress;
            aCircuit.Viewer = viewer;
            aCircuit.Channel = channel;
            aCircuit.Mac = mac;
            aCircuit.Id0 = id0;
            SetServiceURLs(aCircuit, account);

            return aCircuit;
        }
示例#26
0
        protected AgentCircuitData LaunchAgentAtGrid(GridRegion gatekeeper, GridRegion destination, UserAccount account, AvatarAppearance avatar,
            UUID session, UUID secureSession, Vector3 position, string currentWhere, string viewer, string channel, string mac, string id0,
            IPEndPoint clientIP, TeleportFlags flags, out string where, out string reason, out GridRegion dest)
        {
            where = currentWhere;
            ISimulationService simConnector = null;
            reason = string.Empty;
            uint circuitCode = 0;
            AgentCircuitData aCircuit = null;

            if (m_UserAgentService == null)
            {
                // HG standalones have both a localSimulatonDll and a remoteSimulationDll
                // non-HG standalones have just a localSimulationDll
                // independent login servers have just a remoteSimulationDll
                if (m_LocalSimulationService != null)
                    simConnector = m_LocalSimulationService;
                else if (m_RemoteSimulationService != null)
                    simConnector = m_RemoteSimulationService;
            }
            else // User Agent Service is on
            {
                if (gatekeeper == null) // login to local grid
                {
                    if (hostName == string.Empty)
                        SetHostAndPort(m_GatekeeperURL);

                    gatekeeper = new GridRegion(destination);
                    gatekeeper.ExternalHostName = hostName;
                    gatekeeper.HttpPort = (uint)port;
                    gatekeeper.ServerURI = m_GatekeeperURL;
                }
                m_log.Debug("[LLLOGIN SERVICE]: no gatekeeper detected..... using " + m_GatekeeperURL);
            }

            bool success = false;

            if (m_UserAgentService == null && simConnector != null)
            {
                circuitCode = (uint)Util.RandomClass.Next(); ;
                aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position, clientIP.Address.ToString(), viewer, channel, mac, id0);
                success = LaunchAgentDirectly(simConnector, destination, aCircuit, flags, out reason);
                if (!success && m_GridService != null)
                {
                    // Try the fallback regions
                    List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.ScopeID, destination.RegionLocX, destination.RegionLocY);
                    if (fallbacks != null)
                    {
                        foreach (GridRegion r in fallbacks)
                        {
                            success = LaunchAgentDirectly(simConnector, r, aCircuit, flags | TeleportFlags.ViaRegionID, out reason);
                            if (success)
                            {
                                where = "safe";
                                destination = r;
                                break;
                            }
                        }
                    }
                }
            }

            if (m_UserAgentService != null)
            {
                circuitCode = (uint)Util.RandomClass.Next(); ;
                aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position, clientIP.Address.ToString(), viewer, channel, mac, id0);
                aCircuit.teleportFlags |= (uint)flags;
                success = LaunchAgentIndirectly(gatekeeper, destination, aCircuit, clientIP, out reason);
                if (!success && m_GridService != null)
                {
                    // Try the fallback regions
                    List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.ScopeID, destination.RegionLocX, destination.RegionLocY);
                    if (fallbacks != null)
                    {
                        foreach (GridRegion r in fallbacks)
                        {
                            success = LaunchAgentIndirectly(gatekeeper, r, aCircuit, clientIP, out reason);
                            if (success)
                            {
                                where = "safe";
                                destination = r;
                                break;
                            }
                        }
                    }
                }
            }
            dest = destination;
            if (success)
                return aCircuit;
            else
                return null;
        }
示例#27
0
        private GridRegion FindForeignRegion(string domainName, uint port, string regionName, UserAccount account, out GridRegion gatekeeper)
        {
            m_log.Debug("[LLLOGIN SERVICE]: attempting to findforeignregion " + domainName + ":" + port.ToString() + ":" + regionName);
            gatekeeper = new GridRegion();
            gatekeeper.ExternalHostName = domainName;
            gatekeeper.HttpPort = port;
            gatekeeper.RegionName = regionName;
            gatekeeper.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);

            UUID regionID;
            ulong handle;
            string imageURL = string.Empty, reason = string.Empty;
            string message;
            if (m_GatekeeperConnector.LinkRegion(gatekeeper, out regionID, out handle, out domainName, out imageURL, out reason))
            {
                string homeURI = null;
                if (account.ServiceURLs != null && account.ServiceURLs.ContainsKey("HomeURI"))
                    homeURI = (string)account.ServiceURLs["HomeURI"];
                
                GridRegion destination = m_GatekeeperConnector.GetHyperlinkRegion(gatekeeper, regionID, account.PrincipalID, homeURI, out message);
                return destination;
            }

            return null;
        }
示例#28
0
        protected GridRegion FindDestination(
            UserAccount account, UUID scopeID, GridUserInfo pinfo, UUID sessionID, string startLocation,
            GridRegion home, out GridRegion gatekeeper,
            out string where, out Vector3 position, out Vector3 lookAt, out TeleportFlags flags)
        {
            flags = TeleportFlags.ViaLogin;

            m_log.DebugFormat(
                "[LLOGIN SERVICE]: Finding destination matching start location {0} for {1}",
                startLocation, account.Name);

            gatekeeper = null;
            where = "home";
            position = new Vector3(128, 128, 0);
            lookAt = new Vector3(0, 1, 0);

            if (m_GridService == null)
                return null;

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

                GridRegion region = null;

                bool tryDefaults = false;

                if (home == null)
                {
                    tryDefaults = true;
                }
                else
                {
                    region = home;

                    position = pinfo.HomePosition;
                    lookAt = pinfo.HomeLookAt;
                    flags |= TeleportFlags.ViaHome;
                }
                
                if (tryDefaults)
                {
                    List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID);
                    if (defaults != null && defaults.Count > 0)
                    {
                        region = defaults[0];
                        where = "safe";
                    }
                    else
                    {
                        m_log.WarnFormat("[LLOGIN SERVICE]: User {0} {1} does not have a valid home and this grid does not have default locations. Attempting to find random region",
                            account.FirstName, account.LastName);
                        region = FindAlternativeRegion(scopeID);
                        if (region != null)
                            where = "safe";
                    }
                }

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

                if (pinfo == null)
                    return null;

                GridRegion region = null;

                if (pinfo.LastRegionID.Equals(UUID.Zero) || (region = m_GridService.GetRegionByUUID(scopeID, pinfo.LastRegionID)) == null)
                {
                    List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID);
                    if (defaults != null && defaults.Count > 0)
                    {
                        region = defaults[0];
                        where = "safe";
                    }
                    else
                    {
                        m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region");
                        region = FindAlternativeRegion(scopeID);
                        if (region != null)
                            where = "safe";
                    }

                }
                else
                {
                    position = pinfo.LastPosition;
                    lookAt = pinfo.LastLookAt;
                }
                
                return region;
            }
            else
            {
                flags |= TeleportFlags.ViaRegionID;

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

                    string regionName = uriMatch.Groups["region"].ToString();
                    if (regionName != null)
                    {
                        if (!regionName.Contains("@"))
                        {
                            List<GridRegion> regions = m_GridService.GetRegionsByName(scopeID, regionName, 1);
                            if ((regions == null) || (regions != null && regions.Count == 0))
                            {
                                m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}. Trying defaults.", startLocation, regionName);
                                regions = m_GridService.GetDefaultRegions(scopeID);
                                if (regions != null && regions.Count > 0)
                                {
                                    where = "safe"; 
                                    return regions[0];
                                }
                                else
                                {
                                    m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region");
                                    region = FindAlternativeRegion(scopeID);
                                    if (region != null)
                                    {
                                        where = "safe";
                                        return region;
                                    }
                                    else
                                    {
                                        m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, Grid does not provide default regions and no alternative found.", startLocation);
                                        return null;
                                    }
                                }
                            }
                            return regions[0];
                        }
                        else
                        {
                            if (m_UserAgentService == null)
                            {
                                m_log.WarnFormat("[LLLOGIN SERVICE]: This llogin service is not running a user agent service, as such it can't lauch agents at foreign grids");
                                return null;
                            }
                            string[] parts = regionName.Split(new char[] { '@' });
                            if (parts.Length < 2)
                            {
                                m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}", startLocation, regionName);
                                return null;
                            }
                            // Valid specification of a remote grid
                            
                            regionName = parts[0];
                            string domainLocator = parts[1];
                            parts = domainLocator.Split(new char[] {':'});
                            string domainName = parts[0];
                            uint port = 0;
                            if (parts.Length > 1)
                                UInt32.TryParse(parts[1], out port);

                            region = FindForeignRegion(domainName, port, regionName, account, out gatekeeper);
                            return region;
                        }
                    }
                    else
                    {
                        List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID);
                        if (defaults != null && defaults.Count > 0)
                        {
                            where = "safe"; 
                            return defaults[0];
                        }
                        else
                            return null;
                    }
                }
                //response.LookAt = "[r0,r1,r0]";
                //// can be: last, home, safe, url
                //response.StartLocation = "url";

            }

        }