2 // System.Web.Configuration.AuthConfig
5 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
7 // (C) 2002 Ximian, Inc (http://www.ximian.com)
8 // Copyright (c) 2005 Novell, Inc (http://www.novell.com)
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:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
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.
32 using System.Collections;
33 using System.Configuration;
36 namespace System.Web.Configuration
40 AuthenticationMode mode;
44 FormsProtectionEnum protection;
46 FormsAuthPasswordFormat pwdFormat;
47 Hashtable credentialUsers;
51 bool slidingExpiration;
55 HttpCookieMode cookie_mode;
56 bool cookies_supported;
58 bool enable_crossapp_redirects;
61 internal AuthConfig (object parent)
63 if (parent is AuthConfig) {
65 AuthConfig p = (AuthConfig) parent;
67 cookieName = p.cookieName;
68 cookiePath = p.cookiePath;
69 loginUrl = p.loginUrl;
70 protection = p.protection;
72 pwdFormat = p.pwdFormat;
74 requireSSL = p.requireSSL;
75 slidingExpiration = p.slidingExpiration;
78 cookie_domain = p.cookie_domain;
79 cookie_mode = p.cookie_mode;
80 cookies_supported = p.cookies_supported;
81 default_url = p.default_url;
82 enable_crossapp_redirects = p.enable_crossapp_redirects;
84 credentialUsers = new Hashtable (p.CredentialUsers);
88 internal void SetMode (string m)
91 // we default to Forms authentication mode, MS defaults to Windows
93 Mode = AuthenticationMode.Forms;
97 Mode = (AuthenticationMode) Enum.Parse (typeof (AuthenticationMode), m, true);
100 internal void SetProtection (string prot)
104 Protection = FormsProtectionEnum.All;
108 Protection = (FormsProtectionEnum) Enum.Parse (typeof (FormsProtectionEnum),
113 internal void SetTimeout (string minutes)
115 if (minutes != null) {
116 Timeout = Int32.Parse (minutes);
124 internal void SetPasswordFormat (string pwdFormat)
126 if (pwdFormat == null) {
128 PasswordFormat = FormsAuthPasswordFormat.Clear;
133 (FormsAuthPasswordFormat) Enum.Parse (typeof (FormsAuthPasswordFormat),
138 internal AuthenticationMode Mode {
140 set { mode = value; }
143 internal string CookieName {
145 if (cookieName == null)
146 cookieName = ".ASPXAUTH";
158 internal string CookiePath {
160 if (cookiePath == null)
173 internal string LoginUrl {
175 if (loginUrl == null)
176 loginUrl = "login.aspx";
188 internal FormsProtectionEnum Protection {
189 get { return protection; }
190 set { protection = value; }
193 internal int Timeout {
194 get { return timeout; }
197 throw new ArgumentException ("Timeout must be > 0", "value");
203 internal FormsAuthPasswordFormat PasswordFormat {
204 get { return pwdFormat; }
205 set { pwdFormat = value; }
208 internal Hashtable CredentialUsers {
210 if (credentialUsers == null)
211 credentialUsers = new Hashtable ();
213 return credentialUsers;
218 internal bool RequireSSL {
219 get { return requireSSL; }
220 set { requireSSL = value; }
223 internal bool SlidingExpiration {
224 get { return slidingExpiration; }
225 set { slidingExpiration = value; }
230 internal string CookieDomain {
231 get { return cookie_domain; }
232 set { cookie_domain = value; }
235 internal HttpCookieMode CookieMode {
236 get { return cookie_mode; }
237 set { cookie_mode = value; }
240 internal bool CookiesSupported {
241 get { return cookies_supported; }
242 set { cookies_supported = value; }
245 internal string DefaultUrl {
246 get { return default_url; }
247 set { default_url = value; }
250 internal bool EnableCrossAppRedirects {
251 get { return enable_crossapp_redirects; }
252 set { enable_crossapp_redirects = value; }