aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
diff options
context:
space:
mode:
authorMelanie2009-09-04 00:55:21 +0100
committerMelanie2009-09-04 00:55:21 +0100
commite39d0ef6272d5ef837e6cc5339d00abdb42317e6 (patch)
tree584ed94cde2efe297cc4eff2ccb1b785fb416b31 /OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
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/Services/AuthenticationService/AuthenticationServiceBase.cs')
-rw-r--r--OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs106
1 files changed, 106 insertions, 0 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}