diff options
author | Adam Frisby | 2007-07-11 08:02:47 +0000 |
---|---|---|
committer | Adam Frisby | 2007-07-11 08:02:47 +0000 |
commit | 5c7ffdde0b9642a42e8f5987e06eb01220ff7776 (patch) | |
tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /OpenGridServices/OpenGridServices.UserServer | |
parent | Who would have known that the only way of specifying utf-8 without preamble, ... (diff) | |
download | opensim-SC-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.zip opensim-SC-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.tar.gz opensim-SC-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.tar.bz2 opensim-SC-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.tar.xz |
* Wiping trunk in prep for Sugilite
Diffstat (limited to '')
6 files changed, 0 insertions, 1151 deletions
diff --git a/OpenGridServices/OpenGridServices.UserServer/Main.cs b/OpenGridServices/OpenGridServices.UserServer/Main.cs deleted file mode 100644 index bb20576..0000000 --- a/OpenGridServices/OpenGridServices.UserServer/Main.cs +++ /dev/null | |||
@@ -1,216 +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 | */ | ||
28 | |||
29 | using System; | ||
30 | using System.Collections; | ||
31 | using System.Collections.Generic; | ||
32 | using System.Reflection; | ||
33 | using System.IO; | ||
34 | using System.Text; | ||
35 | using libsecondlife; | ||
36 | using OpenSim.Framework.User; | ||
37 | using OpenSim.Framework.Sims; | ||
38 | using OpenSim.Framework.Inventory; | ||
39 | using OpenSim.Framework.Interfaces; | ||
40 | using OpenSim.Framework.Console; | ||
41 | using OpenSim.Servers; | ||
42 | using OpenSim.Framework.Utilities; | ||
43 | using OpenSim.GenericConfig; | ||
44 | |||
45 | namespace OpenGridServices.UserServer | ||
46 | { | ||
47 | /// <summary> | ||
48 | /// </summary> | ||
49 | public class OpenUser_Main : BaseServer, 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; // Replaces below. | ||
57 | |||
58 | //private UserProfileManager m_userProfileManager; // Depreciated | ||
59 | |||
60 | public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>(); | ||
61 | |||
62 | ConsoleBase m_console; | ||
63 | |||
64 | [STAThread] | ||
65 | public static void Main(string[] args) | ||
66 | { | ||
67 | Console.WriteLine("Starting...\n"); | ||
68 | |||
69 | OpenUser_Main userserver = new OpenUser_Main(); | ||
70 | |||
71 | userserver.Startup(); | ||
72 | userserver.Work(); | ||
73 | } | ||
74 | |||
75 | private OpenUser_Main() | ||
76 | { | ||
77 | m_console = new ConsoleBase("opengrid-userserver-console.log", "OpenUser", this , false); | ||
78 | MainConsole.Instance = m_console; | ||
79 | } | ||
80 | |||
81 | private void Work() | ||
82 | { | ||
83 | m_console.Notice("Enter help for a list of commands\n"); | ||
84 | |||
85 | while (true) | ||
86 | { | ||
87 | m_console.MainConsolePrompt(); | ||
88 | } | ||
89 | } | ||
90 | |||
91 | public void Startup() | ||
92 | { | ||
93 | this.localXMLConfig = new XmlConfig("UserServerConfig.xml"); | ||
94 | this.localXMLConfig.LoadData(); | ||
95 | this.ConfigDB(this.localXMLConfig); | ||
96 | this.localXMLConfig.Close(); | ||
97 | |||
98 | MainConsole.Instance.Verbose("Main.cs:Startup() - Loading configuration"); | ||
99 | Cfg = this.LoadConfigDll(this.ConfigDll); | ||
100 | Cfg.InitConfig(); | ||
101 | |||
102 | MainConsole.Instance.Verbose( "Main.cs:Startup() - Establishing data connection"); | ||
103 | m_userManager = new UserManager(); | ||
104 | m_userManager._config = Cfg; | ||
105 | m_userManager.AddPlugin(StorageDll); | ||
106 | |||
107 | MainConsole.Instance.Verbose("Main.cs:Startup() - Starting HTTP process"); | ||
108 | BaseHttpServer httpServer = new BaseHttpServer(8002); | ||
109 | |||
110 | httpServer.AddXmlRPCHandler("login_to_simulator", m_userManager.XmlRpcLoginMethod); | ||
111 | httpServer.AddRestHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod); | ||
112 | |||
113 | httpServer.Start(); | ||
114 | } | ||
115 | |||
116 | |||
117 | public void do_create(string what) | ||
118 | { | ||
119 | switch (what) | ||
120 | { | ||
121 | case "user": | ||
122 | string tempfirstname; | ||
123 | string templastname; | ||
124 | string tempMD5Passwd; | ||
125 | uint regX = 997; | ||
126 | uint regY = 996; | ||
127 | |||
128 | tempfirstname = m_console.CmdPrompt("First name"); | ||
129 | templastname = m_console.CmdPrompt("Last name"); | ||
130 | tempMD5Passwd = m_console.PasswdPrompt("Password"); | ||
131 | regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X")); | ||
132 | regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y")); | ||
133 | |||
134 | tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + ""); | ||
135 | |||
136 | m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); | ||
137 | break; | ||
138 | } | ||
139 | } | ||
140 | |||
141 | public void RunCmd(string cmd, string[] cmdparams) | ||
142 | { | ||
143 | switch (cmd) | ||
144 | { | ||
145 | case "help": | ||
146 | m_console.Notice("create user - create a new user"); | ||
147 | m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)"); | ||
148 | break; | ||
149 | |||
150 | case "create": | ||
151 | do_create(cmdparams[0]); | ||
152 | break; | ||
153 | |||
154 | case "shutdown": | ||
155 | m_console.Close(); | ||
156 | Environment.Exit(0); | ||
157 | break; | ||
158 | } | ||
159 | } | ||
160 | |||
161 | private void ConfigDB(IGenericConfig configData) | ||
162 | { | ||
163 | try | ||
164 | { | ||
165 | string attri = ""; | ||
166 | attri = configData.GetAttribute("DataBaseProvider"); | ||
167 | if (attri == "") | ||
168 | { | ||
169 | StorageDll = "OpenGrid.Framework.Data.DB4o.dll"; | ||
170 | configData.SetAttribute("DataBaseProvider", "OpenGrid.Framework.Data.DB4o.dll"); | ||
171 | } | ||
172 | else | ||
173 | { | ||
174 | StorageDll = attri; | ||
175 | } | ||
176 | configData.Commit(); | ||
177 | } | ||
178 | catch (Exception e) | ||
179 | { | ||
180 | |||
181 | } | ||
182 | } | ||
183 | |||
184 | private UserConfig LoadConfigDll(string dllName) | ||
185 | { | ||
186 | Assembly pluginAssembly = Assembly.LoadFrom(dllName); | ||
187 | UserConfig config = null; | ||
188 | |||
189 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
190 | { | ||
191 | if (pluginType.IsPublic) | ||
192 | { | ||
193 | if (!pluginType.IsAbstract) | ||
194 | { | ||
195 | Type typeInterface = pluginType.GetInterface("IUserConfig", true); | ||
196 | |||
197 | if (typeInterface != null) | ||
198 | { | ||
199 | IUserConfig plug = (IUserConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
200 | config = plug.GetConfigObject(); | ||
201 | break; | ||
202 | } | ||
203 | |||
204 | typeInterface = null; | ||
205 | } | ||
206 | } | ||
207 | } | ||
208 | pluginAssembly = null; | ||
209 | return config; | ||
210 | } | ||
211 | |||
212 | public void Show(string ShowWhat) | ||
213 | { | ||
214 | } | ||
215 | } | ||
216 | } | ||
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 b3d318c..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="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.GenericConfig.Xml" > | ||
78 | <HintPath>OpenSim.GenericConfig.Xml.dll</HintPath> | ||
79 | <Private>False</Private> | ||
80 | </Reference> | ||
81 | <Reference Include="OpenSim.Servers" > | ||
82 | <HintPath>OpenSim.Servers.dll</HintPath> | ||
83 | <Private>False</Private> | ||
84 | </Reference> | ||
85 | <Reference Include="System" > | ||
86 | <HintPath>System.dll</HintPath> | ||
87 | <Private>False</Private> | ||
88 | </Reference> | ||
89 | <Reference Include="System.Data" > | ||
90 | <HintPath>System.Data.dll</HintPath> | ||
91 | <Private>False</Private> | ||
92 | </Reference> | ||
93 | <Reference Include="System.Xml" > | ||
94 | <HintPath>System.Xml.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.exe.build b/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build deleted file mode 100644 index 68cbef7..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="../../bin/Db4objects.Db4o.dll" /> | ||
24 | <include name="../../bin/libsecondlife.dll" /> | ||
25 | <include name="../../bin/OpenGrid.Framework.Data.dll" /> | ||
26 | <include name="../../bin/OpenSim.Framework.dll" /> | ||
27 | <include name="../../bin/OpenSim.Framework.Console.dll" /> | ||
28 | <include name="../../bin/OpenSim.GenericConfig.Xml.dll" /> | ||
29 | <include name="../../bin/OpenSim.Servers.dll" /> | ||
30 | <include name="System.dll" /> | ||
31 | <include name="System.Data.dll" /> | ||
32 | <include name="System.Xml.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 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using 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 4fb7984..0000000 --- a/OpenGridServices/OpenGridServices.UserServer/UserManager.cs +++ /dev/null | |||
@@ -1,660 +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 | */ | ||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Text; | ||
32 | using OpenGrid.Framework.Data; | ||
33 | using libsecondlife; | ||
34 | using System.Reflection; | ||
35 | |||
36 | using System.Xml; | ||
37 | using Nwc.XmlRpc; | ||
38 | using OpenSim.Framework.Sims; | ||
39 | using OpenSim.Framework.Inventory; | ||
40 | using OpenSim.Framework.Utilities; | ||
41 | |||
42 | using System.Security.Cryptography; | ||
43 | |||
44 | namespace OpenGridServices.UserServer | ||
45 | { | ||
46 | public class UserManager | ||
47 | { | ||
48 | public OpenSim.Framework.Interfaces.UserConfig _config; | ||
49 | Dictionary<string, IUserData> _plugins = new Dictionary<string, IUserData>(); | ||
50 | |||
51 | /// <summary> | ||
52 | /// Adds a new user server plugin - user servers will be requested in the order they were loaded. | ||
53 | /// </summary> | ||
54 | /// <param name="FileName">The filename to the user server plugin DLL</param> | ||
55 | public void AddPlugin(string FileName) | ||
56 | { | ||
57 | OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Userstorage: Attempting to load " + FileName); | ||
58 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); | ||
59 | |||
60 | OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Userstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); | ||
61 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
62 | { | ||
63 | if (!pluginType.IsAbstract) | ||
64 | { | ||
65 | Type typeInterface = pluginType.GetInterface("IUserData", true); | ||
66 | |||
67 | if (typeInterface != null) | ||
68 | { | ||
69 | IUserData plug = (IUserData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
70 | plug.Initialise(); | ||
71 | this._plugins.Add(plug.getName(), plug); | ||
72 | OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Userstorage: Added IUserData Interface"); | ||
73 | } | ||
74 | |||
75 | typeInterface = null; | ||
76 | } | ||
77 | } | ||
78 | |||
79 | pluginAssembly = null; | ||
80 | } | ||
81 | |||
82 | /// <summary> | ||
83 | /// | ||
84 | /// </summary> | ||
85 | /// <param name="user"></param> | ||
86 | public void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) | ||
87 | { | ||
88 | UserProfileData user = new UserProfileData(); | ||
89 | user.homeLocation = new LLVector3(128, 128, 100); | ||
90 | user.UUID = LLUUID.Random(); | ||
91 | user.username = firstName; | ||
92 | user.surname = lastName; | ||
93 | user.passwordHash = pass; | ||
94 | user.passwordSalt = ""; | ||
95 | user.created = Util.UnixTimeSinceEpoch(); | ||
96 | user.homeLookAt = new LLVector3(100, 100, 100); | ||
97 | user.homeRegion = Util.UIntsToLong((regX * 256), (regY * 256)); | ||
98 | |||
99 | foreach (KeyValuePair<string, IUserData> plugin in _plugins) | ||
100 | { | ||
101 | try | ||
102 | { | ||
103 | plugin.Value.addNewUserProfile(user); | ||
104 | |||
105 | } | ||
106 | catch (Exception e) | ||
107 | { | ||
108 | OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); | ||
109 | } | ||
110 | } | ||
111 | } | ||
112 | |||
113 | /// <summary> | ||
114 | /// Loads a user profile from a database by UUID | ||
115 | /// </summary> | ||
116 | /// <param name="uuid">The target UUID</param> | ||
117 | /// <returns>A user profile</returns> | ||
118 | public UserProfileData getUserProfile(LLUUID uuid) | ||
119 | { | ||
120 | foreach (KeyValuePair<string, IUserData> plugin in _plugins) | ||
121 | { | ||
122 | try | ||
123 | { | ||
124 | UserProfileData profile = plugin.Value.getUserByUUID(uuid); | ||
125 | profile.currentAgent = getUserAgent(profile.UUID); | ||
126 | return profile; | ||
127 | } | ||
128 | catch (Exception e) | ||
129 | { | ||
130 | OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); | ||
131 | } | ||
132 | } | ||
133 | |||
134 | return null; | ||
135 | } | ||
136 | |||
137 | |||
138 | /// <summary> | ||
139 | /// Loads a user profile by name | ||
140 | /// </summary> | ||
141 | /// <param name="name">The target name</param> | ||
142 | /// <returns>A user profile</returns> | ||
143 | public UserProfileData getUserProfile(string name) | ||
144 | { | ||
145 | foreach (KeyValuePair<string, IUserData> plugin in _plugins) | ||
146 | { | ||
147 | try | ||
148 | { | ||
149 | UserProfileData profile = plugin.Value.getUserByName(name); | ||
150 | profile.currentAgent = getUserAgent(profile.UUID); | ||
151 | return profile; | ||
152 | } | ||
153 | catch (Exception e) | ||
154 | { | ||
155 | OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); | ||
156 | } | ||
157 | } | ||
158 | |||
159 | return null; | ||
160 | } | ||
161 | |||
162 | /// <summary> | ||
163 | /// Loads a user profile by name | ||
164 | /// </summary> | ||
165 | /// <param name="fname">First name</param> | ||
166 | /// <param name="lname">Last name</param> | ||
167 | /// <returns>A user profile</returns> | ||
168 | public UserProfileData getUserProfile(string fname, string lname) | ||
169 | { | ||
170 | foreach (KeyValuePair<string, IUserData> plugin in _plugins) | ||
171 | { | ||
172 | try | ||
173 | { | ||
174 | UserProfileData profile = plugin.Value.getUserByName(fname,lname); | ||
175 | try | ||
176 | { | ||
177 | profile.currentAgent = getUserAgent(profile.UUID); | ||
178 | } | ||
179 | catch (Exception e) | ||
180 | { | ||
181 | // Ignore | ||
182 | } | ||
183 | return profile; | ||
184 | } | ||
185 | catch (Exception e) | ||
186 | { | ||
187 | OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); | ||
188 | } | ||
189 | } | ||
190 | |||
191 | return null; | ||
192 | } | ||
193 | |||
194 | /// <summary> | ||
195 | /// Loads a user agent by uuid (not called directly) | ||
196 | /// </summary> | ||
197 | /// <param name="uuid">The agents UUID</param> | ||
198 | /// <returns>Agent profiles</returns> | ||
199 | public UserAgentData getUserAgent(LLUUID uuid) | ||
200 | { | ||
201 | foreach (KeyValuePair<string, IUserData> plugin in _plugins) | ||
202 | { | ||
203 | try | ||
204 | { | ||
205 | return plugin.Value.getAgentByUUID(uuid); | ||
206 | } | ||
207 | catch (Exception e) | ||
208 | { | ||
209 | OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); | ||
210 | } | ||
211 | } | ||
212 | |||
213 | return null; | ||
214 | } | ||
215 | |||
216 | /// <summary> | ||
217 | /// Loads a user agent by name (not called directly) | ||
218 | /// </summary> | ||
219 | /// <param name="name">The agents name</param> | ||
220 | /// <returns>A user agent</returns> | ||
221 | public UserAgentData getUserAgent(string name) | ||
222 | { | ||
223 | foreach (KeyValuePair<string, IUserData> plugin in _plugins) | ||
224 | { | ||
225 | try | ||
226 | { | ||
227 | return plugin.Value.getAgentByName(name); | ||
228 | } | ||
229 | catch (Exception e) | ||
230 | { | ||
231 | OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); | ||
232 | } | ||
233 | } | ||
234 | |||
235 | return null; | ||
236 | } | ||
237 | |||
238 | /// <summary> | ||
239 | /// Loads a user agent by name (not called directly) | ||
240 | /// </summary> | ||
241 | /// <param name="fname">The agents firstname</param> | ||
242 | /// <param name="lname">The agents lastname</param> | ||
243 | /// <returns>A user agent</returns> | ||
244 | public UserAgentData getUserAgent(string fname, string lname) | ||
245 | { | ||
246 | foreach (KeyValuePair<string, IUserData> plugin in _plugins) | ||
247 | { | ||
248 | try | ||
249 | { | ||
250 | return plugin.Value.getAgentByName(fname,lname); | ||
251 | } | ||
252 | catch (Exception e) | ||
253 | { | ||
254 | OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); | ||
255 | } | ||
256 | } | ||
257 | |||
258 | return null; | ||
259 | } | ||
260 | |||
261 | /// <summary> | ||
262 | /// Creates a error response caused by invalid XML | ||
263 | /// </summary> | ||
264 | /// <returns>An XMLRPC response</returns> | ||
265 | private static XmlRpcResponse CreateErrorConnectingToGridResponse() | ||
266 | { | ||
267 | XmlRpcResponse response = new XmlRpcResponse(); | ||
268 | Hashtable ErrorRespData = new Hashtable(); | ||
269 | ErrorRespData["reason"] = "key"; | ||
270 | ErrorRespData["message"] = "Error connecting to grid. Could not percieve credentials from login XML."; | ||
271 | ErrorRespData["login"] = "false"; | ||
272 | response.Value = ErrorRespData; | ||
273 | return response; | ||
274 | } | ||
275 | |||
276 | /// <summary> | ||
277 | /// Creates an error response caused by bad login credentials | ||
278 | /// </summary> | ||
279 | /// <returns>An XMLRPC response</returns> | ||
280 | private static XmlRpcResponse CreateLoginErrorResponse() | ||
281 | { | ||
282 | XmlRpcResponse response = new XmlRpcResponse(); | ||
283 | Hashtable ErrorRespData = new Hashtable(); | ||
284 | ErrorRespData["reason"] = "key"; | ||
285 | ErrorRespData["message"] = "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist."; | ||
286 | ErrorRespData["login"] = "false"; | ||
287 | response.Value = ErrorRespData; | ||
288 | return response; | ||
289 | } | ||
290 | |||
291 | /// <summary> | ||
292 | /// Creates an error response caused by being logged in already | ||
293 | /// </summary> | ||
294 | /// <returns>An XMLRPC Response</returns> | ||
295 | private static XmlRpcResponse CreateAlreadyLoggedInResponse() | ||
296 | { | ||
297 | XmlRpcResponse response = new XmlRpcResponse(); | ||
298 | Hashtable PresenceErrorRespData = new Hashtable(); | ||
299 | PresenceErrorRespData["reason"] = "presence"; | ||
300 | 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"; | ||
301 | PresenceErrorRespData["login"] = "false"; | ||
302 | response.Value = PresenceErrorRespData; | ||
303 | return response; | ||
304 | } | ||
305 | |||
306 | /// <summary> | ||
307 | /// Creates an error response caused by target region being down | ||
308 | /// </summary> | ||
309 | /// <returns>An XMLRPC Response</returns> | ||
310 | private static XmlRpcResponse CreateDeadRegionResponse() | ||
311 | { | ||
312 | XmlRpcResponse response = new XmlRpcResponse(); | ||
313 | Hashtable PresenceErrorRespData = new Hashtable(); | ||
314 | PresenceErrorRespData["reason"] = "key"; | ||
315 | PresenceErrorRespData["message"] = "The region you are attempting to log into is not responding. Please select another region and try again."; | ||
316 | PresenceErrorRespData["login"] = "false"; | ||
317 | response.Value = PresenceErrorRespData; | ||
318 | return response; | ||
319 | } | ||
320 | |||
321 | /// <summary> | ||
322 | /// Customises the login response and fills in missing values. | ||
323 | /// </summary> | ||
324 | /// <param name="response">The existing response</param> | ||
325 | /// <param name="theUser">The user profile</param> | ||
326 | public virtual void CustomiseResponse(ref Hashtable response, ref UserProfileData theUser) | ||
327 | { | ||
328 | // Load information from the gridserver | ||
329 | SimProfile SimInfo = new SimProfile(); | ||
330 | SimInfo = SimInfo.LoadFromGrid(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey); | ||
331 | |||
332 | // Customise the response | ||
333 | // Home Location | ||
334 | response["home"] = "{'region_handle':[r" + (SimInfo.RegionLocX * 256).ToString() + ",r" + (SimInfo.RegionLocY * 256).ToString() + "], " + | ||
335 | "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + | ||
336 | "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}"; | ||
337 | |||
338 | // Destination | ||
339 | response["sim_ip"] = SimInfo.sim_ip; | ||
340 | response["sim_port"] = (Int32)SimInfo.sim_port; | ||
341 | response["region_y"] = (Int32)SimInfo.RegionLocY * 256; | ||
342 | response["region_x"] = (Int32)SimInfo.RegionLocX * 256; | ||
343 | |||
344 | // Notify the target of an incoming user | ||
345 | Console.WriteLine("Notifying " + SimInfo.regionname + " (" + SimInfo.caps_url + ")"); | ||
346 | |||
347 | // Prepare notification | ||
348 | Hashtable SimParams = new Hashtable(); | ||
349 | SimParams["session_id"] = theUser.currentAgent.sessionID.ToString(); | ||
350 | SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString(); | ||
351 | SimParams["firstname"] = theUser.username; | ||
352 | SimParams["lastname"] = theUser.surname; | ||
353 | SimParams["agent_id"] = theUser.UUID.ToString(); | ||
354 | SimParams["circuit_code"] = (Int32)Convert.ToUInt32(response["circuit_code"]); | ||
355 | SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString(); | ||
356 | SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString(); | ||
357 | SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString(); | ||
358 | SimParams["regionhandle"] = theUser.currentAgent.currentHandle.ToString(); | ||
359 | ArrayList SendParams = new ArrayList(); | ||
360 | SendParams.Add(SimParams); | ||
361 | |||
362 | // Update agent with target sim | ||
363 | theUser.currentAgent.currentRegion = SimInfo.UUID; | ||
364 | theUser.currentAgent.currentHandle = SimInfo.regionhandle; | ||
365 | |||
366 | // Send | ||
367 | XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); | ||
368 | XmlRpcResponse GridResp = GridReq.Send(SimInfo.caps_url, 3000); | ||
369 | } | ||
370 | |||
371 | /// <summary> | ||
372 | /// Checks a user against it's password hash | ||
373 | /// </summary> | ||
374 | /// <param name="profile">The users profile</param> | ||
375 | /// <param name="password">The supplied password</param> | ||
376 | /// <returns>Authenticated?</returns> | ||
377 | public bool AuthenticateUser(ref UserProfileData profile, string password) | ||
378 | { | ||
379 | OpenSim.Framework.Console.MainConsole.Instance.Verbose( | ||
380 | "Authenticating " + profile.username + " " + profile.surname); | ||
381 | |||
382 | password = password.Remove(0, 3); //remove $1$ | ||
383 | |||
384 | string s = Util.Md5Hash(password + ":" + profile.passwordSalt); | ||
385 | |||
386 | return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); | ||
387 | } | ||
388 | |||
389 | /// <summary> | ||
390 | /// Creates and initialises a new user agent - make sure to use CommitAgent when done to submit to the DB | ||
391 | /// </summary> | ||
392 | /// <param name="profile">The users profile</param> | ||
393 | /// <param name="request">The users loginrequest</param> | ||
394 | public void CreateAgent(ref UserProfileData profile, XmlRpcRequest request) | ||
395 | { | ||
396 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
397 | |||
398 | UserAgentData agent = new UserAgentData(); | ||
399 | |||
400 | // User connection | ||
401 | agent.agentIP = ""; | ||
402 | agent.agentOnline = true; | ||
403 | agent.agentPort = 0; | ||
404 | |||
405 | // Generate sessions | ||
406 | RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider(); | ||
407 | byte[] randDataS = new byte[16]; | ||
408 | byte[] randDataSS = new byte[16]; | ||
409 | rand.GetBytes(randDataS); | ||
410 | rand.GetBytes(randDataSS); | ||
411 | |||
412 | agent.secureSessionID = new LLUUID(randDataSS, 0); | ||
413 | agent.sessionID = new LLUUID(randDataS, 0); | ||
414 | |||
415 | // Profile UUID | ||
416 | agent.UUID = profile.UUID; | ||
417 | |||
418 | // Current position (from Home) | ||
419 | agent.currentHandle = profile.homeRegion; | ||
420 | agent.currentPos = profile.homeLocation; | ||
421 | |||
422 | // If user specified additional start, use that | ||
423 | if (requestData.ContainsKey("start")) | ||
424 | { | ||
425 | string startLoc = ((string)requestData["start"]).Trim(); | ||
426 | if (!(startLoc == "last" || startLoc == "home")) | ||
427 | { | ||
428 | // Format: uri:Ahern&162&213&34 | ||
429 | try | ||
430 | { | ||
431 | string[] parts = startLoc.Remove(0, 4).Split('&'); | ||
432 | string region = parts[0]; | ||
433 | |||
434 | //////////////////////////////////////////////////// | ||
435 | //SimProfile SimInfo = new SimProfile(); | ||
436 | //SimInfo = SimInfo.LoadFromGrid(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey); | ||
437 | } | ||
438 | catch (Exception e) | ||
439 | { | ||
440 | |||
441 | } | ||
442 | } | ||
443 | } | ||
444 | |||
445 | // What time did the user login? | ||
446 | agent.loginTime = Util.UnixTimeSinceEpoch(); | ||
447 | agent.logoutTime = 0; | ||
448 | |||
449 | // Current location | ||
450 | agent.regionID = new LLUUID(); // Fill in later | ||
451 | agent.currentRegion = new LLUUID(); // Fill in later | ||
452 | |||
453 | profile.currentAgent = agent; | ||
454 | } | ||
455 | |||
456 | /// <summary> | ||
457 | /// Saves a target agent to the database | ||
458 | /// </summary> | ||
459 | /// <param name="profile">The users profile</param> | ||
460 | /// <returns>Successful?</returns> | ||
461 | public bool CommitAgent(ref UserProfileData profile) | ||
462 | { | ||
463 | // Saves the agent to database | ||
464 | return true; | ||
465 | } | ||
466 | |||
467 | /// <summary> | ||
468 | /// Main user login function | ||
469 | /// </summary> | ||
470 | /// <param name="request">The XMLRPC request</param> | ||
471 | /// <returns>The response to send</returns> | ||
472 | public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) | ||
473 | { | ||
474 | XmlRpcResponse response = new XmlRpcResponse(); | ||
475 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
476 | |||
477 | bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd")); | ||
478 | bool GoodLogin = false; | ||
479 | string firstname = ""; | ||
480 | string lastname = ""; | ||
481 | string passwd = ""; | ||
482 | |||
483 | UserProfileData TheUser; | ||
484 | |||
485 | if (GoodXML) | ||
486 | { | ||
487 | firstname = (string)requestData["first"]; | ||
488 | lastname = (string)requestData["last"]; | ||
489 | passwd = (string)requestData["passwd"]; | ||
490 | |||
491 | TheUser = getUserProfile(firstname, lastname); | ||
492 | if (TheUser == null) | ||
493 | return CreateLoginErrorResponse(); | ||
494 | |||
495 | GoodLogin = AuthenticateUser(ref TheUser, passwd); | ||
496 | } | ||
497 | else | ||
498 | { | ||
499 | return CreateErrorConnectingToGridResponse(); | ||
500 | } | ||
501 | |||
502 | if (!GoodLogin) | ||
503 | { | ||
504 | return CreateLoginErrorResponse(); | ||
505 | } | ||
506 | else | ||
507 | { | ||
508 | // If we already have a session... | ||
509 | if (TheUser.currentAgent != null && TheUser.currentAgent.agentOnline) | ||
510 | { | ||
511 | // Reject the login | ||
512 | return CreateAlreadyLoggedInResponse(); | ||
513 | } | ||
514 | // Otherwise... | ||
515 | // Create a new agent session | ||
516 | CreateAgent(ref TheUser, request); | ||
517 | |||
518 | try | ||
519 | { | ||
520 | Hashtable responseData = new Hashtable(); | ||
521 | |||
522 | LLUUID AgentID = TheUser.UUID; | ||
523 | |||
524 | // Global Texture Section | ||
525 | Hashtable GlobalT = new Hashtable(); | ||
526 | GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271"; | ||
527 | GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
528 | GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
529 | ArrayList GlobalTextures = new ArrayList(); | ||
530 | GlobalTextures.Add(GlobalT); | ||
531 | |||
532 | // Login Flags Section | ||
533 | Hashtable LoginFlagsHash = new Hashtable(); | ||
534 | LoginFlagsHash["daylight_savings"] = "N"; | ||
535 | LoginFlagsHash["stipend_since_login"] = "N"; | ||
536 | LoginFlagsHash["gendered"] = "Y"; // Needs to be combined with below... | ||
537 | LoginFlagsHash["ever_logged_in"] = "Y"; // Should allow male/female av selection | ||
538 | ArrayList LoginFlags = new ArrayList(); | ||
539 | LoginFlags.Add(LoginFlagsHash); | ||
540 | |||
541 | // UI Customisation Section | ||
542 | Hashtable uiconfig = new Hashtable(); | ||
543 | uiconfig["allow_first_life"] = "Y"; | ||
544 | ArrayList ui_config = new ArrayList(); | ||
545 | ui_config.Add(uiconfig); | ||
546 | |||
547 | // Classified Categories Section | ||
548 | Hashtable ClassifiedCategoriesHash = new Hashtable(); | ||
549 | ClassifiedCategoriesHash["category_name"] = "Generic"; | ||
550 | ClassifiedCategoriesHash["category_id"] = (Int32)1; | ||
551 | ArrayList ClassifiedCategories = new ArrayList(); | ||
552 | ClassifiedCategories.Add(ClassifiedCategoriesHash); | ||
553 | |||
554 | // Inventory Library Section | ||
555 | ArrayList AgentInventoryArray = new ArrayList(); | ||
556 | Hashtable TempHash; | ||
557 | |||
558 | AgentInventory Library = new AgentInventory(); | ||
559 | Library.CreateRootFolder(AgentID, true); | ||
560 | |||
561 | foreach (InventoryFolder InvFolder in Library.InventoryFolders.Values) | ||
562 | { | ||
563 | TempHash = new Hashtable(); | ||
564 | TempHash["name"] = InvFolder.FolderName; | ||
565 | TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); | ||
566 | TempHash["version"] = (Int32)InvFolder.Version; | ||
567 | TempHash["type_default"] = (Int32)InvFolder.DefaultType; | ||
568 | TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); | ||
569 | AgentInventoryArray.Add(TempHash); | ||
570 | } | ||
571 | |||
572 | Hashtable InventoryRootHash = new Hashtable(); | ||
573 | InventoryRootHash["folder_id"] = Library.InventoryRoot.FolderID.ToStringHyphenated(); | ||
574 | ArrayList InventoryRoot = new ArrayList(); | ||
575 | InventoryRoot.Add(InventoryRootHash); | ||
576 | |||
577 | Hashtable InitialOutfitHash = new Hashtable(); | ||
578 | InitialOutfitHash["folder_name"] = "Nightclub Female"; | ||
579 | InitialOutfitHash["gender"] = "female"; | ||
580 | ArrayList InitialOutfit = new ArrayList(); | ||
581 | InitialOutfit.Add(InitialOutfitHash); | ||
582 | |||
583 | // Circuit Code | ||
584 | uint circode = (uint)(Util.RandomClass.Next()); | ||
585 | |||
586 | // Generics | ||
587 | responseData["last_name"] = TheUser.surname; | ||
588 | responseData["ui-config"] = ui_config; | ||
589 | responseData["sim_ip"] = "127.0.0.1"; //SimInfo.sim_ip.ToString(); | ||
590 | responseData["login-flags"] = LoginFlags; | ||
591 | responseData["global-textures"] = GlobalTextures; | ||
592 | responseData["classified_categories"] = ClassifiedCategories; | ||
593 | responseData["event_categories"] = new ArrayList(); | ||
594 | responseData["inventory-skeleton"] = AgentInventoryArray; | ||
595 | responseData["inventory-skel-lib"] = new ArrayList(); | ||
596 | responseData["inventory-root"] = InventoryRoot; | ||
597 | responseData["event_notifications"] = new ArrayList(); | ||
598 | responseData["gestures"] = new ArrayList(); | ||
599 | responseData["inventory-lib-owner"] = new ArrayList(); | ||
600 | responseData["initial-outfit"] = InitialOutfit; | ||
601 | responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | ||
602 | responseData["start_location"] = "last"; | ||
603 | responseData["home"] = "!!null temporary value {home}!!"; // Overwritten | ||
604 | responseData["message"] = _config.DefaultStartupMsg; | ||
605 | responseData["first_name"] = TheUser.username; | ||
606 | responseData["circuit_code"] = (Int32)circode; | ||
607 | responseData["sim_port"] = 0; //(Int32)SimInfo.sim_port; | ||
608 | responseData["secure_session_id"] = TheUser.currentAgent.secureSessionID.ToStringHyphenated(); | ||
609 | responseData["look_at"] = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n"; | ||
610 | responseData["agent_id"] = AgentID.ToStringHyphenated(); | ||
611 | responseData["region_y"] = (Int32)0; // Overwritten | ||
612 | responseData["region_x"] = (Int32)0; // Overwritten | ||
613 | responseData["seed_capability"] = ""; | ||
614 | responseData["agent_access"] = "M"; | ||
615 | responseData["session_id"] = TheUser.currentAgent.sessionID.ToStringHyphenated(); | ||
616 | responseData["login"] = "true"; | ||
617 | |||
618 | try | ||
619 | { | ||
620 | this.CustomiseResponse(ref responseData, ref TheUser); | ||
621 | } | ||
622 | catch (Exception e) | ||
623 | { | ||
624 | Console.WriteLine(e.ToString()); | ||
625 | return CreateDeadRegionResponse(); | ||
626 | } | ||
627 | |||
628 | CommitAgent(ref TheUser); | ||
629 | |||
630 | response.Value = responseData; | ||
631 | // TheUser.SendDataToSim(SimInfo); | ||
632 | return response; | ||
633 | |||
634 | } | ||
635 | catch (Exception E) | ||
636 | { | ||
637 | Console.WriteLine(E.ToString()); | ||
638 | } | ||
639 | //} | ||
640 | } | ||
641 | return response; | ||
642 | |||
643 | } | ||
644 | |||
645 | /// <summary> | ||
646 | /// Deletes an active agent session | ||
647 | /// </summary> | ||
648 | /// <param name="request">The request</param> | ||
649 | /// <param name="path">The path (eg /bork/narf/test)</param> | ||
650 | /// <param name="param">Parameters sent</param> | ||
651 | /// <returns>Success "OK" else error</returns> | ||
652 | public string RestDeleteUserSessionMethod(string request, string path, string param) | ||
653 | { | ||
654 | // TODO! Important! | ||
655 | |||
656 | return "OK"; | ||
657 | } | ||
658 | |||
659 | } | ||
660 | } | ||