aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers/Simulation/Utils.cs
diff options
context:
space:
mode:
authordiva2009-05-25 20:30:24 +0000
committerdiva2009-05-25 20:30:24 +0000
commitcb704ecde19c512bfa4fc0b317d37fec63e76713 (patch)
tree1960e54ce2312b95f030009c335b5211322ef60d /OpenSim/Server/Handlers/Simulation/Utils.cs
parent* reseparate inventory item creator id and creator uuid (diff)
downloadopensim-SC_OLD-cb704ecde19c512bfa4fc0b317d37fec63e76713.zip
opensim-SC_OLD-cb704ecde19c512bfa4fc0b317d37fec63e76713.tar.gz
opensim-SC_OLD-cb704ecde19c512bfa4fc0b317d37fec63e76713.tar.bz2
opensim-SC_OLD-cb704ecde19c512bfa4fc0b317d37fec63e76713.tar.xz
Beginning of refactoring RESTComms/LocalComms in the new style of services and connectors. This commit has the beginning of the In connector, not the Out. Nothing of this is finished yet, and it doesn't run. But it should compile ok.
Diffstat (limited to 'OpenSim/Server/Handlers/Simulation/Utils.cs')
-rw-r--r--OpenSim/Server/Handlers/Simulation/Utils.cs70
1 files changed, 70 insertions, 0 deletions
diff --git a/OpenSim/Server/Handlers/Simulation/Utils.cs b/OpenSim/Server/Handlers/Simulation/Utils.cs
new file mode 100644
index 0000000..581622c
--- /dev/null
+++ b/OpenSim/Server/Handlers/Simulation/Utils.cs
@@ -0,0 +1,70 @@
1using System;
2using System.Collections;
3using System.Net;
4
5using OpenSim.Framework;
6using OpenSim.Framework.Servers.HttpServer;
7using OpenSim.Services.Interfaces;
8using OpenMetaverse;
9
10namespace OpenSim.Server.Handlers.Simulation
11{
12 public class Utils
13 {
14 /// <summary>
15 /// Extract the param from an uri.
16 /// </summary>
17 /// <param name="uri">Something like this: /uuid/ or /uuid/handle/release</param>
18 /// <param name="uri">uuid on uuid field</param>
19 /// <param name="action">optional action</param>
20 public static bool GetParams(string path, out UUID uuid, out ulong regionHandle, out string action)
21 {
22 uuid = UUID.Zero;
23 action = "";
24 regionHandle = 0;
25
26 path = path.Trim(new char[] { '/' });
27 string[] parts = path.Split('/');
28 if (parts.Length <= 1)
29 {
30 return false;
31 }
32 else
33 {
34 if (!UUID.TryParse(parts[0], out uuid))
35 return false;
36
37 if (parts.Length >= 2)
38 UInt64.TryParse(parts[1], out regionHandle);
39 if (parts.Length >= 3)
40 action = parts[2];
41
42 return true;
43 }
44 }
45
46 public static bool GetAuthentication(OSHttpRequest httpRequest, out string authority, out string authKey)
47 {
48 authority = string.Empty;
49 authKey = string.Empty;
50
51 Uri authUri;
52
53 string auth = httpRequest.Headers["authentication"];
54 // Authentication keys look like this:
55 // http://orgrid.org:8002/<uuid>
56 if ((auth != null) && (!string.Empty.Equals(auth)) && auth != "None")
57 {
58 if (Uri.TryCreate(auth, UriKind.Absolute, out authUri))
59 {
60 authority = authUri.Authority;
61 authKey = authUri.PathAndQuery.Trim('/');
62 return true;
63 }
64 }
65
66 return false;
67 }
68
69 }
70}