aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.Framework/UserProfileManagerBase.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim.Framework/UserProfileManagerBase.cs91
1 files changed, 91 insertions, 0 deletions
diff --git a/OpenSim.Framework/UserProfileManagerBase.cs b/OpenSim.Framework/UserProfileManagerBase.cs
new file mode 100644
index 0000000..ad03bc2
--- /dev/null
+++ b/OpenSim.Framework/UserProfileManagerBase.cs
@@ -0,0 +1,91 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using OpenSim.Framework.Utilities;
6using OpenSim.Framework.Inventory;
7
8namespace OpenSim.Framework.User
9{
10 public class UserProfileManagerBase
11 {
12
13 public Dictionary<LLUUID, UserProfile> UserProfiles = new Dictionary<LLUUID, UserProfile>();
14
15 public UserProfileManagerBase()
16 {
17 }
18
19 public virtual void InitUserProfiles()
20 {
21 // TODO: need to load from database
22 }
23
24 public UserProfile GetProfileByName(string firstname, string lastname)
25 {
26 foreach (libsecondlife.LLUUID UUID in UserProfiles.Keys)
27 {
28 if ((UserProfiles[UUID].firstname == firstname) && (UserProfiles[UUID].lastname == lastname))
29 {
30 return UserProfiles[UUID];
31 }
32 }
33 return null;
34 }
35
36 public UserProfile GetProfileByLLUUID(LLUUID ProfileLLUUID)
37 {
38 return UserProfiles[ProfileLLUUID];
39 }
40
41 public virtual bool AuthenticateUser(string firstname, string lastname, string passwd)
42 {
43 UserProfile TheUser = GetProfileByName(firstname, lastname);
44 if (TheUser != null)
45 {
46 if (TheUser.MD5passwd == passwd)
47 {
48 return true;
49 }
50 else
51 {
52 return false;
53 }
54 }
55 else
56 {
57 return false;
58 }
59
60 }
61
62 public void SetGod(LLUUID GodID)
63 {
64 this.UserProfiles[GodID].IsGridGod = true;
65 }
66
67 public virtual UserProfile CreateNewProfile(string firstname, string lastname, string MD5passwd)
68 {
69 UserProfile newprofile = new UserProfile();
70 newprofile.homeregionhandle = Helpers.UIntsToLong((997 * 256), (996 * 256));
71 newprofile.firstname = firstname;
72 newprofile.lastname = lastname;
73 newprofile.MD5passwd = MD5passwd;
74 newprofile.UUID = LLUUID.Random();
75 this.UserProfiles.Add(newprofile.UUID, newprofile);
76 return newprofile;
77 }
78
79 public virtual AgentInventory GetUsersInventory(LLUUID agentID)
80 {
81 UserProfile user = this.GetProfileByLLUUID(agentID);
82 if (user != null)
83 {
84 return user.Inventory;
85 }
86
87 return null;
88 }
89
90 }
91}