aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2009-09-04 00:55:21 +0100
committerMelanie2009-09-04 00:55:21 +0100
commite39d0ef6272d5ef837e6cc5339d00abdb42317e6 (patch)
tree584ed94cde2efe297cc4eff2ccb1b785fb416b31 /OpenSim
parentAdd the user authentication data adapter. This is meant to use a new table (diff)
downloadopensim-SC_OLD-e39d0ef6272d5ef837e6cc5339d00abdb42317e6.zip
opensim-SC_OLD-e39d0ef6272d5ef837e6cc5339d00abdb42317e6.tar.gz
opensim-SC_OLD-e39d0ef6272d5ef837e6cc5339d00abdb42317e6.tar.bz2
opensim-SC_OLD-e39d0ef6272d5ef837e6cc5339d00abdb42317e6.tar.xz
Flech out the Authentication service. Add the database loader. Introduce
inheritance to deal with common tasks like crypto. Still untested.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs106
-rw-r--r--OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs25
-rw-r--r--OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs25
3 files changed, 130 insertions, 26 deletions
diff --git a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
new file mode 100644
index 0000000..57d0300
--- /dev/null
+++ b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
@@ -0,0 +1,106 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using OpenMetaverse;
30using log4net;
31using Nini.Config;
32using System.Reflection;
33using OpenSim.Services.Base;
34using OpenSim.Data;
35
36namespace OpenSim.Services.AuthenticationService
37{
38 // Generic Authentication service used for identifying
39 // and authenticating principals.
40 // Principals may be clients acting on users' behalf,
41 // or any other components that need
42 // verifiable identification.
43 //
44 public class AuthenticationServiceBase : ServiceBase
45 {
46 private static readonly ILog m_log =
47 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType);
49
50 protected IAuthenticationData m_Database;
51
52 public AuthenticationServiceBase(IConfigSource config) : base(config)
53 {
54 string dllName = String.Empty;
55 string connString = String.Empty;
56
57 //
58 // Try reading the [AuthenticationService] section first, if it exists
59 //
60 IConfig authConfig = config.Configs["AuthenticationService"];
61 if (authConfig != null)
62 {
63 dllName = authConfig.GetString("StorageProvider", dllName);
64 connString = authConfig.GetString("ConnectionString", connString);
65 }
66
67 //
68 // Try reading the [DatabaseService] section, if it exists
69 //
70 IConfig dbConfig = config.Configs["DatabaseService"];
71 if (dbConfig != null)
72 {
73 if (dllName == String.Empty)
74 dllName = dbConfig.GetString("StorageProvider", String.Empty);
75 if (connString == String.Empty)
76 connString = dbConfig.GetString("ConnectionString", String.Empty);
77 }
78
79 //
80 // We tried, but this doesn't exist. We can't proceed.
81 //
82 if (dllName.Equals(String.Empty))
83 throw new Exception("No StorageProvider configured");
84
85 m_Database = LoadPlugin<IAuthenticationData>(dllName,
86 new Object[] {connString});
87 if (m_Database == null)
88 throw new Exception("Could not find a storage interface in the given module");
89 }
90
91 public virtual byte[] GetPublicKey()
92 {
93 return new byte[0];
94 }
95
96 public virtual bool Release(UUID principalID, string token)
97 {
98 return false;
99 }
100
101 public virtual bool ReleaseEncrypted(byte[] cyphertext, byte[] key)
102 {
103 return false;
104 }
105 }
106}
diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
index d20edb3..5c83299 100644
--- a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
+++ b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
@@ -27,6 +27,10 @@
27 27
28using System; 28using System;
29using OpenMetaverse; 29using OpenMetaverse;
30using OpenSim.Services.Interfaces;
31using log4net;
32using Nini.Config;
33using System.Reflection;
30 34
31namespace OpenSim.Services.AuthenticationService 35namespace OpenSim.Services.AuthenticationService
32{ 36{
@@ -36,11 +40,16 @@ namespace OpenSim.Services.AuthenticationService
36 // or any other components that need 40 // or any other components that need
37 // verifiable identification. 41 // verifiable identification.
38 // 42 //
39 public class PasswordAuthenticationService 43 public class PasswordAuthenticationService :
44 AuthenticationServiceBase, IAuthenticationService
40 { 45 {
41 public byte[] GetPublicKey() 46 private static readonly ILog m_log =
47 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType);
49
50 public PasswordAuthenticationService(IConfigSource config) :
51 base(config)
42 { 52 {
43 return new byte[0];
44 } 53 }
45 54
46 public string Authenticate(UUID principalID, string password) 55 public string Authenticate(UUID principalID, string password)
@@ -62,15 +71,5 @@ namespace OpenSim.Services.AuthenticationService
62 { 71 {
63 return false; 72 return false;
64 } 73 }
65
66 public bool Release(UUID principalID, string token)
67 {
68 return false;
69 }
70
71 public bool ReleaseEncrypted(byte[] cyphertext, byte[] key)
72 {
73 return false;
74 }
75 } 74 }
76} 75}
diff --git a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
index 478d259..af55df0 100644
--- a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
+++ b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
@@ -27,6 +27,10 @@
27 27
28using System; 28using System;
29using OpenMetaverse; 29using OpenMetaverse;
30using OpenSim.Services.Interfaces;
31using log4net;
32using Nini.Config;
33using System.Reflection;
30 34
31namespace OpenSim.Services.AuthenticationService 35namespace OpenSim.Services.AuthenticationService
32{ 36{
@@ -36,11 +40,16 @@ namespace OpenSim.Services.AuthenticationService
36 // or any other components that need 40 // or any other components that need
37 // verifiable identification. 41 // verifiable identification.
38 // 42 //
39 public class WebkeyAuthenticationService 43 public class WebkeyAuthenticationService :
44 AuthenticationServiceBase, IAuthenticationService
40 { 45 {
41 public byte[] GetPublicKey() 46 private static readonly ILog m_log =
47 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType);
49
50 public WebkeyAuthenticationService(IConfigSource config) :
51 base(config)
42 { 52 {
43 return new byte[0];
44 } 53 }
45 54
46 public string Authenticate(UUID principalID, string password) 55 public string Authenticate(UUID principalID, string password)
@@ -62,15 +71,5 @@ namespace OpenSim.Services.AuthenticationService
62 { 71 {
63 return false; 72 return false;
64 } 73 }
65
66 public bool Release(UUID principalID, string token)
67 {
68 return false;
69 }
70
71 public bool ReleaseEncrypted(byte[] cyphertext, byte[] key)
72 {
73 return false;
74 }
75 } 74 }
76} 75}