diff options
author | diva | 2009-03-30 19:26:25 +0000 |
---|---|---|
committer | diva | 2009-03-30 19:26:25 +0000 |
commit | 4cbf963354128f6d30e28ea68fe06a85ba5790c5 (patch) | |
tree | bfe313ab6fc9e2c5fac9d583a71e94993d2cb1a2 /OpenSim | |
parent | * Fix test breakage by always inserting a gods module when testing (diff) | |
download | opensim-SC_OLD-4cbf963354128f6d30e28ea68fe06a85ba5790c5.zip opensim-SC_OLD-4cbf963354128f6d30e28ea68fe06a85ba5790c5.tar.gz opensim-SC_OLD-4cbf963354128f6d30e28ea68fe06a85ba5790c5.tar.bz2 opensim-SC_OLD-4cbf963354128f6d30e28ea68fe06a85ba5790c5.tar.xz |
HGInventoryService now uses the actual authority portion of the user's key to verify the key.
Diffstat (limited to 'OpenSim')
3 files changed, 1160 insertions, 1159 deletions
diff --git a/OpenSim/Framework/Communications/Clients/AuthClient.cs b/OpenSim/Framework/Communications/Clients/AuthClient.cs index ba5cf66..39a886c 100644 --- a/OpenSim/Framework/Communications/Clients/AuthClient.cs +++ b/OpenSim/Framework/Communications/Clients/AuthClient.cs | |||
@@ -1,116 +1,118 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using Nwc.XmlRpc; | 30 | using Nwc.XmlRpc; |
31 | using OpenMetaverse; | 31 | using OpenMetaverse; |
32 | 32 | ||
33 | namespace OpenSim.Framework.Communications.Clients | 33 | namespace OpenSim.Framework.Communications.Clients |
34 | { | 34 | { |
35 | public class AuthClient | 35 | public class AuthClient |
36 | { | 36 | { |
37 | public static string GetNewKey(string authurl, UUID userID, UUID authToken) | 37 | public static string GetNewKey(string authurl, UUID userID, UUID authToken) |
38 | { | 38 | { |
39 | //Hashtable keyParams = new Hashtable(); | 39 | //Hashtable keyParams = new Hashtable(); |
40 | //keyParams["user_id"] = userID; | 40 | //keyParams["user_id"] = userID; |
41 | //keyParams["auth_token"] = authKey; | 41 | //keyParams["auth_token"] = authKey; |
42 | 42 | ||
43 | List<string> SendParams = new List<string>(); | 43 | List<string> SendParams = new List<string>(); |
44 | SendParams.Add(userID.ToString()); | 44 | SendParams.Add(userID.ToString()); |
45 | SendParams.Add(authToken.ToString()); | 45 | SendParams.Add(authToken.ToString()); |
46 | 46 | ||
47 | XmlRpcRequest request = new XmlRpcRequest("hg_new_auth_key", SendParams); | 47 | XmlRpcRequest request = new XmlRpcRequest("hg_new_auth_key", SendParams); |
48 | XmlRpcResponse reply; | 48 | XmlRpcResponse reply; |
49 | try | 49 | try |
50 | { | 50 | { |
51 | reply = request.Send(authurl, 6000); | 51 | reply = request.Send(authurl, 6000); |
52 | } | 52 | } |
53 | catch (Exception e) | 53 | catch (Exception e) |
54 | { | 54 | { |
55 | System.Console.WriteLine("[HGrid]: Failed to get new key. Reason: " + e.Message); | 55 | System.Console.WriteLine("[HGrid]: Failed to get new key. Reason: " + e.Message); |
56 | return string.Empty; | 56 | return string.Empty; |
57 | } | 57 | } |
58 | 58 | ||
59 | if (!reply.IsFault) | 59 | if (!reply.IsFault) |
60 | { | 60 | { |
61 | string newKey = string.Empty; | 61 | string newKey = string.Empty; |
62 | if (reply.Value != null) | 62 | if (reply.Value != null) |
63 | newKey = (string)reply.Value; | 63 | newKey = (string)reply.Value; |
64 | 64 | ||
65 | return newKey; | 65 | return newKey; |
66 | } | 66 | } |
67 | else | 67 | else |
68 | { | 68 | { |
69 | System.Console.WriteLine("[HGrid]: XmlRpc request to get auth key failed with message {0}" + reply.FaultString + ", code " + reply.FaultCode); | 69 | System.Console.WriteLine("[HGrid]: XmlRpc request to get auth key failed with message {0}" + reply.FaultString + ", code " + reply.FaultCode); |
70 | return string.Empty; | 70 | return string.Empty; |
71 | } | 71 | } |
72 | 72 | ||
73 | } | 73 | } |
74 | 74 | ||
75 | public static bool VerifyKey(string authurl, UUID userID, string authKey) | 75 | public static bool VerifyKey(string authurl, UUID userID, string authKey) |
76 | { | 76 | { |
77 | List<string> SendParams = new List<string>(); | 77 | List<string> SendParams = new List<string>(); |
78 | SendParams.Add(userID.ToString()); | 78 | SendParams.Add(userID.ToString()); |
79 | SendParams.Add(authKey); | 79 | SendParams.Add(authKey); |
80 | 80 | ||
81 | XmlRpcRequest request = new XmlRpcRequest("hg_verify_auth_key", SendParams); | 81 | System.Console.WriteLine("[HGrid]: Verifying user key with authority " + authurl); |
82 | XmlRpcResponse reply; | 82 | |
83 | try | 83 | XmlRpcRequest request = new XmlRpcRequest("hg_verify_auth_key", SendParams); |
84 | { | 84 | XmlRpcResponse reply; |
85 | reply = request.Send(authurl, 10000); | 85 | try |
86 | } | 86 | { |
87 | catch (Exception e) | 87 | reply = request.Send(authurl, 10000); |
88 | { | 88 | } |
89 | System.Console.WriteLine("[HGrid]: Failed to verify key. Reason: " + e.Message); | 89 | catch (Exception e) |
90 | return false; | 90 | { |
91 | } | 91 | System.Console.WriteLine("[HGrid]: Failed to verify key. Reason: " + e.Message); |
92 | 92 | return false; | |
93 | if (reply != null) | 93 | } |
94 | { | 94 | |
95 | if (!reply.IsFault) | 95 | if (reply != null) |
96 | { | 96 | { |
97 | bool success = false; | 97 | if (!reply.IsFault) |
98 | if (reply.Value != null) | 98 | { |
99 | success = (bool)reply.Value; | 99 | bool success = false; |
100 | 100 | if (reply.Value != null) | |
101 | return success; | 101 | success = (bool)reply.Value; |
102 | } | 102 | |
103 | else | 103 | return success; |
104 | { | 104 | } |
105 | System.Console.WriteLine("[HGrid]: XmlRpc request to verify key failed with message {0}" + reply.FaultString + ", code " + reply.FaultCode); | 105 | else |
106 | return false; | 106 | { |
107 | } | 107 | System.Console.WriteLine("[HGrid]: XmlRpc request to verify key failed with message {0}" + reply.FaultString + ", code " + reply.FaultCode); |
108 | } | 108 | return false; |
109 | else | 109 | } |
110 | { | 110 | } |
111 | System.Console.WriteLine("[HGrid]: XmlRpc request to verify key returned null reply"); | 111 | else |
112 | return false; | 112 | { |
113 | } | 113 | System.Console.WriteLine("[HGrid]: XmlRpc request to verify key returned null reply"); |
114 | } | 114 | return false; |
115 | } | 115 | } |
116 | } | 116 | } |
117 | } | ||
118 | } | ||
diff --git a/OpenSim/Framework/Communications/Services/HGInventoryService.cs b/OpenSim/Framework/Communications/Services/HGInventoryService.cs index b01c30e..7eaed89 100644 --- a/OpenSim/Framework/Communications/Services/HGInventoryService.cs +++ b/OpenSim/Framework/Communications/Services/HGInventoryService.cs | |||
@@ -1,715 +1,714 @@ | |||
1 | /** | 1 | /** |
2 | * Copyright (c) 2008, Contributors. All rights reserved. | 2 | * Copyright (c) 2008, Contributors. All rights reserved. |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without modification, | 5 | * Redistribution and use in source and binary forms, with or without modification, |
6 | * are permitted provided that the following conditions are met: | 6 | * are permitted provided that the following conditions are met: |
7 | * | 7 | * |
8 | * * Redistributions of source code must retain the above copyright notice, | 8 | * * Redistributions of source code must retain the above copyright notice, |
9 | * this list of conditions and the following disclaimer. | 9 | * this list of conditions and the following disclaimer. |
10 | * * Redistributions in binary form must reproduce the above copyright notice, | 10 | * * Redistributions in binary form must reproduce the above copyright notice, |
11 | * this list of conditions and the following disclaimer in the documentation | 11 | * this list of conditions and the following disclaimer in the documentation |
12 | * and/or other materials provided with the distribution. | 12 | * and/or other materials provided with the distribution. |
13 | * * Neither the name of the Organizations nor the names of Individual | 13 | * * Neither the name of the Organizations nor the names of Individual |
14 | * Contributors may be used to endorse or promote products derived from | 14 | * Contributors may be used to endorse or promote products derived from |
15 | * this software without specific prior written permission. | 15 | * this software without specific prior written permission. |
16 | * | 16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 20 | * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | 22 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 24 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
25 | * OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections; | 30 | using System.Collections; |
31 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using log4net; | 33 | using log4net; |
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using OpenMetaverse; | 35 | using OpenMetaverse; |
36 | using OpenSim.Data; | 36 | using OpenSim.Data; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Communications.Clients; | 38 | using OpenSim.Framework.Communications.Clients; |
39 | using OpenSim.Framework.Communications.Cache; | 39 | using OpenSim.Framework.Communications.Cache; |
40 | using Caps = OpenSim.Framework.Communications.Capabilities.Caps; | 40 | using Caps = OpenSim.Framework.Communications.Capabilities.Caps; |
41 | using LLSDHelpers = OpenSim.Framework.Communications.Capabilities.LLSDHelpers; | 41 | using LLSDHelpers = OpenSim.Framework.Communications.Capabilities.LLSDHelpers; |
42 | using OpenSim.Framework.Servers; | 42 | using OpenSim.Framework.Servers; |
43 | using OpenSim.Framework.Servers.Interfaces; | 43 | using OpenSim.Framework.Servers.Interfaces; |
44 | 44 | ||
45 | using OpenMetaverse.StructuredData; | 45 | using OpenMetaverse.StructuredData; |
46 | 46 | ||
47 | namespace OpenSim.Framework.Communications.Services | 47 | namespace OpenSim.Framework.Communications.Services |
48 | { | 48 | { |
49 | public class HGInventoryService | 49 | public class HGInventoryService |
50 | { | 50 | { |
51 | private static readonly ILog m_log | 51 | private static readonly ILog m_log |
52 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 52 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
53 | 53 | ||
54 | private InventoryServiceBase m_inventoryService; | 54 | private InventoryServiceBase m_inventoryService; |
55 | IHttpServer httpServer; | 55 | IHttpServer httpServer; |
56 | private string m_thisInventoryUrl = "http://localhost:9000"; | 56 | private string m_thisInventoryUrl = "http://localhost:9000"; |
57 | private string m_thisHostname = "127.0.0.1"; | 57 | private string m_thisHostname = "127.0.0.1"; |
58 | private uint m_thisPort = 9000; | 58 | private uint m_thisPort = 9000; |
59 | 59 | ||
60 | // These two used for local access, standalone mode | 60 | // These two used for local access, standalone mode |
61 | private UserManagerBase m_userService = null; | 61 | private UserManagerBase m_userService = null; |
62 | IAssetDataPlugin m_assetProvider = null; | 62 | IAssetDataPlugin m_assetProvider = null; |
63 | 63 | ||
64 | // These two used for remote access | 64 | // These two used for remote access |
65 | string m_UserServerURL = string.Empty; | 65 | string m_UserServerURL = string.Empty; |
66 | string m_AssetServerURL = string.Empty; | 66 | string m_AssetServerURL = string.Empty; |
67 | SynchronousGridAssetClient m_AssetClient = null; | 67 | SynchronousGridAssetClient m_AssetClient = null; |
68 | 68 | ||
69 | // Constructor for grid inventory server | 69 | // Constructor for grid inventory server |
70 | public HGInventoryService(InventoryServiceBase invService, string assetServiceURL, string userServiceURL, IHttpServer httpserver, string thisurl) | 70 | public HGInventoryService(InventoryServiceBase invService, string assetServiceURL, string userServiceURL, IHttpServer httpserver, string thisurl) |
71 | { | 71 | { |
72 | m_UserServerURL = userServiceURL; | 72 | m_UserServerURL = userServiceURL; |
73 | m_AssetServerURL = assetServiceURL; | 73 | m_AssetServerURL = assetServiceURL; |
74 | 74 | ||
75 | m_AssetClient = new SynchronousGridAssetClient(m_AssetServerURL); | 75 | m_AssetClient = new SynchronousGridAssetClient(m_AssetServerURL); |
76 | 76 | ||
77 | Init(invService, thisurl, httpserver); | 77 | Init(invService, thisurl, httpserver); |
78 | } | 78 | } |
79 | 79 | ||
80 | // Constructor for standalone mode | 80 | // Constructor for standalone mode |
81 | public HGInventoryService(InventoryServiceBase invService, IAssetDataPlugin assetService, UserManagerBase userService, IHttpServer httpserver, string thisurl) | 81 | public HGInventoryService(InventoryServiceBase invService, IAssetDataPlugin assetService, UserManagerBase userService, IHttpServer httpserver, string thisurl) |
82 | { | 82 | { |
83 | m_userService = userService; | 83 | m_userService = userService; |
84 | m_assetProvider = assetService; | 84 | m_assetProvider = assetService; |
85 | 85 | ||
86 | Init(invService, thisurl, httpserver); | 86 | Init(invService, thisurl, httpserver); |
87 | } | 87 | } |
88 | 88 | ||
89 | private void Init(InventoryServiceBase invService, string thisurl, IHttpServer httpserver) | 89 | private void Init(InventoryServiceBase invService, string thisurl, IHttpServer httpserver) |
90 | { | 90 | { |
91 | m_inventoryService = invService; | 91 | m_inventoryService = invService; |
92 | m_thisInventoryUrl = thisurl; | 92 | m_thisInventoryUrl = thisurl; |
93 | if (!m_thisInventoryUrl.EndsWith("/")) | 93 | if (!m_thisInventoryUrl.EndsWith("/")) |
94 | m_thisInventoryUrl += "/"; | 94 | m_thisInventoryUrl += "/"; |
95 | 95 | ||
96 | Uri uri = new Uri(m_thisInventoryUrl); | 96 | Uri uri = new Uri(m_thisInventoryUrl); |
97 | if (uri != null) | 97 | if (uri != null) |
98 | { | 98 | { |
99 | m_thisHostname = uri.Host; | 99 | m_thisHostname = uri.Host; |
100 | m_thisPort = (uint)uri.Port; | 100 | m_thisPort = (uint)uri.Port; |
101 | } | 101 | } |
102 | 102 | ||
103 | httpServer = httpserver; | 103 | httpServer = httpserver; |
104 | 104 | ||
105 | AddHttpHandlers(); | 105 | AddHttpHandlers(); |
106 | } | 106 | } |
107 | 107 | ||
108 | public virtual void AddHttpHandlers() | 108 | public virtual void AddHttpHandlers() |
109 | { | 109 | { |
110 | httpServer.AddHTTPHandler("/InvCap/", CapHandler); | 110 | httpServer.AddHTTPHandler("/InvCap/", CapHandler); |
111 | } | 111 | } |
112 | 112 | ||
113 | public bool CheckAuthSession(string session_id, string avatar_id) | 113 | public bool CheckAuthSession(string session_id, string avatar_id) |
114 | { | 114 | { |
115 | return true; | 115 | return true; |
116 | } | 116 | } |
117 | 117 | ||
118 | 118 | ||
119 | // In truth, this is not called from the outside, for standalones. I'm just making it | 119 | // In truth, this is not called from the outside, for standalones. I'm just making it |
120 | // a handler already so that this can be reused for the InventoryServer. | 120 | // a handler already so that this can be reused for the InventoryServer. |
121 | public string CreateCapUrl(Guid _userid) | 121 | public string CreateCapUrl(Guid _userid) |
122 | { | 122 | { |
123 | UUID userID = new UUID(_userid); | 123 | UUID userID = new UUID(_userid); |
124 | UUID random = UUID.Random(); | 124 | UUID random = UUID.Random(); |
125 | string url = m_thisInventoryUrl + random.ToString() + "/"; | 125 | string url = m_thisInventoryUrl + random.ToString() + "/"; |
126 | m_log.InfoFormat("[HGStandaloneInvService] Creating Cap URL {0} for user {1}", url, userID.ToString()); | 126 | m_log.InfoFormat("[HGStandaloneInvService] Creating Cap URL {0} for user {1}", url, userID.ToString()); |
127 | return url; | 127 | return url; |
128 | } | 128 | } |
129 | 129 | ||
130 | /// <summary> | 130 | /// <summary> |
131 | /// Return a user's entire inventory | 131 | /// Return a user's entire inventory |
132 | /// </summary> | 132 | /// </summary> |
133 | /// <param name="rawUserID"></param> | 133 | /// <param name="rawUserID"></param> |
134 | /// <returns>The user's inventory. If an inventory cannot be found then an empty collection is returned.</returns> | 134 | /// <returns>The user's inventory. If an inventory cannot be found then an empty collection is returned.</returns> |
135 | public InventoryCollection GetUserInventory(Guid rawUserID) | 135 | public InventoryCollection GetUserInventory(Guid rawUserID) |
136 | { | 136 | { |
137 | UUID userID = new UUID(rawUserID); | 137 | UUID userID = new UUID(rawUserID); |
138 | 138 | ||
139 | m_log.Info("[HGStandaloneInvModule]: Processing request for inventory of " + userID); | 139 | m_log.Info("[HGStandaloneInvModule]: Processing request for inventory of " + userID); |
140 | 140 | ||
141 | // Uncomment me to simulate a slow responding inventory server | 141 | // Uncomment me to simulate a slow responding inventory server |
142 | //Thread.Sleep(16000); | 142 | //Thread.Sleep(16000); |
143 | 143 | ||
144 | InventoryCollection invCollection = new InventoryCollection(); | 144 | InventoryCollection invCollection = new InventoryCollection(); |
145 | 145 | ||
146 | List<InventoryFolderBase> allFolders = m_inventoryService.GetInventorySkeleton(userID); | 146 | List<InventoryFolderBase> allFolders = m_inventoryService.GetInventorySkeleton(userID); |
147 | 147 | ||
148 | if (null == allFolders) | 148 | if (null == allFolders) |
149 | { | 149 | { |
150 | m_log.WarnFormat("[HGStandaloneInvModule]: No inventory found for user {0}", rawUserID); | 150 | m_log.WarnFormat("[HGStandaloneInvModule]: No inventory found for user {0}", rawUserID); |
151 | 151 | ||
152 | return invCollection; | 152 | return invCollection; |
153 | } | 153 | } |
154 | 154 | ||
155 | List<InventoryItemBase> allItems = new List<InventoryItemBase>(); | 155 | List<InventoryItemBase> allItems = new List<InventoryItemBase>(); |
156 | 156 | ||
157 | foreach (InventoryFolderBase folder in allFolders) | 157 | foreach (InventoryFolderBase folder in allFolders) |
158 | { | 158 | { |
159 | List<InventoryItemBase> items = m_inventoryService.RequestFolderItems(folder.ID); | 159 | List<InventoryItemBase> items = m_inventoryService.RequestFolderItems(folder.ID); |
160 | 160 | ||
161 | if (items != null) | 161 | if (items != null) |
162 | { | 162 | { |
163 | allItems.InsertRange(0, items); | 163 | allItems.InsertRange(0, items); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
167 | invCollection.UserID = userID; | 167 | invCollection.UserID = userID; |
168 | invCollection.Folders = allFolders; | 168 | invCollection.Folders = allFolders; |
169 | invCollection.Items = allItems; | 169 | invCollection.Items = allItems; |
170 | 170 | ||
171 | // foreach (InventoryFolderBase folder in invCollection.Folders) | 171 | // foreach (InventoryFolderBase folder in invCollection.Folders) |
172 | // { | 172 | // { |
173 | // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back folder {0} {1}", folder.Name, folder.ID); | 173 | // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back folder {0} {1}", folder.Name, folder.ID); |
174 | // } | 174 | // } |
175 | // | 175 | // |
176 | // foreach (InventoryItemBase item in invCollection.Items) | 176 | // foreach (InventoryItemBase item in invCollection.Items) |
177 | // { | 177 | // { |
178 | // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder); | 178 | // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder); |
179 | // } | 179 | // } |
180 | 180 | ||
181 | m_log.InfoFormat( | 181 | m_log.InfoFormat( |
182 | "[HGStandaloneInvModule]: Sending back inventory response to user {0} containing {1} folders and {2} items", | 182 | "[HGStandaloneInvModule]: Sending back inventory response to user {0} containing {1} folders and {2} items", |
183 | invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count); | 183 | invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count); |
184 | 184 | ||
185 | return invCollection; | 185 | return invCollection; |
186 | } | 186 | } |
187 | 187 | ||
188 | public InventoryCollection FetchDescendants(InventoryFolderBase fb) | 188 | public InventoryCollection FetchDescendants(InventoryFolderBase fb) |
189 | { | 189 | { |
190 | m_log.Info("[HGStandaloneInvService]: Processing request for folder " + fb.ID); | 190 | m_log.Info("[HGStandaloneInvService]: Processing request for folder " + fb.ID); |
191 | 191 | ||
192 | // Uncomment me to simulate a slow responding inventory server | 192 | // Uncomment me to simulate a slow responding inventory server |
193 | //Thread.Sleep(16000); | 193 | //Thread.Sleep(16000); |
194 | 194 | ||
195 | InventoryCollection invCollection = new InventoryCollection(); | 195 | InventoryCollection invCollection = new InventoryCollection(); |
196 | 196 | ||
197 | List<InventoryItemBase> items = m_inventoryService.RequestFolderItems(fb.ID); | 197 | List<InventoryItemBase> items = m_inventoryService.RequestFolderItems(fb.ID); |
198 | List<InventoryFolderBase> folders = m_inventoryService.RequestSubFolders(fb.ID); | 198 | List<InventoryFolderBase> folders = m_inventoryService.RequestSubFolders(fb.ID); |
199 | 199 | ||
200 | invCollection.UserID = fb.Owner; | 200 | invCollection.UserID = fb.Owner; |
201 | invCollection.Folders = folders; | 201 | invCollection.Folders = folders; |
202 | invCollection.Items = items; | 202 | invCollection.Items = items; |
203 | 203 | ||
204 | m_log.DebugFormat("[HGStandaloneInvService]: Found {0} items and {1} folders", items.Count, folders.Count); | 204 | m_log.DebugFormat("[HGStandaloneInvService]: Found {0} items and {1} folders", items.Count, folders.Count); |
205 | 205 | ||
206 | return invCollection; | 206 | return invCollection; |
207 | } | 207 | } |
208 | 208 | ||
209 | public bool RemoveFolder(InventoryFolderBase folder) | 209 | public bool RemoveFolder(InventoryFolderBase folder) |
210 | { | 210 | { |
211 | m_log.Debug("[HGStandaloneInvService]: Removefolder: Operation not implemented yet."); | 211 | m_log.Debug("[HGStandaloneInvService]: Removefolder: Operation not implemented yet."); |
212 | return false; | 212 | return false; |
213 | } | 213 | } |
214 | 214 | ||
215 | public InventoryItemBase GetInventoryItem(InventoryItemBase item) | 215 | public InventoryItemBase GetInventoryItem(InventoryItemBase item) |
216 | { | 216 | { |
217 | m_log.Info("[HGStandaloneInvService]: Get item " + item.ID); | 217 | m_log.Info("[HGStandaloneInvService]: Get item " + item.ID); |
218 | 218 | ||
219 | item = m_inventoryService.GetInventoryItem(item.ID); | 219 | item = m_inventoryService.GetInventoryItem(item.ID); |
220 | if (item == null) | 220 | if (item == null) |
221 | m_log.Debug("[HGStandaloneInvService]: null item"); | 221 | m_log.Debug("[HGStandaloneInvService]: null item"); |
222 | return item; | 222 | return item; |
223 | } | 223 | } |
224 | 224 | ||
225 | public InventoryItemBase AddItem(InventoryItemBase item) | 225 | public InventoryItemBase AddItem(InventoryItemBase item) |
226 | { | 226 | { |
227 | m_log.DebugFormat("[HGStandaloneInvService]: Add item {0} from {1}", item.ID, item.Owner); | 227 | m_log.DebugFormat("[HGStandaloneInvService]: Add item {0} from {1}", item.ID, item.Owner); |
228 | if (m_inventoryService.AddItem(item)) | 228 | if (m_inventoryService.AddItem(item)) |
229 | return item; | 229 | return item; |
230 | else | 230 | else |
231 | { | 231 | { |
232 | item.ID = UUID.Zero; | 232 | item.ID = UUID.Zero; |
233 | return item; | 233 | return item; |
234 | } | 234 | } |
235 | } | 235 | } |
236 | 236 | ||
237 | public InventoryItemBase UpdateItem(InventoryItemBase item) | 237 | public InventoryItemBase UpdateItem(InventoryItemBase item) |
238 | { | 238 | { |
239 | m_log.DebugFormat("[HGStandaloneInvService]: Update item {0} from {1}", item.ID, item.Owner); | 239 | m_log.DebugFormat("[HGStandaloneInvService]: Update item {0} from {1}", item.ID, item.Owner); |
240 | InventoryItemBase it = m_inventoryService.GetInventoryItem(item.ID); | 240 | InventoryItemBase it = m_inventoryService.GetInventoryItem(item.ID); |
241 | item.CurrentPermissions = it.CurrentPermissions; | 241 | item.CurrentPermissions = it.CurrentPermissions; |
242 | item.AssetID = it.AssetID; | 242 | item.AssetID = it.AssetID; |
243 | if (m_inventoryService.UpdateItem(item)) | 243 | if (m_inventoryService.UpdateItem(item)) |
244 | return item; | 244 | return item; |
245 | else | 245 | else |
246 | { | 246 | { |
247 | item.ID = UUID.Zero; | 247 | item.ID = UUID.Zero; |
248 | return item; | 248 | return item; |
249 | } | 249 | } |
250 | } | 250 | } |
251 | 251 | ||
252 | public InventoryItemBase MoveItem(InventoryItemBase newitem) | 252 | public InventoryItemBase MoveItem(InventoryItemBase newitem) |
253 | { | 253 | { |
254 | m_log.DebugFormat("[HGStandaloneInvService]: Move item {0} from {1}", newitem.ID, newitem.Owner); | 254 | m_log.DebugFormat("[HGStandaloneInvService]: Move item {0} from {1}", newitem.ID, newitem.Owner); |
255 | InventoryItemBase Item = m_inventoryService.GetInventoryItem(newitem.ID); | 255 | InventoryItemBase Item = m_inventoryService.GetInventoryItem(newitem.ID); |
256 | if (Item != null) | 256 | if (Item != null) |
257 | { | 257 | { |
258 | if (newitem.Name != String.Empty) | 258 | if (newitem.Name != String.Empty) |
259 | { | 259 | { |
260 | Item.Name = newitem.Name; | 260 | Item.Name = newitem.Name; |
261 | } | 261 | } |
262 | Item.Folder = newitem.Folder; | 262 | Item.Folder = newitem.Folder; |
263 | m_inventoryService.UpdateItem(Item); | 263 | m_inventoryService.UpdateItem(Item); |
264 | return Item; | 264 | return Item; |
265 | } | 265 | } |
266 | else | 266 | else |
267 | { | 267 | { |
268 | m_log.Debug("[HGStandaloneInvService]: Failed to find item " + newitem.ID); | 268 | m_log.Debug("[HGStandaloneInvService]: Failed to find item " + newitem.ID); |
269 | newitem.ID = UUID.Zero; | 269 | newitem.ID = UUID.Zero; |
270 | return newitem; | 270 | return newitem; |
271 | } | 271 | } |
272 | 272 | ||
273 | } | 273 | } |
274 | 274 | ||
275 | public InventoryItemBase DeleteItem(InventoryItemBase item) | 275 | public InventoryItemBase DeleteItem(InventoryItemBase item) |
276 | { | 276 | { |
277 | item = m_inventoryService.GetInventoryItem(item.ID); | 277 | item = m_inventoryService.GetInventoryItem(item.ID); |
278 | if (m_inventoryService.DeleteItem(item)) | 278 | if (m_inventoryService.DeleteItem(item)) |
279 | return item; | 279 | return item; |
280 | else | 280 | else |
281 | { | 281 | { |
282 | item.ID = UUID.Zero; | 282 | item.ID = UUID.Zero; |
283 | return item; | 283 | return item; |
284 | } | 284 | } |
285 | } | 285 | } |
286 | 286 | ||
287 | public InventoryItemBase CopyItem(InventoryItemBase olditem) | 287 | public InventoryItemBase CopyItem(InventoryItemBase olditem) |
288 | { | 288 | { |
289 | m_log.DebugFormat("[HGStandaloneInvService]: Copy item {0} from {1}", olditem.ID, olditem.Owner); | 289 | m_log.DebugFormat("[HGStandaloneInvService]: Copy item {0} from {1}", olditem.ID, olditem.Owner); |
290 | InventoryItemBase Item = m_inventoryService.GetInventoryItem(olditem.ID); // this is the old item id | 290 | InventoryItemBase Item = m_inventoryService.GetInventoryItem(olditem.ID); // this is the old item id |
291 | // BIG HACK here | 291 | // BIG HACK here |
292 | UUID newID = olditem.AssetID; | 292 | UUID newID = olditem.AssetID; |
293 | if (Item != null) | 293 | if (Item != null) |
294 | { | 294 | { |
295 | if (olditem.Name != String.Empty) | 295 | if (olditem.Name != String.Empty) |
296 | { | 296 | { |
297 | Item.Name = olditem.Name; | 297 | Item.Name = olditem.Name; |
298 | } | 298 | } |
299 | Item.ID = newID; | 299 | Item.ID = newID; |
300 | Item.Folder = olditem.Folder; | 300 | Item.Folder = olditem.Folder; |
301 | Item.Owner = olditem.Owner; | 301 | Item.Owner = olditem.Owner; |
302 | // There should be some tests here about the owner, etc but I'm going to ignore that | 302 | // There should be some tests here about the owner, etc but I'm going to ignore that |
303 | // because I'm not sure it makes any sense | 303 | // because I'm not sure it makes any sense |
304 | // Also I should probably clone the asset... | 304 | // Also I should probably clone the asset... |
305 | m_inventoryService.AddItem(Item); | 305 | m_inventoryService.AddItem(Item); |
306 | return Item; | 306 | return Item; |
307 | } | 307 | } |
308 | else | 308 | else |
309 | { | 309 | { |
310 | m_log.Debug("[HGStandaloneInvService]: Failed to find item " + olditem.ID); | 310 | m_log.Debug("[HGStandaloneInvService]: Failed to find item " + olditem.ID); |
311 | olditem.ID = UUID.Zero; | 311 | olditem.ID = UUID.Zero; |
312 | return olditem; | 312 | return olditem; |
313 | } | 313 | } |
314 | 314 | ||
315 | } | 315 | } |
316 | 316 | ||
317 | /// <summary> | 317 | /// <summary> |
318 | /// Guid to UUID wrapper for same name IInventoryServices method | 318 | /// Guid to UUID wrapper for same name IInventoryServices method |
319 | /// </summary> | 319 | /// </summary> |
320 | /// <param name="rawUserID"></param> | 320 | /// <param name="rawUserID"></param> |
321 | /// <returns></returns> | 321 | /// <returns></returns> |
322 | public List<InventoryFolderBase> GetInventorySkeleton(Guid rawUserID) | 322 | public List<InventoryFolderBase> GetInventorySkeleton(Guid rawUserID) |
323 | { | 323 | { |
324 | UUID userID = new UUID(rawUserID); | 324 | UUID userID = new UUID(rawUserID); |
325 | return m_inventoryService.GetInventorySkeleton(userID); | 325 | return m_inventoryService.GetInventorySkeleton(userID); |
326 | } | 326 | } |
327 | 327 | ||
328 | public List<InventoryItemBase> GetActiveGestures(Guid rawUserID) | 328 | public List<InventoryItemBase> GetActiveGestures(Guid rawUserID) |
329 | { | 329 | { |
330 | UUID userID = new UUID(rawUserID); | 330 | UUID userID = new UUID(rawUserID); |
331 | 331 | ||
332 | m_log.InfoFormat("[HGStandaloneInvService]: fetching active gestures for user {0}", userID); | 332 | m_log.InfoFormat("[HGStandaloneInvService]: fetching active gestures for user {0}", userID); |
333 | 333 | ||
334 | return m_inventoryService.GetActiveGestures(userID); | 334 | return m_inventoryService.GetActiveGestures(userID); |
335 | } | 335 | } |
336 | 336 | ||
337 | public AssetBase GetAsset(InventoryItemBase item) | 337 | public AssetBase GetAsset(InventoryItemBase item) |
338 | { | 338 | { |
339 | m_log.Info("[HGStandaloneInvService]: Get asset " + item.AssetID + " for item " + item.ID); | 339 | m_log.Info("[HGStandaloneInvService]: Get asset " + item.AssetID + " for item " + item.ID); |
340 | AssetBase asset = new AssetBase(item.AssetID, "NULL"); // send an asset with no data | 340 | AssetBase asset = new AssetBase(item.AssetID, "NULL"); // send an asset with no data |
341 | InventoryItemBase item2 = m_inventoryService.GetInventoryItem(item.ID); | 341 | InventoryItemBase item2 = m_inventoryService.GetInventoryItem(item.ID); |
342 | if (item2 == null) | 342 | if (item2 == null) |
343 | { | 343 | { |
344 | m_log.Debug("[HGStandaloneInvService]: null item"); | 344 | m_log.Debug("[HGStandaloneInvService]: null item"); |
345 | return asset; | 345 | return asset; |
346 | } | 346 | } |
347 | if (item2.Owner != item.Owner) | 347 | if (item2.Owner != item.Owner) |
348 | { | 348 | { |
349 | m_log.DebugFormat("[HGStandaloneInvService]: client with uuid {0} is trying to get an item of owner {1}", item.Owner, item2.Owner); | 349 | m_log.DebugFormat("[HGStandaloneInvService]: client with uuid {0} is trying to get an item of owner {1}", item.Owner, item2.Owner); |
350 | return asset; | 350 | return asset; |
351 | } | 351 | } |
352 | 352 | ||
353 | // All good, get the asset | 353 | // All good, get the asset |
354 | //AssetBase theasset = m_assetProvider.FetchAsset(item.AssetID); | 354 | //AssetBase theasset = m_assetProvider.FetchAsset(item.AssetID); |
355 | AssetBase theasset = FetchAsset(item.AssetID, (item.InvType == (int)InventoryType.Texture)); | 355 | AssetBase theasset = FetchAsset(item.AssetID, (item.InvType == (int)InventoryType.Texture)); |
356 | 356 | ||
357 | m_log.Debug("[HGStandaloneInvService] Found asset " + ((theasset == null) ? "NULL" : "Not Null")); | 357 | m_log.Debug("[HGStandaloneInvService] Found asset " + ((theasset == null) ? "NULL" : "Not Null")); |
358 | if (theasset != null) | 358 | if (theasset != null) |
359 | { | 359 | { |
360 | asset = theasset; | 360 | asset = theasset; |
361 | //m_log.Debug(" >> Sending assetID " + item.AssetID); | 361 | //m_log.Debug(" >> Sending assetID " + item.AssetID); |
362 | } | 362 | } |
363 | return asset; | 363 | return asset; |
364 | } | 364 | } |
365 | 365 | ||
366 | public bool PostAsset(AssetBase asset) | 366 | public bool PostAsset(AssetBase asset) |
367 | { | 367 | { |
368 | m_log.Info("[HGStandaloneInvService]: Post asset " + asset.FullID); | 368 | m_log.Info("[HGStandaloneInvService]: Post asset " + asset.FullID); |
369 | //m_assetProvider.CreateAsset(asset); | 369 | //m_assetProvider.CreateAsset(asset); |
370 | StoreAsset(asset); | 370 | StoreAsset(asset); |
371 | 371 | ||
372 | return true; | 372 | return true; |
373 | } | 373 | } |
374 | 374 | ||
375 | /// <summary> | 375 | /// <summary> |
376 | /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see> | 376 | /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see> |
377 | /// </summary> | 377 | /// </summary> |
378 | public UUID UpdateInventoryItemAsset(UUID userID, UUID itemID, byte[] data) | 378 | public UUID UpdateInventoryItemAsset(UUID userID, UUID itemID, byte[] data) |
379 | { | 379 | { |
380 | m_log.Debug("[HGStandaloneInvService]: UpdateInventoryitemAsset for user " + userID + " item " + itemID); | 380 | m_log.Debug("[HGStandaloneInvService]: UpdateInventoryitemAsset for user " + userID + " item " + itemID); |
381 | InventoryItemBase item = m_inventoryService.GetInventoryItem(itemID); | 381 | InventoryItemBase item = m_inventoryService.GetInventoryItem(itemID); |
382 | 382 | ||
383 | if (item != null) | 383 | if (item != null) |
384 | { | 384 | { |
385 | // We're still not dealing with permissions | 385 | // We're still not dealing with permissions |
386 | //if ((InventoryType)item.InvType == InventoryType.Notecard) | 386 | //if ((InventoryType)item.InvType == InventoryType.Notecard) |
387 | //{ | 387 | //{ |
388 | // if (!Permissions.CanEditNotecard(itemID, UUID.Zero, userID)) | 388 | // if (!Permissions.CanEditNotecard(itemID, UUID.Zero, userID)) |
389 | // { | 389 | // { |
390 | // //remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false); | 390 | // //remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false); |
391 | // return UUID.Zero; | 391 | // return UUID.Zero; |
392 | // } | 392 | // } |
393 | 393 | ||
394 | // //remoteClient.SendAgentAlertMessage("Notecard saved", false); | 394 | // //remoteClient.SendAgentAlertMessage("Notecard saved", false); |
395 | //} | 395 | //} |
396 | //else if ((InventoryType)item.InvType == InventoryType.LSL) | 396 | //else if ((InventoryType)item.InvType == InventoryType.LSL) |
397 | //{ | 397 | //{ |
398 | // if (!Permissions.CanEditScript(itemID, UUID.Zero, remoteClient.AgentId)) | 398 | // if (!Permissions.CanEditScript(itemID, UUID.Zero, remoteClient.AgentId)) |
399 | // { | 399 | // { |
400 | // //remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false); | 400 | // //remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false); |
401 | // return UUID.Zero; | 401 | // return UUID.Zero; |
402 | // } | 402 | // } |
403 | 403 | ||
404 | // //remoteClient.SendAgentAlertMessage("Script saved", false); | 404 | // //remoteClient.SendAgentAlertMessage("Script saved", false); |
405 | //} | 405 | //} |
406 | 406 | ||
407 | AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data); | 407 | AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data); |
408 | PostAsset(asset); | 408 | PostAsset(asset); |
409 | 409 | ||
410 | item.AssetID = asset.FullID; | 410 | item.AssetID = asset.FullID; |
411 | item.Owner = userID; | 411 | item.Owner = userID; |
412 | m_inventoryService.UpdateItem(item); | 412 | m_inventoryService.UpdateItem(item); |
413 | 413 | ||
414 | return (asset.FullID); | 414 | return (asset.FullID); |
415 | } | 415 | } |
416 | return UUID.Zero; | 416 | return UUID.Zero; |
417 | } | 417 | } |
418 | 418 | ||
419 | private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data) | 419 | private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data) |
420 | { | 420 | { |
421 | AssetBase asset = new AssetBase(); | 421 | AssetBase asset = new AssetBase(); |
422 | asset.Name = name; | 422 | asset.Name = name; |
423 | asset.Description = description; | 423 | asset.Description = description; |
424 | asset.Type = assetType; | 424 | asset.Type = assetType; |
425 | asset.FullID = UUID.Random(); | 425 | asset.FullID = UUID.Random(); |
426 | asset.Data = (data == null) ? new byte[1] : data; | 426 | asset.Data = (data == null) ? new byte[1] : data; |
427 | 427 | ||
428 | return asset; | 428 | return asset; |
429 | } | 429 | } |
430 | 430 | ||
431 | #region Caps | 431 | #region Caps |
432 | 432 | ||
433 | Dictionary<UUID, Hashtable> invCaps = new Dictionary<UUID, Hashtable>(); | 433 | Dictionary<UUID, Hashtable> invCaps = new Dictionary<UUID, Hashtable>(); |
434 | 434 | ||
435 | public Hashtable CapHandler(Hashtable request) | 435 | public Hashtable CapHandler(Hashtable request) |
436 | { | 436 | { |
437 | m_log.Debug("[CONNECTION DEBUGGING]: InvCapHandler Called"); | 437 | m_log.Debug("[CONNECTION DEBUGGING]: InvCapHandler Called"); |
438 | 438 | ||
439 | m_log.Debug("---------------------------"); | 439 | m_log.Debug("---------------------------"); |
440 | m_log.Debug(" >> uri=" + request["uri"]); | 440 | m_log.Debug(" >> uri=" + request["uri"]); |
441 | m_log.Debug(" >> content-type=" + request["content-type"]); | 441 | m_log.Debug(" >> content-type=" + request["content-type"]); |
442 | m_log.Debug(" >> http-method=" + request["http-method"]); | 442 | m_log.Debug(" >> http-method=" + request["http-method"]); |
443 | m_log.Debug("---------------------------\n"); | 443 | m_log.Debug("---------------------------\n"); |
444 | 444 | ||
445 | // these are requests if the type | 445 | // these are requests if the type |
446 | // http://inventoryserver/InvCap/uuuuuuuu-uuuu-uuuu-uuuu-uuuuuuuuuuuu/kkkkkkkk-kkkk-kkkk-kkkk-kkkkkkkkkkkk/ | 446 | // http://inventoryserver/InvCap/uuuuuuuu-uuuu-uuuu-uuuu-uuuuuuuuuuuu/kkkkkkkk-kkkk-kkkk-kkkk-kkkkkkkkkkkk/ |
447 | 447 | ||
448 | Hashtable responsedata = new Hashtable(); | 448 | Hashtable responsedata = new Hashtable(); |
449 | responsedata["content_type"] = "text/plain"; | 449 | responsedata["content_type"] = "text/plain"; |
450 | 450 | ||
451 | UUID userID; | 451 | UUID userID; |
452 | string authToken = string.Empty; | 452 | string authToken = string.Empty; |
453 | string authority = string.Empty; | 453 | string authority = string.Empty; |
454 | if (!GetParams(request, out userID, out authority, out authToken)) | 454 | if (!GetParams(request, out userID, out authority, out authToken)) |
455 | { | 455 | { |
456 | m_log.InfoFormat("[HGStandaloneInvService]: Invalid parameters for InvCap message {0}", request["uri"]); | 456 | m_log.InfoFormat("[HGStandaloneInvService]: Invalid parameters for InvCap message {0}", request["uri"]); |
457 | responsedata["int_response_code"] = 404; | 457 | responsedata["int_response_code"] = 404; |
458 | responsedata["str_response_string"] = "Not found"; | 458 | responsedata["str_response_string"] = "Not found"; |
459 | 459 | ||
460 | return responsedata; | 460 | return responsedata; |
461 | } | 461 | } |
462 | 462 | ||
463 | // Next, let's parse the verb | 463 | // Next, let's parse the verb |
464 | string method = (string)request["http-method"]; | 464 | string method = (string)request["http-method"]; |
465 | if (method.Equals("GET")) | 465 | if (method.Equals("GET")) |
466 | { | 466 | { |
467 | DoInvCapPost(request, responsedata, userID, authToken); | 467 | DoInvCapPost(request, responsedata, userID, authority, authToken); |
468 | return responsedata; | 468 | return responsedata; |
469 | } | 469 | } |
470 | //else if (method.Equals("DELETE")) | 470 | //else if (method.Equals("DELETE")) |
471 | //{ | 471 | //{ |
472 | // DoAgentDelete(request, responsedata, agentID, action, regionHandle); | 472 | // DoAgentDelete(request, responsedata, agentID, action, regionHandle); |
473 | 473 | ||
474 | // return responsedata; | 474 | // return responsedata; |
475 | //} | 475 | //} |
476 | else | 476 | else |
477 | { | 477 | { |
478 | m_log.InfoFormat("[HGStandaloneInvService]: method {0} not supported in agent message", method); | 478 | m_log.InfoFormat("[HGStandaloneInvService]: method {0} not supported in agent message", method); |
479 | responsedata["int_response_code"] = 405; | 479 | responsedata["int_response_code"] = 405; |
480 | responsedata["str_response_string"] = "Method not allowed"; | 480 | responsedata["str_response_string"] = "Method not allowed"; |
481 | 481 | ||
482 | return responsedata; | 482 | return responsedata; |
483 | } | 483 | } |
484 | 484 | ||
485 | } | 485 | } |
486 | 486 | ||
487 | public virtual void DoInvCapPost(Hashtable request, Hashtable responsedata, UUID userID, string authToken) | 487 | public virtual void DoInvCapPost(Hashtable request, Hashtable responsedata, UUID userID, string authority, string authToken) |
488 | { | 488 | { |
489 | 489 | ||
490 | // This is the meaning of POST agent | 490 | // This is the meaning of POST agent |
491 | 491 | ||
492 | // Check Auth Token | 492 | // Check Auth Token |
493 | if ((m_userService != null) && !(m_userService is IAuthentication)) | 493 | if ((m_userService != null) && !(m_userService is IAuthentication)) |
494 | { | 494 | { |
495 | m_log.Debug("[HGStandaloneInvService]: UserService is not IAuthentication. Denying access to inventory."); | 495 | m_log.Debug("[HGStandaloneInvService]: UserService is not IAuthentication. Denying access to inventory."); |
496 | responsedata["int_response_code"] = 501; | 496 | responsedata["int_response_code"] = 501; |
497 | responsedata["str_response_string"] = "Not implemented"; | 497 | responsedata["str_response_string"] = "Not implemented"; |
498 | return; | 498 | return; |
499 | } | 499 | } |
500 | 500 | ||
501 | bool success = VerifyKey(userID, authToken); | 501 | bool success = VerifyKey(userID, authority, authToken); |
502 | m_log.Debug("[HGStandaloneInvService]: Key verification returned " + success); | 502 | |
503 | 503 | if (success) | |
504 | if (success) | 504 | { |
505 | { | 505 | |
506 | 506 | m_log.DebugFormat("[HGStandaloneInvService]: User has been authorized. Creating service handlers."); | |
507 | m_log.DebugFormat("[HGStandaloneInvService]: User has been authorized. Creating service handlers."); | 507 | |
508 | 508 | // Then establish secret service handlers | |
509 | // Then establish secret service handlers | 509 | |
510 | 510 | Hashtable usercaps = RegisterCaps(userID, authToken); | |
511 | Hashtable usercaps = RegisterCaps(userID, authToken); | 511 | |
512 | 512 | responsedata["int_response_code"] = 200; | |
513 | responsedata["int_response_code"] = 200; | 513 | //responsedata["str_response_string"] = "OK"; |
514 | //responsedata["str_response_string"] = "OK"; | 514 | responsedata["str_response_string"] = SerializeHashtable(usercaps); |
515 | responsedata["str_response_string"] = SerializeHashtable(usercaps); | 515 | } |
516 | } | 516 | else |
517 | else | 517 | { |
518 | { | 518 | m_log.DebugFormat("[HGStandaloneInvService]: User has is unauthorized. Denying service handlers."); |
519 | m_log.DebugFormat("[HGStandaloneInvService]: User has is unauthorized. Denying service handlers."); | 519 | responsedata["int_response_code"] = 403; |
520 | responsedata["int_response_code"] = 403; | 520 | responsedata["str_response_string"] = "Forbidden"; |
521 | responsedata["str_response_string"] = "Forbidden"; | 521 | } |
522 | } | 522 | } |
523 | } | 523 | |
524 | 524 | ||
525 | 525 | /// <summary> | |
526 | /// <summary> | 526 | /// Extract the params from a request. |
527 | /// Extract the params from a request. | 527 | /// </summary> |
528 | /// </summary> | 528 | public static bool GetParams(Hashtable request, out UUID uuid, out string authority, out string authKey) |
529 | public static bool GetParams(Hashtable request, out UUID uuid, out string authority, out string authKey) | 529 | { |
530 | { | 530 | uuid = UUID.Zero; |
531 | uuid = UUID.Zero; | 531 | authority = string.Empty; |
532 | authority = string.Empty; | 532 | authKey = string.Empty; |
533 | authKey = string.Empty; | 533 | |
534 | 534 | string uri = (string)request["uri"]; | |
535 | string uri = (string)request["uri"]; | 535 | uri = uri.Trim(new char[] { '/' }); |
536 | uri = uri.Trim(new char[] { '/' }); | 536 | string[] parts = uri.Split('/'); |
537 | string[] parts = uri.Split('/'); | 537 | if (parts.Length <= 1) |
538 | if (parts.Length <= 1) | 538 | { |
539 | { | 539 | return false; |
540 | return false; | 540 | } |
541 | } | 541 | else |
542 | else | 542 | { |
543 | { | 543 | if (!UUID.TryParse(parts[1], out uuid)) |
544 | if (!UUID.TryParse(parts[1], out uuid)) | 544 | return false; |
545 | return false; | 545 | |
546 | 546 | if (parts.Length >= 3) | |
547 | if (parts.Length >= 3) | 547 | { |
548 | { | 548 | authKey = parts[2]; |
549 | authKey = parts[2]; | 549 | return true; |
550 | return true; | 550 | } |
551 | } | 551 | } |
552 | } | 552 | |
553 | 553 | Uri authUri; | |
554 | Uri authUri; | 554 | Hashtable headers = (Hashtable)request["headers"]; |
555 | Hashtable headers = (Hashtable)request["headers"]; | 555 | |
556 | 556 | // Authorization keys look like this: | |
557 | // Authorization keys look like this: | 557 | // http://orgrid.org:8002/<uuid> |
558 | // http://orgrid.org:8002/<uuid> | 558 | if (headers.ContainsKey("authorization")) |
559 | if (headers.ContainsKey("authorization")) | 559 | { |
560 | { | 560 | if (Uri.TryCreate((string)headers["authorization"], UriKind.Absolute, out authUri)) |
561 | if (Uri.TryCreate((string)headers["authorization"], UriKind.Absolute, out authUri)) | 561 | { |
562 | { | 562 | authority = authUri.Authority; |
563 | authority = authUri.Authority; | 563 | authKey = authUri.PathAndQuery.Trim('/'); |
564 | authKey = authUri.PathAndQuery.Trim('/'); | 564 | m_log.DebugFormat("[HGStandaloneInvService]: Got authority {0} and key {1}", authority, authKey); |
565 | m_log.DebugFormat("[HGStandaloneInvService]: Got authority {0} and key {1}", authority, authKey); | 565 | return true; |
566 | return true; | 566 | } |
567 | } | 567 | else |
568 | else | 568 | m_log.Debug("[HGStandaloneInvService]: Wrong format for Authorization header: " + (string)headers["authorization"]); |
569 | m_log.Debug("[HGStandaloneInvService]: Wrong format for Authorization header: " + (string)headers["authorization"]); | 569 | } |
570 | } | 570 | else |
571 | else | 571 | m_log.Debug("[HGStandaloneInvService]: Authorization header not found"); |
572 | m_log.Debug("[HGStandaloneInvService]: Authorization header not found"); | 572 | |
573 | 573 | return false; | |
574 | return false; | 574 | } |
575 | } | 575 | |
576 | 576 | string SerializeHashtable(Hashtable hash) | |
577 | string SerializeHashtable(Hashtable hash) | 577 | { |
578 | { | 578 | string result = string.Empty; |
579 | string result = string.Empty; | 579 | foreach (object key in hash.Keys) |
580 | foreach (object key in hash.Keys) | 580 | { |
581 | { | 581 | result += key.ToString() + "," + hash[key].ToString() + ";"; |
582 | result += key.ToString() + "," + hash[key].ToString() + ";"; | 582 | } |
583 | } | 583 | return result; |
584 | return result; | 584 | } |
585 | } | 585 | |
586 | 586 | Hashtable RegisterCaps(UUID userID, string authToken) | |
587 | Hashtable RegisterCaps(UUID userID, string authToken) | 587 | { |
588 | { | 588 | lock (invCaps) |
589 | lock (invCaps) | 589 | { |
590 | { | 590 | if (invCaps.ContainsKey(userID)) |
591 | if (invCaps.ContainsKey(userID)) | 591 | { |
592 | { | 592 | // Remove the old ones |
593 | // Remove the old ones | 593 | DeregisterCaps(httpServer, invCaps[userID]); |
594 | DeregisterCaps(httpServer, invCaps[userID]); | 594 | invCaps.Remove(userID); |
595 | invCaps.Remove(userID); | 595 | } |
596 | } | 596 | } |
597 | } | 597 | |
598 | 598 | Caps caps = new Caps(null, httpServer, m_thisHostname, m_thisPort, authToken, userID, false, "Inventory"); | |
599 | Caps caps = new Caps(null, httpServer, m_thisHostname, m_thisPort, authToken, userID, false, "Inventory"); | 599 | caps.RegisterInventoryServiceHandlers("/" + authToken + "/InventoryCap/"); |
600 | caps.RegisterInventoryServiceHandlers("/" + authToken + "/InventoryCap/"); | 600 | caps.ItemUpdatedCall = UpdateInventoryItemAsset; |
601 | caps.ItemUpdatedCall = UpdateInventoryItemAsset; | 601 | Hashtable capsHandlers = caps.CapsHandlers.CapsDetails; |
602 | Hashtable capsHandlers = caps.CapsHandlers.CapsDetails; | 602 | |
603 | 603 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<Guid, InventoryCollection>( | |
604 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<Guid, InventoryCollection>( | 604 | "POST", AddAndGetCapUrl(authToken, "GetInventory", capsHandlers), GetUserInventory, CheckAuthSession)); |
605 | "POST", AddAndGetCapUrl(authToken, "GetInventory", capsHandlers), GetUserInventory, CheckAuthSession)); | 605 | |
606 | 606 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, InventoryCollection>( | |
607 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, InventoryCollection>( | 607 | "POST", AddAndGetCapUrl(authToken, "FetchDescendants", capsHandlers), FetchDescendants, CheckAuthSession)); |
608 | "POST", AddAndGetCapUrl(authToken, "FetchDescendants", capsHandlers), FetchDescendants, CheckAuthSession)); | 608 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( |
609 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | 609 | "POST", AddAndGetCapUrl(authToken, "NewFolder", capsHandlers), m_inventoryService.AddFolder, CheckAuthSession)); |
610 | "POST", AddAndGetCapUrl(authToken, "NewFolder", capsHandlers), m_inventoryService.AddFolder, CheckAuthSession)); | 610 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( |
611 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | 611 | "POST", AddAndGetCapUrl(authToken, "UpdateFolder", capsHandlers), m_inventoryService.UpdateFolder, CheckAuthSession)); |
612 | "POST", AddAndGetCapUrl(authToken, "UpdateFolder", capsHandlers), m_inventoryService.UpdateFolder, CheckAuthSession)); | 612 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( |
613 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | 613 | "POST", AddAndGetCapUrl(authToken, "MoveFolder", capsHandlers), m_inventoryService.MoveFolder, CheckAuthSession)); |
614 | "POST", AddAndGetCapUrl(authToken, "MoveFolder", capsHandlers), m_inventoryService.MoveFolder, CheckAuthSession)); | 614 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( |
615 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | 615 | "POST", AddAndGetCapUrl(authToken, "PurgeFolder", capsHandlers), m_inventoryService.PurgeFolder, CheckAuthSession)); |
616 | "POST", AddAndGetCapUrl(authToken, "PurgeFolder", capsHandlers), m_inventoryService.PurgeFolder, CheckAuthSession)); | 616 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( |
617 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( | 617 | "POST", AddAndGetCapUrl(authToken, "RemoveFolder", capsHandlers), RemoveFolder, CheckAuthSession)); |
618 | "POST", AddAndGetCapUrl(authToken, "RemoveFolder", capsHandlers), RemoveFolder, CheckAuthSession)); | 618 | |
619 | 619 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>( | |
620 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>( | 620 | "POST", AddAndGetCapUrl(authToken, "GetItem", capsHandlers), GetInventoryItem, CheckAuthSession)); |
621 | "POST", AddAndGetCapUrl(authToken, "GetItem", capsHandlers), GetInventoryItem, CheckAuthSession)); | 621 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>( |
622 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>( | 622 | "POST", AddAndGetCapUrl(authToken, "NewItem", capsHandlers), AddItem, CheckAuthSession)); |
623 | "POST", AddAndGetCapUrl(authToken, "NewItem", capsHandlers), AddItem, CheckAuthSession)); | 623 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>( |
624 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>( | 624 | "POST", AddAndGetCapUrl(authToken, "UpdateItem", capsHandlers), UpdateItem, CheckAuthSession)); |
625 | "POST", AddAndGetCapUrl(authToken, "UpdateItem", capsHandlers), UpdateItem, CheckAuthSession)); | 625 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>( |
626 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>( | 626 | "POST", AddAndGetCapUrl(authToken, "MoveItem", capsHandlers), MoveItem, CheckAuthSession)); |
627 | "POST", AddAndGetCapUrl(authToken, "MoveItem", capsHandlers), MoveItem, CheckAuthSession)); | 627 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>( |
628 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>( | 628 | "POST", AddAndGetCapUrl(authToken, "DeleteItem", capsHandlers), DeleteItem, CheckAuthSession)); |
629 | "POST", AddAndGetCapUrl(authToken, "DeleteItem", capsHandlers), DeleteItem, CheckAuthSession)); | 629 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>( |
630 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>( | 630 | "POST", AddAndGetCapUrl(authToken, "CopyItem", capsHandlers), CopyItem, CheckAuthSession)); |
631 | "POST", AddAndGetCapUrl(authToken, "CopyItem", capsHandlers), CopyItem, CheckAuthSession)); | 631 | |
632 | 632 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, AssetBase>( | |
633 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<InventoryItemBase, AssetBase>( | 633 | "POST", AddAndGetCapUrl(authToken, "GetAsset", capsHandlers), GetAsset, CheckAuthSession)); |
634 | "POST", AddAndGetCapUrl(authToken, "GetAsset", capsHandlers), GetAsset, CheckAuthSession)); | 634 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<AssetBase, bool>( |
635 | httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<AssetBase, bool>( | 635 | "POST", AddAndGetCapUrl(authToken, "PostAsset", capsHandlers), PostAsset, CheckAuthSession)); |
636 | "POST", AddAndGetCapUrl(authToken, "PostAsset", capsHandlers), PostAsset, CheckAuthSession)); | 636 | |
637 | 637 | lock (invCaps) | |
638 | lock (invCaps) | 638 | invCaps.Add(userID, capsHandlers); |
639 | invCaps.Add(userID, capsHandlers); | 639 | |
640 | 640 | return capsHandlers; | |
641 | return capsHandlers; | 641 | } |
642 | } | 642 | |
643 | 643 | string AddAndGetCapUrl(string authToken, string capType, Hashtable caps) | |
644 | string AddAndGetCapUrl(string authToken, string capType, Hashtable caps) | 644 | { |
645 | { | 645 | string capUrl = "/" + authToken + "/" + capType + "/"; |
646 | string capUrl = "/" + authToken + "/" + capType + "/"; | 646 | |
647 | 647 | m_log.Debug("[HGStandaloneInvService] Adding inventory cap " + capUrl); | |
648 | m_log.Debug("[HGStandaloneInvService] Adding inventory cap " + capUrl); | 648 | caps.Add(capType, capUrl); |
649 | caps.Add(capType, capUrl); | 649 | return capUrl; |
650 | return capUrl; | 650 | } |
651 | } | 651 | |
652 | 652 | void DeregisterCaps(IHttpServer httpServer, Hashtable caps) | |
653 | void DeregisterCaps(IHttpServer httpServer, Hashtable caps) | 653 | { |
654 | { | 654 | foreach (string capUrl in caps.Values) |
655 | foreach (string capUrl in caps.Values) | 655 | { |
656 | { | 656 | m_log.Debug("[HGStandaloneInvService] Removing inventory cap " + capUrl); |
657 | m_log.Debug("[HGStandaloneInvService] Removing inventory cap " + capUrl); | 657 | httpServer.RemoveStreamHandler("POST", capUrl); |
658 | httpServer.RemoveStreamHandler("POST", capUrl); | 658 | } |
659 | } | 659 | } |
660 | } | 660 | |
661 | 661 | #endregion Caps | |
662 | #endregion Caps | 662 | |
663 | 663 | #region Local vs Remote | |
664 | #region Local vs Remote | 664 | |
665 | 665 | bool VerifyKey(UUID userID, string authority, string key) | |
666 | bool VerifyKey(UUID userID, string key) | 666 | { |
667 | { | 667 | // Remote call to the Authorization server |
668 | // Remote call to the Authorization server | 668 | if (m_userService == null) |
669 | if (m_userService == null) | 669 | return AuthClient.VerifyKey("http://" + authority, userID, key); |
670 | return AuthClient.VerifyKey(m_UserServerURL, userID, key); | 670 | // local call |
671 | // local call | 671 | else |
672 | else | 672 | return ((IAuthentication)m_userService).VerifyKey(userID, key); |
673 | return ((IAuthentication)m_userService).VerifyKey(userID, key); | 673 | } |
674 | } | 674 | |
675 | 675 | AssetBase FetchAsset(UUID assetID, bool isTexture) | |
676 | AssetBase FetchAsset(UUID assetID, bool isTexture) | 676 | { |
677 | { | 677 | // Remote call to the Asset server |
678 | // Remote call to the Asset server | 678 | if (m_assetProvider == null) |
679 | if (m_assetProvider == null) | 679 | return m_AssetClient.SyncGetAsset(assetID, isTexture); |
680 | return m_AssetClient.SyncGetAsset(assetID, isTexture); | 680 | // local call |
681 | // local call | 681 | else |
682 | else | 682 | return m_assetProvider.FetchAsset(assetID); |
683 | return m_assetProvider.FetchAsset(assetID); | 683 | } |
684 | } | 684 | |
685 | 685 | void StoreAsset(AssetBase asset) | |
686 | void StoreAsset(AssetBase asset) | 686 | { |
687 | { | 687 | // Remote call to the Asset server |
688 | // Remote call to the Asset server | 688 | if (m_assetProvider == null) |
689 | if (m_assetProvider == null) | 689 | m_AssetClient.StoreAsset(asset); |
690 | m_AssetClient.StoreAsset(asset); | 690 | // local call |
691 | // local call | 691 | else |
692 | else | 692 | m_assetProvider.CreateAsset(asset); |
693 | m_assetProvider.CreateAsset(asset); | 693 | } |
694 | } | 694 | |
695 | 695 | #endregion Local vs Remote | |
696 | #endregion Local vs Remote | 696 | } |
697 | } | 697 | |
698 | 698 | class SynchronousGridAssetClient : GridAssetClient | |
699 | class SynchronousGridAssetClient : GridAssetClient | 699 | { |
700 | { | 700 | public SynchronousGridAssetClient(string url) |
701 | public SynchronousGridAssetClient(string url) | 701 | : base(url) |
702 | : base(url) | 702 | { |
703 | { | 703 | } |
704 | } | 704 | |
705 | 705 | public AssetBase SyncGetAsset(UUID assetID, bool isTexture) | |
706 | public AssetBase SyncGetAsset(UUID assetID, bool isTexture) | 706 | { |
707 | { | 707 | AssetRequest assReq = new AssetRequest(); |
708 | AssetRequest assReq = new AssetRequest(); | 708 | assReq.AssetID = assetID; |
709 | assReq.AssetID = assetID; | 709 | assReq.IsTexture = isTexture; |
710 | assReq.IsTexture = isTexture; | 710 | return base.GetAsset(assReq); |
711 | return base.GetAsset(assReq); | 711 | } |
712 | } | 712 | |
713 | 713 | } | |
714 | } | 714 | } |
715 | } | ||
diff --git a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs index 72e2dfb..99fbb2b 100644 --- a/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs +++ b/OpenSim/Framework/Communications/Services/HGLoginAuthService.cs | |||
@@ -1,328 +1,328 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSimulator Project nor the | 12 | * * Neither the name of the OpenSimulator Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Net; | 31 | using System.Net; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.Text.RegularExpressions; | 33 | using System.Text.RegularExpressions; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Communications.Cache; | 35 | using OpenSim.Framework.Communications.Cache; |
36 | using OpenSim.Framework.Communications.Capabilities; | 36 | using OpenSim.Framework.Communications.Capabilities; |
37 | using OpenSim.Framework.Servers; | 37 | using OpenSim.Framework.Servers; |
38 | 38 | ||
39 | using OpenMetaverse; | 39 | using OpenMetaverse; |
40 | 40 | ||
41 | using log4net; | 41 | using log4net; |
42 | using Nini.Config; | 42 | using Nini.Config; |
43 | using Nwc.XmlRpc; | 43 | using Nwc.XmlRpc; |
44 | 44 | ||
45 | namespace OpenSim.Framework.Communications.Services | 45 | namespace OpenSim.Framework.Communications.Services |
46 | { | 46 | { |
47 | public class HGLoginAuthService : LoginService | 47 | public class HGLoginAuthService : LoginService |
48 | { | 48 | { |
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
50 | 50 | ||
51 | protected NetworkServersInfo m_serversInfo; | 51 | protected NetworkServersInfo m_serversInfo; |
52 | protected bool m_authUsers = false; | 52 | protected bool m_authUsers = false; |
53 | 53 | ||
54 | /// <summary> | 54 | /// <summary> |
55 | /// Used by the login service to make requests to the inventory service. | 55 | /// Used by the login service to make requests to the inventory service. |
56 | /// </summary> | 56 | /// </summary> |
57 | protected IInterServiceInventoryServices m_interServiceInventoryService; | 57 | protected IInterServiceInventoryServices m_interServiceInventoryService; |
58 | 58 | ||
59 | /// <summary> | 59 | /// <summary> |
60 | /// Used to make requests to the local regions. | 60 | /// Used to make requests to the local regions. |
61 | /// </summary> | 61 | /// </summary> |
62 | protected ILoginServiceToRegionsConnector m_regionsConnector; | 62 | protected ILoginServiceToRegionsConnector m_regionsConnector; |
63 | 63 | ||
64 | 64 | ||
65 | public HGLoginAuthService( | 65 | public HGLoginAuthService( |
66 | UserManagerBase userManager, string welcomeMess, | 66 | UserManagerBase userManager, string welcomeMess, |
67 | IInterServiceInventoryServices interServiceInventoryService, | 67 | IInterServiceInventoryServices interServiceInventoryService, |
68 | NetworkServersInfo serversInfo, | 68 | NetworkServersInfo serversInfo, |
69 | bool authenticate, LibraryRootFolder libraryRootFolder, ILoginServiceToRegionsConnector regionsConnector) | 69 | bool authenticate, LibraryRootFolder libraryRootFolder, ILoginServiceToRegionsConnector regionsConnector) |
70 | : base(userManager, libraryRootFolder, welcomeMess) | 70 | : base(userManager, libraryRootFolder, welcomeMess) |
71 | { | 71 | { |
72 | this.m_serversInfo = serversInfo; | 72 | this.m_serversInfo = serversInfo; |
73 | if (m_serversInfo != null) | 73 | if (m_serversInfo != null) |
74 | { | 74 | { |
75 | m_defaultHomeX = this.m_serversInfo.DefaultHomeLocX; | 75 | m_defaultHomeX = this.m_serversInfo.DefaultHomeLocX; |
76 | m_defaultHomeY = this.m_serversInfo.DefaultHomeLocY; | 76 | m_defaultHomeY = this.m_serversInfo.DefaultHomeLocY; |
77 | } | 77 | } |
78 | m_authUsers = authenticate; | 78 | m_authUsers = authenticate; |
79 | 79 | ||
80 | m_interServiceInventoryService = interServiceInventoryService; | 80 | m_interServiceInventoryService = interServiceInventoryService; |
81 | m_regionsConnector = regionsConnector; | 81 | m_regionsConnector = regionsConnector; |
82 | m_inventoryService = interServiceInventoryService; | 82 | m_inventoryService = interServiceInventoryService; |
83 | } | 83 | } |
84 | 84 | ||
85 | public void SetServersInfo(NetworkServersInfo sinfo) | 85 | public void SetServersInfo(NetworkServersInfo sinfo) |
86 | { | 86 | { |
87 | m_serversInfo = sinfo; | 87 | m_serversInfo = sinfo; |
88 | } | 88 | } |
89 | 89 | ||
90 | public override XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) | 90 | public override XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) |
91 | { | 91 | { |
92 | m_log.Info("[HGLOGIN] HGLogin called " + request.MethodName); | 92 | m_log.Info("[HGLOGIN] HGLogin called " + request.MethodName); |
93 | XmlRpcResponse response = base.XmlRpcLoginMethod(request); | 93 | XmlRpcResponse response = base.XmlRpcLoginMethod(request); |
94 | Hashtable responseData = (Hashtable)response.Value; | 94 | Hashtable responseData = (Hashtable)response.Value; |
95 | 95 | ||
96 | responseData["grid_service"] = m_serversInfo.GridURL; | 96 | responseData["grid_service"] = m_serversInfo.GridURL; |
97 | responseData["grid_service_send_key"] = m_serversInfo.GridSendKey; | 97 | responseData["grid_service_send_key"] = m_serversInfo.GridSendKey; |
98 | responseData["inventory_service"] = m_serversInfo.InventoryURL; | 98 | responseData["inventory_service"] = m_serversInfo.InventoryURL; |
99 | responseData["asset_service"] = m_serversInfo.AssetURL; | 99 | responseData["asset_service"] = m_serversInfo.AssetURL; |
100 | responseData["asset_service_send_key"] = m_serversInfo.AssetSendKey; | 100 | responseData["asset_service_send_key"] = m_serversInfo.AssetSendKey; |
101 | int x = (Int32)responseData["region_x"]; | 101 | int x = (Int32)responseData["region_x"]; |
102 | int y = (Int32)responseData["region_y"]; | 102 | int y = (Int32)responseData["region_y"]; |
103 | uint ux = (uint)(x / Constants.RegionSize); | 103 | uint ux = (uint)(x / Constants.RegionSize); |
104 | uint uy = (uint)(y / Constants.RegionSize); | 104 | uint uy = (uint)(y / Constants.RegionSize); |
105 | ulong regionHandle = Util.UIntsToLong(ux, uy); | 105 | ulong regionHandle = Util.UIntsToLong(ux, uy); |
106 | responseData["region_handle"] = regionHandle.ToString(); | 106 | responseData["region_handle"] = regionHandle.ToString(); |
107 | 107 | ||
108 | // Let's remove the seed cap from the login | 108 | // Let's remove the seed cap from the login |
109 | //responseData.Remove("seed_capability"); | 109 | //responseData.Remove("seed_capability"); |
110 | 110 | ||
111 | // Let's add the appearance | 111 | // Let's add the appearance |
112 | UUID userID = UUID.Zero; | 112 | UUID userID = UUID.Zero; |
113 | UUID.TryParse((string)responseData["agent_id"], out userID); | 113 | UUID.TryParse((string)responseData["agent_id"], out userID); |
114 | AvatarAppearance appearance = m_userManager.GetUserAppearance(userID); | 114 | AvatarAppearance appearance = m_userManager.GetUserAppearance(userID); |
115 | if (appearance == null) | 115 | if (appearance == null) |
116 | { | 116 | { |
117 | m_log.WarnFormat("[INTER]: Appearance not found for {0}. Creating default.", userID); | 117 | m_log.WarnFormat("[INTER]: Appearance not found for {0}. Creating default.", userID); |
118 | appearance = new AvatarAppearance(); | 118 | appearance = new AvatarAppearance(); |
119 | } | 119 | } |
120 | 120 | ||
121 | responseData["appearance"] = appearance.ToHashTable(); | 121 | responseData["appearance"] = appearance.ToHashTable(); |
122 | 122 | ||
123 | // Let's also send the auth token | 123 | // Let's also send the auth token |
124 | UUID token = UUID.Random(); | 124 | UUID token = UUID.Random(); |
125 | responseData["auth_token"] = token.ToString(); | 125 | responseData["auth_token"] = token.ToString(); |
126 | UserProfileData userProfile = m_userManager.GetUserProfile(userID); | 126 | UserProfileData userProfile = m_userManager.GetUserProfile(userID); |
127 | if (userProfile != null) | 127 | if (userProfile != null) |
128 | { | 128 | { |
129 | userProfile.WebLoginKey = token; | 129 | userProfile.WebLoginKey = token; |
130 | m_userManager.CommitAgent(ref userProfile); | 130 | m_userManager.CommitAgent(ref userProfile); |
131 | } | 131 | } |
132 | 132 | ||
133 | return response; | 133 | return response; |
134 | } | 134 | } |
135 | 135 | ||
136 | public XmlRpcResponse XmlRpcGenerateKeyMethod(XmlRpcRequest request) | 136 | public XmlRpcResponse XmlRpcGenerateKeyMethod(XmlRpcRequest request) |
137 | { | 137 | { |
138 | 138 | ||
139 | // Verify the key of who's calling | 139 | // Verify the key of who's calling |
140 | UUID userID = UUID.Zero; | 140 | UUID userID = UUID.Zero; |
141 | UUID authKey = UUID.Zero; | 141 | UUID authKey = UUID.Zero; |
142 | UUID.TryParse((string)request.Params[0], out userID); | 142 | UUID.TryParse((string)request.Params[0], out userID); |
143 | UUID.TryParse((string)request.Params[1], out authKey); | 143 | UUID.TryParse((string)request.Params[1], out authKey); |
144 | 144 | ||
145 | m_log.InfoFormat("[HGLOGIN] HGGenerateKey called with authToken ", authKey); | 145 | m_log.InfoFormat("[HGLOGIN] HGGenerateKey called with authToken ", authKey); |
146 | string newKey = string.Empty; | 146 | string newKey = string.Empty; |
147 | 147 | ||
148 | if (!(m_userManager is IAuthentication)) | 148 | if (!(m_userManager is IAuthentication)) |
149 | { | 149 | { |
150 | m_log.Debug("[HGLOGIN]: UserManager is not IAuthentication service. Returning empty key."); | 150 | m_log.Debug("[HGLOGIN]: UserManager is not IAuthentication service. Returning empty key."); |
151 | } | 151 | } |
152 | else | 152 | else |
153 | { | 153 | { |
154 | newKey = ((IAuthentication)m_userManager).GetNewKey(m_serversInfo.UserURL, userID, authKey); | 154 | newKey = ((IAuthentication)m_userManager).GetNewKey(m_serversInfo.UserURL, userID, authKey); |
155 | } | 155 | } |
156 | 156 | ||
157 | XmlRpcResponse response = new XmlRpcResponse(); | 157 | XmlRpcResponse response = new XmlRpcResponse(); |
158 | response.Value = (string) newKey; | 158 | response.Value = (string) newKey; |
159 | return response; | 159 | return response; |
160 | } | 160 | } |
161 | 161 | ||
162 | public XmlRpcResponse XmlRpcVerifyKeyMethod(XmlRpcRequest request) | 162 | public XmlRpcResponse XmlRpcVerifyKeyMethod(XmlRpcRequest request) |
163 | { | 163 | { |
164 | bool success = false; | 164 | bool success = false; |
165 | 165 | ||
166 | if (request.Params.Count >= 2) | 166 | if (request.Params.Count >= 2) |
167 | { | 167 | { |
168 | // Verify the key of who's calling | 168 | // Verify the key of who's calling |
169 | UUID userID = UUID.Zero; | 169 | UUID userID = UUID.Zero; |
170 | string authKey = string.Empty; | 170 | string authKey = string.Empty; |
171 | if (UUID.TryParse((string)request.Params[0], out userID)) | 171 | if (UUID.TryParse((string)request.Params[0], out userID)) |
172 | { | 172 | { |
173 | authKey = (string)request.Params[1]; | 173 | authKey = (string)request.Params[1]; |
174 | 174 | ||
175 | m_log.InfoFormat("[HGLOGIN] HGVerifyKey called with key {0}", authKey); | 175 | m_log.InfoFormat("[HGLOGIN] HGVerifyKey called with key {0}", authKey); |
176 | 176 | ||
177 | if (!(m_userManager is IAuthentication)) | 177 | if (!(m_userManager is IAuthentication)) |
178 | { | 178 | { |
179 | m_log.Debug("[HGLOGIN]: UserManager is not IAuthentication service. Denying."); | 179 | m_log.Debug("[HGLOGIN]: UserManager is not IAuthentication service. Denying."); |
180 | } | 180 | } |
181 | else | 181 | else |
182 | { | 182 | { |
183 | success = ((IAuthentication)m_userManager).VerifyKey(userID, authKey); | 183 | success = ((IAuthentication)m_userManager).VerifyKey(userID, authKey); |
184 | } | 184 | } |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | m_log.DebugFormat("[HGLOGIN]: Response to VerifyKey is {0}", success); | 188 | m_log.DebugFormat("[HGLOGIN]: Response to VerifyKey is {0}", success); |
189 | XmlRpcResponse response = new XmlRpcResponse(); | 189 | XmlRpcResponse response = new XmlRpcResponse(); |
190 | response.Value = success; | 190 | response.Value = success; |
191 | return response; | 191 | return response; |
192 | } | 192 | } |
193 | 193 | ||
194 | public override UserProfileData GetTheUser(string firstname, string lastname) | 194 | public override UserProfileData GetTheUser(string firstname, string lastname) |
195 | { | 195 | { |
196 | UserProfileData profile = m_userManager.GetUserProfile(firstname, lastname); | 196 | UserProfileData profile = m_userManager.GetUserProfile(firstname, lastname); |
197 | if (profile != null) | 197 | if (profile != null) |
198 | { | 198 | { |
199 | return profile; | 199 | return profile; |
200 | } | 200 | } |
201 | 201 | ||
202 | if (!m_authUsers) | 202 | if (!m_authUsers) |
203 | { | 203 | { |
204 | //no current user account so make one | 204 | //no current user account so make one |
205 | m_log.Info("[LOGIN]: No user account found so creating a new one."); | 205 | m_log.Info("[LOGIN]: No user account found so creating a new one."); |
206 | 206 | ||
207 | m_userManager.AddUser(firstname, lastname, "test", "", m_defaultHomeX, m_defaultHomeY); | 207 | m_userManager.AddUser(firstname, lastname, "test", "", m_defaultHomeX, m_defaultHomeY); |
208 | 208 | ||
209 | return m_userManager.GetUserProfile(firstname, lastname); | 209 | return m_userManager.GetUserProfile(firstname, lastname); |
210 | } | 210 | } |
211 | 211 | ||
212 | return null; | 212 | return null; |
213 | } | 213 | } |
214 | 214 | ||
215 | public override bool AuthenticateUser(UserProfileData profile, string password) | 215 | public override bool AuthenticateUser(UserProfileData profile, string password) |
216 | { | 216 | { |
217 | if (!m_authUsers) | 217 | if (!m_authUsers) |
218 | { | 218 | { |
219 | //for now we will accept any password in sandbox mode | 219 | //for now we will accept any password in sandbox mode |
220 | m_log.Info("[LOGIN]: Authorising user (no actual password check)"); | 220 | m_log.Info("[LOGIN]: Authorising user (no actual password check)"); |
221 | 221 | ||
222 | return true; | 222 | return true; |
223 | } | 223 | } |
224 | else | 224 | else |
225 | { | 225 | { |
226 | m_log.Info( | 226 | m_log.Info( |
227 | "[LOGIN]: Authenticating " + profile.FirstName + " " + profile.SurName); | 227 | "[LOGIN]: Authenticating " + profile.FirstName + " " + profile.SurName); |
228 | 228 | ||
229 | if (!password.StartsWith("$1$")) | 229 | if (!password.StartsWith("$1$")) |
230 | password = "$1$" + Util.Md5Hash(password); | 230 | password = "$1$" + Util.Md5Hash(password); |
231 | 231 | ||
232 | password = password.Remove(0, 3); //remove $1$ | 232 | password = password.Remove(0, 3); //remove $1$ |
233 | 233 | ||
234 | string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); | 234 | string s = Util.Md5Hash(password + ":" + profile.PasswordSalt); |
235 | 235 | ||
236 | bool loginresult = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) | 236 | bool loginresult = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) |
237 | || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); | 237 | || profile.PasswordHash.Equals(password, StringComparison.InvariantCultureIgnoreCase)); |
238 | return loginresult; | 238 | return loginresult; |
239 | } | 239 | } |
240 | } | 240 | } |
241 | 241 | ||
242 | protected override RegionInfo RequestClosestRegion(string region) | 242 | protected override RegionInfo RequestClosestRegion(string region) |
243 | { | 243 | { |
244 | return m_regionsConnector.RequestClosestRegion(region); | 244 | return m_regionsConnector.RequestClosestRegion(region); |
245 | } | 245 | } |
246 | 246 | ||
247 | protected override RegionInfo GetRegionInfo(ulong homeRegionHandle) | 247 | protected override RegionInfo GetRegionInfo(ulong homeRegionHandle) |
248 | { | 248 | { |
249 | return m_regionsConnector.RequestNeighbourInfo(homeRegionHandle); | 249 | return m_regionsConnector.RequestNeighbourInfo(homeRegionHandle); |
250 | } | 250 | } |
251 | 251 | ||
252 | protected override RegionInfo GetRegionInfo(UUID homeRegionId) | 252 | protected override RegionInfo GetRegionInfo(UUID homeRegionId) |
253 | { | 253 | { |
254 | return m_regionsConnector.RequestNeighbourInfo(homeRegionId); | 254 | return m_regionsConnector.RequestNeighbourInfo(homeRegionId); |
255 | } | 255 | } |
256 | 256 | ||
257 | 257 | ||
258 | /// <summary> | 258 | /// <summary> |
259 | /// Not really informing the region. Just filling out the response fields related to the region. | 259 | /// Not really informing the region. Just filling out the response fields related to the region. |
260 | /// </summary> | 260 | /// </summary> |
261 | /// <param name="sim"></param> | 261 | /// <param name="sim"></param> |
262 | /// <param name="user"></param> | 262 | /// <param name="user"></param> |
263 | /// <param name="response"></param> | 263 | /// <param name="response"></param> |
264 | /// <returns>true if the region was successfully contacted, false otherwise</returns> | 264 | /// <returns>true if the region was successfully contacted, false otherwise</returns> |
265 | protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response) | 265 | protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response) |
266 | { | 266 | { |
267 | IPEndPoint endPoint = regionInfo.ExternalEndPoint; | 267 | IPEndPoint endPoint = regionInfo.ExternalEndPoint; |
268 | response.SimAddress = endPoint.Address.ToString(); | 268 | response.SimAddress = endPoint.Address.ToString(); |
269 | response.SimPort = (uint)endPoint.Port; | 269 | response.SimPort = (uint)endPoint.Port; |
270 | response.RegionX = regionInfo.RegionLocX; | 270 | response.RegionX = regionInfo.RegionLocX; |
271 | response.RegionY = regionInfo.RegionLocY; | 271 | response.RegionY = regionInfo.RegionLocY; |
272 | response.SimHttpPort = regionInfo.HttpPort; | 272 | response.SimHttpPort = regionInfo.HttpPort; |
273 | 273 | ||
274 | string capsPath = CapsUtil.GetRandomCapsObjectPath(); | 274 | string capsPath = CapsUtil.GetRandomCapsObjectPath(); |
275 | string capsSeedPath = CapsUtil.GetCapsSeedPath(capsPath); | 275 | string capsSeedPath = CapsUtil.GetCapsSeedPath(capsPath); |
276 | 276 | ||
277 | // Don't use the following! It Fails for logging into any region not on the same port as the http server! | 277 | // Don't use the following! It Fails for logging into any region not on the same port as the http server! |
278 | // Kept here so it doesn't happen again! | 278 | // Kept here so it doesn't happen again! |
279 | // response.SeedCapability = regionInfo.ServerURI + capsSeedPath; | 279 | // response.SeedCapability = regionInfo.ServerURI + capsSeedPath; |
280 | 280 | ||
281 | string seedcap = "http://"; | 281 | string seedcap = "http://"; |
282 | 282 | ||
283 | if (m_serversInfo.HttpUsesSSL) | 283 | if (m_serversInfo.HttpUsesSSL) |
284 | { | 284 | { |
285 | seedcap = "https://" + m_serversInfo.HttpSSLCN + ":" + regionInfo.HttpPort + capsSeedPath; | 285 | seedcap = "https://" + m_serversInfo.HttpSSLCN + ":" + regionInfo.HttpPort + capsSeedPath; |
286 | } | 286 | } |
287 | else | 287 | else |
288 | { | 288 | { |
289 | seedcap = "http://" + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + capsSeedPath; | 289 | seedcap = "http://" + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + capsSeedPath; |
290 | } | 290 | } |
291 | 291 | ||
292 | response.SeedCapability = seedcap; | 292 | response.SeedCapability = seedcap; |
293 | 293 | ||
294 | // Notify the target of an incoming user | 294 | // Notify the target of an incoming user |
295 | m_log.InfoFormat( | 295 | m_log.InfoFormat( |
296 | "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection", | 296 | "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection", |
297 | regionInfo.RegionName, response.RegionX, response.RegionY, regionInfo.ServerURI); | 297 | regionInfo.RegionName, response.RegionX, response.RegionY, regionInfo.ServerURI); |
298 | 298 | ||
299 | // Update agent with target sim | 299 | // Update agent with target sim |
300 | user.CurrentAgent.Region = regionInfo.RegionID; | 300 | user.CurrentAgent.Region = regionInfo.RegionID; |
301 | user.CurrentAgent.Handle = regionInfo.RegionHandle; | 301 | user.CurrentAgent.Handle = regionInfo.RegionHandle; |
302 | 302 | ||
303 | return true; | 303 | return true; |
304 | } | 304 | } |
305 | 305 | ||
306 | public override void LogOffUser(UserProfileData theUser, string message) | 306 | public override void LogOffUser(UserProfileData theUser, string message) |
307 | { | 307 | { |
308 | RegionInfo SimInfo; | 308 | RegionInfo SimInfo; |
309 | try | 309 | try |
310 | { | 310 | { |
311 | SimInfo = this.m_regionsConnector.RequestNeighbourInfo(theUser.CurrentAgent.Handle); | 311 | SimInfo = this.m_regionsConnector.RequestNeighbourInfo(theUser.CurrentAgent.Handle); |
312 | 312 | ||
313 | if (SimInfo == null) | 313 | if (SimInfo == null) |
314 | { | 314 | { |
315 | m_log.Error("[LOCAL LOGIN]: Region user was in isn't currently logged in"); | 315 | m_log.Error("[LOCAL LOGIN]: Region user was in isn't currently logged in"); |
316 | return; | 316 | return; |
317 | } | 317 | } |
318 | } | 318 | } |
319 | catch (Exception) | 319 | catch (Exception) |
320 | { | 320 | { |
321 | m_log.Error("[LOCAL LOGIN]: Unable to look up region to log user off"); | 321 | m_log.Error("[LOCAL LOGIN]: Unable to look up region to log user off"); |
322 | return; | 322 | return; |
323 | } | 323 | } |
324 | 324 | ||
325 | m_regionsConnector.LogOffUserFromGrid(SimInfo.RegionHandle, theUser.ID, theUser.CurrentAgent.SecureSessionID, "Logging you off"); | 325 | m_regionsConnector.LogOffUserFromGrid(SimInfo.RegionHandle, theUser.ID, theUser.CurrentAgent.SecureSessionID, "Logging you off"); |
326 | } | 326 | } |
327 | } | 327 | } |
328 | } | 328 | } |