aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/AuthenticationService
diff options
context:
space:
mode:
authorMelanie Thielker2009-06-30 21:48:03 +0000
committerMelanie Thielker2009-06-30 21:48:03 +0000
commit858b0a2efd4790042c3e248ce895a426462a2576 (patch)
tree2d9e9f61b5ca0219537e6debbcf75c703be52854 /OpenSim/Services/AuthenticationService
parentFrom: Chris Yeoh <yeohc@au1.ibm.com> (diff)
downloadopensim-SC_OLD-858b0a2efd4790042c3e248ce895a426462a2576.zip
opensim-SC_OLD-858b0a2efd4790042c3e248ce895a426462a2576.tar.gz
opensim-SC_OLD-858b0a2efd4790042c3e248ce895a426462a2576.tar.bz2
opensim-SC_OLD-858b0a2efd4790042c3e248ce895a426462a2576.tar.xz
Updated services to allow external applications like web interfaces to
authenticate against the services. This paves the way for such apps to directly talk to services.
Diffstat (limited to 'OpenSim/Services/AuthenticationService')
-rw-r--r--OpenSim/Services/AuthenticationService/AuthenticationService.cs93
1 files changed, 85 insertions, 8 deletions
diff --git a/OpenSim/Services/AuthenticationService/AuthenticationService.cs b/OpenSim/Services/AuthenticationService/AuthenticationService.cs
index 06f0e8f..3e6c3b2 100644
--- a/OpenSim/Services/AuthenticationService/AuthenticationService.cs
+++ b/OpenSim/Services/AuthenticationService/AuthenticationService.cs
@@ -98,16 +98,70 @@ namespace OpenSim.Services.AuthenticationService
98 m_Database.Initialise(connString); 98 m_Database.Initialise(connString);
99 } 99 }
100 100
101 public UUID AuthenticateKey(UUID principalID, string key)
102 {
103 bool writeAgentData = false;
104
105 UserAgentData agent = m_Database.GetAgentByUUID(principalID);
106 if (agent == null)
107 {
108 agent = new UserAgentData();
109 agent.ProfileID = principalID;
110 agent.SessionID = UUID.Random();
111 agent.SecureSessionID = UUID.Random();
112 agent.AgentIP = "127.0.0.1";
113 agent.AgentPort = 0;
114 agent.AgentOnline = false;
115
116 writeAgentData = true;
117 }
118
119 if (!m_PerformAuthentication)
120 {
121 if (writeAgentData)
122 m_Database.AddNewUserAgent(agent);
123 return agent.SessionID;
124 }
125
126 if (!VerifyKey(principalID, key))
127 return UUID.Zero;
128
129 if (writeAgentData)
130 m_Database.AddNewUserAgent(agent);
131
132 return agent.SessionID;
133 }
134
101 /// <summary> 135 /// <summary>
102 /// This implementation only authenticates users. 136 /// This implementation only authenticates users.
103 /// </summary> 137 /// </summary>
104 /// <param name="principalID"></param> 138 /// <param name="principalID"></param>
105 /// <param name="password"></param> 139 /// <param name="password"></param>
106 /// <returns></returns> 140 /// <returns></returns>
107 public bool Authenticate(UUID principalID, string password) 141 public UUID AuthenticatePassword(UUID principalID, string password)
108 { 142 {
143 bool writeAgentData = false;
144
145 UserAgentData agent = m_Database.GetAgentByUUID(principalID);
146 if (agent == null)
147 {
148 agent = new UserAgentData();
149 agent.ProfileID = principalID;
150 agent.SessionID = UUID.Random();
151 agent.SecureSessionID = UUID.Random();
152 agent.AgentIP = "127.0.0.1";
153 agent.AgentPort = 0;
154 agent.AgentOnline = false;
155
156 writeAgentData = true;
157 }
158
109 if (!m_PerformAuthentication) 159 if (!m_PerformAuthentication)
110 return true; 160 {
161 if (writeAgentData)
162 m_Database.AddNewUserAgent(agent);
163 return agent.SessionID;
164 }
111 165
112 UserProfileData profile = m_Database.GetUserByUUID(principalID); 166 UserProfileData profile = m_Database.GetUserByUUID(principalID);
113 bool passwordSuccess = false; 167 bool passwordSuccess = false;
@@ -128,7 +182,13 @@ namespace OpenSim.Services.AuthenticationService
128 passwordSuccess = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) 182 passwordSuccess = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase)
129 || profile.PasswordHash.Equals(password, StringComparison.InvariantCulture)); 183 || profile.PasswordHash.Equals(password, StringComparison.InvariantCulture));
130 184
131 return passwordSuccess; 185 if (!passwordSuccess)
186 return UUID.Zero;
187
188 if (writeAgentData)
189 m_Database.AddNewUserAgent(agent);
190
191 return agent.SessionID;
132 } 192 }
133 193
134 /// <summary> 194 /// <summary>
@@ -203,10 +263,17 @@ namespace OpenSim.Services.AuthenticationService
203 } 263 }
204 } 264 }
205 265
206 public UUID AllocateUserSession(UUID userID) 266 public UUID CreateUserSession(UUID userID, UUID oldSessionID)
207 { 267 {
208 // Not implemented yet 268 UserAgentData agent = m_Database.GetAgentByUUID(userID);
209 return UUID.Zero; 269
270 if (agent == null)
271 return UUID.Zero;
272
273 agent.SessionID = UUID.Random();
274
275 m_Database.AddNewUserAgent(agent);
276 return agent.SessionID;
210 } 277 }
211 278
212 public bool VerifyUserSession(UUID userID, UUID sessionID) 279 public bool VerifyUserSession(UUID userID, UUID sessionID)
@@ -225,9 +292,19 @@ namespace OpenSim.Services.AuthenticationService
225 return false; 292 return false;
226 } 293 }
227 294
228 public void DestroyUserSession(UUID userID) 295 public bool DestroyUserSession(UUID userID, UUID sessionID)
229 { 296 {
230 // Not implemented yet 297 if (!VerifyUserSession(userID, sessionID))
298 return false;
299
300 UserAgentData agent = m_Database.GetAgentByUUID(userID);
301 if (agent == null)
302 return false;
303
304 agent.SessionID = UUID.Zero;
305 m_Database.AddNewUserAgent(agent);
306
307 return true;
231 } 308 }
232 } 309 }
233} 310}