aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices/OpenGridServices.UserServer
diff options
context:
space:
mode:
Diffstat (limited to 'OpenGridServices/OpenGridServices.UserServer')
-rw-r--r--OpenGridServices/OpenGridServices.UserServer/Main.cs217
-rw-r--r--OpenGridServices/OpenGridServices.UserServer/OGS-UserServer.csproj63
-rw-r--r--OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj128
-rw-r--r--OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj.user12
-rw-r--r--OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build51
-rw-r--r--OpenGridServices/OpenGridServices.UserServer/Properties/AssemblyInfo.cs33
-rw-r--r--OpenGridServices/OpenGridServices.UserServer/UserManager.cs597
7 files changed, 0 insertions, 1101 deletions
diff --git a/OpenGridServices/OpenGridServices.UserServer/Main.cs b/OpenGridServices/OpenGridServices.UserServer/Main.cs
deleted file mode 100644
index aec80dc..0000000
--- a/OpenGridServices/OpenGridServices.UserServer/Main.cs
+++ /dev/null
@@ -1,217 +0,0 @@
1/*
2Copyright (c) OpenSim project, http://osgrid.org/
3
4
5* All rights reserved.
6*
7* Redistribution and use in source and binary forms, with or without
8* modification, are permitted provided that the following conditions are met:
9* * Redistributions of source code must retain the above copyright
10* notice, this list of conditions and the following disclaimer.
11* * Redistributions in binary form must reproduce the above copyright
12* notice, this list of conditions and the following disclaimer in the
13* documentation and/or other materials provided with the distribution.
14* * Neither the name of the <organization> nor the
15* names of its contributors may be used to endorse or promote products
16* derived from this software without specific prior written permission.
17*
18* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
19* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
22* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30using System;
31using System.Collections;
32using System.Collections.Generic;
33using System.Reflection;
34using System.IO;
35using System.Text;
36using libsecondlife;
37using OpenSim.Framework.User;
38using OpenSim.Framework.Sims;
39using OpenSim.Framework.Inventory;
40using OpenSim.Framework.Interfaces;
41using OpenSim.Framework.Console;
42using OpenSim.Servers;
43using OpenSim.Framework.Utilities;
44using OpenSim.GenericConfig;
45
46namespace OpenGridServices.UserServer
47{
48 /// <summary>
49 /// </summary>
50 public class OpenUser_Main : BaseServer, conscmd_callback
51 {
52 private string ConfigDll = "OpenUser.Config.UserConfigDb4o.dll";
53 private string StorageDll = "OpenGrid.Framework.Data.DB4o.dll";
54 private UserConfig Cfg;
55 protected IGenericConfig localXMLConfig;
56
57 public UserManager m_userManager; // Replaces below.
58
59 //private UserProfileManager m_userProfileManager; // Depreciated
60
61 public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>();
62
63 ConsoleBase m_console;
64
65 [STAThread]
66 public static void Main(string[] args)
67 {
68 Console.WriteLine("Starting...\n");
69
70 OpenUser_Main userserver = new OpenUser_Main();
71
72 userserver.Startup();
73 userserver.Work();
74 }
75
76 private OpenUser_Main()
77 {
78 m_console = new ConsoleBase("opengrid-userserver-console.log", "OpenUser", this , false);
79 MainConsole.Instance = m_console;
80 }
81
82 private void Work()
83 {
84 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"\nEnter help for a list of commands\n");
85
86 while (true)
87 {
88 m_console.MainConsolePrompt();
89 }
90 }
91
92 public void Startup()
93 {
94 this.localXMLConfig = new XmlConfig("UserServerConfig.xml");
95 this.localXMLConfig.LoadData();
96 this.ConfigDB(this.localXMLConfig);
97 this.localXMLConfig.Close();
98
99 MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Loading configuration");
100 Cfg = this.LoadConfigDll(this.ConfigDll);
101 Cfg.InitConfig();
102
103 MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Establishing data connection");
104 m_userManager = new UserManager();
105 m_userManager._config = Cfg;
106 m_userManager.AddPlugin(StorageDll);
107
108 MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Starting HTTP process");
109 BaseHttpServer httpServer = new BaseHttpServer(8002);
110
111 httpServer.AddXmlRPCHandler("login_to_simulator", m_userManager.XmlRpcLoginMethod);
112 httpServer.AddRestHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod);
113
114 httpServer.Start();
115 }
116
117
118 public void do_create(string what)
119 {
120 switch (what)
121 {
122 case "user":
123 string tempfirstname;
124 string templastname;
125 string tempMD5Passwd;
126 uint regX = 997;
127 uint regY = 996;
128
129 tempfirstname = m_console.CmdPrompt("First name");
130 templastname = m_console.CmdPrompt("Last name");
131 tempMD5Passwd = m_console.PasswdPrompt("Password");
132 regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X"));
133 regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y"));
134
135 tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + "");
136
137 m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
138 break;
139 }
140 }
141
142 public void RunCmd(string cmd, string[] cmdparams)
143 {
144 switch (cmd)
145 {
146 case "help":
147 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"create user - create a new user");
148 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"shutdown - shutdown the grid (USE CAUTION!)");
149 break;
150
151 case "create":
152 do_create(cmdparams[0]);
153 break;
154
155 case "shutdown":
156 m_console.Close();
157 Environment.Exit(0);
158 break;
159 }
160 }
161
162 private void ConfigDB(IGenericConfig configData)
163 {
164 try
165 {
166 string attri = "";
167 attri = configData.GetAttribute("DataBaseProvider");
168 if (attri == "")
169 {
170 StorageDll = "OpenGrid.Framework.Data.DB4o.dll";
171 configData.SetAttribute("DataBaseProvider", "OpenGrid.Framework.Data.DB4o.dll");
172 }
173 else
174 {
175 StorageDll = attri;
176 }
177 configData.Commit();
178 }
179 catch (Exception e)
180 {
181
182 }
183 }
184
185 private UserConfig LoadConfigDll(string dllName)
186 {
187 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
188 UserConfig config = null;
189
190 foreach (Type pluginType in pluginAssembly.GetTypes())
191 {
192 if (pluginType.IsPublic)
193 {
194 if (!pluginType.IsAbstract)
195 {
196 Type typeInterface = pluginType.GetInterface("IUserConfig", true);
197
198 if (typeInterface != null)
199 {
200 IUserConfig plug = (IUserConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
201 config = plug.GetConfigObject();
202 break;
203 }
204
205 typeInterface = null;
206 }
207 }
208 }
209 pluginAssembly = null;
210 return config;
211 }
212
213 public void Show(string ShowWhat)
214 {
215 }
216 }
217}
diff --git a/OpenGridServices/OpenGridServices.UserServer/OGS-UserServer.csproj b/OpenGridServices/OpenGridServices.UserServer/OGS-UserServer.csproj
deleted file mode 100644
index f4fa8b6..0000000
--- a/OpenGridServices/OpenGridServices.UserServer/OGS-UserServer.csproj
+++ /dev/null
@@ -1,63 +0,0 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ProductVersion>8.0.50727</ProductVersion>
6 <SchemaVersion>2.0</SchemaVersion>
7 <ProjectGuid>{D45B6E48-5668-478D-B9CB-6D46E665FACF}</ProjectGuid>
8 <OutputType>Exe</OutputType>
9 <AppDesignerFolder>Properties</AppDesignerFolder>
10 <RootNamespace>OGS_UserServer</RootNamespace>
11 <AssemblyName>OGS-UserServer</AssemblyName>
12 <StartupObject>OpenGridServices.OpenUser_Main</StartupObject>
13 </PropertyGroup>
14 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
15 <DebugSymbols>true</DebugSymbols>
16 <DebugType>full</DebugType>
17 <Optimize>false</Optimize>
18 <OutputPath>bin\Debug\</OutputPath>
19 <DefineConstants>DEBUG;TRACE</DefineConstants>
20 <ErrorReport>prompt</ErrorReport>
21 <WarningLevel>4</WarningLevel>
22 </PropertyGroup>
23 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
24 <DebugType>pdbonly</DebugType>
25 <Optimize>true</Optimize>
26 <OutputPath>bin\Release\</OutputPath>
27 <DefineConstants>TRACE</DefineConstants>
28 <ErrorReport>prompt</ErrorReport>
29 <WarningLevel>4</WarningLevel>
30 </PropertyGroup>
31 <ItemGroup>
32 <Reference Include="libsecondlife, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
33 <SpecificVersion>False</SpecificVersion>
34 <HintPath>..\..\common\bin\libsecondlife.dll</HintPath>
35 </Reference>
36 <Reference Include="System" />
37 <Reference Include="System.Data" />
38 <Reference Include="System.Xml" />
39 </ItemGroup>
40 <ItemGroup>
41 <Compile Include="..\..\common\src\OGS-Console.cs">
42 <Link>OGS-Console.cs</Link>
43 </Compile>
44 <Compile Include="..\..\common\VersionInfo\VersionInfo.cs">
45 <Link>VersionInfo.cs</Link>
46 </Compile>
47 <Compile Include="ConsoleCmds.cs" />
48 <Compile Include="Main.cs" />
49 <Compile Include="Properties\AssemblyInfo.cs" />
50 <Compile Include="UserHttp.cs" />
51 </ItemGroup>
52 <ItemGroup>
53 <ProjectReference Include="..\..\..\OpenSim.FrameWork\OpenSim.Framework.csproj">
54 <Project>{2E46A825-3168-492F-93BC-637126B5B72B}</Project>
55 <Name>OpenSim.Framework</Name>
56 </ProjectReference>
57 <ProjectReference Include="..\..\ServerConsole\ServerConsole.csproj">
58 <Project>{7667E6E2-F227-41A2-B1B2-315613E1BAFC}</Project>
59 <Name>ServerConsole</Name>
60 </ProjectReference>
61 </ItemGroup>
62 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
63</Project> \ No newline at end of file
diff --git a/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj b/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj
deleted file mode 100644
index 1bd07fb..0000000
--- a/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj
+++ /dev/null
@@ -1,128 +0,0 @@
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>{66591469-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>OpenGridServices.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>OpenGridServices.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="System" >
62 <HintPath>System.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System.Data" >
66 <HintPath>System.Data.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="System.Xml" >
70 <HintPath>System.Xml.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="OpenSim.Framework" >
74 <HintPath>OpenSim.Framework.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 <Reference Include="OpenSim.Framework.Console" >
78 <HintPath>OpenSim.Framework.Console.dll</HintPath>
79 <Private>False</Private>
80 </Reference>
81 <Reference Include="OpenSim.GenericConfig.Xml" >
82 <HintPath>OpenSim.GenericConfig.Xml.dll</HintPath>
83 <Private>False</Private>
84 </Reference>
85 <Reference Include="OpenSim.Servers" >
86 <HintPath>OpenSim.Servers.dll</HintPath>
87 <Private>False</Private>
88 </Reference>
89 <Reference Include="libsecondlife.dll" >
90 <HintPath>..\..\bin\libsecondlife.dll</HintPath>
91 <Private>False</Private>
92 </Reference>
93 <Reference Include="Db4objects.Db4o.dll" >
94 <HintPath>..\..\bin\Db4objects.Db4o.dll</HintPath>
95 <Private>False</Private>
96 </Reference>
97 <Reference Include="XMLRPC" >
98 <HintPath>XMLRPC.dll</HintPath>
99 <Private>False</Private>
100 </Reference>
101 </ItemGroup>
102 <ItemGroup>
103 <ProjectReference Include="..\OpenGrid.Framework.Data\OpenGrid.Framework.Data.csproj">
104 <Name>OpenGrid.Framework.Data</Name>
105 <Project>{62CDF671-0000-0000-0000-000000000000}</Project>
106 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
107 <Private>False</Private>
108 </ProjectReference>
109 </ItemGroup>
110 <ItemGroup>
111 <Compile Include="Main.cs">
112 <SubType>Code</SubType>
113 </Compile>
114 <Compile Include="UserManager.cs">
115 <SubType>Code</SubType>
116 </Compile>
117 <Compile Include="Properties\AssemblyInfo.cs">
118 <SubType>Code</SubType>
119 </Compile>
120 </ItemGroup>
121 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
122 <PropertyGroup>
123 <PreBuildEvent>
124 </PreBuildEvent>
125 <PostBuildEvent>
126 </PostBuildEvent>
127 </PropertyGroup>
128</Project>
diff --git a/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj.user b/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj.user
deleted file mode 100644
index 9bfaf67..0000000
--- a/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj.user
+++ /dev/null
@@ -1,12 +0,0 @@
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\opensim26-05\branches\Sugilite\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/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build b/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build
deleted file mode 100644
index 5275ef4..0000000
--- a/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build
+++ /dev/null
@@ -1,51 +0,0 @@
1<?xml version="1.0" ?>
2<project name="OpenGridServices.UserServer" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="exe" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.exe">
11 <resources prefix="OpenGridServices.UserServer" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="Main.cs" />
15 <include name="UserManager.cs" />
16 <include name="Properties/AssemblyInfo.cs" />
17 </sources>
18 <references basedir="${project::get-base-directory()}">
19 <lib>
20 <include name="${project::get-base-directory()}" />
21 <include name="${project::get-base-directory()}/${build.dir}" />
22 </lib>
23 <include name="System.dll" />
24 <include name="System.Data.dll" />
25 <include name="System.Xml.dll" />
26 <include name="../../bin/OpenSim.Framework.dll" />
27 <include name="../../bin/OpenSim.Framework.Console.dll" />
28 <include name="../../bin/OpenGrid.Framework.Data.dll" />
29 <include name="../../bin/OpenSim.GenericConfig.Xml.dll" />
30 <include name="../../bin/OpenSim.Servers.dll" />
31 <include name="../../bin/libsecondlife.dll" />
32 <include name="../../bin/Db4objects.Db4o.dll" />
33 <include name="../../bin/XMLRPC.dll" />
34 </references>
35 </csc>
36 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />
37 <mkdir dir="${project::get-base-directory()}/../../bin/"/>
38 <copy todir="${project::get-base-directory()}/../../bin/">
39 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
40 <include name="*.dll"/>
41 <include name="*.exe"/>
42 </fileset>
43 </copy>
44 </target>
45 <target name="clean">
46 <delete dir="${bin.dir}" failonerror="false" />
47 <delete dir="${obj.dir}" failonerror="false" />
48 </target>
49 <target name="doc" description="Creates documentation.">
50 </target>
51</project>
diff --git a/OpenGridServices/OpenGridServices.UserServer/Properties/AssemblyInfo.cs b/OpenGridServices/OpenGridServices.UserServer/Properties/AssemblyInfo.cs
deleted file mode 100644
index 5d5ce8d..0000000
--- a/OpenGridServices/OpenGridServices.UserServer/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,33 +0,0 @@
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/OpenGridServices/OpenGridServices.UserServer/UserManager.cs b/OpenGridServices/OpenGridServices.UserServer/UserManager.cs
deleted file mode 100644
index fdda63b..0000000
--- a/OpenGridServices/OpenGridServices.UserServer/UserManager.cs
+++ /dev/null
@@ -1,597 +0,0 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Text;
5using OpenGrid.Framework.Data;
6using libsecondlife;
7using System.Reflection;
8
9using System.Xml;
10using Nwc.XmlRpc;
11using OpenSim.Framework.Sims;
12using OpenSim.Framework.Inventory;
13using OpenSim.Framework.Utilities;
14
15using System.Security.Cryptography;
16
17namespace OpenGridServices.UserServer
18{
19 public class UserManager
20 {
21 public OpenSim.Framework.Interfaces.UserConfig _config;
22 Dictionary<string, IUserData> _plugins = new Dictionary<string, IUserData>();
23
24 /// <summary>
25 /// Adds a new user server plugin - user servers will be requested in the order they were loaded.
26 /// </summary>
27 /// <param name="FileName">The filename to the user server plugin DLL</param>
28 public void AddPlugin(string FileName)
29 {
30 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Userstorage: Attempting to load " + FileName);
31 Assembly pluginAssembly = Assembly.LoadFrom(FileName);
32
33 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Userstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces.");
34 foreach (Type pluginType in pluginAssembly.GetTypes())
35 {
36 if (!pluginType.IsAbstract)
37 {
38 Type typeInterface = pluginType.GetInterface("IUserData", true);
39
40 if (typeInterface != null)
41 {
42 IUserData plug = (IUserData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
43 plug.Initialise();
44 this._plugins.Add(plug.getName(), plug);
45 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Userstorage: Added IUserData Interface");
46 }
47
48 typeInterface = null;
49 }
50 }
51
52 pluginAssembly = null;
53 }
54
55 /// <summary>
56 ///
57 /// </summary>
58 /// <param name="user"></param>
59 public void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY)
60 {
61 UserProfileData user = new UserProfileData();
62 user.homeLocation = new LLVector3(128, 128, 100);
63 user.UUID = LLUUID.Random();
64 user.username = firstName;
65 user.surname = lastName;
66 user.passwordHash = pass;
67 user.passwordSalt = "";
68 user.created = Util.UnixTimeSinceEpoch();
69 user.homeLookAt = new LLVector3(100, 100, 100);
70 user.homeRegion = Util.UIntsToLong((regX * 256), (regY * 256));
71
72 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
73 {
74 try
75 {
76 plugin.Value.addNewUserProfile(user);
77
78 }
79 catch (Exception e)
80 {
81 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
82 }
83 }
84 }
85
86 /// <summary>
87 /// Loads a user profile from a database by UUID
88 /// </summary>
89 /// <param name="uuid">The target UUID</param>
90 /// <returns>A user profile</returns>
91 public UserProfileData getUserProfile(LLUUID uuid)
92 {
93 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
94 {
95 try
96 {
97 UserProfileData profile = plugin.Value.getUserByUUID(uuid);
98 profile.currentAgent = getUserAgent(profile.UUID);
99 return profile;
100 }
101 catch (Exception e)
102 {
103 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
104 }
105 }
106
107 return null;
108 }
109
110
111 /// <summary>
112 /// Loads a user profile by name
113 /// </summary>
114 /// <param name="name">The target name</param>
115 /// <returns>A user profile</returns>
116 public UserProfileData getUserProfile(string name)
117 {
118 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
119 {
120 try
121 {
122 UserProfileData profile = plugin.Value.getUserByName(name);
123 profile.currentAgent = getUserAgent(profile.UUID);
124 return profile;
125 }
126 catch (Exception e)
127 {
128 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
129 }
130 }
131
132 return null;
133 }
134
135 /// <summary>
136 /// Loads a user profile by name
137 /// </summary>
138 /// <param name="fname">First name</param>
139 /// <param name="lname">Last name</param>
140 /// <returns>A user profile</returns>
141 public UserProfileData getUserProfile(string fname, string lname)
142 {
143 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
144 {
145 try
146 {
147 UserProfileData profile = plugin.Value.getUserByName(fname,lname);
148 try
149 {
150 profile.currentAgent = getUserAgent(profile.UUID);
151 }
152 catch (Exception e)
153 {
154 // Ignore
155 }
156 return profile;
157 }
158 catch (Exception e)
159 {
160 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
161 }
162 }
163
164 return null;
165 }
166
167 /// <summary>
168 /// Loads a user agent by uuid (not called directly)
169 /// </summary>
170 /// <param name="uuid">The agents UUID</param>
171 /// <returns>Agent profiles</returns>
172 public UserAgentData getUserAgent(LLUUID uuid)
173 {
174 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
175 {
176 try
177 {
178 return plugin.Value.getAgentByUUID(uuid);
179 }
180 catch (Exception e)
181 {
182 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
183 }
184 }
185
186 return null;
187 }
188
189 /// <summary>
190 /// Loads a user agent by name (not called directly)
191 /// </summary>
192 /// <param name="name">The agents name</param>
193 /// <returns>A user agent</returns>
194 public UserAgentData getUserAgent(string name)
195 {
196 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
197 {
198 try
199 {
200 return plugin.Value.getAgentByName(name);
201 }
202 catch (Exception e)
203 {
204 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
205 }
206 }
207
208 return null;
209 }
210
211 /// <summary>
212 /// Loads a user agent by name (not called directly)
213 /// </summary>
214 /// <param name="fname">The agents firstname</param>
215 /// <param name="lname">The agents lastname</param>
216 /// <returns>A user agent</returns>
217 public UserAgentData getUserAgent(string fname, string lname)
218 {
219 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
220 {
221 try
222 {
223 return plugin.Value.getAgentByName(fname,lname);
224 }
225 catch (Exception e)
226 {
227 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
228 }
229 }
230
231 return null;
232 }
233
234 /// <summary>
235 /// Creates a error response caused by invalid XML
236 /// </summary>
237 /// <returns>An XMLRPC response</returns>
238 private static XmlRpcResponse CreateErrorConnectingToGridResponse()
239 {
240 XmlRpcResponse response = new XmlRpcResponse();
241 Hashtable ErrorRespData = new Hashtable();
242 ErrorRespData["reason"] = "key";
243 ErrorRespData["message"] = "Error connecting to grid. Could not percieve credentials from login XML.";
244 ErrorRespData["login"] = "false";
245 response.Value = ErrorRespData;
246 return response;
247 }
248
249 /// <summary>
250 /// Creates an error response caused by bad login credentials
251 /// </summary>
252 /// <returns>An XMLRPC response</returns>
253 private static XmlRpcResponse CreateLoginErrorResponse()
254 {
255 XmlRpcResponse response = new XmlRpcResponse();
256 Hashtable ErrorRespData = new Hashtable();
257 ErrorRespData["reason"] = "key";
258 ErrorRespData["message"] = "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.";
259 ErrorRespData["login"] = "false";
260 response.Value = ErrorRespData;
261 return response;
262 }
263
264 /// <summary>
265 /// Creates an error response caused by being logged in already
266 /// </summary>
267 /// <returns>An XMLRPC Response</returns>
268 private static XmlRpcResponse CreateAlreadyLoggedInResponse()
269 {
270 XmlRpcResponse response = new XmlRpcResponse();
271 Hashtable PresenceErrorRespData = new Hashtable();
272 PresenceErrorRespData["reason"] = "presence";
273 PresenceErrorRespData["message"] = "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner";
274 PresenceErrorRespData["login"] = "false";
275 response.Value = PresenceErrorRespData;
276 return response;
277 }
278
279 /// <summary>
280 /// Customises the login response and fills in missing values.
281 /// </summary>
282 /// <param name="response">The existing response</param>
283 /// <param name="theUser">The user profile</param>
284 public virtual void CustomiseResponse(ref Hashtable response, ref UserProfileData theUser)
285 {
286 // Load information from the gridserver
287 SimProfile SimInfo = new SimProfile();
288 SimInfo = SimInfo.LoadFromGrid(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey);
289
290 // Customise the response
291 // Home Location
292 response["home"] = "{'region_handle':[r" + (SimInfo.RegionLocX * 256).ToString() + ",r" + (SimInfo.RegionLocY * 256).ToString() + "], " +
293 "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
294 "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
295
296 // Destination
297 response["sim_ip"] = SimInfo.sim_ip;
298 response["sim_port"] = (Int32)SimInfo.sim_port;
299 response["region_y"] = (Int32)SimInfo.RegionLocY * 256;
300 response["region_x"] = (Int32)SimInfo.RegionLocX * 256;
301
302 // Notify the target of an incoming user
303 Console.WriteLine("Notifying " + SimInfo.regionname + " (" + SimInfo.caps_url + ")");
304
305 // Prepare notification
306 Hashtable SimParams = new Hashtable();
307 SimParams["session_id"] = theUser.currentAgent.sessionID.ToString();
308 SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString();
309 SimParams["firstname"] = theUser.username;
310 SimParams["lastname"] = theUser.surname;
311 SimParams["agent_id"] = theUser.UUID.ToString();
312 SimParams["circuit_code"] = (Int32)Convert.ToUInt32(response["circuit_code"]);
313 SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString();
314 SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString();
315 SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString();
316 ArrayList SendParams = new ArrayList();
317 SendParams.Add(SimParams);
318
319 // Update agent with target sim
320 theUser.currentAgent.currentRegion = SimInfo.UUID;
321 theUser.currentAgent.currentHandle = SimInfo.regionhandle;
322
323 // Send
324 XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
325 XmlRpcResponse GridResp = GridReq.Send(SimInfo.caps_url, 3000);
326 }
327
328 /// <summary>
329 /// Checks a user against it's password hash
330 /// </summary>
331 /// <param name="profile">The users profile</param>
332 /// <param name="password">The supplied password</param>
333 /// <returns>Authenticated?</returns>
334 public bool AuthenticateUser(ref UserProfileData profile, string password)
335 {
336 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(
337 OpenSim.Framework.Console.LogPriority.LOW,
338 "Authenticating " + profile.username + " " + profile.surname);
339
340 password = password.Remove(0, 3); //remove $1$
341
342 string s = Util.Md5Hash(password + ":" + profile.passwordSalt);
343
344 return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase);
345 }
346
347 /// <summary>
348 /// Creates and initialises a new user agent - make sure to use CommitAgent when done to submit to the DB
349 /// </summary>
350 /// <param name="profile">The users profile</param>
351 /// <param name="request">The users loginrequest</param>
352 public void CreateAgent(ref UserProfileData profile, XmlRpcRequest request)
353 {
354 Hashtable requestData = (Hashtable)request.Params[0];
355
356 UserAgentData agent = new UserAgentData();
357
358 // User connection
359 agent.agentIP = "";
360 agent.agentOnline = true;
361 agent.agentPort = 0;
362
363 // Generate sessions
364 RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider();
365 byte[] randDataS = new byte[16];
366 byte[] randDataSS = new byte[16];
367 rand.GetBytes(randDataS);
368 rand.GetBytes(randDataSS);
369
370 agent.secureSessionID = new LLUUID(randDataSS, 0);
371 agent.sessionID = new LLUUID(randDataS, 0);
372
373 // Profile UUID
374 agent.UUID = profile.UUID;
375
376 // Current position (from Home)
377 agent.currentHandle = profile.homeRegion;
378 agent.currentPos = profile.homeLocation;
379
380 // If user specified additional start, use that
381 if (requestData.ContainsKey("start"))
382 {
383 string startLoc = (string)requestData["start"];
384 if (!(startLoc == "last" || startLoc == "home"))
385 {
386 // Ignore it! Heh.
387 }
388 }
389
390 // What time did the user login?
391 agent.loginTime = Util.UnixTimeSinceEpoch();
392 agent.logoutTime = 0;
393
394 // Current location
395 agent.regionID = new LLUUID(); // Fill in later
396 agent.currentRegion = new LLUUID(); // Fill in later
397
398 profile.currentAgent = agent;
399 }
400
401 /// <summary>
402 /// Saves a target agent to the database
403 /// </summary>
404 /// <param name="profile">The users profile</param>
405 /// <returns>Successful?</returns>
406 public bool CommitAgent(ref UserProfileData profile)
407 {
408 // Saves the agent to database
409 return true;
410 }
411
412 /// <summary>
413 /// Main user login function
414 /// </summary>
415 /// <param name="request">The XMLRPC request</param>
416 /// <returns>The response to send</returns>
417 public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
418 {
419 XmlRpcResponse response = new XmlRpcResponse();
420 Hashtable requestData = (Hashtable)request.Params[0];
421
422 bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd"));
423 bool GoodLogin = false;
424 string firstname = "";
425 string lastname = "";
426 string passwd = "";
427
428 UserProfileData TheUser;
429
430 if (GoodXML)
431 {
432 firstname = (string)requestData["first"];
433 lastname = (string)requestData["last"];
434 passwd = (string)requestData["passwd"];
435
436 TheUser = getUserProfile(firstname, lastname);
437 if (TheUser == null)
438 return CreateLoginErrorResponse();
439
440 GoodLogin = AuthenticateUser(ref TheUser, passwd);
441 }
442 else
443 {
444 return CreateErrorConnectingToGridResponse();
445 }
446
447 if (!GoodLogin)
448 {
449 return CreateLoginErrorResponse();
450 }
451 else
452 {
453 // If we already have a session...
454 if (TheUser.currentAgent != null && TheUser.currentAgent.agentOnline)
455 {
456 // Reject the login
457 return CreateAlreadyLoggedInResponse();
458 }
459 // Otherwise...
460 // Create a new agent session
461 CreateAgent(ref TheUser, request);
462
463 try
464 {
465 Hashtable responseData = new Hashtable();
466
467 LLUUID AgentID = TheUser.UUID;
468
469 // Global Texture Section
470 Hashtable GlobalT = new Hashtable();
471 GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271";
472 GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
473 GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
474 ArrayList GlobalTextures = new ArrayList();
475 GlobalTextures.Add(GlobalT);
476
477 // Login Flags Section
478 Hashtable LoginFlagsHash = new Hashtable();
479 LoginFlagsHash["daylight_savings"] = "N";
480 LoginFlagsHash["stipend_since_login"] = "N";
481 LoginFlagsHash["gendered"] = "Y";
482 LoginFlagsHash["ever_logged_in"] = "N"; // Should allow male/female av selection
483 ArrayList LoginFlags = new ArrayList();
484 LoginFlags.Add(LoginFlagsHash);
485
486 // UI Customisation Section
487 Hashtable uiconfig = new Hashtable();
488 uiconfig["allow_first_life"] = "Y";
489 ArrayList ui_config = new ArrayList();
490 ui_config.Add(uiconfig);
491
492 // Classified Categories Section
493 Hashtable ClassifiedCategoriesHash = new Hashtable();
494 ClassifiedCategoriesHash["category_name"] = "Generic";
495 ClassifiedCategoriesHash["category_id"] = (Int32)1;
496 ArrayList ClassifiedCategories = new ArrayList();
497 ClassifiedCategories.Add(ClassifiedCategoriesHash);
498
499 // Inventory Library Section
500 ArrayList AgentInventoryArray = new ArrayList();
501 Hashtable TempHash;
502
503 AgentInventory Library = new AgentInventory();
504 Library.CreateRootFolder(AgentID, true);
505
506 foreach (InventoryFolder InvFolder in Library.InventoryFolders.Values)
507 {
508 TempHash = new Hashtable();
509 TempHash["name"] = InvFolder.FolderName;
510 TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
511 TempHash["version"] = (Int32)InvFolder.Version;
512 TempHash["type_default"] = (Int32)InvFolder.DefaultType;
513 TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated();
514 AgentInventoryArray.Add(TempHash);
515 }
516
517 Hashtable InventoryRootHash = new Hashtable();
518 InventoryRootHash["folder_id"] = Library.InventoryRoot.FolderID.ToStringHyphenated();
519 ArrayList InventoryRoot = new ArrayList();
520 InventoryRoot.Add(InventoryRootHash);
521
522 Hashtable InitialOutfitHash = new Hashtable();
523 InitialOutfitHash["folder_name"] = "Nightclub Female";
524 InitialOutfitHash["gender"] = "female";
525 ArrayList InitialOutfit = new ArrayList();
526 InitialOutfit.Add(InitialOutfitHash);
527
528 // Circuit Code
529 uint circode = (uint)(Util.RandomClass.Next());
530
531 // Generics
532 responseData["last_name"] = TheUser.surname;
533 responseData["ui-config"] = ui_config;
534 responseData["sim_ip"] = "127.0.0.1"; //SimInfo.sim_ip.ToString();
535 responseData["login-flags"] = LoginFlags;
536 responseData["global-textures"] = GlobalTextures;
537 responseData["classified_categories"] = ClassifiedCategories;
538 responseData["event_categories"] = new ArrayList();
539 responseData["inventory-skeleton"] = AgentInventoryArray;
540 responseData["inventory-skel-lib"] = new ArrayList();
541 responseData["inventory-root"] = InventoryRoot;
542 responseData["event_notifications"] = new ArrayList();
543 responseData["gestures"] = new ArrayList();
544 responseData["inventory-lib-owner"] = new ArrayList();
545 responseData["initial-outfit"] = InitialOutfit;
546 responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
547 responseData["start_location"] = "last";
548 responseData["home"] = "!!null temporary value {home}!!"; // Overwritten
549 responseData["message"] = _config.DefaultStartupMsg;
550 responseData["first_name"] = TheUser.username;
551 responseData["circuit_code"] = (Int32)circode;
552 responseData["sim_port"] = 0; //(Int32)SimInfo.sim_port;
553 responseData["secure_session_id"] = TheUser.currentAgent.secureSessionID.ToStringHyphenated();
554 responseData["look_at"] = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n";
555 responseData["agent_id"] = AgentID.ToStringHyphenated();
556 responseData["region_y"] = (Int32)0; // Overwritten
557 responseData["region_x"] = (Int32)0; // Overwritten
558 responseData["seed_capability"] = "";
559 responseData["agent_access"] = "M";
560 responseData["session_id"] = TheUser.currentAgent.sessionID.ToStringHyphenated();
561 responseData["login"] = "true";
562
563 this.CustomiseResponse(ref responseData, ref TheUser);
564
565 CommitAgent(ref TheUser);
566
567 response.Value = responseData;
568 // TheUser.SendDataToSim(SimInfo);
569 return response;
570
571 }
572 catch (Exception E)
573 {
574 Console.WriteLine(E.ToString());
575 }
576 //}
577 }
578 return response;
579
580 }
581
582 /// <summary>
583 /// Deletes an active agent session
584 /// </summary>
585 /// <param name="request">The request</param>
586 /// <param name="path">The path (eg /bork/narf/test)</param>
587 /// <param name="param">Parameters sent</param>
588 /// <returns>Success "OK" else error</returns>
589 public string RestDeleteUserSessionMethod(string request, string path, string param)
590 {
591 // TODO! Important!
592
593 return "OK";
594 }
595
596 }
597}