Backport of some changes from svn trunk - performance improvement and a fix for bug...
[mono-project.git] / mcs / class / System.Web / System.Web.Configuration_2.0 / RoleManagerSection.cs
blob2cdeeb204bc8a6c74bb3015286f4ce7fd0a7dd56
1 //
2 // System.Web.Configuration.RoleManagerSection
3 //
4 // Authors:
5 // Chris Toshok (toshok@ximian.com)
6 //
7 // (C) 2005 Novell, Inc (http://www.novell.com)
8 //
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.
31 using System;
32 using System.ComponentModel;
33 using System.Configuration;
34 using System.Web.Security;
36 #if NET_2_0
38 namespace System.Web.Configuration {
40 public sealed class RoleManagerSection : ConfigurationSection
42 static ConfigurationProperty cacheRolesInCookieProp;
43 static ConfigurationProperty cookieNameProp;
44 static ConfigurationProperty cookiePathProp;
45 static ConfigurationProperty cookieProtectionProp;
46 static ConfigurationProperty cookieRequireSSLProp;
47 static ConfigurationProperty cookieSlidingExpirationProp;
48 static ConfigurationProperty cookieTimeoutProp;
49 static ConfigurationProperty createPersistentCookieProp;
50 static ConfigurationProperty defaultProviderProp;
51 static ConfigurationProperty domainProp;
52 static ConfigurationProperty enabledProp;
53 static ConfigurationProperty maxCachedResultsProp;
54 static ConfigurationProperty providersProp;
56 static ConfigurationPropertyCollection properties;
58 static RoleManagerSection ()
60 cacheRolesInCookieProp = new ConfigurationProperty ("cacheRolesInCookie", typeof (bool), false);
61 cookieNameProp = new ConfigurationProperty ("cookieName", typeof (string), ".ASPXROLES");
62 cookiePathProp = new ConfigurationProperty ("cookiePath", typeof (string), "/");
63 cookieProtectionProp = new ConfigurationProperty ("cookieProtection", typeof (CookieProtection),
64 CookieProtection.All);
65 cookieRequireSSLProp = new ConfigurationProperty ("cookieRequireSSL", typeof (bool), false);
66 cookieSlidingExpirationProp = new ConfigurationProperty ("cookieSlidingExpiration", typeof (bool), true);
67 cookieTimeoutProp = new ConfigurationProperty ("cookieTimeout", typeof (TimeSpan), TimeSpan.FromMinutes (30));
68 createPersistentCookieProp = new ConfigurationProperty ("createPersistentCookie", typeof (bool), false);
69 defaultProviderProp = new ConfigurationProperty ("defaultProvider", typeof (string), "AspNetSqlRoleProvider");
70 domainProp = new ConfigurationProperty ("domain", typeof (string), "");
71 enabledProp = new ConfigurationProperty ("enabled", typeof (bool), false);
72 maxCachedResultsProp = new ConfigurationProperty ("maxCachedResults", typeof (int), 25);
73 providersProp = new ConfigurationProperty ("providers", typeof (ProviderSettingsCollection));
75 properties = new ConfigurationPropertyCollection ();
76 properties.Add (cacheRolesInCookieProp);
77 properties.Add (cookieNameProp);
78 properties.Add (cookiePathProp);
79 properties.Add (cookieProtectionProp);
80 properties.Add (cookieRequireSSLProp);
81 properties.Add (cookieSlidingExpirationProp);
82 properties.Add (cookieTimeoutProp);
83 properties.Add (createPersistentCookieProp);
84 properties.Add (defaultProviderProp);
85 properties.Add (domainProp);
86 properties.Add (enabledProp);
87 properties.Add (maxCachedResultsProp);
88 properties.Add (providersProp);
91 [ConfigurationProperty ("cacheRolesInCookie", DefaultValue = false)]
92 public bool CacheRolesInCookie {
93 get { return (bool) base [cacheRolesInCookieProp]; }
94 set { base [cacheRolesInCookieProp] = value; }
97 [TypeConverter (typeof (WhiteSpaceTrimStringConverter))]
98 [StringValidator (MinLength = 1)]
99 [ConfigurationProperty ("cookieName", DefaultValue = ".ASPXROLES")]
100 public string CookieName {
101 get { return (string) base [cookieNameProp]; }
102 set { base [cookieNameProp] = value; }
105 [TypeConverter (typeof (WhiteSpaceTrimStringConverter))]
106 [StringValidator (MinLength = 1)]
107 [ConfigurationProperty ("cookiePath", DefaultValue = "/")]
108 public string CookiePath {
109 get { return (string) base [cookiePathProp]; }
110 set { base [cookiePathProp] = value; }
113 [ConfigurationProperty ("cookieProtection", DefaultValue = "All")]
114 public CookieProtection CookieProtection {
115 get { return (CookieProtection) base [cookieProtectionProp]; }
116 set { base [cookieProtectionProp] = value; }
119 [ConfigurationProperty ("cookieRequireSSL", DefaultValue = false)]
120 public bool CookieRequireSSL {
121 get { return (bool) base [cookieRequireSSLProp]; }
122 set { base [cookieRequireSSLProp] = value; }
125 [ConfigurationProperty ("cookieSlidingExpiration", DefaultValue = true)]
126 public bool CookieSlidingExpiration {
127 get { return (bool) base [cookieSlidingExpirationProp]; }
128 set { base [cookieSlidingExpirationProp] = value; }
131 [TimeSpanValidatorAttribute(MinValueString = "00:00:00", MaxValueString = "10675199.02:48:05.4775807")]
132 [ConfigurationPropertyAttribute("cookieTimeout", DefaultValue = "00:30:00")]
133 [TypeConverterAttribute(typeof(TimeSpanMinutesOrInfiniteConverter))]
134 public TimeSpan CookieTimeout {
135 get { return (TimeSpan) base [cookieTimeoutProp]; }
136 set { base [cookieTimeoutProp] = value; }
139 [ConfigurationProperty ("createPersistentCookie", DefaultValue = false)]
140 public bool CreatePersistentCookie {
141 get { return (bool) base [createPersistentCookieProp]; }
142 set { base [createPersistentCookieProp] = value; }
145 [TypeConverter (typeof (WhiteSpaceTrimStringConverter))]
146 [StringValidator (MinLength = 1)]
147 [ConfigurationProperty ("defaultProvider", DefaultValue = "AspNetSqlRoleProvider")]
148 public string DefaultProvider {
149 get { return (string) base [defaultProviderProp]; }
150 set { base [defaultProviderProp] = value; }
153 [ConfigurationProperty ("domain")]
154 public string Domain {
155 get { return (string) base [domainProp]; }
156 set { base [domainProp] = value; }
159 [ConfigurationProperty ("enabled", DefaultValue = false)]
160 public bool Enabled {
161 get { return (bool) base [enabledProp]; }
162 set { base [enabledProp] = value; }
165 [ConfigurationProperty ("maxCachedResults", DefaultValue = 25)]
166 public int MaxCachedResults {
167 get { return (int) base [maxCachedResultsProp]; }
168 set { base [maxCachedResultsProp] = value; }
171 [ConfigurationProperty ("providers")]
172 public ProviderSettingsCollection Providers {
173 get { return (ProviderSettingsCollection) base [providersProp]; }
176 protected override ConfigurationPropertyCollection Properties {
177 get { return properties; }
182 #endif