aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices/OpenGridServices.UserServer
diff options
context:
space:
mode:
Diffstat (limited to 'OpenGridServices/OpenGridServices.UserServer')
-rw-r--r--OpenGridServices/OpenGridServices.UserServer/Main.cs197
-rw-r--r--OpenGridServices/OpenGridServices.UserServer/OGS-UserServer.csproj63
-rw-r--r--OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj132
-rw-r--r--OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj.user12
-rw-r--r--OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build50
-rw-r--r--OpenGridServices/OpenGridServices.UserServer/Properties/AssemblyInfo.cs33
-rw-r--r--OpenGridServices/OpenGridServices.UserServer/UserManager.cs566
7 files changed, 1053 insertions, 0 deletions
diff --git a/OpenGridServices/OpenGridServices.UserServer/Main.cs b/OpenGridServices/OpenGridServices.UserServer/Main.cs
new file mode 100644
index 0000000..0eb314b
--- /dev/null
+++ b/OpenGridServices/OpenGridServices.UserServer/Main.cs
@@ -0,0 +1,197 @@
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;
43
44namespace OpenGridServices.UserServer
45{
46 /// <summary>
47 /// </summary>
48 public class OpenUser_Main : BaseServer, conscmd_callback
49 {
50 private string ConfigDll = "OpenUser.Config.UserConfigDb4o.dll";
51 private string StorageDll = "OpenGrid.Framework.Data.MySQL.dll";
52 private UserConfig Cfg;
53
54 public UserManager m_userManager; // Replaces below.
55
56 //private UserProfileManager m_userProfileManager; // Depreciated
57
58 public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>();
59
60 ConsoleBase m_console;
61
62 [STAThread]
63 public static void Main(string[] args)
64 {
65 Console.WriteLine("Starting...\n");
66
67 OpenUser_Main userserver = new OpenUser_Main();
68
69 userserver.Startup();
70 userserver.Work();
71 }
72
73 private OpenUser_Main()
74 {
75 m_console = new ConsoleBase("opengrid-userserver-console.log", "OpenUser", this , false);
76 MainConsole.Instance = m_console;
77 }
78
79 private void Work()
80 {
81 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"\nEnter help for a list of commands\n");
82
83 while (true)
84 {
85 m_console.MainConsolePrompt();
86 }
87 }
88
89 public void Startup()
90 {
91 MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Loading configuration");
92 Cfg = this.LoadConfigDll(this.ConfigDll);
93 Cfg.InitConfig();
94
95 MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Establishing data connection");
96 m_userManager = new UserManager();
97 m_userManager._config = Cfg;
98 m_userManager.AddPlugin(StorageDll);
99
100 MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Starting HTTP process");
101 BaseHttpServer httpServer = new BaseHttpServer(8002);
102
103 httpServer.AddXmlRPCHandler("login_to_simulator", m_userManager.XmlRpcLoginMethod);
104 httpServer.AddRestHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod);
105
106 httpServer.Start();
107 }
108
109
110 public void do_create(string what)
111 {
112 switch (what)
113 {
114 case "user":
115 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"Commandline user creation is currently disabled.");
116 break;
117 /*
118 string tempfirstname;
119 string templastname;
120 string tempMD5Passwd;
121
122 tempfirstname = m_console.CmdPrompt("First name");
123 templastname = m_console.CmdPrompt("Last name");
124 tempMD5Passwd = m_console.PasswdPrompt("Password");
125
126 System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
127 byte[] bs = System.Text.Encoding.UTF8.GetBytes(tempMD5Passwd);
128 bs = x.ComputeHash(bs);
129 System.Text.StringBuilder s = new System.Text.StringBuilder();
130 foreach (byte b in bs)
131 {
132 s.Append(b.ToString("x2").ToLower());
133 }
134 tempMD5Passwd = s.ToString();
135
136 UserProfile newuser = m_userProfileManager.CreateNewProfile(tempfirstname, templastname, tempMD5Passwd);
137 newuser.homelookat = new LLVector3(-0.57343f, -0.819255f, 0f);
138 newuser.homepos = new LLVector3(128f, 128f, 150f);
139 m_userProfileManager.SaveUserProfiles();
140 break;
141 */
142 }
143 }
144
145 public void RunCmd(string cmd, string[] cmdparams)
146 {
147 switch (cmd)
148 {
149 case "help":
150 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"create user - create a new user");
151 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"shutdown - shutdown the grid (USE CAUTION!)");
152 break;
153
154 case "create":
155 do_create(cmdparams[0]);
156 break;
157
158 case "shutdown":
159 m_console.Close();
160 Environment.Exit(0);
161 break;
162 }
163 }
164
165 private UserConfig LoadConfigDll(string dllName)
166 {
167 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
168 UserConfig config = null;
169
170 foreach (Type pluginType in pluginAssembly.GetTypes())
171 {
172 if (pluginType.IsPublic)
173 {
174 if (!pluginType.IsAbstract)
175 {
176 Type typeInterface = pluginType.GetInterface("IUserConfig", true);
177
178 if (typeInterface != null)
179 {
180 IUserConfig plug = (IUserConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
181 config = plug.GetConfigObject();
182 break;
183 }
184
185 typeInterface = null;
186 }
187 }
188 }
189 pluginAssembly = null;
190 return config;
191 }
192
193 public void Show(string ShowWhat)
194 {
195 }
196 }
197}
diff --git a/OpenGridServices/OpenGridServices.UserServer/OGS-UserServer.csproj b/OpenGridServices/OpenGridServices.UserServer/OGS-UserServer.csproj
new file mode 100644
index 0000000..f4fa8b6
--- /dev/null
+++ b/OpenGridServices/OpenGridServices.UserServer/OGS-UserServer.csproj
@@ -0,0 +1,63 @@
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
new file mode 100644
index 0000000..9f4da40
--- /dev/null
+++ b/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj
@@ -0,0 +1,132 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{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="libsecondlife.dll" >
74 <HintPath>..\bin\libsecondlife.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 <Reference Include="Db4objects.Db4o.dll" >
78 <HintPath>..\bin\Db4objects.Db4o.dll</HintPath>
79 <Private>False</Private>
80 </Reference>
81 </ItemGroup>
82 <ItemGroup>
83 <ProjectReference Include="..\OpenSim.Framework\OpenSim.Framework.csproj">
84 <Name>OpenSim.Framework</Name>
85 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
86 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
87 <Private>False</Private>
88 </ProjectReference>
89 <ProjectReference Include="..\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
90 <Name>OpenSim.Framework.Console</Name>
91 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
92 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
93 <Private>False</Private>
94 </ProjectReference>
95 <ProjectReference Include="..\OpenGrid.Framework.Data\OpenGrid.Framework.Data.csproj">
96 <Name>OpenGrid.Framework.Data</Name>
97 <Project>{62CDF671-0000-0000-0000-000000000000}</Project>
98 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
99 <Private>False</Private>
100 </ProjectReference>
101 <ProjectReference Include="..\OpenSim.Servers\OpenSim.Servers.csproj">
102 <Name>OpenSim.Servers</Name>
103 <Project>{8BB20F0A-0000-0000-0000-000000000000}</Project>
104 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
105 <Private>False</Private>
106 </ProjectReference>
107 <ProjectReference Include="..\XmlRpcCS\XMLRPC.csproj">
108 <Name>XMLRPC</Name>
109 <Project>{8E81D43C-0000-0000-0000-000000000000}</Project>
110 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
111 <Private>False</Private>
112 </ProjectReference>
113 </ItemGroup>
114 <ItemGroup>
115 <Compile Include="Main.cs">
116 <SubType>Code</SubType>
117 </Compile>
118 <Compile Include="UserManager.cs">
119 <SubType>Code</SubType>
120 </Compile>
121 <Compile Include="Properties\AssemblyInfo.cs">
122 <SubType>Code</SubType>
123 </Compile>
124 </ItemGroup>
125 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
126 <PropertyGroup>
127 <PreBuildEvent>
128 </PreBuildEvent>
129 <PostBuildEvent>
130 </PostBuildEvent>
131 </PropertyGroup>
132</Project>
diff --git a/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj.user b/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj.user
new file mode 100644
index 0000000..d47d65d
--- /dev/null
+++ b/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\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
new file mode 100644
index 0000000..548c3cc
--- /dev/null
+++ b/OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build
@@ -0,0 +1,50 @@
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.Servers.dll" />
30 <include name="../bin/libsecondlife.dll" />
31 <include name="../bin/Db4objects.Db4o.dll" />
32 <include name="../bin/XMLRPC.dll" />
33 </references>
34 </csc>
35 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../bin/" />
36 <mkdir dir="${project::get-base-directory()}/../bin/"/>
37 <copy todir="${project::get-base-directory()}/../bin/">
38 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
39 <include name="*.dll"/>
40 <include name="*.exe"/>
41 </fileset>
42 </copy>
43 </target>
44 <target name="clean">
45 <delete dir="${bin.dir}" failonerror="false" />
46 <delete dir="${obj.dir}" failonerror="false" />
47 </target>
48 <target name="doc" description="Creates documentation.">
49 </target>
50</project>
diff --git a/OpenGridServices/OpenGridServices.UserServer/Properties/AssemblyInfo.cs b/OpenGridServices/OpenGridServices.UserServer/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..5d5ce8d
--- /dev/null
+++ b/OpenGridServices/OpenGridServices.UserServer/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly.
8[assembly: AssemblyTitle("OGS-UserServer")]
9[assembly: AssemblyDescription("")]
10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("")]
12[assembly: AssemblyProduct("OGS-UserServer")]
13[assembly: AssemblyCopyright("Copyright © 2007")]
14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")]
16
17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)]
21
22// The following GUID is for the ID of the typelib if this project is exposed to COM
23[assembly: Guid("e266513a-090b-4d38-80f6-8599eef68c8c")]
24
25// Version information for an assembly consists of the following four values:
26//
27// Major Version
28// Minor Version
29// Build Number
30// Revision
31//
32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/OpenGridServices/OpenGridServices.UserServer/UserManager.cs b/OpenGridServices/OpenGridServices.UserServer/UserManager.cs
new file mode 100644
index 0000000..a312445
--- /dev/null
+++ b/OpenGridServices/OpenGridServices.UserServer/UserManager.cs
@@ -0,0 +1,566 @@
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 /// Loads a user profile from a database by UUID
57 /// </summary>
58 /// <param name="uuid">The target UUID</param>
59 /// <returns>A user profile</returns>
60 public UserProfileData getUserProfile(LLUUID uuid)
61 {
62 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
63 {
64 try
65 {
66 UserProfileData profile = plugin.Value.getUserByUUID(uuid);
67 profile.currentAgent = getUserAgent(profile.UUID);
68 return profile;
69 }
70 catch (Exception e)
71 {
72 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
73 }
74 }
75
76 return null;
77 }
78
79
80 /// <summary>
81 /// Loads a user profile by name
82 /// </summary>
83 /// <param name="name">The target name</param>
84 /// <returns>A user profile</returns>
85 public UserProfileData getUserProfile(string name)
86 {
87 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
88 {
89 try
90 {
91 UserProfileData profile = plugin.Value.getUserByName(name);
92 profile.currentAgent = getUserAgent(profile.UUID);
93 return profile;
94 }
95 catch (Exception e)
96 {
97 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
98 }
99 }
100
101 return null;
102 }
103
104 /// <summary>
105 /// Loads a user profile by name
106 /// </summary>
107 /// <param name="fname">First name</param>
108 /// <param name="lname">Last name</param>
109 /// <returns>A user profile</returns>
110 public UserProfileData getUserProfile(string fname, string lname)
111 {
112 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
113 {
114 try
115 {
116 UserProfileData profile = plugin.Value.getUserByName(fname,lname);
117 try
118 {
119 profile.currentAgent = getUserAgent(profile.UUID);
120 }
121 catch (Exception e)
122 {
123 // Ignore
124 }
125 return profile;
126 }
127 catch (Exception e)
128 {
129 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
130 }
131 }
132
133 return null;
134 }
135
136 /// <summary>
137 /// Loads a user agent by uuid (not called directly)
138 /// </summary>
139 /// <param name="uuid">The agents UUID</param>
140 /// <returns>Agent profiles</returns>
141 public UserAgentData getUserAgent(LLUUID uuid)
142 {
143 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
144 {
145 try
146 {
147 return plugin.Value.getAgentByUUID(uuid);
148 }
149 catch (Exception e)
150 {
151 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
152 }
153 }
154
155 return null;
156 }
157
158 /// <summary>
159 /// Loads a user agent by name (not called directly)
160 /// </summary>
161 /// <param name="name">The agents name</param>
162 /// <returns>A user agent</returns>
163 public UserAgentData getUserAgent(string name)
164 {
165 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
166 {
167 try
168 {
169 return plugin.Value.getAgentByName(name);
170 }
171 catch (Exception e)
172 {
173 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
174 }
175 }
176
177 return null;
178 }
179
180 /// <summary>
181 /// Loads a user agent by name (not called directly)
182 /// </summary>
183 /// <param name="fname">The agents firstname</param>
184 /// <param name="lname">The agents lastname</param>
185 /// <returns>A user agent</returns>
186 public UserAgentData getUserAgent(string fname, string lname)
187 {
188 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
189 {
190 try
191 {
192 return plugin.Value.getAgentByName(fname,lname);
193 }
194 catch (Exception e)
195 {
196 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")");
197 }
198 }
199
200 return null;
201 }
202
203 /// <summary>
204 /// Creates a error response caused by invalid XML
205 /// </summary>
206 /// <returns>An XMLRPC response</returns>
207 private static XmlRpcResponse CreateErrorConnectingToGridResponse()
208 {
209 XmlRpcResponse response = new XmlRpcResponse();
210 Hashtable ErrorRespData = new Hashtable();
211 ErrorRespData["reason"] = "key";
212 ErrorRespData["message"] = "Error connecting to grid. Could not percieve credentials from login XML.";
213 ErrorRespData["login"] = "false";
214 response.Value = ErrorRespData;
215 return response;
216 }
217
218 /// <summary>
219 /// Creates an error response caused by bad login credentials
220 /// </summary>
221 /// <returns>An XMLRPC response</returns>
222 private static XmlRpcResponse CreateLoginErrorResponse()
223 {
224 XmlRpcResponse response = new XmlRpcResponse();
225 Hashtable ErrorRespData = new Hashtable();
226 ErrorRespData["reason"] = "key";
227 ErrorRespData["message"] = "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.";
228 ErrorRespData["login"] = "false";
229 response.Value = ErrorRespData;
230 return response;
231 }
232
233 /// <summary>
234 /// Creates an error response caused by being logged in already
235 /// </summary>
236 /// <returns>An XMLRPC Response</returns>
237 private static XmlRpcResponse CreateAlreadyLoggedInResponse()
238 {
239 XmlRpcResponse response = new XmlRpcResponse();
240 Hashtable PresenceErrorRespData = new Hashtable();
241 PresenceErrorRespData["reason"] = "presence";
242 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";
243 PresenceErrorRespData["login"] = "false";
244 response.Value = PresenceErrorRespData;
245 return response;
246 }
247
248 /// <summary>
249 /// Customises the login response and fills in missing values.
250 /// </summary>
251 /// <param name="response">The existing response</param>
252 /// <param name="theUser">The user profile</param>
253 public virtual void CustomiseResponse(ref Hashtable response, ref UserProfileData theUser)
254 {
255 // Load information from the gridserver
256 SimProfile SimInfo = new SimProfile();
257 SimInfo = SimInfo.LoadFromGrid(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey);
258
259 // Customise the response
260 // Home Location
261 response["home"] = "{'region_handle':[r" + (SimInfo.RegionLocX * 256).ToString() + ",r" + (SimInfo.RegionLocY * 256).ToString() + "], " +
262 "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
263 "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
264
265 // Destination
266 response["sim_ip"] = SimInfo.sim_ip;
267 response["sim_port"] = (Int32)SimInfo.sim_port;
268 response["region_y"] = (Int32)SimInfo.RegionLocY * 256;
269 response["region_x"] = (Int32)SimInfo.RegionLocX * 256;
270
271 // Notify the target of an incoming user
272 Console.WriteLine("Notifying " + SimInfo.regionname + " (" + SimInfo.caps_url + ")");
273
274 // Prepare notification
275 Hashtable SimParams = new Hashtable();
276 SimParams["session_id"] = theUser.currentAgent.sessionID.ToString();
277 SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString();
278 SimParams["firstname"] = theUser.username;
279 SimParams["lastname"] = theUser.surname;
280 SimParams["agent_id"] = theUser.UUID.ToString();
281 SimParams["circuit_code"] = (Int32)Convert.ToUInt32(response["circuit_code"]);
282 SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString();
283 SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString();
284 SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString();
285 ArrayList SendParams = new ArrayList();
286 SendParams.Add(SimParams);
287
288 // Update agent with target sim
289 theUser.currentAgent.currentRegion = SimInfo.UUID;
290 theUser.currentAgent.currentHandle = SimInfo.regionhandle;
291
292 // Send
293 XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
294 XmlRpcResponse GridResp = GridReq.Send(SimInfo.caps_url, 3000);
295 }
296
297 /// <summary>
298 /// Checks a user against it's password hash
299 /// </summary>
300 /// <param name="profile">The users profile</param>
301 /// <param name="password">The supplied password</param>
302 /// <returns>Authenticated?</returns>
303 public bool AuthenticateUser(ref UserProfileData profile, string password)
304 {
305 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(
306 OpenSim.Framework.Console.LogPriority.LOW,
307 "Authenticating " + profile.username + " " + profile.surname);
308
309 password = password.Remove(0, 3); //remove $1$
310
311 string s = Util.Md5Hash(password + ":" + profile.passwordSalt);
312
313 return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase);
314 }
315
316 /// <summary>
317 /// Creates and initialises a new user agent - make sure to use CommitAgent when done to submit to the DB
318 /// </summary>
319 /// <param name="profile">The users profile</param>
320 /// <param name="request">The users loginrequest</param>
321 public void CreateAgent(ref UserProfileData profile, XmlRpcRequest request)
322 {
323 Hashtable requestData = (Hashtable)request.Params[0];
324
325 UserAgentData agent = new UserAgentData();
326
327 // User connection
328 agent.agentIP = "";
329 agent.agentOnline = true;
330 agent.agentPort = 0;
331
332 // Generate sessions
333 RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider();
334 byte[] randDataS = new byte[16];
335 byte[] randDataSS = new byte[16];
336 rand.GetBytes(randDataS);
337 rand.GetBytes(randDataSS);
338
339 agent.secureSessionID = new LLUUID(randDataSS, 0);
340 agent.sessionID = new LLUUID(randDataS, 0);
341
342 // Profile UUID
343 agent.UUID = profile.UUID;
344
345 // Current position (from Home)
346 agent.currentHandle = profile.homeRegion;
347 agent.currentPos = profile.homeLocation;
348
349 // If user specified additional start, use that
350 if (requestData.ContainsKey("start"))
351 {
352 string startLoc = (string)requestData["start"];
353 if (!(startLoc == "last" || startLoc == "home"))
354 {
355 // Ignore it! Heh.
356 }
357 }
358
359 // What time did the user login?
360 agent.loginTime = Util.UnixTimeSinceEpoch();
361 agent.logoutTime = 0;
362
363 // Current location
364 agent.regionID = new LLUUID(); // Fill in later
365 agent.currentRegion = new LLUUID(); // Fill in later
366
367 profile.currentAgent = agent;
368 }
369
370 /// <summary>
371 /// Saves a target agent to the database
372 /// </summary>
373 /// <param name="profile">The users profile</param>
374 /// <returns>Successful?</returns>
375 public bool CommitAgent(ref UserProfileData profile)
376 {
377 // Saves the agent to database
378 return true;
379 }
380
381 /// <summary>
382 /// Main user login function
383 /// </summary>
384 /// <param name="request">The XMLRPC request</param>
385 /// <returns>The response to send</returns>
386 public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
387 {
388 XmlRpcResponse response = new XmlRpcResponse();
389 Hashtable requestData = (Hashtable)request.Params[0];
390
391 bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd"));
392 bool GoodLogin = false;
393 string firstname = "";
394 string lastname = "";
395 string passwd = "";
396
397 UserProfileData TheUser;
398
399 if (GoodXML)
400 {
401 firstname = (string)requestData["first"];
402 lastname = (string)requestData["last"];
403 passwd = (string)requestData["passwd"];
404
405 TheUser = getUserProfile(firstname, lastname);
406 if (TheUser == null)
407 return CreateLoginErrorResponse();
408
409 GoodLogin = AuthenticateUser(ref TheUser, passwd);
410 }
411 else
412 {
413 return CreateErrorConnectingToGridResponse();
414 }
415
416 if (!GoodLogin)
417 {
418 return CreateLoginErrorResponse();
419 }
420 else
421 {
422 // If we already have a session...
423 if (TheUser.currentAgent != null && TheUser.currentAgent.agentOnline)
424 {
425 // Reject the login
426 return CreateAlreadyLoggedInResponse();
427 }
428 // Otherwise...
429 // Create a new agent session
430 CreateAgent(ref TheUser, request);
431
432 try
433 {
434 Hashtable responseData = new Hashtable();
435
436 LLUUID AgentID = TheUser.UUID;
437
438 // Global Texture Section
439 Hashtable GlobalT = new Hashtable();
440 GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271";
441 GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
442 GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
443 ArrayList GlobalTextures = new ArrayList();
444 GlobalTextures.Add(GlobalT);
445
446 // Login Flags Section
447 Hashtable LoginFlagsHash = new Hashtable();
448 LoginFlagsHash["daylight_savings"] = "N";
449 LoginFlagsHash["stipend_since_login"] = "N";
450 LoginFlagsHash["gendered"] = "Y";
451 LoginFlagsHash["ever_logged_in"] = "N"; // Should allow male/female av selection
452 ArrayList LoginFlags = new ArrayList();
453 LoginFlags.Add(LoginFlagsHash);
454
455 // UI Customisation Section
456 Hashtable uiconfig = new Hashtable();
457 uiconfig["allow_first_life"] = "Y";
458 ArrayList ui_config = new ArrayList();
459 ui_config.Add(uiconfig);
460
461 // Classified Categories Section
462 Hashtable ClassifiedCategoriesHash = new Hashtable();
463 ClassifiedCategoriesHash["category_name"] = "Generic";
464 ClassifiedCategoriesHash["category_id"] = (Int32)1;
465 ArrayList ClassifiedCategories = new ArrayList();
466 ClassifiedCategories.Add(ClassifiedCategoriesHash);
467
468 // Inventory Library Section
469 ArrayList AgentInventoryArray = new ArrayList();
470 Hashtable TempHash;
471
472 AgentInventory Library = new AgentInventory();
473 Library.CreateRootFolder(AgentID, true);
474
475 foreach (InventoryFolder InvFolder in Library.InventoryFolders.Values)
476 {
477 TempHash = new Hashtable();
478 TempHash["name"] = InvFolder.FolderName;
479 TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
480 TempHash["version"] = (Int32)InvFolder.Version;
481 TempHash["type_default"] = (Int32)InvFolder.DefaultType;
482 TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated();
483 AgentInventoryArray.Add(TempHash);
484 }
485
486 Hashtable InventoryRootHash = new Hashtable();
487 InventoryRootHash["folder_id"] = Library.InventoryRoot.FolderID.ToStringHyphenated();
488 ArrayList InventoryRoot = new ArrayList();
489 InventoryRoot.Add(InventoryRootHash);
490
491 Hashtable InitialOutfitHash = new Hashtable();
492 InitialOutfitHash["folder_name"] = "Nightclub Female";
493 InitialOutfitHash["gender"] = "female";
494 ArrayList InitialOutfit = new ArrayList();
495 InitialOutfit.Add(InitialOutfitHash);
496
497 // Circuit Code
498 uint circode = (uint)(Util.RandomClass.Next());
499
500 // Generics
501 responseData["last_name"] = TheUser.surname;
502 responseData["ui-config"] = ui_config;
503 responseData["sim_ip"] = "127.0.0.1"; //SimInfo.sim_ip.ToString();
504 responseData["login-flags"] = LoginFlags;
505 responseData["global-textures"] = GlobalTextures;
506 responseData["classified_categories"] = ClassifiedCategories;
507 responseData["event_categories"] = new ArrayList();
508 responseData["inventory-skeleton"] = AgentInventoryArray;
509 responseData["inventory-skel-lib"] = new ArrayList();
510 responseData["inventory-root"] = InventoryRoot;
511 responseData["event_notifications"] = new ArrayList();
512 responseData["gestures"] = new ArrayList();
513 responseData["inventory-lib-owner"] = new ArrayList();
514 responseData["initial-outfit"] = InitialOutfit;
515 responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
516 responseData["start_location"] = "last";
517 responseData["home"] = "!!null temporary value {home}!!"; // Overwritten
518 responseData["message"] = _config.DefaultStartupMsg;
519 responseData["first_name"] = TheUser.username;
520 responseData["circuit_code"] = (Int32)circode;
521 responseData["sim_port"] = 0; //(Int32)SimInfo.sim_port;
522 responseData["secure_session_id"] = TheUser.currentAgent.secureSessionID.ToStringHyphenated();
523 responseData["look_at"] = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n";
524 responseData["agent_id"] = AgentID.ToStringHyphenated();
525 responseData["region_y"] = (Int32)0; // Overwritten
526 responseData["region_x"] = (Int32)0; // Overwritten
527 responseData["seed_capability"] = "";
528 responseData["agent_access"] = "M";
529 responseData["session_id"] = TheUser.currentAgent.sessionID.ToStringHyphenated();
530 responseData["login"] = "true";
531
532 this.CustomiseResponse(ref responseData, ref TheUser);
533
534 CommitAgent(ref TheUser);
535
536 response.Value = responseData;
537 // TheUser.SendDataToSim(SimInfo);
538 return response;
539
540 }
541 catch (Exception E)
542 {
543 Console.WriteLine(E.ToString());
544 }
545 //}
546 }
547 return response;
548
549 }
550
551 /// <summary>
552 /// Deletes an active agent session
553 /// </summary>
554 /// <param name="request">The request</param>
555 /// <param name="path">The path (eg /bork/narf/test)</param>
556 /// <param name="param">Parameters sent</param>
557 /// <returns>Success "OK" else error</returns>
558 public string RestDeleteUserSessionMethod(string request, string path, string param)
559 {
560 // TODO! Important!
561
562 return "OK";
563 }
564
565 }
566}