2005-02-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / class / System.Web / System.Web.Security / FormsAuthentication.cs
index 2c06a7937a2970f8803bcac876c439b1ca16a279..813da89ece7a0a357dfe49530a711e3b4cbbc752 100644 (file)
@@ -7,6 +7,27 @@
 // (C) 2002,2003 Ximian, Inc (http://www.ximian.com)
 //
 
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
 using System;
 using System.Collections;
 using System.IO;
@@ -26,6 +47,7 @@ namespace System.Web.Security
                static string cookiePath;
                static int timeout;
                static FormsProtectionEnum protection;
+               static object locker = new object ();
 #if NET_1_1
                static bool requireSSL;
                static bool slidingExpiration;
@@ -59,10 +81,10 @@ namespace System.Web.Security
                                /* Do nothing */
                                break;
                        case FormsAuthPasswordFormat.MD5:
-                               stored = HashPasswordForStoringInConfigFile (stored, "MD5");
+                               password = HashPasswordForStoringInConfigFile (password, "MD5");
                                break;
                        case FormsAuthPasswordFormat.SHA1:
-                               stored = HashPasswordForStoringInConfigFile (stored, "SHA1");
+                               password = HashPasswordForStoringInConfigFile (password, "SHA1");
                                break;
                        }
 
@@ -91,7 +113,7 @@ namespace System.Web.Security
                                                                        (values [4] == "1"),
                                                                        values [5],
                                                                        values [6]);
-                       } catch (Exception e) {
+                       } catch (Exception) {
                                ticket = null;
                        }
 
@@ -230,7 +252,7 @@ namespace System.Web.Security
                        if (initialized)
                                return;
 
-                       lock (typeof (FormsAuthentication)) {
+                       lock (locker) {
                                if (initialized)
                                        return;
 
@@ -290,7 +312,7 @@ namespace System.Web.Security
                                return tOld;
 
                        FormsAuthenticationTicket tNew = tOld.Clone ();
-                       tNew.SetDates (now, now - toExpiration + toIssue);
+                       tNew.SetDates (now, now + (tOld.Expiration - tOld.IssueDate));
                        return tNew;
                }