2008-01-12 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mcs / class / Mainsoft.Web / Mainsoft.Web.SessionState / ServletSessionIDManager.cs
1 //\r
2 // (C) 2006 Mainsoft Corporation (http://www.mainsoft.com)\r
3 // Author: Konstantin Triger <kostat@mainsoft.com>\r
4 //\r
5 \r
6 //\r
7 // Permission is hereby granted, free of charge, to any person obtaining\r
8 // a copy of this software and associated documentation files (the\r
9 // "Software"), to deal in the Software without restriction, including\r
10 // without limitation the rights to use, copy, modify, merge, publish,\r
11 // distribute, sublicense, and/or sell copies of the Software, and to\r
12 // permit persons to whom the Software is furnished to do so, subject to\r
13 // the following conditions:\r
14 //\r
15 // The above copyright notice and this permission notice shall be\r
16 // included in all copies or substantial portions of the Software.\r
17 //\r
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
19 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
20 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
21 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
22 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
23 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
24 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
25 //\r
26 \r
27 using System;\r
28 using System.Collections.Generic;\r
29 using System.Text;\r
30 using System.Web;\r
31 using System.Web.SessionState;\r
32 using javax.servlet.http;\r
33 using Mainsoft.Web.Hosting;\r
34 \r
35 namespace Mainsoft.Web.SessionState\r
36 {\r
37         /// <summary>\r
38         /// <para>This class supports the Framework infrastructure and is not intended to be used directly from your code.</para>\r
39         /// </summary>\r
40         public sealed class ServletSessionIDManager : ISessionIDManager\r
41         {\r
42                 #region ISessionIDManager Members\r
43 \r
44                 public string CreateSessionID (HttpContext context) {\r
45                         return ServletSessionStateStoreProvider.GetSession (context, true).getId ();\r
46                 }\r
47 \r
48                 public string GetSessionID (HttpContext context) {\r
49                         BaseWorkerRequest request = J2EEUtils.GetWorkerRequest (context);\r
50                         return request.IsRequestedSessionIdValid () ? request.GetRequestedSessionId () : null;\r
51                 }\r
52 \r
53                 public void Initialize () {\r
54                 }\r
55 \r
56                 public bool InitializeRequest (HttpContext context, bool suppressAutoDetectRedirect, out bool supportSessionIDReissue) {\r
57                         supportSessionIDReissue = true;\r
58                         return false;\r
59                 }\r
60 \r
61                 public void RemoveSessionID (HttpContext context) {\r
62                         ServletSessionStateStoreProvider.GetSession (context, false).invalidate ();\r
63                 }\r
64 \r
65                 public void SaveSessionID (HttpContext context, string id, out bool redirected, out bool cookieAdded) {\r
66                         redirected = false;\r
67                         cookieAdded = false;\r
68                 }\r
69 \r
70                 public bool Validate (string id) {\r
71                         return true;\r
72                 }\r
73 \r
74                 #endregion\r
75         }\r
76 }\r