diff options
author | Melanie | 2009-09-17 23:39:58 +0100 |
---|---|---|
committer | Melanie | 2009-09-17 23:39:58 +0100 |
commit | 6779abf7f59e518b0cd18e52dd91a500049dfda6 (patch) | |
tree | 16b33fae811359c5e80f1c2630fba4deb3066006 /OpenSim/Grid/InventoryServer/AuthedSessionCache.cs | |
parent | While running a test case I had written to pursue problems with (diff) | |
download | opensim-SC_OLD-6779abf7f59e518b0cd18e52dd91a500049dfda6.zip opensim-SC_OLD-6779abf7f59e518b0cd18e52dd91a500049dfda6.tar.gz opensim-SC_OLD-6779abf7f59e518b0cd18e52dd91a500049dfda6.tar.bz2 opensim-SC_OLD-6779abf7f59e518b0cd18e52dd91a500049dfda6.tar.xz |
Remove The legacy inventory and asset servers. Bump interface version to 6
Diffstat (limited to 'OpenSim/Grid/InventoryServer/AuthedSessionCache.cs')
-rw-r--r-- | OpenSim/Grid/InventoryServer/AuthedSessionCache.cs | 133 |
1 files changed, 0 insertions, 133 deletions
diff --git a/OpenSim/Grid/InventoryServer/AuthedSessionCache.cs b/OpenSim/Grid/InventoryServer/AuthedSessionCache.cs deleted file mode 100644 index dadf34a..0000000 --- a/OpenSim/Grid/InventoryServer/AuthedSessionCache.cs +++ /dev/null | |||
@@ -1,133 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
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 | ||
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 | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | |||
31 | namespace OpenSim.Grid.InventoryServer | ||
32 | { | ||
33 | public class AuthedSessionCache | ||
34 | { | ||
35 | public class CacheData | ||
36 | { | ||
37 | private static readonly DateTime UNIX_EPOCH = new DateTime(1970, 1, 1); | ||
38 | private string m_session_id; | ||
39 | private string m_agent_id; | ||
40 | private int m_expire; | ||
41 | |||
42 | private int get_current_unix_time() | ||
43 | { | ||
44 | return (int)(DateTime.UtcNow - UNIX_EPOCH).TotalSeconds; | ||
45 | } | ||
46 | |||
47 | public CacheData(string sid, string aid) | ||
48 | { | ||
49 | m_session_id = sid; | ||
50 | m_agent_id = aid; | ||
51 | m_expire = get_current_unix_time() + DEFAULT_LIFETIME; | ||
52 | } | ||
53 | |||
54 | public CacheData(string sid, string aid, int time_now) | ||
55 | { | ||
56 | m_session_id = sid; | ||
57 | m_agent_id = aid; | ||
58 | m_expire = time_now + DEFAULT_LIFETIME; | ||
59 | } | ||
60 | |||
61 | public string SessionID | ||
62 | { | ||
63 | get { return m_session_id; } | ||
64 | set { m_session_id = value; } | ||
65 | } | ||
66 | |||
67 | public string AgentID | ||
68 | { | ||
69 | get { return m_agent_id; } | ||
70 | set { m_agent_id = value; } | ||
71 | } | ||
72 | |||
73 | public bool isExpired | ||
74 | { | ||
75 | get { return m_expire < get_current_unix_time(); } | ||
76 | } | ||
77 | |||
78 | public void Renew() | ||
79 | { | ||
80 | m_expire = get_current_unix_time() + DEFAULT_LIFETIME; | ||
81 | } | ||
82 | } | ||
83 | |||
84 | private static readonly int DEFAULT_LIFETIME = 30; | ||
85 | private Dictionary<string, CacheData> m_authed_sessions = new Dictionary<string,CacheData>(); | ||
86 | // private int m_session_lifetime = DEFAULT_LIFETIME; | ||
87 | |||
88 | public AuthedSessionCache() | ||
89 | { | ||
90 | // m_session_lifetime = DEFAULT_LIFETIME; | ||
91 | } | ||
92 | |||
93 | public AuthedSessionCache(int timeout) | ||
94 | { | ||
95 | // m_session_lifetime = timeout; | ||
96 | } | ||
97 | |||
98 | public CacheData getCachedSession(string session_id, string agent_id) | ||
99 | { | ||
100 | CacheData ret = null; | ||
101 | lock (m_authed_sessions) | ||
102 | { | ||
103 | if (m_authed_sessions.ContainsKey(session_id)) | ||
104 | { | ||
105 | CacheData cached_session = m_authed_sessions[session_id]; | ||
106 | if (!cached_session.isExpired && cached_session.AgentID == agent_id) | ||
107 | { | ||
108 | ret = m_authed_sessions[session_id]; | ||
109 | // auto renew | ||
110 | m_authed_sessions[session_id].Renew(); | ||
111 | } | ||
112 | } | ||
113 | } | ||
114 | return ret; | ||
115 | } | ||
116 | |||
117 | public void Add(string session_id, string agent_id) | ||
118 | { | ||
119 | CacheData data = new CacheData(session_id, agent_id); | ||
120 | lock (m_authed_sessions) | ||
121 | { | ||
122 | if (m_authed_sessions.ContainsKey(session_id)) | ||
123 | { | ||
124 | m_authed_sessions[session_id] = data; | ||
125 | } | ||
126 | else | ||
127 | { | ||
128 | m_authed_sessions.Add(session_id, data); | ||
129 | } | ||
130 | } | ||
131 | } | ||
132 | } | ||
133 | } | ||