2005-11-18 Chris Toshok <toshok@ximian.com>
[mono.git] / mcs / class / System.Web / System.Web.Configuration_2.0 / FormsAuthenticationConfiguration.cs
1 //
2 // System.Web.Configuration.FormsAuthenticationConfiguration
3 //
4 // Authors:
5 //      Lluis Sanchez Gual (lluis@novell.com)
6 //      Chris Toshok (toshok@ximian.com)
7 //
8 // (C) 2004-2005 Novell, Inc (http://www.novell.com)
9 //
10
11 //
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:
19 // 
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 // 
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.
30 //
31
32 #if NET_2_0
33
34 using System.Configuration;
35 using System.ComponentModel;
36
37 namespace System.Web.Configuration
38 {
39         public sealed class FormsAuthenticationConfiguration: ConfigurationElement
40         {
41                 static ConfigurationPropertyCollection properties;
42
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;
55
56                 static FormsAuthenticationConfiguration ()
57                 {
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));
70
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);
84                 }
85
86                 public FormsAuthenticationConfiguration ()
87                 {
88                 }
89
90                 [ConfigurationProperty ("cookieless", DefaultValue = "UseDeviceProfile")]
91                 public HttpCookieMode Cookieless {
92                         get { return (HttpCookieMode)base[cookielessProp]; }
93                         set { base[cookielessProp] = value; }
94                 }
95
96                 [ConfigurationProperty ("credentials")]
97                 public FormsAuthenticationCredentials Credentials {
98                         get { return (FormsAuthenticationCredentials) base[credentialsProp]; }
99                 }
100
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; }
106                 }
107
108                 [ConfigurationProperty ("domain", DefaultValue = "")]
109                 public string Domain {
110                         get { return (string) base[domainProp]; }
111                         set { base[domainProp] = value; }
112                 }
113
114                 [ConfigurationProperty ("enableCrossAppRedirects", DefaultValue = "False")]
115                 public bool EnableCrossAppRedirects {
116                         get { return (bool) base[enableCrossAppRedirectsProp]; }
117                         set { base[enableCrossAppRedirectsProp] = value; }
118                 }
119
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; }
125                 }
126
127                 [StringValidator (MinLength = 1)]
128                 [ConfigurationProperty ("name", DefaultValue = ".ASPXAUTH")]
129                 public string Name {
130                         get { return (string) base[nameProp]; }
131                         set { base[nameProp] = value; }
132                 }
133
134                 [StringValidator (MinLength = 1)]
135                 [ConfigurationProperty ("path", DefaultValue = "/")]
136                 public string Path {
137                         get { return (string) base[pathProp]; }
138                         set { base[pathProp] = value; }
139                 }
140
141                 [ConfigurationProperty ("protection", DefaultValue = "All")]
142                 public FormsProtectionEnum Protection {
143                         get { return (FormsProtectionEnum) base[protectionProp]; }
144                         set { base[protectionProp] = value; }
145                 }
146
147                 [ConfigurationProperty ("requireSSL", DefaultValue = "False")]
148                 public bool RequireSSL {
149                         get { return (bool) base[requireSSLProp]; }
150                         set { base[requireSSLProp] = value; }
151                 }
152
153                 [ConfigurationProperty ("slidingExpiration", DefaultValue = "True")]
154                 public bool SlidingExpiration {
155                         get { return (bool) base[slidingExpirationProp]; }
156                         set { base[slidingExpirationProp] = value; }
157                 }
158
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; }
165                 }
166
167                 protected override ConfigurationPropertyCollection Properties {
168                         get { return properties; }
169                 }
170
171 #if notyet
172                 [MonoTODO]
173                 protected override ConfigurationElementProperty ElementProperty {
174                         get { throw new NotImplementedException (); }
175                 }
176 #endif
177         }
178 }
179
180 #endif