aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers/Simulation/Utils.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-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}