public AuthData Get(UUID principalID, string authType)
 {
     QueryFilter filter = new QueryFilter();
     filter.andFilters["UUID"] = principalID;
     filter.andFilters["accountType"] = authType;
     List<string> query = GD.Query(new string[1] { "*" }, m_realm, filter, null, null, null);
     AuthData data = null;
     for (int i = 0; i < query.Count; i += 5)
     {
         data = new AuthData
         {
             PrincipalID = UUID.Parse(query[i]),
             PasswordHash = query[i + 1],
             PasswordSalt = query[i + 2],
             AccountType = query[i + 3]
         };
     }
     return data;
 }
        public virtual bool SetPassword(UUID principalID, string authType, string password)
        {
            string passwordSalt = Util.Md5Hash(UUID.Random().ToString());
            string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + passwordSalt);

            AuthData auth = m_Database.Get(principalID, authType);
            if (auth == null)
            {
                auth = new AuthData {PrincipalID = principalID, AccountType = authType};
            }
            auth.PasswordHash = md5PasswdHash;
            auth.PasswordSalt = passwordSalt;
            if (!m_Database.Store(auth))
            {
                MainConsole.Instance.DebugFormat("[AUTHENTICATION DB]: Failed to store authentication data");
                return false;
            }

            MainConsole.Instance.InfoFormat("[AUTHENTICATION DB]: Set password for principalID {0}", principalID);
            return true;
        }
 public AuthData Get(UUID principalID, string authType)
 {
     Dictionary<string, object> where = new Dictionary<string, object>(2);
     where["UUID"] = principalID;
     where["accountType"] = authType;
     List<string> query = GD.Query(new string[1] { "*" }, m_realm, new QueryFilter{
         andFilters = where
     }, null, null, null);
     AuthData data = null;
     for (int i = 0; i < query.Count; i += 5)
     {
         data = new AuthData
         {
             PrincipalID = UUID.Parse(query[i]),
             PasswordHash = query[i + 1],
             PasswordSalt = query[i + 2],
             AccountType = query[i + 3]
         };
     }
     return data;
 }
 public bool Store(AuthData data)
 {
     GD.Delete(m_realm, new string[2] {"UUID", "accountType"}, new object[2] {data.PrincipalID, data.AccountType});
     return GD.Insert(m_realm, new[]
                                   {
                                       "UUID", "passwordHash", "passwordSalt",
                                       "accountType"
                                   }, new object[]
                                          {
                                              data.PrincipalID,
                                              data.PasswordHash.MySqlEscape(1024), data.PasswordSalt.MySqlEscape(1024),
                                              data.AccountType.MySqlEscape(32)
                                          });
 }
        public virtual bool SetPlainPassword(UUID principalID, string authType, string pass)
        {
            AuthData auth = m_Database.Get(principalID, authType);
            if (auth == null)
            {
                auth = new AuthData {PrincipalID = principalID, AccountType = authType};
            }
            auth.PasswordHash = pass;
            auth.PasswordSalt = "";
            if (!m_Database.Store(auth))
            {
                MainConsole.Instance.DebugFormat("[AUTHENTICATION DB]: Failed to store authentication data");
                return false;
            }

            MainConsole.Instance.InfoFormat("[AUTHENTICATION DB]: Set password for principalID {0}", principalID);
            return true;
        }
 public bool Store(AuthData data)
 {
     QueryFilter filter = new QueryFilter();
     filter.andFilters["UUID"] = data.PrincipalID;
     filter.andFilters["accountType"] = data.AccountType;
     GD.Delete(m_realm, filter);
     Dictionary<string, object> row = new Dictionary<string, object>(4);
     row["UUID"] = data.PrincipalID;
     row["passwordHash"] = data.PasswordHash;
     row["passwordSalt"] = data.PasswordSalt;
     row["accountType"] = data.AccountType;
     return GD.Insert(m_realm, row);
 }
 public bool Store(AuthData data)
 {
     throw new System.NotImplementedException();
 }