public static bool TryPrepareLogin(OpenSim.Grid.UserServer.Modules.RexLogin.Avatar avatar, CableBeachMessages.RegionInfo startRegion, Vector3 startPosition, string clientVersion, System.Net.IPAddress clientIP, ref OpenSim.Grid.UserServer.Modules.RexLogin.LindenLoginData response, X509Certificate2 httpCertificate ) { EnableClientMessage message = new EnableClientMessage(); message.Identity = avatar.Identity; message.AgentID = avatar.ID; message.Attributes = avatar.Attributes; message.CallbackUri = null; message.ChildAgent = false; message.CircuitCode = CreateCircuitCode(); message.ClientVersion = clientVersion; message.IP = clientIP; message.RegionHandle = startRegion.Handle; message.SecureSessionID = response.SecureSessionID; message.Services = avatar.Services.ToMessageDictionary(); Dictionary<Uri, Uri> avStrgDict = new Dictionary<Uri, Uri>(); avStrgDict.Add( OpenSim.Grid.UserServer.Modules.RexLogin.RexAvatarAttributes.AVATAR_STORAGE_URL, avatar.Attributes[OpenSim.Grid.UserServer.Modules.RexLogin.RexAvatarAttributes.AVATAR_STORAGE_URL].AsUri()); message.Services.Add(OpenSim.Grid.UserServer.Modules.RexLogin.RexAvatarAttributes.AVATAR_STORAGE_URL, avStrgDict); message.SessionID = response.SessionID; Uri enableClientCap; if (startRegion.Capabilities.TryGetValue(new Uri(CableBeachServices.SIMULATOR_ENABLE_CLIENT), out enableClientCap)) { CapsClient request = (httpCertificate != null) ? new CapsClient(enableClientCap, httpCertificate) : new CapsClient(enableClientCap); OSDMap responseMap = request.GetResponse(message.Serialize(), OSDFormat.Json, REQUEST_TIMEOUT) as OSDMap; if (responseMap != null) { EnableClientReplyMessage reply = new EnableClientReplyMessage(); reply.Deserialize(responseMap); if (reply.SeedCapability != null) { m_log.Info("enable_client succeeded, sent circuit code " + message.CircuitCode + " and received seed capability " + reply.SeedCapability + " from " + enableClientCap); response.CircuitCode = message.CircuitCode; response.SeedCapability = reply.SeedCapability.ToString(); return true; } else { m_log.Error("[LindenLoginHelper] enable_client call to region " + startRegion.Name + " for login from " + avatar.Identity + " failed, did not return a seed capability"); } } else { m_log.Error("[LindenLoginHelper] enable_client call to region " + startRegion.Name + " for login from " + avatar.Identity + " failed, could not contact or invalid response"); } } else { m_log.Error("[LindenLoginHelper] enable_client call failed, region " + startRegion.Name + " does not have an enable_client capability"); } return false; }
private OSD EnableClientMessageHandler(string path, OSD request, string endpoint) { EnableClientMessage message = new EnableClientMessage(); EnableClientReplyMessage reply = new EnableClientReplyMessage(); if (request.Type == OSDType.Map) { message.Deserialize((OSDMap)request); WorldServiceConnector wsConnector; if (m_regionWorldServiceConnectors.TryGetValue(message.RegionHandle, out wsConnector)) { Scene scene = wsConnector.Scene; AgentCircuitData agentData = new AgentCircuitData(); agentData.AgentID = message.AgentID; agentData.BaseFolder = UUID.Zero; // TODO: What is this? agentData.CapsPath = CapsUtil.GetRandomCapsObjectPath(); agentData.child = message.ChildAgent; agentData.circuitcode = (uint)message.CircuitCode; agentData.firstname = GetStringAttribute(message.Attributes, AvatarAttributes.FIRST_NAME); agentData.lastname = GetStringAttribute(message.Attributes, AvatarAttributes.LAST_NAME); agentData.SecureSessionID = message.SecureSessionID; agentData.SessionID = message.SessionID; agentData.startpos = GetVector3Attribute(message.Attributes, AvatarAttributes.LAST_POSITION); UserAgentData useragent = new UserAgentData(); useragent.AgentIP = message.IP.ToString(); useragent.AgentOnline = true; useragent.AgentPort = 0u; useragent.Handle = scene.RegionInfo.RegionHandle; useragent.InitialRegion = scene.RegionInfo.RegionID; useragent.LoginTime = Util.UnixTimeSinceEpoch(); useragent.LogoutTime = 0; useragent.Position = agentData.startpos; useragent.Region = useragent.InitialRegion; useragent.SecureSessionID = agentData.SecureSessionID; useragent.SessionID = agentData.SessionID; UserProfileData userProfile = new UserProfileData(); userProfile.AboutText = GetStringAttribute(message.Attributes, AvatarAttributes.BIOGRAPHY); userProfile.CanDoMask = (uint)GetIntegerAttribute(message.Attributes, AvatarAttributes.CAN_DO); userProfile.Created = (int)Utils.DateTimeToUnixTime(GetDateAttribute(message.Attributes, AvatarAttributes.BIRTH_DATE)); userProfile.CurrentAgent = useragent; userProfile.CustomType = "CableBeach"; userProfile.FirstLifeAboutText = GetStringAttribute(message.Attributes, AvatarAttributes.FIRST_LIFE_BIOGRAPHY); userProfile.FirstLifeImage = GetUUIDAttribute(message.Attributes, AvatarAttributes.FIRST_LIFE_IMAGE_ID); userProfile.FirstName = agentData.firstname; userProfile.GodLevel = GetIntegerAttribute(message.Attributes, AvatarAttributes.GOD_LEVEL); userProfile.HomeLocation = GetVector3Attribute(message.Attributes, AvatarAttributes.HOME_POSITION); userProfile.HomeLocationX = userProfile.HomeLocation.X; userProfile.HomeLocationY = userProfile.HomeLocation.Y; userProfile.HomeLocationZ = userProfile.HomeLocation.Z; userProfile.HomeLookAt = GetVector3Attribute(message.Attributes, AvatarAttributes.HOME_LOOKAT); userProfile.HomeLookAtX = userProfile.HomeLookAt.X; userProfile.HomeLookAtY = userProfile.HomeLookAt.Y; userProfile.HomeLookAtZ = userProfile.HomeLookAt.Z; userProfile.HomeRegionID = GetUUIDAttribute(message.Attributes, AvatarAttributes.HOME_REGION_ID); userProfile.HomeRegionX = (uint)GetIntegerAttribute(message.Attributes, AvatarAttributes.HOME_REGION_X); userProfile.HomeRegionY = (uint)GetIntegerAttribute(message.Attributes, AvatarAttributes.HOME_REGION_Y); userProfile.HomeRegion = Utils.UIntsToLong(userProfile.HomeRegionX, userProfile.HomeRegionY); userProfile.ID = agentData.AgentID; userProfile.Image = UUID.Zero; userProfile.LastLogin = useragent.LoginTime; userProfile.Partner = GetUUIDAttribute(message.Attributes, AvatarAttributes.PARTNER_ID); userProfile.PasswordHash = "$1$"; userProfile.PasswordSalt = String.Empty; userProfile.SurName = agentData.lastname; userProfile.UserFlags = GetIntegerAttribute(message.Attributes, AvatarAttributes.USER_FLAGS); userProfile.WantDoMask = (uint)GetIntegerAttribute(message.Attributes, AvatarAttributes.WANT_DO); userProfile.WebLoginKey = UUID.Zero; // Cable Beach does not tie all endpoints for a service under a single URL, so these won't do userProfile.UserAssetURI = String.Empty; userProfile.UserInventoryURI = String.Empty; // Stick our user data in the cache so the region will know something about us scene.CommsManager.UserProfileCacheService.PreloadUserCache(userProfile); // Add this incoming EnableClient message to the database of active sessions wsConnector.EnableClientMessages.Add(message.Identity, message.AgentID, message); // Call 'new user' event handler string reason; if (wsConnector.NewUserConnection(agentData, out reason)) { string capsSeedPath = CapsUtil.GetCapsSeedPath( scene.CapsModule.GetCapsHandlerForUser(agentData.AgentID).CapsObjectPath); // Set the response message to successful reply.Success = true; reply.SeedCapability = wsConnector.GetServiceEndpoint(capsSeedPath); m_Log.Info("[CABLE BEACH MOD]: enable_client succeeded for " + userProfile.Name); } else { reply.Message = "Connection refused: " + reason; m_Log.Error("[CABLE BEACH MOD]: enable_client failed: " + reason); } } else { m_Log.Error("[CABLE BEACH MOD]: enable_client received an unrecognized region handle " + message.RegionHandle); } } return reply.Serialize(); }