public override OSDArray GetLLSDItems(string[] fields, string[] vals) { string query = ""; for (int i = 0; i < fields.Length; i++) { query += String.Format("where {0} = '{1}' and ", fields[i], vals[i]); i++; } query = query.Remove(query.Length - 5); if (fields[0] == "inventoryID") { IInventoryService invService = m_registry.RequestModuleInterface <IInventoryService>(); if (invService != null) { UUID inventoryID = UUID.Parse(vals[0]); InventoryItemBase baseItem = new InventoryItemBase(UUID.Parse(vals[0])); if (vals.Count() > 1) { UUID avatarID = UUID.Parse(vals[1]); IUserFinder userFinder = m_registry.RequestModuleInterface <IUserFinder>(); if (userFinder != null && !userFinder.IsLocalGridUser(avatarID)) { string serverURL = userFinder.GetUserServerURL(avatarID, "InventoryServerURI") + "xinventory"; XInventoryServicesConnector xinv = new XInventoryServicesConnector(serverURL); return(BuildLLSDInventoryItems(xinv.GetItem(baseItem))); } } return(BuildLLSDInventoryItems(invService.GetItem(baseItem))); } } return(null); }
public void RequestAvatarProperty(IClientAPI remoteClient, UUID target) { IUserProfileInfo UPI = ProfileFrontend.GetUserProfile(target); UserAccount TargetAccount = remoteClient.Scene.UserAccountService.GetUserAccount(remoteClient.AllScopeIDs, target); IUserFinder userFinder = remoteClient.Scene.RequestModuleInterface <IUserFinder>(); if (UPI == null || TargetAccount == null) { if (userFinder == null || userFinder.IsLocalGridUser(target)) { remoteClient.SendAvatarProperties(target, "", Util.ToDateTime(0).ToString("M/d/yyyy", CultureInfo.InvariantCulture), new Byte[1], "", 0, UUID.Zero, UUID.Zero, "", UUID.Zero); return; } } UserInfo TargetPI = remoteClient.Scene.RequestModuleInterface <IAgentInfoService>().GetUserInfo(target.ToString()); //See if all can see this person uint agentOnline = 0; if (TargetPI != null && TargetPI.IsOnline && UPI.Visible) { agentOnline = 16; } if (IsFriendOfUser(remoteClient.AgentId, target)) { SendProfile(remoteClient, UPI, TargetAccount, agentOnline); } else { //Not a friend, so send the first page only and if they are online Byte[] charterMember; if (UPI.MembershipGroup == "") { charterMember = new Byte[1]; if (TargetAccount != null) { charterMember[0] = (Byte)((TargetAccount.UserFlags & 0xf00) >> 8); } } else { charterMember = Utils.StringToBytes(UPI.MembershipGroup); } remoteClient.SendAvatarProperties(UPI.PrincipalID, UPI.AboutText, Util.ToDateTime(UPI.Created).ToString("M/d/yyyy", CultureInfo.InvariantCulture), charterMember, UPI.FirstLifeAboutText, (uint)(TargetAccount == null ? 0 : TargetAccount.UserFlags & agentOnline), UPI.FirstLifeImage, UPI.Image, UPI.WebURL, UPI.Partner); } }
private bool GetUserProfileData(UUID userID, out Dictionary <string, object> userInfo) { IUserFinder uManage = m_registry.RequestModuleInterface <IUserFinder>(); userInfo = new Dictionary <string, object>(); if (!uManage.IsLocalGridUser(userID)) { // Is Foreign string home_url = uManage.GetUserServerURL(userID, "HomeURI"); if (String.IsNullOrEmpty(home_url)) { userInfo["user_flags"] = 0; userInfo["user_created"] = 0; userInfo["user_title"] = "Unavailable"; return(true); } UserAgentServiceConnector uConn = new UserAgentServiceConnector(home_url); Dictionary <string, object> account = uConn.GetUserInfo(userID); if (account.Count > 0) { if (account.ContainsKey("user_flags")) { userInfo["user_flags"] = account["user_flags"]; } else { userInfo["user_flags"] = ""; } if (account.ContainsKey("user_created")) { userInfo["user_created"] = account["user_created"]; } else { userInfo["user_created"] = ""; } userInfo["user_title"] = "HG Visitor"; } else { userInfo["user_flags"] = 0; userInfo["user_created"] = 0; userInfo["user_title"] = "HG Visitor"; } return(true); } return(false); }
public override List <InventoryItemBase> GetItems(UUID avatarID, string[] fields, string[] vals) { IUserFinder userFinder = m_registry.RequestModuleInterface <IUserFinder>(); if (userFinder != null && !userFinder.IsLocalGridUser(avatarID)) { string serverURL = userFinder.GetUserServerURL(avatarID, "InventoryServerURI") + "xinventory"; UUID id = UUID.Parse(vals[0]); XInventoryServicesConnector xinv = new XInventoryServicesConnector(serverURL); if (fields[0] == "parentFolderID") { return(xinv.GetFolderContent(avatarID, id).Items); } else { return(new List <InventoryItemBase> { xinv.GetItem(new InventoryItemBase(id)) }); } } return(base.GetItems(avatarID, fields, vals)); }
/// <summary> /// Look up the given user id to check whether it's one that is valid for this grid. /// </summary> /// <param name="uuid"></param> /// <param name="creatorID"></param> /// <param name="creatorData"></param> /// <param name="location"></param> /// <param name="parcels"></param> /// <returns></returns> private UUID ResolveUserUuid(UUID uuid, UUID creatorID, string creatorData, Vector3 location, IEnumerable <LandData> parcels) { UUID u; if (!m_validUserUuids.TryGetValue(uuid, out u)) { UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.AllScopeIDs, uuid); if (account != null) { m_validUserUuids.Add(uuid, uuid); return(uuid); } if (uuid == creatorID) { UUID hid; string first, last, url, secret; if (HGUtil.ParseUniversalUserIdentifier(creatorData, out hid, out url, out first, out last, out secret)) { account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.AllScopeIDs, first, last); if (account != null) { m_validUserUuids.Add(uuid, account.PrincipalID); return(account.PrincipalID);//Fix the UUID } } } IUserFinder uf = m_scene.RequestModuleInterface <IUserFinder>(); if (uf != null) { if (!uf.IsLocalGridUser(uuid))//Foreign user, don't remove their info { m_validUserUuids.Add(uuid, uuid); return(uuid); } } UUID id = UUID.Zero; if (m_checkOwnership || (m_useParcelOwnership && parcels == null))//parcels == null is a parcel owner, ask for it if useparcel is on { tryAgain: string ownerName = MainConsole.Instance.Prompt(string.Format("User Name to use instead of UUID '{0}'", uuid), ""); account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.AllScopeIDs, ownerName); if (account != null) { id = account.PrincipalID; } else if (ownerName != "") { if ((ownerName = MainConsole.Instance.Prompt("User was not found, do you want to try again?", "no", new List <string>(new[] { "no", "yes" }))) == "yes") { goto tryAgain; } } } if (m_useParcelOwnership && id == UUID.Zero && location != Vector3.Zero && parcels != null) { foreach (LandData data in parcels) { if (ContainsPoint(data, (int)location.X + m_offsetX, (int)location.Y + m_offsetY)) { if (uuid != data.OwnerID) { id = data.OwnerID; } } } } if (id == UUID.Zero) { id = m_scene.RegionInfo.EstateSettings.EstateOwner; } m_validUserUuids.Add(uuid, id); return(m_validUserUuids[uuid]); } return(u); }
public bool LoginAgent(AgentCircuitData aCircuit, GridRegion destination, out string reason) { reason = string.Empty; string authURL = string.Empty; if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) { authURL = aCircuit.ServiceURLs["HomeURI"].ToString(); } MainConsole.Instance.InfoFormat("[GATEKEEPER SERVICE]: Login request for {0} {1} @ {2}", authURL, aCircuit.AgentID, destination.RegionName); // // Authenticate the user // if (!Authenticate(aCircuit)) { reason = "Unable to verify identity"; MainConsole.Instance.InfoFormat("[GATEKEEPER SERVICE]: Unable to verify identity of agent {0}. Refusing service.", aCircuit.AgentID); return(false); } MainConsole.Instance.DebugFormat("[GATEKEEPER SERVICE]: Identity verified for {0} @ {1}", aCircuit.AgentID, authURL); // // Check for impersonations // UserAccount account = null; if (m_UserAccountService != null) { // Check to see if we have a local user with that UUID account = m_UserAccountService.GetUserAccount(null, aCircuit.AgentID); if (account != null && m_userFinder.IsLocalGridUser(account.PrincipalID)) { // Make sure this is the user coming home, and not a foreign user with same UUID as a local user if (m_UserAgentService != null) { if (!m_UserAgentService.AgentIsComingHome(aCircuit.SessionID, m_ExternalName)) { // Can't do, sorry reason = "Unauthorized"; MainConsole.Instance.InfoFormat("[GATEKEEPER SERVICE]: Foreign agent {0} has same ID as local user. Refusing service.", aCircuit.AgentID); return(false); } } } } MainConsole.Instance.InfoFormat("[GATEKEEPER SERVICE]: User is ok"); // May want to authorize //bool isFirstLogin = false; // // Login the presence, if it's not there yet (by the login service) // UserInfo presence = m_PresenceService.GetUserInfo(aCircuit.AgentID.ToString()); if (m_userFinder.IsLocalGridUser(aCircuit.AgentID) && presence != null && presence.IsOnline) // it has been placed there by the login service { // isFirstLogin = true; } else { IUserAgentService userAgentService = new UserAgentServiceConnector(aCircuit.ServiceURLs["HomeURI"].ToString()); Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY; GridRegion finalDestination = userAgentService.GetHomeRegion(aCircuit.AgentID, out position, out lookAt); if (finalDestination == null) { reason = "You do not have a home position set."; return(false); } m_PresenceService.SetHomePosition(aCircuit.AgentID.ToString(), finalDestination.RegionID, position, lookAt); m_PresenceService.SetLoggedIn(aCircuit.AgentID.ToString(), true, true, destination.RegionID); } MainConsole.Instance.DebugFormat("[GATEKEEPER SERVICE]: Login presence ok"); // // Get the region // destination = m_GridService.GetRegionByUUID(null, destination.RegionID); if (destination == null) { reason = "Destination region not found"; return(false); } // // Adjust the visible name // if (account != null) { aCircuit.firstname = account.FirstName; aCircuit.lastname = account.LastName; } if (account == null && !aCircuit.lastname.StartsWith("@")) { aCircuit.firstname = aCircuit.firstname + "." + aCircuit.lastname; try { Uri uri = new Uri(aCircuit.ServiceURLs["HomeURI"].ToString()); aCircuit.lastname = "@" + uri.Host; // + ":" + uri.Port; } catch { MainConsole.Instance.WarnFormat("[GATEKEEPER SERVICE]: Malformed HomeURI (this should never happen): {0}", aCircuit.ServiceURLs["HomeURI"]); aCircuit.lastname = "@" + aCircuit.ServiceURLs["HomeURI"].ToString(); } m_userFinder.AddUser(aCircuit.AgentID, aCircuit.firstname, aCircuit.lastname, aCircuit.ServiceURLs); m_UserAccountService.CacheAccount(new UserAccount(UUID.Zero, aCircuit.AgentID, aCircuit.firstname + aCircuit.lastname, "") { UserFlags = 1024 }); } retry: // // Finally launch the agent at the destination // TeleportFlags loginFlag = /*isFirstLogin ? */ TeleportFlags.ViaLogin /* : TeleportFlags.ViaHGLogin*/; IRegionClientCapsService regionClientCaps = null; if (m_CapsService != null) { //Remove any previous users string ServerCapsBase = Aurora.Framework.Capabilities.CapsUtil.GetRandomCapsObjectPath(); m_CapsService.CreateCAPS(aCircuit.AgentID, Aurora.Framework.Capabilities.CapsUtil.GetCapsSeedPath(ServerCapsBase), destination.RegionHandle, true, aCircuit, 0); regionClientCaps = m_CapsService.GetClientCapsService(aCircuit.AgentID).GetCapsService(destination.RegionHandle); if (aCircuit.ServiceURLs == null) { aCircuit.ServiceURLs = new Dictionary <string, object>(); } aCircuit.ServiceURLs["IncomingCAPSHandler"] = regionClientCaps.CapsUrl; } aCircuit.child = false;//FIX THIS, OPENSIM ALWAYS SENDS CHILD! int requestedUDPPort = 0; bool success = m_SimulationService.CreateAgent(destination, aCircuit, (uint)loginFlag, null, out requestedUDPPort, out reason); if (success) { if (regionClientCaps != null) { if (requestedUDPPort == 0) { requestedUDPPort = destination.ExternalEndPoint.Port; } IPAddress ipAddress = destination.ExternalEndPoint.Address; aCircuit.RegionUDPPort = requestedUDPPort; regionClientCaps.LoopbackRegionIP = ipAddress; regionClientCaps.CircuitData.RegionUDPPort = requestedUDPPort; OSDMap responseMap = (OSDMap)OSDParser.DeserializeJson(reason); OSDMap SimSeedCaps = (OSDMap)responseMap["CapsUrls"]; regionClientCaps.AddCAPS(SimSeedCaps); } } else { if (m_CapsService != null) { m_CapsService.RemoveCAPS(aCircuit.AgentID); } m_GridService.SetRegionUnsafe(destination.RegionID); if (!m_foundDefaultRegion) { m_DefaultGatewayRegion = FindDefaultRegion(); } if (destination != m_DefaultGatewayRegion) { destination = m_DefaultGatewayRegion; goto retry; } else { m_DefaultGatewayRegion = FindDefaultRegion(); if (m_DefaultGatewayRegion == destination) { return(false);//It failed to find a new one } destination = m_DefaultGatewayRegion; goto retry;//It found a new default region } } return(success); }