aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
authorDiva Canto2010-01-01 16:54:24 -0800
committerDiva Canto2010-01-01 16:54:24 -0800
commit4240f2dec6f7348a99aea0d1b040fca6ea9d493b (patch)
tree267b986654ab2ffbc3a60d3e95fd7b697f9b089c /OpenSim/Services
parentRemove the inner Md5 to let the auth service handle md5 passwords (diff)
downloadopensim-SC_OLD-4240f2dec6f7348a99aea0d1b040fca6ea9d493b.zip
opensim-SC_OLD-4240f2dec6f7348a99aea0d1b040fca6ea9d493b.tar.gz
opensim-SC_OLD-4240f2dec6f7348a99aea0d1b040fca6ea9d493b.tar.bz2
opensim-SC_OLD-4240f2dec6f7348a99aea0d1b040fca6ea9d493b.tar.xz
New LL login service is working! -- tested in standalone only. Things still missing from response, namely Library and Friends. Appearance service is also missing.
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs8
-rw-r--r--OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs4
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginResponse.cs18
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs189
-rw-r--r--OpenSim/Services/PresenceService/PresenceService.cs40
5 files changed, 159 insertions, 100 deletions
diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
index ab50943..021dcf3 100644
--- a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
+++ b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
@@ -47,9 +47,9 @@ namespace OpenSim.Services.AuthenticationService
47 public class PasswordAuthenticationService : 47 public class PasswordAuthenticationService :
48 AuthenticationServiceBase, IAuthenticationService 48 AuthenticationServiceBase, IAuthenticationService
49 { 49 {
50// private static readonly ILog m_log = 50 //private static readonly ILog m_log =
51// LogManager.GetLogger( 51 // LogManager.GetLogger(
52// MethodBase.GetCurrentMethod().DeclaringType); 52 // MethodBase.GetCurrentMethod().DeclaringType);
53 53
54 public PasswordAuthenticationService(IConfigSource config) : 54 public PasswordAuthenticationService(IConfigSource config) :
55 base(config) 55 base(config)
@@ -69,6 +69,8 @@ namespace OpenSim.Services.AuthenticationService
69 string hashed = Util.Md5Hash(password + ":" + 69 string hashed = Util.Md5Hash(password + ":" +
70 data.Data["passwordSalt"].ToString()); 70 data.Data["passwordSalt"].ToString());
71 71
72 //m_log.DebugFormat("[PASS AUTH]: got {0}; hashed = {1}; stored = {2}", password, hashed, data.Data["passwordHash"].ToString());
73
72 if (data.Data["passwordHash"].ToString() == hashed) 74 if (data.Data["passwordHash"].ToString() == hashed)
73 { 75 {
74 return GetToken(principalID, lifetime); 76 return GetToken(principalID, lifetime);
diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs
index 19bb3e2..1250658 100644
--- a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs
@@ -67,7 +67,7 @@ namespace OpenSim.Services.Connectors
67 IConfig assetConfig = source.Configs["AuthenticationService"]; 67 IConfig assetConfig = source.Configs["AuthenticationService"];
68 if (assetConfig == null) 68 if (assetConfig == null)
69 { 69 {
70 m_log.Error("[USER CONNECTOR]: AuthenticationService missing from OpanSim.ini"); 70 m_log.Error("[AUTH CONNECTOR]: AuthenticationService missing from OpanSim.ini");
71 throw new Exception("Authentication connector init error"); 71 throw new Exception("Authentication connector init error");
72 } 72 }
73 73
@@ -76,7 +76,7 @@ namespace OpenSim.Services.Connectors
76 76
77 if (serviceURI == String.Empty) 77 if (serviceURI == String.Empty)
78 { 78 {
79 m_log.Error("[USER CONNECTOR]: No Server URI named in section AuthenticationService"); 79 m_log.Error("[AUTH CONNECTOR]: No Server URI named in section AuthenticationService");
80 throw new Exception("Authentication connector init error"); 80 throw new Exception("Authentication connector init error");
81 } 81 }
82 m_ServerURI = serviceURI; 82 m_ServerURI = serviceURI;
diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
index 18a4f02..c80ab7f 100644
--- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
@@ -51,6 +51,7 @@ namespace OpenSim.Services.LLLoginService
51 string m_login; 51 string m_login;
52 52
53 public static LLFailedLoginResponse UserProblem; 53 public static LLFailedLoginResponse UserProblem;
54 public static LLFailedLoginResponse AuthorizationProblem;
54 public static LLFailedLoginResponse GridProblem; 55 public static LLFailedLoginResponse GridProblem;
55 public static LLFailedLoginResponse InventoryProblem; 56 public static LLFailedLoginResponse InventoryProblem;
56 public static LLFailedLoginResponse DeadRegionProblem; 57 public static LLFailedLoginResponse DeadRegionProblem;
@@ -63,8 +64,11 @@ namespace OpenSim.Services.LLLoginService
63 UserProblem = new LLFailedLoginResponse("key", 64 UserProblem = new LLFailedLoginResponse("key",
64 "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", 65 "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.",
65 "false"); 66 "false");
67 AuthorizationProblem = new LLFailedLoginResponse("key",
68 "Error connecting to grid. Unable to authorize your session into the region.",
69 "false");
66 GridProblem = new LLFailedLoginResponse("key", 70 GridProblem = new LLFailedLoginResponse("key",
67 "Error connecting to grid. Could not percieve credentials from login XML.", 71 "Error connecting to the desired location. Try connecting to another region.",
68 "false"); 72 "false");
69 InventoryProblem = new LLFailedLoginResponse("key", 73 InventoryProblem = new LLFailedLoginResponse("key",
70 "The inventory service is not responding. Please notify your login region operator.", 74 "The inventory service is not responding. Please notify your login region operator.",
@@ -288,8 +292,8 @@ namespace OpenSim.Services.LLLoginService
288 292
289 Home = string.Format( 293 Home = string.Format(
290 "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", 294 "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
291 home.RegionLocX, 295 x,
292 home.RegionLocY, 296 y,
293 pinfo.HomePosition.X, pinfo.HomePosition.Y, pinfo.HomePosition.Z, 297 pinfo.HomePosition.X, pinfo.HomePosition.Y, pinfo.HomePosition.Z,
294 pinfo.HomeLookAt.X, pinfo.HomeLookAt.Y, pinfo.HomeLookAt.Z); 298 pinfo.HomeLookAt.X, pinfo.HomeLookAt.Y, pinfo.HomeLookAt.Z);
295 299
@@ -441,8 +445,8 @@ namespace OpenSim.Services.LLLoginService
441 responseData["home"] = home; 445 responseData["home"] = home;
442 responseData["look_at"] = lookAt; 446 responseData["look_at"] = lookAt;
443 responseData["message"] = welcomeMessage; 447 responseData["message"] = welcomeMessage;
444 responseData["region_x"] = (Int32)(RegionX * Constants.RegionSize); 448 responseData["region_x"] = (Int32)(RegionX);
445 responseData["region_y"] = (Int32)(RegionY * Constants.RegionSize); 449 responseData["region_y"] = (Int32)(RegionY);
446 450
447 if (m_buddyList != null) 451 if (m_buddyList != null)
448 { 452 {
@@ -537,8 +541,8 @@ namespace OpenSim.Services.LLLoginService
537 map["home"] = OSD.FromString(home); 541 map["home"] = OSD.FromString(home);
538 map["look_at"] = OSD.FromString(lookAt); 542 map["look_at"] = OSD.FromString(lookAt);
539 map["message"] = OSD.FromString(welcomeMessage); 543 map["message"] = OSD.FromString(welcomeMessage);
540 map["region_x"] = OSD.FromInteger(RegionX * Constants.RegionSize); 544 map["region_x"] = OSD.FromInteger(RegionX);
541 map["region_y"] = OSD.FromInteger(RegionY * Constants.RegionSize); 545 map["region_y"] = OSD.FromInteger(RegionY);
542 546
543 if (m_buddyList != null) 547 if (m_buddyList != null)
544 { 548 {
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index 57b703c..ba3fd53 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -75,104 +75,120 @@ namespace OpenSim.Services.LLLoginService
75 public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, IPEndPoint clientIP) 75 public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, IPEndPoint clientIP)
76 { 76 {
77 bool success = false; 77 bool success = false;
78 UUID session = UUID.Random();
78 79
79 // Get the account and check that it exists 80 try
80 UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName);
81 if (account == null)
82 { 81 {
83 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: user not found"); 82 // Get the account and check that it exists
84 return LLFailedLoginResponse.UserProblem; 83 UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName);
85 } 84 if (account == null)
85 {
86 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: user not found");
87 return LLFailedLoginResponse.UserProblem;
88 }
86 89
87 // Authenticate this user 90 // Authenticate this user
88 string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30); 91 if (!passwd.StartsWith("$1$"))
89 UUID secureSession = UUID.Zero; 92 passwd = "$1$" + Util.Md5Hash(passwd);
90 if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession))) 93 passwd = passwd.Remove(0, 3); //remove $1$
91 { 94 string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30);
92 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: authentication failed"); 95 UUID secureSession = UUID.Zero;
93 return LLFailedLoginResponse.UserProblem; 96 if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession)))
94 } 97 {
98 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: authentication failed");
99 return LLFailedLoginResponse.UserProblem;
100 }
95 101
96 // Get the user's inventory 102 // Get the user's inventory
97 List<InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID); 103 List<InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID);
98 if (m_RequireInventory && ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0))) 104 if (m_RequireInventory && ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0)))
99 { 105 {
100 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: unable to retrieve user inventory"); 106 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: unable to retrieve user inventory");
101 return LLFailedLoginResponse.InventoryProblem; 107 return LLFailedLoginResponse.InventoryProblem;
102 } 108 }
103 109
104 // Login the presence 110 // Login the presence
105 // We may want to check for user already logged in, to 111 // We may want to check for user already logged in, to
106 // stay compatible with what people expect... 112 // stay compatible with what people expect...
107 UUID session = UUID.Random(); 113 PresenceInfo presence = null;
108 PresenceInfo presence = null; 114 GridRegion home = null;
109 GridRegion home = null; 115 if (m_PresenceService != null)
110 if (m_PresenceService != null) 116 {
111 { 117 success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession);
112 success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession); 118 if (!success)
113 if (!success) 119 {
120 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: could not login presence");
121 return LLFailedLoginResponse.GridProblem;
122 }
123
124 // Get the updated presence info
125 presence = m_PresenceService.GetAgent(session);
126
127 // Get the home region
128 if ((presence.HomeRegionID != UUID.Zero) && m_GridService != null)
129 {
130 home = m_GridService.GetRegionByUUID(account.ScopeID, presence.HomeRegionID);
131 }
132 }
133
134 // Find the destination region/grid
135 string where = string.Empty;
136 Vector3 position = Vector3.Zero;
137 Vector3 lookAt = Vector3.Zero;
138 GridRegion destination = FindDestination(account, presence, session, startLocation, out where, out position, out lookAt);
139 if (destination == null)
114 { 140 {
115 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: could not login presence"); 141 m_PresenceService.LogoutAgent(session);
142 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: destination not found");
116 return LLFailedLoginResponse.GridProblem; 143 return LLFailedLoginResponse.GridProblem;
117 } 144 }
118 // Get the updated presence info
119 presence = m_PresenceService.GetAgent(session);
120 145
121 // Get the home region 146 // Instantiate/get the simulation interface and launch an agent at the destination
122 if ((presence.HomeRegionID != UUID.Zero) && m_GridService != null) 147 ISimulationService simConnector = null;
148 string reason = string.Empty;
149 uint circuitCode = 0;
150 AgentCircuitData aCircuit = null;
151 Object[] args = new Object[] { destination };
152 // HG standalones have both a localSimulatonDll and a remoteSimulationDll
153 // non-HG standalones have just a localSimulationDll
154 // independent login servers have just a remoteSimulationDll
155 if (!startLocation.Contains("@") && (m_LocalSimulationService != null))
156 simConnector = m_LocalSimulationService;
157 else if (m_RemoteSimulationDll != string.Empty)
158 simConnector = ServerUtils.LoadPlugin<ISimulationService>(m_RemoteSimulationDll, args);
159 if (simConnector != null)
123 { 160 {
124 home = m_GridService.GetRegionByUUID(account.ScopeID, presence.HomeRegionID); 161 circuitCode = (uint)Util.RandomClass.Next(); ;
162 aCircuit = LaunchAgent(simConnector, destination, account, session, secureSession, circuitCode, position, out reason);
163 }
164 if (aCircuit == null)
165 {
166 m_PresenceService.LogoutAgent(session);
167 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: {0}", reason);
168 return LLFailedLoginResponse.AuthorizationProblem;
125 } 169 }
126 }
127 170
128 // Find the destination region/grid 171 // TODO: Get Friends list...
129 string where = string.Empty;
130 Vector3 position = Vector3.Zero;
131 Vector3 lookAt = Vector3.Zero;
132 GridRegion destination = FindDestination(account, presence, session, startLocation, out where, out position, out lookAt);
133 if (destination == null)
134 {
135 m_PresenceService.LogoutAgent(session);
136 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: destination not found");
137 return LLFailedLoginResponse.GridProblem;
138 }
139 172
140 // Instantiate/get the simulation interface and launch an agent at the destination 173 // Finally, fill out the response and return it
141 ISimulationService simConnector = null; 174 LLLoginResponse response = new LLLoginResponse(account, aCircuit, presence, destination, inventorySkel,
142 string reason = string.Empty; 175 where, startLocation, position, lookAt, m_WelcomeMessage, home, clientIP);
143 uint circuitCode = 0; 176
144 AgentCircuitData aCircuit = null; 177 return response;
145 Object[] args = new Object[] { destination };
146 // HG standalones have both a localSimulatonDll and a remoteSimulationDll
147 // non-HG standalones have just a localSimulationDll
148 // independent login servers have just a remoteSimulationDll
149 if (!startLocation.Contains("@") && (m_LocalSimulationService != null))
150 simConnector = m_LocalSimulationService;
151 else if (m_RemoteSimulationDll != string.Empty)
152 simConnector = ServerUtils.LoadPlugin<ISimulationService>(m_RemoteSimulationDll, args);
153 if (simConnector != null)
154 {
155 circuitCode = (uint)Util.RandomClass.Next(); ;
156 aCircuit = LaunchAgent(simConnector, destination, account, session, secureSession, circuitCode, position, out reason);
157 } 178 }
158 if (aCircuit == null) 179 catch (Exception e)
159 { 180 {
160 m_PresenceService.LogoutAgent(session); 181 m_log.WarnFormat("[LLOGIN SERVICE]: Exception processing login for {0} {1}: {2}", firstName, lastName, e.StackTrace);
161 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: {0}", reason); 182 if (m_PresenceService != null)
162 return LLFailedLoginResponse.GridProblem; 183 m_PresenceService.LogoutAgent(session);
184 return LLFailedLoginResponse.InternalError;
163 } 185 }
164
165 // TODO: Get Friends list...
166
167 // Finally, fill out the response and return it
168 LLLoginResponse response = new LLLoginResponse(account, aCircuit, presence, destination, inventorySkel,
169 where, startLocation, position, lookAt, m_WelcomeMessage, home, clientIP);
170
171 return response;
172 } 186 }
173 187
174 private GridRegion FindDestination(UserAccount account, PresenceInfo pinfo, UUID sessionID, string startLocation, out string where, out Vector3 position, out Vector3 lookAt) 188 private GridRegion FindDestination(UserAccount account, PresenceInfo pinfo, UUID sessionID, string startLocation, out string where, out Vector3 position, out Vector3 lookAt)
175 { 189 {
190 m_log.DebugFormat("[LLOGIN SERVICE]: FindDestination for start location {0}", startLocation);
191
176 where = "home"; 192 where = "home";
177 position = new Vector3(128, 128, 0); 193 position = new Vector3(128, 128, 0);
178 lookAt = new Vector3(0, 1, 0); 194 lookAt = new Vector3(0, 1, 0);
@@ -188,7 +204,16 @@ namespace OpenSim.Services.LLLoginService
188 GridRegion region = null; 204 GridRegion region = null;
189 205
190 if (pinfo.HomeRegionID.Equals(UUID.Zero)) 206 if (pinfo.HomeRegionID.Equals(UUID.Zero))
191 region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName); 207 {
208 if (m_DefaultRegionName != string.Empty)
209 {
210 region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName);
211 where = "safe";
212 }
213 else
214 m_log.WarnFormat("[LLOGIN SERVICE]: User {0} {1} does not have a home set and this grid does not have a default location." +
215 "Please specify DefaultLocation in [LoginService]", account.FirstName, account.LastName);
216 }
192 else 217 else
193 region = m_GridService.GetRegionByUUID(account.ScopeID, pinfo.HomeRegionID); 218 region = m_GridService.GetRegionByUUID(account.ScopeID, pinfo.HomeRegionID);
194 219
@@ -207,7 +232,10 @@ namespace OpenSim.Services.LLLoginService
207 GridRegion region = null; 232 GridRegion region = null;
208 233
209 if (pinfo.RegionID.Equals(UUID.Zero)) 234 if (pinfo.RegionID.Equals(UUID.Zero))
235 {
210 region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName); 236 region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName);
237 where = "safe";
238 }
211 else 239 else
212 { 240 {
213 region = m_GridService.GetRegionByUUID(account.ScopeID, pinfo.RegionID); 241 region = m_GridService.GetRegionByUUID(account.ScopeID, pinfo.RegionID);
@@ -240,6 +268,9 @@ namespace OpenSim.Services.LLLoginService
240 { 268 {
241 if (!regionName.Contains("@")) 269 if (!regionName.Contains("@"))
242 { 270 {
271 if (m_GridService == null)
272 return null;
273
243 List<GridRegion> regions = m_GridService.GetRegionsByName(account.ScopeID, regionName, 1); 274 List<GridRegion> regions = m_GridService.GetRegionsByName(account.ScopeID, regionName, 1);
244 if ((regions == null) || (regions != null && regions.Count == 0)) 275 if ((regions == null) || (regions != null && regions.Count == 0))
245 { 276 {
diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs
index fc6a6e1..7da0f23 100644
--- a/OpenSim/Services/PresenceService/PresenceService.cs
+++ b/OpenSim/Services/PresenceService/PresenceService.cs
@@ -63,15 +63,22 @@ namespace OpenSim.Services.PresenceService
63 data.UserID = userID; 63 data.UserID = userID;
64 data.RegionID = UUID.Zero; 64 data.RegionID = UUID.Zero;
65 data.SessionID = sessionID; 65 data.SessionID = sessionID;
66 data.Data = new Dictionary<string, string>();
66 data.Data["SecureSessionID"] = secureSessionID.ToString(); 67 data.Data["SecureSessionID"] = secureSessionID.ToString();
67 data.Data["Online"] = "true"; 68 data.Data["Online"] = "true";
68 data.Data["Login"] = Util.UnixTimeSinceEpoch().ToString(); 69 data.Data["Login"] = Util.UnixTimeSinceEpoch().ToString();
69 if (d.Length > 0) 70 if (d != null && d.Length > 0)
70 { 71 {
71 data.Data["HomeRegionID"] = d[0].Data["HomeRegionID"]; 72 data.Data["HomeRegionID"] = d[0].Data["HomeRegionID"];
72 data.Data["HomePosition"] = d[0].Data["HomePosition"]; 73 data.Data["HomePosition"] = d[0].Data["HomePosition"];
73 data.Data["HomeLookAt"] = d[0].Data["HomeLookAt"]; 74 data.Data["HomeLookAt"] = d[0].Data["HomeLookAt"];
74 } 75 }
76 else
77 {
78 data.Data["HomeRegionID"] = UUID.Zero.ToString();
79 data.Data["HomePosition"] = new Vector3(128, 128, 0).ToString();
80 data.Data["HomeLookAt"] = new Vector3(0, 1, 0).ToString();
81 }
75 82
76 m_Database.Store(data); 83 m_Database.Store(data);
77 84
@@ -86,9 +93,10 @@ namespace OpenSim.Services.PresenceService
86 93
87 PresenceData[] d = m_Database.Get("UserID", data.UserID); 94 PresenceData[] d = m_Database.Get("UserID", data.UserID);
88 95
96 m_log.WarnFormat("[PRESENCE SERVICE]: LogoutAgent {0} with {1} sessions currently present", data.UserID, d.Length);
89 if (d.Length > 1) 97 if (d.Length > 1)
90 { 98 {
91 m_Database.Delete("SessionID", sessionID.ToString()); 99 m_Database.Delete("UserID", data.UserID);
92 } 100 }
93 101
94 data.Data["Online"] = "false"; 102 data.Data["Online"] = "false";
@@ -110,14 +118,28 @@ namespace OpenSim.Services.PresenceService
110 public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) 118 public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt)
111 { 119 {
112 m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent with session {0} in region {1}", sessionID, regionID); 120 m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent with session {0} in region {1}", sessionID, regionID);
113 PresenceData pdata = m_Database.Get(sessionID); 121 try
114 if (pdata == null) 122 {
115 return false; 123 PresenceData pdata = m_Database.Get(sessionID);
116 if (pdata.Data["Online"] == "false") 124 if (pdata == null)
117 return false; 125 return false;
126 if (pdata.Data == null)
127 return false;
128
129 if (!pdata.Data.ContainsKey("Online") || (pdata.Data.ContainsKey("Online") && pdata.Data["Online"] == "false"))
130 {
131 m_log.WarnFormat("[PRESENCE SERVICE]: Someone tried to report presence of an agent who's not online");
132 return false;
133 }
118 134
119 return m_Database.ReportAgent(sessionID, regionID, 135 return m_Database.ReportAgent(sessionID, regionID,
120 position.ToString(), lookAt.ToString()); 136 position.ToString(), lookAt.ToString());
137 }
138 catch (Exception e)
139 {
140 m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent threw exception {0}", e.StackTrace);
141 return false;
142 }
121 } 143 }
122 144
123 public PresenceInfo GetAgent(UUID sessionID) 145 public PresenceInfo GetAgent(UUID sessionID)