aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Grid/UserServer')
-rw-r--r--OpenSim/Grid/UserServer/Main.cs219
-rw-r--r--OpenSim/Grid/UserServer/OpenSim.Grid.UserServer.csproj132
-rw-r--r--OpenSim/Grid/UserServer/OpenSim.Grid.UserServer.csproj.user12
-rw-r--r--OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Grid/UserServer/UserManager.cs103
5 files changed, 499 insertions, 0 deletions
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
new file mode 100644
index 0000000..5c27d57
--- /dev/null
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -0,0 +1,219 @@
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*/
28
29using System;
30using System.Collections;
31using System.Collections.Generic;
32using System.Reflection;
33using System.IO;
34using System.Text;
35using libsecondlife;
36using OpenSim.Framework.User;
37using OpenSim.Framework.Sims;
38using OpenSim.Framework.Inventory;
39using OpenSim.Framework.Interfaces;
40using OpenSim.Framework.Console;
41using OpenSim.Servers;
42using OpenSim.Framework.Utilities;
43using OpenSim.GenericConfig;
44
45namespace OpenGridServices.UserServer
46{
47 /// <summary>
48 /// </summary>
49 public class OpenUser_Main : conscmd_callback
50 {
51 private string ConfigDll = "OpenUser.Config.UserConfigDb4o.dll";
52 private string StorageDll = "OpenGrid.Framework.Data.MySQL.dll";
53 private UserConfig Cfg;
54 protected IGenericConfig localXMLConfig;
55
56 public UserManager m_userManager;
57
58 public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>();
59
60 LogBase m_console;
61
62 [STAThread]
63 public static void Main(string[] args)
64 {
65 Console.WriteLine("Launching UserServer...");
66
67 OpenUser_Main userserver = new OpenUser_Main();
68
69 userserver.Startup();
70 userserver.Work();
71 }
72
73 private OpenUser_Main()
74 {
75 m_console = new LogBase("opengrid-userserver-console.log", "OpenUser", this , false);
76 OpenSim.Framework.Console.MainLog.Instance = m_console;
77 }
78
79 private void Work()
80 {
81 m_console.Notice("Enter help for a list of commands\n");
82
83 while (true)
84 {
85 m_console.MainLogPrompt();
86 }
87 }
88
89 public void Startup()
90 {
91 this.localXMLConfig = new XmlConfig("UserServerConfig.xml");
92 this.localXMLConfig.LoadData();
93 this.ConfigDB(this.localXMLConfig);
94 this.localXMLConfig.Close();
95
96 OpenSim.Framework.Console.MainLog.Instance.Verbose("Main.cs:Startup() - Loading configuration");
97 Cfg = this.LoadConfigDll(this.ConfigDll);
98 Cfg.InitConfig();
99
100 OpenSim.Framework.Console.MainLog.Instance.Verbose("Main.cs:Startup() - Establishing data connection");
101 m_userManager = new UserManager();
102 m_userManager._config = Cfg;
103 m_userManager.AddPlugin(StorageDll);
104
105 OpenSim.Framework.Console.MainLog.Instance.Verbose("Main.cs:Startup() - Starting HTTP process");
106 BaseHttpServer httpServer = new BaseHttpServer(8002);
107
108 httpServer.AddXmlRPCHandler("login_to_simulator", m_userManager.XmlRpcLoginMethod);
109
110 httpServer.AddRestHandler("GET", "/user/name/", m_userManager.RestGetUserMethodName);
111 httpServer.AddRestHandler("GET", "/user/uuid/", m_userManager.RestGetUserMethodUUID);
112
113 httpServer.AddRestHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod);
114
115 httpServer.Start();
116 m_console.Status("Userserver 0.3 - Startup complete");
117 }
118
119
120 public void do_create(string what)
121 {
122 switch (what)
123 {
124 case "user":
125 string tempfirstname;
126 string templastname;
127 string tempMD5Passwd;
128 uint regX = 997;
129 uint regY = 996;
130
131 tempfirstname = m_console.CmdPrompt("First name");
132 templastname = m_console.CmdPrompt("Last name");
133 tempMD5Passwd = m_console.PasswdPrompt("Password");
134 regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X"));
135 regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y"));
136
137 tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + "");
138
139 m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
140 break;
141 }
142 }
143
144 public void RunCmd(string cmd, string[] cmdparams)
145 {
146 switch (cmd)
147 {
148 case "help":
149 m_console.Notice("create user - create a new user");
150 m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)");
151 break;
152
153 case "create":
154 do_create(cmdparams[0]);
155 break;
156
157 case "shutdown":
158 m_console.Close();
159 Environment.Exit(0);
160 break;
161 }
162 }
163
164 private void ConfigDB(IGenericConfig configData)
165 {
166 try
167 {
168 string attri = "";
169 attri = configData.GetAttribute("DataBaseProvider");
170 if (attri == "")
171 {
172 StorageDll = "OpenGrid.Framework.Data.DB4o.dll";
173 configData.SetAttribute("DataBaseProvider", "OpenGrid.Framework.Data.DB4o.dll");
174 }
175 else
176 {
177 StorageDll = attri;
178 }
179 configData.Commit();
180 }
181 catch (Exception e)
182 {
183
184 }
185 }
186
187 private UserConfig LoadConfigDll(string dllName)
188 {
189 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
190 UserConfig config = null;
191
192 foreach (Type pluginType in pluginAssembly.GetTypes())
193 {
194 if (pluginType.IsPublic)
195 {
196 if (!pluginType.IsAbstract)
197 {
198 Type typeInterface = pluginType.GetInterface("IUserConfig", true);
199
200 if (typeInterface != null)
201 {
202 IUserConfig plug = (IUserConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
203 config = plug.GetConfigObject();
204 break;
205 }
206
207 typeInterface = null;
208 }
209 }
210 }
211 pluginAssembly = null;
212 return config;
213 }
214
215 public void Show(string ShowWhat)
216 {
217 }
218 }
219}
diff --git a/OpenSim/Grid/UserServer/OpenSim.Grid.UserServer.csproj b/OpenSim/Grid/UserServer/OpenSim.Grid.UserServer.csproj
new file mode 100644
index 0000000..3c93b78
--- /dev/null
+++ b/OpenSim/Grid/UserServer/OpenSim.Grid.UserServer.csproj
@@ -0,0 +1,132 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{2FC96F92-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Grid.UserServer</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Exe</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Grid.UserServer</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="Db4objects.Db4o.dll" >
62 <HintPath>..\..\..\bin\Db4objects.Db4o.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="libsecondlife.dll" >
66 <HintPath>..\..\..\bin\libsecondlife.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="OpenSim.Framework" >
70 <HintPath>OpenSim.Framework.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="OpenSim.Framework.Console" >
74 <HintPath>OpenSim.Framework.Console.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 <Reference Include="OpenSim.Framework.GenericConfig.Xml" >
78 <HintPath>OpenSim.Framework.GenericConfig.Xml.dll</HintPath>
79 <Private>False</Private>
80 </Reference>
81 <Reference Include="OpenSim.Framework.Servers" >
82 <HintPath>OpenSim.Framework.Servers.dll</HintPath>
83 <Private>False</Private>
84 </Reference>
85 <Reference Include="OpenSim.Framework.UserManager" >
86 <HintPath>OpenSim.Framework.UserManager.dll</HintPath>
87 <Private>False</Private>
88 </Reference>
89 <Reference Include="System" >
90 <HintPath>System.dll</HintPath>
91 <Private>False</Private>
92 </Reference>
93 <Reference Include="System.Data" >
94 <HintPath>System.Data.dll</HintPath>
95 <Private>False</Private>
96 </Reference>
97 <Reference Include="System.Xml" >
98 <HintPath>System.Xml.dll</HintPath>
99 <Private>False</Private>
100 </Reference>
101 <Reference Include="XMLRPC.dll" >
102 <HintPath>..\..\..\bin\XMLRPC.dll</HintPath>
103 <Private>False</Private>
104 </Reference>
105 </ItemGroup>
106 <ItemGroup>
107 <ProjectReference Include="..\..\Framework\Data\OpenSim.Framework.Data.csproj">
108 <Name>OpenSim.Framework.Data</Name>
109 <Project>{36B72A9B-0000-0000-0000-000000000000}</Project>
110 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
111 <Private>False</Private>
112 </ProjectReference>
113 </ItemGroup>
114 <ItemGroup>
115 <Compile Include="Main.cs">
116 <SubType>Code</SubType>
117 </Compile>
118 <Compile Include="UserManager.cs">
119 <SubType>Code</SubType>
120 </Compile>
121 <Compile Include="Properties\AssemblyInfo.cs">
122 <SubType>Code</SubType>
123 </Compile>
124 </ItemGroup>
125 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
126 <PropertyGroup>
127 <PreBuildEvent>
128 </PreBuildEvent>
129 <PostBuildEvent>
130 </PostBuildEvent>
131 </PropertyGroup>
132</Project>
diff --git a/OpenSim/Grid/UserServer/OpenSim.Grid.UserServer.csproj.user b/OpenSim/Grid/UserServer/OpenSim.Grid.UserServer.csproj.user
new file mode 100644
index 0000000..6841907
--- /dev/null
+++ b/OpenSim/Grid/UserServer/OpenSim.Grid.UserServer.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-06\NameSpaceChanges\bin\</ReferencePath>
6 <LastOpenVersion>8.0.50727</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>
diff --git a/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs b/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..5d5ce8d
--- /dev/null
+++ b/OpenSim/Grid/UserServer/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly.
8[assembly: AssemblyTitle("OGS-UserServer")]
9[assembly: AssemblyDescription("")]
10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("")]
12[assembly: AssemblyProduct("OGS-UserServer")]
13[assembly: AssemblyCopyright("Copyright © 2007")]
14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")]
16
17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)]
21
22// The following GUID is for the ID of the typelib if this project is exposed to COM
23[assembly: Guid("e266513a-090b-4d38-80f6-8599eef68c8c")]
24
25// Version information for an assembly consists of the following four values:
26//
27// Major Version
28// Minor Version
29// Build Number
30// Revision
31//
32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs
new file mode 100644
index 0000000..0704de1
--- /dev/null
+++ b/OpenSim/Grid/UserServer/UserManager.cs
@@ -0,0 +1,103 @@
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;
30using System.Collections.Generic;
31using System.Text;
32using OpenGrid.Framework.Data;
33using libsecondlife;
34using System.Reflection;
35
36using System.Xml;
37using Nwc.XmlRpc;
38using OpenSim.Framework.Sims;
39using OpenSim.Framework.Inventory;
40using OpenSim.Framework.Utilities;
41using OpenGrid.Framework.UserManagement;
42
43using System.Security.Cryptography;
44
45namespace OpenGridServices.UserServer
46{
47 public class UserManager : UserManagerBase
48 {
49 public UserManager()
50 {
51 }
52
53 /// <summary>
54 /// Customises the login response and fills in missing values.
55 /// </summary>
56 /// <param name="response">The existing response</param>
57 /// <param name="theUser">The user profile</param>
58 public override void CustomiseResponse(ref LoginResponse response, ref UserProfileData theUser)
59 {
60 // Load information from the gridserver
61 SimProfile SimInfo = new SimProfile();
62 SimInfo = SimInfo.LoadFromGrid(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey);
63
64 // Customise the response
65 // Home Location
66 response.Home = "{'region_handle':[r" + (SimInfo.RegionLocX * 256).ToString() + ",r" + (SimInfo.RegionLocY * 256).ToString() + "], " +
67 "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
68 "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
69
70 // Destination
71 response.SimAddress = SimInfo.sim_ip;
72 response.SimPort = (Int32)SimInfo.sim_port;
73 response.RegionX = SimInfo.RegionLocY ;
74 response.RegionY = SimInfo.RegionLocX ;
75
76 // Notify the target of an incoming user
77 Console.WriteLine("Notifying " + SimInfo.regionname + " (" + SimInfo.caps_url + ")");
78
79 // Prepare notification
80 Hashtable SimParams = new Hashtable();
81 SimParams["session_id"] = theUser.currentAgent.sessionID.ToString();
82 SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString();
83 SimParams["firstname"] = theUser.username;
84 SimParams["lastname"] = theUser.surname;
85 SimParams["agent_id"] = theUser.UUID.ToString();
86 SimParams["circuit_code"] = (Int32)Convert.ToUInt32(response.CircuitCode);
87 SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString();
88 SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString();
89 SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString();
90 SimParams["regionhandle"] = theUser.currentAgent.currentHandle.ToString();
91 ArrayList SendParams = new ArrayList();
92 SendParams.Add(SimParams);
93
94 // Update agent with target sim
95 theUser.currentAgent.currentRegion = SimInfo.UUID;
96 theUser.currentAgent.currentHandle = SimInfo.regionhandle;
97
98 // Send
99 XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
100 XmlRpcResponse GridResp = GridReq.Send(SimInfo.caps_url, 3000);
101 }
102 }
103}