2 // System.Web.Configuration.AnonymousIdentificationSection.cs
5 // Lluis Sanchez Gual (lluis@novell.com)
7 // (C) 2004 Novell, Inc (http://www.novell.com)
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:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
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.
34 using System.Configuration;
35 using System.Web.Security;
36 using System.ComponentModel;
38 namespace System.Web.Configuration
40 public sealed class AnonymousIdentificationSection: ConfigurationSection
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 domainProp;
53 static AnonymousIdentificationSection ()
55 enabledProp = new ConfigurationProperty ("enabled", typeof(bool), false);
56 cookielessProp = new ConfigurationProperty ("cookieless", typeof (HttpCookieMode), HttpCookieMode.UseCookies,
57 new GenericEnumConverter (typeof (HttpCookieMode)),
58 PropertyHelper.DefaultValidator,
59 ConfigurationPropertyOptions.None);
60 cookieNameProp = new ConfigurationProperty ("cookieName", typeof (string), ".ASPXANONYMOUS", TypeDescriptor.GetConverter (typeof (string)),
61 PropertyHelper.NonEmptyStringValidator, ConfigurationPropertyOptions.None);
62 cookieTimeoutProp = new ConfigurationProperty ("cookieTimeout", typeof (TimeSpan), new TimeSpan (69,10,40,0), new TimeSpanMinutesOrInfiniteConverter(),
63 PropertyHelper.PositiveTimeSpanValidator,
64 ConfigurationPropertyOptions.None);
65 cookiePathProp = new ConfigurationProperty ("cookiePath", typeof (string), "/", TypeDescriptor.GetConverter (typeof (string)),
66 PropertyHelper.NonEmptyStringValidator, ConfigurationPropertyOptions.None);
67 cookieRequireSSLProp = new ConfigurationProperty ("cookieRequireSSL", typeof(bool), false);
68 cookieSlidingExpirationProp = new ConfigurationProperty ("cookieSlidingExpiration", typeof(bool), true);
69 cookieProtectionProp = new ConfigurationProperty ("cookieProtection", typeof(CookieProtection), CookieProtection.Validation,
70 new GenericEnumConverter (typeof (CookieProtection)),
71 null, ConfigurationPropertyOptions.None);
73 domainProp = new ConfigurationProperty ("domain", typeof(string), null);
75 properties = new ConfigurationPropertyCollection ();
76 properties.Add (enabledProp);
77 properties.Add (cookielessProp);
78 properties.Add (cookieNameProp);
79 properties.Add (cookieTimeoutProp);
80 properties.Add (cookiePathProp);
81 properties.Add (cookieRequireSSLProp);
82 properties.Add (cookieSlidingExpirationProp);
83 properties.Add (cookieProtectionProp);
84 properties.Add (domainProp);
87 [ConfigurationProperty ("cookieless", DefaultValue = "UseCookies")]
88 public HttpCookieMode Cookieless {
89 get { return (HttpCookieMode) base [cookielessProp]; }
90 set { base [cookielessProp] = value; }
93 [StringValidator (MinLength = 1)]
94 [ConfigurationProperty ("cookieName", DefaultValue = ".ASPXANONYMOUS")]
95 public string CookieName {
96 get { return (string) base [cookieNameProp]; }
97 set { base [cookieNameProp] = value; }
100 [StringValidator (MinLength = 1)]
101 [ConfigurationProperty ("cookiePath", DefaultValue = "/")]
102 public string CookiePath {
103 get { return (string) base [cookiePathProp]; }
104 set { base [cookiePathProp] = value; }
107 [ConfigurationProperty ("cookieProtection", DefaultValue = "Validation")]
108 public CookieProtection CookieProtection {
109 get { return (CookieProtection) base [cookieProtectionProp]; }
110 set { base [cookieProtectionProp] = value; }
113 [ConfigurationProperty ("cookieRequireSSL", DefaultValue = "False")]
114 public bool CookieRequireSSL {
115 get { return (bool) base [cookieRequireSSLProp]; }
116 set { base [cookieRequireSSLProp] = value; }
119 [ConfigurationProperty ("cookieSlidingExpiration", DefaultValue = "True")]
120 public bool CookieSlidingExpiration {
121 get { return (bool) base [cookieSlidingExpirationProp]; }
122 set { base [cookieSlidingExpirationProp] = value; }
125 [TimeSpanValidator (MinValueString = "00:00:00", MaxValueString = "10675199.02:48:05.4775807")]
126 [TypeConverter (typeof(TimeSpanMinutesOrInfiniteConverter))]
127 [ConfigurationProperty ("cookieTimeout", DefaultValue = "69.10:40:00")]
128 public TimeSpan CookieTimeout {
129 get { return (TimeSpan) base [cookieTimeoutProp]; }
130 set { base [cookieTimeoutProp] = value; }
133 [ConfigurationProperty ("domain")]
134 public string Domain {
135 get { return (string) base [domainProp]; }
136 set { base [domainProp] = value; }
139 [ConfigurationProperty ("enabled", DefaultValue = "False")]
140 public bool Enabled {
141 get { return (bool) base [enabledProp]; }
142 set { base [enabledProp] = value; }
145 protected override ConfigurationPropertyCollection Properties {
146 get { return properties; }