merge -r 58784:58785
[mono.git] / mcs / class / System.Web / System.Web.Configuration_2.0 / AnonymousIdentificationSection.cs
1 //
2 // System.Web.Configuration.AnonymousIdentificationSection.cs
3 //
4 // Authors:
5 //      Lluis Sanchez Gual (lluis@novell.com)
6 //
7 // (C) 2004 Novell, Inc (http://www.novell.com)
8 //
9
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 #if NET_2_0
32
33 using System;
34 using System.Configuration;
35 using System.Web.Security;
36 using System.ComponentModel;
37
38 namespace System.Web.Configuration
39 {
40         public sealed class AnonymousIdentificationSection: ConfigurationSection
41         {
42                 static ConfigurationPropertyCollection properties;
43                 static ConfigurationProperty enabledProp;
44                 static ConfigurationProperty cookielessProp;
45                 static ConfigurationProperty cookieNameProp;
46                 static ConfigurationProperty cookieTimeoutProp;
47                 static ConfigurationProperty cookiePathProp;
48                 static ConfigurationProperty cookieRequireSSLProp;
49                 static ConfigurationProperty cookieSlidingExpirationProp;
50                 static ConfigurationProperty cookieProtectionProp;
51                 static ConfigurationProperty cookilessProp;
52                 static ConfigurationProperty domainProp;
53
54                 static AnonymousIdentificationSection ()
55                 {
56                         enabledProp = new ConfigurationProperty ("enabled", typeof(bool), false);
57                         cookielessProp = new ConfigurationProperty ("cookieless", typeof (HttpCookieMode), HttpCookieMode.UseCookies);
58                         cookieNameProp = new ConfigurationProperty ("cookieName", typeof (string), ".ASPXANONYMOUS", TypeDescriptor.GetConverter (typeof (string)),
59                                                                     new StringValidator (1), ConfigurationPropertyOptions.None);
60                         cookieTimeoutProp = new ConfigurationProperty ("cookieTimeout", typeof (TimeSpan), new TimeSpan (69,10,40,0), new TimeSpanMinutesOrInfiniteConverter(),
61                                                                        new TimeSpanValidator (TimeSpan.Zero, TimeSpan.MaxValue),
62                                                                        ConfigurationPropertyOptions.None);
63                         cookiePathProp = new ConfigurationProperty ("cookiePath", typeof (string), "/", TypeDescriptor.GetConverter (typeof (string)),
64                                                                     new StringValidator (1), ConfigurationPropertyOptions.None);
65                         cookieRequireSSLProp = new ConfigurationProperty ("cookieRequireSSL", typeof(bool), false);
66                         cookieSlidingExpirationProp = new ConfigurationProperty ("cookieSlidingExpiration", typeof(bool), true);
67                         cookieProtectionProp = new ConfigurationProperty ("cookieProtection", typeof(CookieProtection), CookieProtection.Validation);
68                         cookilessProp = new ConfigurationProperty ("cookiless", typeof(HttpCookieMode), HttpCookieMode.UseDeviceProfile);
69                         domainProp = new ConfigurationProperty ("domain", typeof(string), null);
70                         
71                         properties = new ConfigurationPropertyCollection ();
72                         properties.Add (enabledProp);
73                         properties.Add (cookielessProp);
74                         properties.Add (cookieNameProp);
75                         properties.Add (cookieTimeoutProp);
76                         properties.Add (cookiePathProp);
77                         properties.Add (cookieRequireSSLProp);
78                         properties.Add (cookieSlidingExpirationProp);
79                         properties.Add (cookieProtectionProp);
80                         properties.Add (cookilessProp);
81                         properties.Add (domainProp);
82                 }
83                 
84                 [ConfigurationProperty ("cookieless", DefaultValue = "UseCookies")]
85                 public HttpCookieMode Cookieless {
86                         get { return (HttpCookieMode) base [cookielessProp]; }
87                         set { base [cookielessProp] = value; }
88                 }
89                 
90                 [StringValidator (MinLength = 1)]
91                 [ConfigurationProperty ("cookieName", DefaultValue = ".ASPXANONYMOUS")]
92                 public string CookieName {
93                         get { return (string) base [cookieNameProp]; }
94                         set { base [cookieNameProp] = value; }
95                 }
96                 
97                 [StringValidator (MinLength = 1)]
98                 [ConfigurationProperty ("cookiePath", DefaultValue = "/")]
99                 public string CookiePath {
100                         get { return (string) base [cookiePathProp]; }
101                         set { base [cookiePathProp] = value; }
102                 }
103                 
104                 [ConfigurationProperty ("cookieProtection", DefaultValue = "Validation")]
105                 public CookieProtection CookieProtection {
106                         get { return (CookieProtection) base [cookieProtectionProp]; }
107                         set { base [cookieProtectionProp] = value; }
108                 }
109                 
110                 [ConfigurationProperty ("cookieRequireSSL", DefaultValue = "False")]
111                 public bool CookieRequireSSL {
112                         get { return (bool) base [cookieRequireSSLProp]; }
113                         set { base [cookieRequireSSLProp] = value; }
114                 }
115                 
116                 [ConfigurationProperty ("cookieSlidingExpiration", DefaultValue = "True")]
117                 public bool CookieSlidingExpiration {
118                         get { return (bool) base [cookieSlidingExpirationProp]; }
119                         set { base [cookieSlidingExpirationProp] = value; }
120                 }
121                 
122                 [TimeSpanValidator (MinValueString = "00:00:00", MaxValueString = "10675199.02:48:05.4775807")]
123                 [TypeConverter (typeof(TimeSpanMinutesOrInfiniteConverter))]
124                 [ConfigurationProperty ("cookieTimeout", DefaultValue = "69.10:40:00")]
125                 public TimeSpan CookieTimeout {
126                         get { return (TimeSpan) base [cookieTimeoutProp]; }
127                         set { base [cookieTimeoutProp] = value; }
128                 }
129                 
130                 [ConfigurationProperty ("domain")]
131                 public string Domain {
132                         get { return (string) base [domainProp]; }
133                         set { base [domainProp] = value; }
134                 }
135                 
136                 [ConfigurationProperty ("enabled", DefaultValue = "False")]
137                 public bool Enabled {
138                         get { return (bool) base [enabledProp]; }
139                         set { base [enabledProp] = value; }
140                 }
141
142                 protected override ConfigurationPropertyCollection Properties {
143                         get { return properties; }
144                 }               
145         }
146 }
147
148 #endif