2 // System.Web.Configuration.FormsAuthenticationConfiguration
5 // Lluis Sanchez Gual (lluis@novell.com)
6 // Chris Toshok (toshok@ximian.com)
8 // (C) 2004-2005 Novell, Inc (http://www.novell.com)
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using System.Configuration;
35 using System.ComponentModel;
37 namespace System.Web.Configuration
39 public sealed class FormsAuthenticationConfiguration: ConfigurationElement
41 static ConfigurationPropertyCollection properties;
43 static ConfigurationProperty cookielessProp;
44 static ConfigurationProperty credentialsProp;
45 static ConfigurationProperty defaultUrlProp;
46 static ConfigurationProperty domainProp;
47 static ConfigurationProperty enableCrossAppRedirectsProp;
48 static ConfigurationProperty loginUrlProp;
49 static ConfigurationProperty nameProp;
50 static ConfigurationProperty pathProp;
51 static ConfigurationProperty protectionProp;
52 static ConfigurationProperty requireSSLProp;
53 static ConfigurationProperty slidingExpirationProp;
54 static ConfigurationProperty timeoutProp;
56 static FormsAuthenticationConfiguration ()
58 cookielessProp = new ConfigurationProperty ("cookieless", typeof (HttpCookieMode), HttpCookieMode.UseDeviceProfile);
59 credentialsProp = new ConfigurationProperty ("credentials", typeof (FormsAuthenticationCredentials), null);
60 defaultUrlProp = new ConfigurationProperty ("defaultUrl", typeof (string), "default.aspx");
61 domainProp = new ConfigurationProperty ("domain", typeof (string), "");
62 enableCrossAppRedirectsProp = new ConfigurationProperty ("enableCrossAppRedirects", typeof (bool), false);
63 loginUrlProp = new ConfigurationProperty ("loginUrl", typeof (string), "login.aspx");
64 nameProp = new ConfigurationProperty ("name", typeof (string), ".ASPXAUTH");
65 pathProp = new ConfigurationProperty ("path", typeof (string), "/");
66 protectionProp = new ConfigurationProperty ("protection", typeof (FormsProtectionEnum), FormsProtectionEnum.All);
67 requireSSLProp = new ConfigurationProperty ("requireSSL", typeof (bool), false);
68 slidingExpirationProp = new ConfigurationProperty ("slidingExpiration", typeof (bool), true);
69 timeoutProp = new ConfigurationProperty ("timeout", typeof (TimeSpan), TimeSpan.FromMinutes (30));
71 properties = new ConfigurationPropertyCollection ();
72 properties.Add (cookielessProp);
73 properties.Add (credentialsProp);
74 properties.Add (defaultUrlProp);
75 properties.Add (domainProp);
76 properties.Add (enableCrossAppRedirectsProp);
77 properties.Add (loginUrlProp);
78 properties.Add (nameProp);
79 properties.Add (pathProp);
80 properties.Add (protectionProp);
81 properties.Add (requireSSLProp);
82 properties.Add (slidingExpirationProp);
83 properties.Add (timeoutProp);
86 public FormsAuthenticationConfiguration ()
90 [ConfigurationProperty ("cookieless", DefaultValue = "UseDeviceProfile")]
91 public HttpCookieMode Cookieless {
92 get { return (HttpCookieMode)base[cookielessProp]; }
93 set { base[cookielessProp] = value; }
96 [ConfigurationProperty ("credentials")]
97 public FormsAuthenticationCredentials Credentials {
98 get { return (FormsAuthenticationCredentials) base[credentialsProp]; }
101 [StringValidator (MinLength = 1)]
102 [ConfigurationProperty ("defaultUrl", DefaultValue = "default.aspx")]
103 public string DefaultUrl {
104 get { return (string) base[defaultUrlProp]; }
105 set { base[defaultUrlProp] = value; }
108 [ConfigurationProperty ("domain", DefaultValue = "")]
109 public string Domain {
110 get { return (string) base[domainProp]; }
111 set { base[domainProp] = value; }
114 [ConfigurationProperty ("enableCrossAppRedirects", DefaultValue = "False")]
115 public bool EnableCrossAppRedirects {
116 get { return (bool) base[enableCrossAppRedirectsProp]; }
117 set { base[enableCrossAppRedirectsProp] = value; }
120 [StringValidator (MinLength = 1)]
121 [ConfigurationProperty ("loginUrl", DefaultValue = "login.aspx")]
122 public string LoginUrl {
123 get { return (string) base[loginUrlProp]; }
124 set { base[loginUrlProp] = value; }
127 [StringValidator (MinLength = 1)]
128 [ConfigurationProperty ("name", DefaultValue = ".ASPXAUTH")]
130 get { return (string) base[nameProp]; }
131 set { base[nameProp] = value; }
134 [StringValidator (MinLength = 1)]
135 [ConfigurationProperty ("path", DefaultValue = "/")]
137 get { return (string) base[pathProp]; }
138 set { base[pathProp] = value; }
141 [ConfigurationProperty ("protection", DefaultValue = "All")]
142 public FormsProtectionEnum Protection {
143 get { return (FormsProtectionEnum) base[protectionProp]; }
144 set { base[protectionProp] = value; }
147 [ConfigurationProperty ("requireSSL", DefaultValue = "False")]
148 public bool RequireSSL {
149 get { return (bool) base[requireSSLProp]; }
150 set { base[requireSSLProp] = value; }
153 [ConfigurationProperty ("slidingExpiration", DefaultValue = "True")]
154 public bool SlidingExpiration {
155 get { return (bool) base[slidingExpirationProp]; }
156 set { base[slidingExpirationProp] = value; }
159 [TypeConverter (typeof (TimeSpanMinutesConverter))]
160 [TimeSpanValidator (MinValueString = "00:00:00")]
161 [ConfigurationProperty ("timeout", DefaultValue = "00:30:00")]
162 public TimeSpan Timeout {
163 get { return (TimeSpan) base[timeoutProp]; }
164 set { base [timeoutProp] = value; }
167 protected override ConfigurationPropertyCollection Properties {
168 get { return properties; }
173 protected override ConfigurationElementProperty ElementProperty {
174 get { throw new NotImplementedException (); }