1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- using System;
- using System.Collections.Generic;
- using OpenMetaverse;
- using OpenSim.Services.Interfaces;
- using log4net;
- using Nini.Config;
- using System.Reflection;
- using OpenSim.Data;
- using OpenSim.Framework;
- using OpenSim.Framework.Console;
- namespace OpenSim.Services.AuthenticationService
- {
-
-
-
-
-
-
- public class PasswordAuthenticationService :
- AuthenticationServiceBase, IAuthenticationService
- {
- private static readonly ILog m_log =
- LogManager.GetLogger(
- MethodBase.GetCurrentMethod().DeclaringType);
-
- public PasswordAuthenticationService(IConfigSource config) :
- base(config)
- {
- }
- public string Authenticate(UUID principalID, string password, int lifetime)
- {
- AuthenticationData data = m_Database.Get(principalID);
- if (data != null && data.Data != null)
- {
- if (!data.Data.ContainsKey("passwordHash") ||
- !data.Data.ContainsKey("passwordSalt"))
- {
- return String.Empty;
- }
- string hashed = Util.Md5Hash(password + ":" +
- data.Data["passwordSalt"].ToString());
-
- if (data.Data["passwordHash"].ToString() == hashed)
- {
- return GetToken(principalID, lifetime);
- }
- }
- m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} or its data not found", principalID);
- return String.Empty;
- }
- }
- }
|