2005-02-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / class / System.Web / System.Web.Security / FormsAuthentication.cs
index 938b1ff134061827fc5543d5f78c9984cd838166..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;
                        }
 
@@ -172,11 +194,6 @@ namespace System.Web.Security
                        if (returnUrl != null)
                                return returnUrl;
 
-                       AuthConfig authConfig = HttpContext.Current.GetConfig (authConfigPath) as AuthConfig;
-                       if (authConfig.LoginUrl != null) {
-                               return authConfig.LoginUrl;
-                       }
-
                        returnUrl = request.ApplicationPath;
                        string apppath = request.PhysicalApplicationPath;
                        bool found = false;
@@ -235,7 +252,7 @@ namespace System.Web.Security
                        if (initialized)
                                return;
 
-                       lock (typeof (FormsAuthentication)) {
+                       lock (locker) {
                                if (initialized)
                                        return;
 
@@ -295,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;
                }