aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Common/OpenSim.Framework/UserProfileManagerBase.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Common/OpenSim.Framework/UserProfileManagerBase.cs')
-rw-r--r--Common/OpenSim.Framework/UserProfileManagerBase.cs151
1 files changed, 0 insertions, 151 deletions
diff --git a/Common/OpenSim.Framework/UserProfileManagerBase.cs b/Common/OpenSim.Framework/UserProfileManagerBase.cs
deleted file mode 100644
index 638077e..0000000
--- a/Common/OpenSim.Framework/UserProfileManagerBase.cs
+++ /dev/null
@@ -1,151 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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 System.Collections.Generic;
30using System.Text;
31using libsecondlife;
32using OpenSim.Framework.Utilities;
33using OpenSim.Framework.Inventory;
34using Db4objects.Db4o;
35
36namespace OpenSim.Framework.User
37{
38 public class UserProfileManagerBase
39 {
40
41 public Dictionary<LLUUID, UserProfile> UserProfiles = new Dictionary<LLUUID, UserProfile>();
42
43 public UserProfileManagerBase()
44 {
45 }
46
47 public virtual void InitUserProfiles()
48 {
49 IObjectContainer db;
50 db = Db4oFactory.OpenFile("userprofiles.yap");
51 IObjectSet result = db.Get(typeof(UserProfile));
52 foreach (UserProfile userprof in result)
53 {
54 UserProfiles.Add(userprof.UUID, userprof);
55 }
56 System.Console.WriteLine("UserProfiles.Cs:InitUserProfiles() - Successfully loaded " + result.Count.ToString() + " from database");
57 db.Close();
58 }
59
60 public virtual void SaveUserProfiles() // ZOMG! INEFFICIENT!
61 {
62 IObjectContainer db;
63 db = Db4oFactory.OpenFile("userprofiles.yap");
64 IObjectSet result = db.Get(typeof(UserProfile));
65 foreach (UserProfile userprof in result)
66 {
67 db.Delete(userprof);
68 db.Commit();
69 }
70 foreach (UserProfile userprof in UserProfiles.Values)
71 {
72 db.Set(userprof);
73 db.Commit();
74 }
75 db.Close();
76 }
77
78 public UserProfile GetProfileByName(string firstname, string lastname)
79 {
80 foreach (libsecondlife.LLUUID UUID in UserProfiles.Keys)
81 {
82 if (UserProfiles[UUID].firstname.Equals(firstname)) if (UserProfiles[UUID].lastname.Equals(lastname))
83 {
84 return UserProfiles[UUID];
85 }
86 }
87 return null;
88 }
89
90 public UserProfile GetProfileByLLUUID(LLUUID ProfileLLUUID)
91 {
92 return UserProfiles[ProfileLLUUID];
93 }
94
95 public virtual bool AuthenticateUser(string firstname, string lastname, string passwd)
96 {
97 UserProfile TheUser = GetProfileByName(firstname, lastname);
98 passwd = passwd.Remove(0, 3); //remove $1$
99 if (TheUser != null)
100 {
101 if (TheUser.MD5passwd == passwd)
102 {
103 System.Console.WriteLine("UserProfile - authorised " + firstname + " " + lastname);
104 return true;
105 }
106 else
107 {
108 System.Console.WriteLine("UserProfile - not authorised, password not match " + TheUser.MD5passwd + " and " + passwd);
109 return false;
110 }
111 }
112 else
113 {
114 System.Console.WriteLine("UserProfile - not authorised , unkown: " + firstname + " , " + lastname);
115 return false;
116 }
117
118 }
119
120 public void SetGod(LLUUID GodID)
121 {
122 this.UserProfiles[GodID].IsGridGod = true;
123 }
124
125 public virtual UserProfile CreateNewProfile(string firstname, string lastname, string MD5passwd)
126 {
127 System.Console.WriteLine("creating new profile for : " + firstname + " , " + lastname);
128 UserProfile newprofile = new UserProfile();
129 newprofile.homeregionhandle = Helpers.UIntsToLong((997 * 256), (996 * 256));
130 newprofile.firstname = firstname;
131 newprofile.lastname = lastname;
132 newprofile.MD5passwd = MD5passwd;
133 newprofile.UUID = LLUUID.Random();
134 newprofile.Inventory.CreateRootFolder(newprofile.UUID, true);
135 this.UserProfiles.Add(newprofile.UUID, newprofile);
136 return newprofile;
137 }
138
139 public virtual AgentInventory GetUsersInventory(LLUUID agentID)
140 {
141 UserProfile user = this.GetProfileByLLUUID(agentID);
142 if (user != null)
143 {
144 return user.Inventory;
145 }
146
147 return null;
148 }
149
150 }
151}