Removing hard-coded plugin loading in favour of direct class instantiation

0.7.1-dev
SignpostMarv Martin 2011-03-24 17:04:29 +00:00 committed by Justin Clark-Casey (justincc)
parent 3f4be42a87
commit 361b3e7ab8
1 changed files with 5 additions and 6 deletions

View File

@ -16,25 +16,25 @@ namespace OpenSim.Services.AuthenticationService
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private IConfigSource config; private IConfigSource config;
private Dictionary<string, IAuthenticationService> svc_checks;
public WebkeyOrPasswordAuthenticationService(IConfigSource config) public WebkeyOrPasswordAuthenticationService(IConfigSource config)
: base(config) : base(config)
{ {
this.config = config; this.config = config;
svc_checks["web_login_key"] = new WebkeyAuthenticationService(config);
svc_checks["password"] = new PasswordAuthenticationService(config);
} }
public string Authenticate(UUID principalID, string password, int lifetime) public string Authenticate(UUID principalID, string password, int lifetime)
{ {
AuthenticationData data = m_Database.Get(principalID); AuthenticationData data = m_Database.Get(principalID);
IAuthenticationService svc;
Object[] args = new Object[] { config };
string result = String.Empty; string result = String.Empty;
if (data != null && data.Data != null) if (data != null && data.Data != null)
{ {
if (data.Data.ContainsKey("webLoginKey")) if (data.Data.ContainsKey("webLoginKey"))
{ {
m_log.DebugFormat("[AUTH SERVICE]: Attempting web key authentication for PrincipalID {0}", principalID); m_log.DebugFormat("[AUTH SERVICE]: Attempting web key authentication for PrincipalID {0}", principalID);
svc = ServerUtils.LoadPlugin<IAuthenticationService>("OpenSim.Services.AuthenticationService.dll", "WebkeyAuthenticationService", args); result = svc_checks["web_login_key"].Authenticate(principalID, password, lifetime);
result = svc.Authenticate(principalID, password, lifetime);
if (result == String.Empty) if (result == String.Empty)
{ {
m_log.DebugFormat("[AUTH SERVICE]: Web Login failed for PrincipalID {0}", principalID); m_log.DebugFormat("[AUTH SERVICE]: Web Login failed for PrincipalID {0}", principalID);
@ -43,8 +43,7 @@ namespace OpenSim.Services.AuthenticationService
if (result == string.Empty && data.Data.ContainsKey("passwordHash") && data.Data.ContainsKey("passwordSalt")) if (result == string.Empty && data.Data.ContainsKey("passwordHash") && data.Data.ContainsKey("passwordSalt"))
{ {
m_log.DebugFormat("[AUTH SERVICE]: Attempting password authentication for PrincipalID {0}", principalID); m_log.DebugFormat("[AUTH SERVICE]: Attempting password authentication for PrincipalID {0}", principalID);
svc = ServerUtils.LoadPlugin<IAuthenticationService>("OpenSim.Services.AuthenticationService.dll", "PasswordAuthenticationService", args); result = svc_checks["password"].Authenticate(principalID, password, lifetime);
result = svc.Authenticate(principalID, password, lifetime);
if (result == String.Empty) if (result == String.Empty)
{ {
m_log.DebugFormat("[AUTH SERVICE]: Password login failed for PrincipalID {0}", principalID); m_log.DebugFormat("[AUTH SERVICE]: Password login failed for PrincipalID {0}", principalID);