Merge pull request #2735 from xmcclure/early-lookup-addr
[mono.git] / mcs / class / System.Web / System.Web.Security / FormsAuthentication.cs
index c94f508c5c85dc1c3185c8a5d524eb5c189062a6..491d74f6c4d49884b7a72f0fe70695f6c068871e 100644 (file)
@@ -50,107 +50,6 @@ namespace System.Web.Security
                static string authConfigPath = "system.web/authentication";
                static string machineKeyConfigPath = "system.web/machineKey";
                static object locker = new object ();
-#if TARGET_J2EE
-               const string Forms_initialized = "Forms.initialized";
-               const string Forms_cookieName = "Forms.cookieName";
-               const string Forms_cookiePath = "Forms.cookiePath";
-               const string Forms_timeout = "Forms.timeout";
-               const string Forms_protection = "Forms.protection";
-               static bool initialized
-               {
-                       get {
-                               object o = AppDomain.CurrentDomain.GetData (Forms_initialized);
-                               return o != null ? (bool) o : false;
-                       }
-                       set { AppDomain.CurrentDomain.SetData (Forms_initialized, value); }
-               }
-               static string cookieName
-               {
-                       get { return (string) AppDomain.CurrentDomain.GetData (Forms_cookieName); }
-                       set { AppDomain.CurrentDomain.SetData (Forms_cookieName, value); }
-               }
-               static string cookiePath
-               {
-                       get { return (string) AppDomain.CurrentDomain.GetData (Forms_cookiePath); }
-                       set { AppDomain.CurrentDomain.SetData (Forms_cookiePath, value); }
-               }
-               static int timeout
-               {
-                       get {
-                               object o = AppDomain.CurrentDomain.GetData (Forms_timeout);
-                               return o != null ? (int) o : 0;
-                       }
-                       set { AppDomain.CurrentDomain.SetData (Forms_timeout, value); }
-               }
-               static FormsProtectionEnum protection
-               {
-                       get { return (FormsProtectionEnum) AppDomain.CurrentDomain.GetData (Forms_protection); }
-                       set { AppDomain.CurrentDomain.SetData (Forms_protection, value); }
-               }
-
-               const string Forms_requireSSL = "Forms.requireSSL";
-               const string Forms_slidingExpiration = "Forms.slidingExpiration";
-
-               static bool requireSSL
-               {
-                       get {
-                               object o = AppDomain.CurrentDomain.GetData (Forms_requireSSL);
-                               return o != null ? (bool) o : false;
-                       }
-                       set { AppDomain.CurrentDomain.SetData (Forms_requireSSL, value); }
-               }
-               static bool slidingExpiration
-               {
-                       get {
-                               object o = AppDomain.CurrentDomain.GetData (Forms_slidingExpiration);
-                               return o != null ? (bool) o : false;
-                       }
-                       set { AppDomain.CurrentDomain.SetData (Forms_slidingExpiration, value); }
-               }
-
-               const string Forms_cookie_domain = "Forms.cookie_domain";
-               const string Forms_cookie_mode = "Forms.cookie_mode";
-               const string Forms_cookies_supported = "Forms.cookies_supported";
-               const string Forms_default_url = "Forms.default_url";
-               const string Forms_enable_crossapp_redirects = "Forms.enable_crossapp_redirects";
-               const string Forms_login_url = "Forms.login_url";
-               static string cookie_domain
-               {
-                       get { return (string) AppDomain.CurrentDomain.GetData (Forms_cookie_domain); }
-                       set { AppDomain.CurrentDomain.SetData (Forms_cookie_domain, value); }
-               }
-               static HttpCookieMode cookie_mode
-               {
-                       get { return (HttpCookieMode) AppDomain.CurrentDomain.GetData (Forms_cookie_mode); }
-                       set { AppDomain.CurrentDomain.SetData (Forms_cookie_mode, value); }
-               }
-               static bool cookies_supported
-               {
-                       get {
-                               object o = AppDomain.CurrentDomain.GetData (Forms_cookies_supported);
-                               return o != null ? (bool) o : false;
-                       }
-                       set { AppDomain.CurrentDomain.SetData (Forms_cookies_supported, value); }
-               }
-               static string default_url
-               {
-                       get { return (string) AppDomain.CurrentDomain.GetData (Forms_default_url); }
-                       set { AppDomain.CurrentDomain.SetData (Forms_default_url, value); }
-               }
-               static bool enable_crossapp_redirects
-               {
-                       get {
-                               object o = AppDomain.CurrentDomain.GetData (Forms_enable_crossapp_redirects);
-                               return o != null ? (bool) o : false;
-                       }
-                       set { AppDomain.CurrentDomain.SetData (Forms_enable_crossapp_redirects, value); }
-               }
-               static string login_url
-               {
-                       get { return (string) AppDomain.CurrentDomain.GetData (Forms_login_url); }
-                       set { AppDomain.CurrentDomain.SetData (Forms_login_url, value); }
-               }
-#else
                static bool initialized;
                static string cookieName;
                static string cookiePath;
