12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- using System;
- 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 WebkeyAuthenticationService :
- AuthenticationServiceBase, IAuthenticationService
- {
- private static readonly ILog m_log =
- LogManager.GetLogger(
- MethodBase.GetCurrentMethod().DeclaringType);
- public WebkeyAuthenticationService(IConfigSource config) :
- base(config)
- {
- }
- public string Authenticate(UUID principalID, string password, int lifetime)
- {
- if (new UUID(password) == UUID.Zero)
- {
- m_log.DebugFormat("[AUTH SERVICE]: UUID.Zero is not a valid web_login_key on PrincipalID {0}", principalID);
- }
- else
- {
- AuthenticationData data = m_Database.Get(principalID);
- if (data != null && data.Data != null)
- {
- if (data.Data.ContainsKey("webLoginKey"))
- {
- string key = data.Data["webLoginKey"].ToString();
- if (key == password)
- {
- data.Data["webLoginKey"] = UUID.Zero.ToString();
- m_Database.Store(data);
- return GetToken(principalID, lifetime);
- }
- else
- {
- m_log.DebugFormat("[AUTH SERVICE]: web login auth failed, got PrincipalID {0} gave {1} instead of {2}", principalID, password, key);
- }
- }else{
- m_log.DebugFormat("[AUTH SERVICE]: no col webLoginKey in passwd.db");
- }
- }
- m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} or its data not found", principalID);
- }
- return String.Empty;
- }
- }
- }
|