aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/AuthenticationService
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/AuthenticationService')
-rw-r--r--OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs34
-rw-r--r--OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs10
2 files changed, 37 insertions, 7 deletions
diff --git a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
index dcf090e..9af61a9 100644
--- a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
+++ b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
@@ -32,6 +32,7 @@ using Nini.Config;
32using System.Reflection; 32using System.Reflection;
33using OpenSim.Services.Base; 33using OpenSim.Services.Base;
34using OpenSim.Data; 34using OpenSim.Data;
35using OpenSim.Framework;
35 36
36namespace OpenSim.Services.AuthenticationService 37namespace OpenSim.Services.AuthenticationService
37{ 38{
@@ -43,9 +44,9 @@ namespace OpenSim.Services.AuthenticationService
43 // 44 //
44 public class AuthenticationServiceBase : ServiceBase 45 public class AuthenticationServiceBase : ServiceBase
45 { 46 {
46// private static readonly ILog m_log = 47 private static readonly ILog m_log =
47// LogManager.GetLogger( 48 LogManager.GetLogger(
48// MethodBase.GetCurrentMethod().DeclaringType); 49 MethodBase.GetCurrentMethod().DeclaringType);
49 50
50 protected IAuthenticationData m_Database; 51 protected IAuthenticationData m_Database;
51 52
@@ -100,6 +101,32 @@ namespace OpenSim.Services.AuthenticationService
100 return m_Database.CheckToken(principalID, token, 0); 101 return m_Database.CheckToken(principalID, token, 0);
101 } 102 }
102 103
104 public virtual bool SetPassword(UUID principalID, string password)
105 {
106 string passwordSalt = Util.Md5Hash(UUID.Random().ToString());
107 string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + passwordSalt);
108
109 AuthenticationData auth = m_Database.Get(principalID);
110 if (auth == null)
111 {
112 auth = new AuthenticationData();
113 auth.PrincipalID = principalID;
114 auth.Data = new System.Collections.Generic.Dictionary<string, object>();
115 auth.Data["accountType"] = "UserAccount";
116 auth.Data["webLoginKey"] = UUID.Zero.ToString();
117 }
118 auth.Data["passwordHash"] = md5PasswdHash;
119 auth.Data["passwordSalt"] = passwordSalt;
120 if (!m_Database.Store(auth))
121 {
122 m_log.DebugFormat("[AUTHENTICATION DB]: Failed to store authentication data");
123 return false;
124 }
125
126 m_log.InfoFormat("[AUTHENTICATION DB]: Set password for principalID {0}", principalID);
127 return true;
128 }
129
103 protected string GetToken(UUID principalID, int lifetime) 130 protected string GetToken(UUID principalID, int lifetime)
104 { 131 {
105 UUID token = UUID.Random(); 132 UUID token = UUID.Random();
@@ -109,5 +136,6 @@ namespace OpenSim.Services.AuthenticationService
109 136
110 return String.Empty; 137 return String.Empty;
111 } 138 }
139
112 } 140 }
113} 141}
diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
index d65665a..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)
@@ -66,9 +66,11 @@ namespace OpenSim.Services.AuthenticationService
66 return String.Empty; 66 return String.Empty;
67 } 67 }
68 68
69 string hashed = Util.Md5Hash(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);