@@ -164,14 +63,12 @@ namespace System.Web.Security
                static string default_url;
                static bool enable_crossapp_redirects;
                static string login_url;
-#endif
                // same names and order used in xsp
                static string [] indexFiles = { "index.aspx",
                                                "Default.aspx",
                                                "default.aspx",
                                                "index.html",
                                                "index.htm" };
-#if NET_4_0
                public static TimeSpan Timeout {
                        get; private set;
                }
@@ -194,7 +91,6 @@ namespace System.Web.Security
                        if (!String.IsNullOrEmpty (value))
                                default_url = value;
                }
-#endif
                public FormsAuthentication ()
                {
                }
@@ -317,22 +213,19 @@ namespace System.Web.Security
 
                        DateTime now = DateTime.Now;
                        DateTime then;
-                       if (createPersistentCookie)
-                               then = now.AddYears (50);
-                       else
-                               then = now.AddMinutes (timeout);
+                       if (createPersistentCookie)
+                               then = now.AddMinutes(timeout);
+                       else
+                               then = DateTime.MinValue;
 
                        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket (1,
                                                                                          userName,
                                                                                          now,
-                                                                                         then,
+                                              createPersistentCookie?then:now.AddYears (50),
                                                                                          createPersistentCookie,
                                                                                          String.Empty,
                                                                                          cookiePath);
 
-                       if (!createPersistentCookie)
-                               then = DateTime.MinValue;
-
                        HttpCookie cookie = new HttpCookie (cookieName, Encrypt (ticket), strCookiePath, then);
                        if (requireSSL)
                                cookie.Secure = true;
@@ -428,9 +321,7 @@ namespace System.Web.Security
                                FormsAuthenticationConfiguration config = section.Forms;
 
                                cookieName = config.Name;
-#if NET_4_0
                                Timeout = config.Timeout;
-#endif
                                timeout = (int)config.Timeout.TotalMinutes;
                                cookiePath = config.Path;
                                protection = config.Protection;
@@ -439,18 +330,14 @@ namespace System.Web.Security
                                cookie_domain = config.Domain;
                                cookie_mode = config.Cookieless;
                                cookies_supported = true; /* XXX ? */
-#if NET_4_0
                                if (!String.IsNullOrEmpty (default_url))
                                        default_url = MapUrl (default_url);
                                else
-#endif
                                        default_url = MapUrl(config.DefaultUrl);
                                enable_crossapp_redirects = config.EnableCrossAppRedirects;
-#if NET_4_0
                                if (!String.IsNullOrEmpty (login_url))
                                        login_url = MapUrl (login_url);
                                else
-#endif
                                        login_url = MapUrl(config.LoginUrl);
 
                                initialized = true;