aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs121
1 files changed, 28 insertions, 93 deletions
diff --git a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
index daf1fb0..2098625 100644
--- a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
+++ b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
@@ -41,6 +41,7 @@ using OpenSim.Client.MXP.ClientStack;
41using OpenSim.Framework; 41using OpenSim.Framework;
42using OpenSim.Region.Framework.Scenes; 42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Framework.Communications; 43using OpenSim.Framework.Communications;
44using OpenSim.Services.Interfaces;
44using System.Security.Cryptography; 45using System.Security.Cryptography;
45 46
46namespace OpenSim.Client.MXP.PacketHandler 47namespace OpenSim.Client.MXP.PacketHandler
@@ -295,13 +296,11 @@ namespace OpenSim.Client.MXP.PacketHandler
295 regionExists = false; 296 regionExists = false;
296 } 297 }
297 298
298 UserProfileData user = null;
299 UUID userId = UUID.Zero; 299 UUID userId = UUID.Zero;
300 string firstName = null; 300 UserAccount account = null;
301 string lastName = null;
302 bool authorized = regionExists ? AuthoriseUser(joinRequestMessage.ParticipantName, 301 bool authorized = regionExists ? AuthoriseUser(joinRequestMessage.ParticipantName,
303 joinRequestMessage.ParticipantPassphrase, 302 joinRequestMessage.ParticipantPassphrase,
304 new UUID(joinRequestMessage.BubbleId), out userId, out firstName, out lastName, out user) 303 new UUID(joinRequestMessage.BubbleId), out account)
305 : false; 304 : false;
306 305
307 if (authorized) 306 if (authorized)
@@ -316,10 +315,11 @@ namespace OpenSim.Client.MXP.PacketHandler
316 session.RemoteEndPoint.Port + ")"); 315 session.RemoteEndPoint.Port + ")");
317 316
318 m_log.Debug("[MXP ClientStack]: Attaching UserAgent to UserProfile..."); 317 m_log.Debug("[MXP ClientStack]: Attaching UserAgent to UserProfile...");
319 AttachUserAgentToUserProfile(session, mxpSessionID, sceneId, user); 318 UUID secureSession = UUID.Zero;
319 AttachUserAgentToUserProfile(account, session, mxpSessionID, sceneId, out secureSession);
320 m_log.Debug("[MXP ClientStack]: Attached UserAgent to UserProfile."); 320 m_log.Debug("[MXP ClientStack]: Attached UserAgent to UserProfile.");
321 m_log.Debug("[MXP ClientStack]: Preparing Scene to Connection..."); 321 m_log.Debug("[MXP ClientStack]: Preparing Scene to Connection...");
322 if (!PrepareSceneForConnection(mxpSessionID, sceneId, user, out reason)) 322 if (!PrepareSceneForConnection(mxpSessionID, secureSession, sceneId, account, out reason))
323 { 323 {
324 m_log.DebugFormat("[MXP ClientStack]: Scene refused connection: {0}", reason); 324 m_log.DebugFormat("[MXP ClientStack]: Scene refused connection: {0}", reason);
325 DeclineConnection(session, joinRequestMessage); 325 DeclineConnection(session, joinRequestMessage);
@@ -332,7 +332,7 @@ namespace OpenSim.Client.MXP.PacketHandler
332 m_log.Info("[MXP ClientStack]: Accepted connection."); 332 m_log.Info("[MXP ClientStack]: Accepted connection.");
333 333
334 m_log.Debug("[MXP ClientStack]: Creating ClientView...."); 334 m_log.Debug("[MXP ClientStack]: Creating ClientView....");
335 MXPClientView client = new MXPClientView(session, mxpSessionID, userId, scene, firstName, lastName); 335 MXPClientView client = new MXPClientView(session, mxpSessionID, userId, scene, account.FirstName, account.LastName);
336 m_clients.Add(client); 336 m_clients.Add(client);
337 m_log.Debug("[MXP ClientStack]: Created ClientView."); 337 m_log.Debug("[MXP ClientStack]: Created ClientView.");
338 338
@@ -489,12 +489,12 @@ namespace OpenSim.Client.MXP.PacketHandler
489 session.SetStateDisconnected(); 489 session.SetStateDisconnected();
490 } 490 }
491 491
492 public bool AuthoriseUser(string participantName, string password, UUID sceneId, out UUID userId, out string firstName, out string lastName, out UserProfileData userProfile) 492 public bool AuthoriseUser(string participantName, string password, UUID sceneId, out UserAccount account)
493 { 493 {
494 userId = UUID.Zero; 494 UUID userId = UUID.Zero;
495 firstName = ""; 495 string firstName = "";
496 lastName = ""; 496 string lastName = "";
497 userProfile = null; 497 account = null;
498 498
499 string[] nameParts = participantName.Split(' '); 499 string[] nameParts = participantName.Split(' ');
500 if (nameParts.Length != 2) 500 if (nameParts.Length != 2)
@@ -505,103 +505,38 @@ namespace OpenSim.Client.MXP.PacketHandler
505 firstName = nameParts[0]; 505 firstName = nameParts[0];
506 lastName = nameParts[1]; 506 lastName = nameParts[1];
507 507
508 userProfile = m_scenes[sceneId].CommsManager.UserService.GetUserProfile(firstName, lastName); 508 account = m_scenes[sceneId].UserAccountService.GetUserAccount(m_scenes[sceneId].RegionInfo.ScopeID, firstName, lastName);
509 if (account != null)
510 return (m_scenes[sceneId].AuthenticationService.Authenticate(account.PrincipalID, password, 1) != string.Empty);
509 511
510 if (userProfile == null && !m_accountsAuthenticate) 512 return false;
511 {
512 userId = ((UserManagerBase)m_scenes[sceneId].CommsManager.UserService).AddUser(firstName, lastName, "test", "", 1000, 1000);
513 }
514 else
515 {
516 if (userProfile == null)
517 {
518 m_log.Error("[MXP ClientStack]: Login failed as user was not found: " + participantName);
519 return false;
520 }
521 userId = userProfile.ID;
522 }
523
524 if (m_accountsAuthenticate)
525 {
526 if (!password.StartsWith("$1$"))
527 {
528 password = "$1$" + Util.Md5Hash(password);
529 }
530 password = password.Remove(0, 3); //remove $1$
531 string s = Util.Md5Hash(password + ":" + userProfile.PasswordSalt);
532 return (userProfile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase)
533 || userProfile.PasswordHash.Equals(password, StringComparison.InvariantCulture));
534 }
535 else
536 {
537 return true;
538 }
539 } 513 }
540 514
541 private void AttachUserAgentToUserProfile(Session session, UUID sessionId, UUID sceneId, UserProfileData userProfile) 515 private void AttachUserAgentToUserProfile(UserAccount account, Session session, UUID sessionId, UUID sceneId, out UUID secureSessionId)
542 { 516 {
543 //Scene scene = m_scenes[sceneId]; 517 secureSessionId = UUID.Random();
544 CommunicationsManager commsManager = m_scenes[sceneId].CommsManager; 518 Scene scene = m_scenes[sceneId];
545 IUserService userService = (IUserService)commsManager.UserService; 519 scene.PresenceService.LoginAgent(account.PrincipalID.ToString(), sessionId, secureSessionId);
546
547 UserAgentData agent = new UserAgentData();
548
549 // User connection
550 agent.AgentOnline = true;
551 agent.AgentIP = session.RemoteEndPoint.Address.ToString();
552 agent.AgentPort = (uint)session.RemoteEndPoint.Port;
553
554 agent.SecureSessionID = UUID.Random();
555 agent.SessionID = sessionId;
556
557 // Profile UUID
558 agent.ProfileID = userProfile.ID;
559
560 // Current location/position/alignment
561 if (userProfile.CurrentAgent != null)
562 {
563 agent.Region = userProfile.CurrentAgent.Region;
564 agent.Handle = userProfile.CurrentAgent.Handle;
565 agent.Position = userProfile.CurrentAgent.Position;
566 agent.LookAt = userProfile.CurrentAgent.LookAt;
567 }
568 else
569 {
570 agent.Region = userProfile.HomeRegionID;
571 agent.Handle = userProfile.HomeRegion;
572 agent.Position = userProfile.HomeLocation;
573 agent.LookAt = userProfile.HomeLookAt;
574 }
575
576 // What time did the user login?
577 agent.LoginTime = Util.UnixTimeSinceEpoch();
578 agent.LogoutTime = 0;
579
580 userProfile.CurrentAgent = agent;
581
582
583 userService.UpdateUserProfile(userProfile);
584 //userService.CommitAgent(ref userProfile);
585 } 520 }
586 521
587 private bool PrepareSceneForConnection(UUID sessionId, UUID sceneId, UserProfileData userProfile, out string reason) 522 private bool PrepareSceneForConnection(UUID sessionId, UUID secureSessionId, UUID sceneId, UserAccount account, out string reason)
588 { 523 {
589 Scene scene = m_scenes[sceneId]; 524 Scene scene = m_scenes[sceneId];
590 CommunicationsManager commsManager = m_scenes[sceneId].CommsManager;
591 UserManagerBase userService = (UserManagerBase)commsManager.UserService;
592 525
593 AgentCircuitData agent = new AgentCircuitData(); 526 AgentCircuitData agent = new AgentCircuitData();
594 agent.AgentID = userProfile.ID; 527 agent.AgentID = account.PrincipalID;
595 agent.firstname = userProfile.FirstName; 528 agent.firstname = account.FirstName;
596 agent.lastname = userProfile.SurName; 529 agent.lastname = account.LastName;
597 agent.SessionID = sessionId; 530 agent.SessionID = sessionId;
598 agent.SecureSessionID = userProfile.CurrentAgent.SecureSessionID; 531 agent.SecureSessionID = secureSessionId;
599 agent.circuitcode = sessionId.CRC(); 532 agent.circuitcode = sessionId.CRC();
600 agent.BaseFolder = UUID.Zero; 533 agent.BaseFolder = UUID.Zero;
601 agent.InventoryFolder = UUID.Zero; 534 agent.InventoryFolder = UUID.Zero;
602 agent.startpos = new Vector3(0, 0, 0); // TODO Fill in region start position 535 agent.startpos = new Vector3(0, 0, 0); // TODO Fill in region start position
603 agent.CapsPath = "http://localhost/"; 536 agent.CapsPath = "http://localhost/";
604 agent.Appearance = userService.GetUserAppearance(userProfile.ID); 537 AvatarData avatar = scene.AvatarService.GetAvatar(account.PrincipalID);
538 if (avatar != null)
539 agent.Appearance = avatar.ToAvatarAppearance(account.PrincipalID); //userService.GetUserAppearance(userProfile.ID);
605 540
606 if (agent.Appearance == null) 541 if (agent.Appearance == null)
607 { 542 {