diff options
author | Diva Canto | 2012-03-13 08:06:30 -0700 |
---|---|---|
committer | Diva Canto | 2012-03-13 08:06:30 -0700 |
commit | 4eb2605c790857a86178bf3d170ea5a1a88f696e (patch) | |
tree | 8c753f83040b842c4463a1a091017fa7209b8147 /OpenSim/Region/DataSnapshot/DataRequestHandler.cs | |
parent | DataSnapshot: renamed gridserverURL to gatekeeperURL, and normalimzed the cap... (diff) | |
download | opensim-SC_OLD-4eb2605c790857a86178bf3d170ea5a1a88f696e.zip opensim-SC_OLD-4eb2605c790857a86178bf3d170ea5a1a88f696e.tar.gz opensim-SC_OLD-4eb2605c790857a86178bf3d170ea5a1a88f696e.tar.bz2 opensim-SC_OLD-4eb2605c790857a86178bf3d170ea5a1a88f696e.tar.xz |
Datasnapshot: added "secret" to the registration/deregistration query so that data providers can verify authenticity if they want.
Diffstat (limited to 'OpenSim/Region/DataSnapshot/DataRequestHandler.cs')
-rw-r--r-- | OpenSim/Region/DataSnapshot/DataRequestHandler.cs | 52 |
1 files changed, 20 insertions, 32 deletions
diff --git a/OpenSim/Region/DataSnapshot/DataRequestHandler.cs b/OpenSim/Region/DataSnapshot/DataRequestHandler.cs index 93648d6..2f2b3e6 100644 --- a/OpenSim/Region/DataSnapshot/DataRequestHandler.cs +++ b/OpenSim/Region/DataSnapshot/DataRequestHandler.cs | |||
@@ -46,8 +46,6 @@ namespace OpenSim.Region.DataSnapshot | |||
46 | private DataSnapshotManager m_externalData = null; | 46 | private DataSnapshotManager m_externalData = null; |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 48 | ||
49 | private readonly string m_discoveryPath = "DS0001/"; | ||
50 | |||
51 | public DataRequestHandler(Scene scene, DataSnapshotManager externalData) | 49 | public DataRequestHandler(Scene scene, DataSnapshotManager externalData) |
52 | { | 50 | { |
53 | m_scene = scene; | 51 | m_scene = scene; |
@@ -58,37 +56,9 @@ namespace OpenSim.Region.DataSnapshot | |||
58 | { | 56 | { |
59 | m_log.Info("[DATASNAPSHOT]: Set up snapshot service"); | 57 | m_log.Info("[DATASNAPSHOT]: Set up snapshot service"); |
60 | } | 58 | } |
59 | // Register validation callback handler | ||
60 | MainServer.Instance.AddHTTPHandler("validate", OnValidate); | ||
61 | 61 | ||
62 | //Register CAPS handler event | ||
63 | m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; | ||
64 | |||
65 | //harbl | ||
66 | } | ||
67 | |||
68 | public void OnRegisterCaps(UUID agentID, Caps caps) | ||
69 | { | ||
70 | // m_log.InfoFormat("[DATASNAPSHOT]: Registering service discovery capability for {0}", agentID); | ||
71 | string capsBase = "/CAPS/" + caps.CapsObjectPath; | ||
72 | caps.RegisterHandler("PublicSnapshotDataInfo", | ||
73 | new RestStreamHandler("POST", capsBase + m_discoveryPath, OnDiscoveryAttempt)); | ||
74 | } | ||
75 | |||
76 | public string OnDiscoveryAttempt(string request, string path, string param, | ||
77 | IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||
78 | { | ||
79 | //Very static for now, flexible enough to add new formats | ||
80 | LLSDDiscoveryResponse llsd_response = new LLSDDiscoveryResponse(); | ||
81 | llsd_response.snapshot_resources = new OSDArray(); | ||
82 | |||
83 | LLSDDiscoveryDataURL llsd_dataurl = new LLSDDiscoveryDataURL(); | ||
84 | llsd_dataurl.snapshot_format = "os-datasnapshot-v1"; | ||
85 | llsd_dataurl.snapshot_url = "http://" + m_externalData.m_hostname + ":" + m_externalData.m_listener_port + "/?method=collector"; | ||
86 | |||
87 | llsd_response.snapshot_resources.Array.Add(llsd_dataurl); | ||
88 | |||
89 | string response = LLSDHelpers.SerialiseLLSDReply(llsd_response); | ||
90 | |||
91 | return response; | ||
92 | } | 62 | } |
93 | 63 | ||
94 | public Hashtable OnGetSnapshot(Hashtable keysvals) | 64 | public Hashtable OnGetSnapshot(Hashtable keysvals) |
@@ -107,5 +77,23 @@ namespace OpenSim.Region.DataSnapshot | |||
107 | 77 | ||
108 | return reply; | 78 | return reply; |
109 | } | 79 | } |
80 | |||
81 | public Hashtable OnValidate(Hashtable keysvals) | ||
82 | { | ||
83 | m_log.Info("[DATASNAPSHOT] Received validation request"); | ||
84 | Hashtable reply = new Hashtable(); | ||
85 | int statuscode = 200; | ||
86 | |||
87 | string secret = (string)keysvals["secret"]; | ||
88 | if (secret == m_externalData.Secret.ToString()) | ||
89 | statuscode = 403; | ||
90 | |||
91 | reply["str_response_string"] = string.Empty; | ||
92 | reply["int_response_code"] = statuscode; | ||
93 | reply["content_type"] = "text/plain"; | ||
94 | |||
95 | return reply; | ||
96 | } | ||
97 | |||
110 | } | 98 | } |
111 | } | 99 | } |