diff options
Diffstat (limited to 'OpenSim/Grid/InventoryServer/GridInventoryService.cs')
-rw-r--r-- | OpenSim/Grid/InventoryServer/GridInventoryService.cs | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/OpenSim/Grid/InventoryServer/GridInventoryService.cs b/OpenSim/Grid/InventoryServer/GridInventoryService.cs index b8a0436..63eeced 100644 --- a/OpenSim/Grid/InventoryServer/GridInventoryService.cs +++ b/OpenSim/Grid/InventoryServer/GridInventoryService.cs | |||
@@ -38,6 +38,7 @@ using Nwc.XmlRpc; | |||
38 | 38 | ||
39 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
40 | using OpenSim.Framework.Communications; | 40 | using OpenSim.Framework.Communications; |
41 | using OpenSim.Framework.Communications.Cache; | ||
41 | 42 | ||
42 | namespace OpenSim.Grid.InventoryServer | 43 | namespace OpenSim.Grid.InventoryServer |
43 | { | 44 | { |
@@ -48,8 +49,10 @@ namespace OpenSim.Grid.InventoryServer | |||
48 | { | 49 | { |
49 | private static readonly ILog m_log | 50 | private static readonly ILog m_log |
50 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 51 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | private static readonly int INVENTORY_DEFAULT_SESSION_TIME = 30; // secs | ||
51 | 53 | ||
52 | private string m_userserver_url; | 54 | private string m_userserver_url; |
55 | private AuthedSessionCache m_session_cache = new AuthedSessionCache(INVENTORY_DEFAULT_SESSION_TIME); | ||
53 | 56 | ||
54 | public GridInventoryService(string userserver_url) | 57 | public GridInventoryService(string userserver_url) |
55 | { | 58 | { |
@@ -72,20 +75,33 @@ namespace OpenSim.Grid.InventoryServer | |||
72 | public bool CheckAuthSession(string session_id, string avatar_id) | 75 | public bool CheckAuthSession(string session_id, string avatar_id) |
73 | { | 76 | { |
74 | m_log.InfoFormat("[GRID AGENT INVENTORY]: checking authed session {0} {1}", session_id, avatar_id); | 77 | m_log.InfoFormat("[GRID AGENT INVENTORY]: checking authed session {0} {1}", session_id, avatar_id); |
75 | Hashtable requestData = new Hashtable(); | 78 | if (m_session_cache.getCachedSession(session_id, avatar_id) == null) |
76 | requestData["avatar_uuid"] = avatar_id; | 79 | { |
77 | requestData["session_id"] = session_id; | 80 | // cache miss, ask userserver |
78 | ArrayList SendParams = new ArrayList(); | 81 | Hashtable requestData = new Hashtable(); |
79 | SendParams.Add(requestData); | 82 | requestData["avatar_uuid"] = avatar_id; |
80 | XmlRpcRequest UserReq = new XmlRpcRequest("check_auth_session", SendParams); | 83 | requestData["session_id"] = session_id; |
81 | XmlRpcResponse UserResp = UserReq.Send(m_userserver_url, 3000); | 84 | ArrayList SendParams = new ArrayList(); |
82 | 85 | SendParams.Add(requestData); | |
83 | Hashtable responseData = (Hashtable)UserResp.Value; | 86 | XmlRpcRequest UserReq = new XmlRpcRequest("check_auth_session", SendParams); |
84 | 87 | XmlRpcResponse UserResp = UserReq.Send(m_userserver_url, 3000); | |
85 | if (responseData.ContainsKey("auth_session") && responseData["auth_session"].ToString() == "TRUE") | 88 | |
89 | Hashtable responseData = (Hashtable)UserResp.Value; | ||
90 | if (responseData.ContainsKey("auth_session") && responseData["auth_session"].ToString() == "TRUE") | ||
91 | { | ||
92 | m_log.Info("[GRID AGENT INVENTORY]: got authed session from userserver"); | ||
93 | // add to cache; the session time will be automatically renewed | ||
94 | m_session_cache.Add(session_id, avatar_id); | ||
95 | return true; | ||
96 | } | ||
97 | } | ||
98 | else | ||
86 | { | 99 | { |
100 | // cache hits | ||
101 | m_log.Info("[GRID AGENT INVENTORY]: got authed session from cache"); | ||
87 | return true; | 102 | return true; |
88 | } | 103 | } |
104 | m_log.Info("[GRID AGENT INVENTORY]: unknown session_id, request rejected"); | ||
89 | return false; | 105 | return false; |
90 | } | 106 | } |
91 | 107 | ||