merge -r 58784:58785
[mono.git] / mcs / class / System.Web / System.Web.Configuration_2.0 / RoleManagerSection.cs
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 //
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 using System;
32 using System.ComponentModel;
33 using System.Configuration;
34 using System.Web.Security;
35
36 #if NET_2_0
37
38 namespace System.Web.Configuration {
39
40         public sealed class RoleManagerSection : ConfigurationSection
41         {
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;
55                 static ConfigurationPropertyCollection properties;
56
57                 static RoleManagerSection ()
58                 {
59                         cacheRolesInCookieProp = new ConfigurationProperty ("cacheRolesInCookie", typeof (bool), false);
60                         cookieNameProp = new ConfigurationProperty ("cookieName", typeof (string), ".ASPXROLES");
61                         cookiePathProp = new ConfigurationProperty ("cookiePath", typeof (string), "/");
62                         cookieProtectionProp = new ConfigurationProperty ("cookieProtection", typeof (CookieProtection), CookieProtection.All);
63                         cookieRequireSSLProp = new ConfigurationProperty ("cookieRequireSSL", typeof (bool), false);
64                         cookieSlidingExpirationProp = new ConfigurationProperty ("cookieSlidingExpiration", typeof (bool), true);
65                         cookieTimeoutProp = new ConfigurationProperty ("cookieTimeout", typeof (TimeSpan), TimeSpan.FromMinutes (30));
66                         createPersistentCookieProp = new ConfigurationProperty ("createPersistentCookie", typeof (bool), false);
67                         defaultProviderProp = new ConfigurationProperty ("defaultProvider", typeof (string), "AspNetSqlRoleProvider");
68                         domainProp = new ConfigurationProperty ("domain", typeof (string));
69                         enabledProp = new ConfigurationProperty ("enabled", typeof (bool), false);
70                         maxCachedResultsProp = new ConfigurationProperty ("maxCachedResults", typeof (int), 25);
71                         providersProp = new ConfigurationProperty ("providers", typeof (ProviderSettingsCollection));
72                         properties = new ConfigurationPropertyCollection ();
73
74                         properties.Add (cacheRolesInCookieProp);
75                         properties.Add (cookieNameProp);
76                         properties.Add (cookiePathProp);
77                         properties.Add (cookieProtectionProp);
78                         properties.Add (cookieRequireSSLProp);
79                         properties.Add (cookieSlidingExpirationProp);
80                         properties.Add (cookieTimeoutProp);
81                         properties.Add (createPersistentCookieProp);
82                         properties.Add (defaultProviderProp);
83                         properties.Add (domainProp);
84                         properties.Add (enabledProp);
85                         properties.Add (maxCachedResultsProp);
86                         properties.Add (providersProp);
87                 }
88
89                 [ConfigurationProperty ("cacheRolesInCookie", DefaultValue = "False")]
90                 public bool CacheRolesInCookie {
91                         get { return (bool) base [cacheRolesInCookieProp];}
92                         set { base[cacheRolesInCookieProp] = value; }
93                 }
94
95                 [TypeConverter (typeof (WhiteSpaceTrimStringConverter))]
96                 [StringValidator (MinLength = 1)]
97                 [ConfigurationProperty ("cookieName", DefaultValue = ".ASPXROLES")]
98                 public string CookieName {
99                         get { return (string) base [cookieNameProp];}
100                         set { base[cookieNameProp] = value; }
101                 }
102
103                 [TypeConverter (typeof (WhiteSpaceTrimStringConverter))]
104                 [StringValidator (MinLength = 1)]
105                 [ConfigurationProperty ("cookiePath", DefaultValue = "/")]
106                 public string CookiePath {
107                         get { return (string) base [cookiePathProp];}
108                         set { base[cookiePathProp] = value; }
109                 }
110
111                 [ConfigurationProperty ("cookieProtection", DefaultValue = "All")]
112                 public CookieProtection CookieProtection {
113                         get { return (CookieProtection) base [cookieProtectionProp];}
114                         set { base[cookieProtectionProp] = value; }
115                 }
116
117                 [ConfigurationProperty ("cookieRequireSSL", DefaultValue = "False")]
118                 public bool CookieRequireSSL {
119                         get { return (bool) base [cookieRequireSSLProp];}
120                         set { base[cookieRequireSSLProp] = value; }
121                 }
122
123                 [ConfigurationProperty ("cookieSlidingExpiration", DefaultValue = "True")]
124                 public bool CookieSlidingExpiration {
125                         get { return (bool) base [cookieSlidingExpirationProp];}
126                         set { base[cookieSlidingExpirationProp] = value; }
127                 }
128
129                 [TypeConverter (typeof (TimeSpanMinutesOrInfiniteConverter))]
130                 [TimeSpanValidator (MinValueString = "00:00:00", MaxValueString = "10675199.02:48:05.4775807")]
131                 [ConfigurationProperty ("cookieTimeout", DefaultValue = "00:30:00")]
132                 public TimeSpan CookieTimeout {
133                         get { return (TimeSpan) base [cookieTimeoutProp];}
134                         set { base[cookieTimeoutProp] = value; }
135                 }
136
137                 [ConfigurationProperty ("createPersistentCookie", DefaultValue = "False")]
138                 public bool CreatePersistentCookie {
139                         get { return (bool) base [createPersistentCookieProp];}
140                         set { base[createPersistentCookieProp] = value; }
141                 }
142
143                 [TypeConverter (typeof (WhiteSpaceTrimStringConverter))]
144                 [StringValidator (MinLength = 1)]
145                 [ConfigurationProperty ("defaultProvider", DefaultValue = "AspNetSqlRoleProvider")]
146                 public string DefaultProvider {
147                         get { return (string) base [defaultProviderProp];}
148                         set { base[defaultProviderProp] = value; }
149                 }
150
151                 [ConfigurationProperty ("domain")]
152                 public string Domain {
153                         get { return (string) base [domainProp];}
154                         set { base[domainProp] = value; }
155                 }
156
157                 [ConfigurationProperty ("enabled", DefaultValue = "False")]
158                 public bool Enabled {
159                         get { return (bool) base [enabledProp];}
160                         set { base[enabledProp] = value; }
161                 }
162
163                 [ConfigurationProperty ("maxCachedResults", DefaultValue = "25")]
164                 public int MaxCachedResults {
165                         get { return (int) base [maxCachedResultsProp];}
166                         set { base[maxCachedResultsProp] = value; }
167                 }
168
169                 [ConfigurationProperty ("providers")]
170                 public ProviderSettingsCollection Providers {
171                         get { return (ProviderSettingsCollection) base [providersProp];}
172                 }
173
174                 protected override ConfigurationPropertyCollection Properties {
175                         get { return properties; }
176                 }
177         }
178 }
179
180 #endif