aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs
diff options
context:
space:
mode:
authorDan Lake2012-03-27 12:51:58 -0700
committerDan Lake2012-03-27 12:51:58 -0700
commit971d32fda3cf8384987a6709cd2242afecce13ab (patch)
tree2607c27fad429ff0036fe7b7d275ddf717397282 /OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs
parentWhen loading objects from DB, first add to scene, then call TriggerOnSceneObj... (diff)
parentHG: beginning of a more restrictive inventory access procedure (optional). Ex... (diff)
downloadopensim-SC_OLD-971d32fda3cf8384987a6709cd2242afecce13ab.zip
opensim-SC_OLD-971d32fda3cf8384987a6709cd2242afecce13ab.tar.gz
opensim-SC_OLD-971d32fda3cf8384987a6709cd2242afecce13ab.tar.bz2
opensim-SC_OLD-971d32fda3cf8384987a6709cd2242afecce13ab.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs161
1 files changed, 161 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs
new file mode 100644
index 0000000..4eecaa2
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs
@@ -0,0 +1,161 @@
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 */
27using System;
28using System.Collections.Generic;
29using System.IO;
30using System.Reflection;
31
32using OpenSim.Framework;
33using OpenSim.Framework.Console;
34using OpenSim.Region.Framework;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Services.Interfaces;
38using OpenSim.Services.Connectors.Hypergrid;
39
40using OpenMetaverse;
41using OpenMetaverse.Packets;
42using log4net;
43using Nini.Config;
44
45namespace OpenSim.Region.CoreModules.Framework.UserManagement
46{
47 public class HGUserManagementModule : UserManagementModule, ISharedRegionModule, IUserManagement
48 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51
52 #region ISharedRegionModule
53
54 public new void Initialise(IConfigSource config)
55 {
56 string umanmod = config.Configs["Modules"].GetString("UserManagementModule", base.Name);
57 if (umanmod == Name)
58 {
59 m_Enabled = true;
60 RegisterConsoleCmds();
61 m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name);
62 }
63 }
64
65 public override string Name
66 {
67 get { return "HGUserManagementModule"; }
68 }
69
70 #endregion ISharedRegionModule
71
72 protected override void AddAdditionalUsers(UUID avatarID, string query, List<UserData> users)
73 {
74 if (query.Contains("@")) // First.Last@foo.com, maybe?
75 {
76 string[] words = query.Split(new char[] { '@' });
77 if (words.Length != 2)
78 {
79 m_log.DebugFormat("[USER MANAGEMENT MODULE]: Malformed address {0}", query);
80 return;
81 }
82
83 words[0] = words[0].Trim(); // it has at least 1
84 words[1] = words[1].Trim();
85
86 if (words[0] == String.Empty) // query was @foo.com?
87 {
88 foreach (UserData d in m_UserCache.Values)
89 {
90 if (d.LastName.ToLower().StartsWith("@" + words[1].ToLower()))
91 users.Add(d);
92 }
93
94 // We're done
95 return;
96 }
97
98 // words.Length == 2 and words[0] != string.empty
99 // first.last@foo.com ?
100 foreach (UserData d in m_UserCache.Values)
101 {
102 if (d.LastName.StartsWith("@") &&
103 d.FirstName.ToLower().Equals(words[0].ToLower()) &&
104 d.LastName.ToLower().Equals("@" + words[1].ToLower()))
105 {
106 users.Add(d);
107 // It's cached. We're done
108 return;
109 }
110 }
111
112 // This is it! Let's ask the other world
113 if (words[0].Contains("."))
114 {
115 string[] names = words[0].Split(new char[] { '.' });
116 if (names.Length >= 2)
117 {
118
119 string uriStr = "http://" + words[1];
120 // Let's check that the last name is a valid address
121 try
122 {
123 new Uri(uriStr);
124 }
125 catch (UriFormatException)
126 {
127 m_log.DebugFormat("[USER MANAGEMENT MODULE]: Malformed address {0}", uriStr);
128 return;
129 }
130
131 UserAgentServiceConnector uasConn = new UserAgentServiceConnector(uriStr);
132 UUID userID = uasConn.GetUUID(names[0], names[1]);
133 if (!userID.Equals(UUID.Zero))
134 {
135 UserData ud = new UserData();
136 ud.Id = userID;
137 ud.FirstName = words[0];
138 ud.LastName = "@" + words[1];
139 users.Add(ud);
140 AddUser(userID, names[0], names[1], uriStr);
141 m_log.DebugFormat("[USER MANAGEMENT MODULE]: User {0}@{1} found", words[0], words[1]);
142 }
143 else
144 m_log.DebugFormat("[USER MANAGEMENT MODULE]: User {0}@{1} not found", words[0], words[1]);
145 }
146 }
147 }
148 //else
149 //{
150 // foreach (UserData d in m_UserCache.Values)
151 // {
152 // if (d.LastName.StartsWith("@") &&
153 // (d.FirstName.ToLower().StartsWith(query.ToLower()) ||
154 // d.LastName.ToLower().StartsWith(query.ToLower())))
155 // users.Add(d);
156 // }
157 //}
158 }
159
160 }
161} \ No newline at end of file