2 // System.Web.Configuration.AuthConfig
5 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
7 // (C) 2002 Ximian, Inc (http://www.ximian.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.
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;
54 internal AuthConfig (object parent)
56 if (parent is AuthConfig) {
58 AuthConfig p = (AuthConfig) parent;
60 cookieName = p.cookieName;
61 cookiePath = p.cookiePath;
62 loginUrl = p.loginUrl;
63 protection = p.protection;
65 pwdFormat = p.pwdFormat;
67 requireSSL = p.requireSSL;
68 slidingExpiration = p.slidingExpiration;
70 credentialUsers = new Hashtable (p.CredentialUsers);
74 internal void SetMode (string m)
77 // we default to Forms authentication mode, MS defaults to Windows
79 Mode = AuthenticationMode.Forms;
83 Mode = (AuthenticationMode) Enum.Parse (typeof (AuthenticationMode), m, true);
86 internal void SetProtection (string prot)
90 Protection = FormsProtectionEnum.All;
94 Protection = (FormsProtectionEnum) Enum.Parse (typeof (FormsProtectionEnum),
99 internal void SetTimeout (string minutes)
101 if (minutes != null) {
102 Timeout = Int32.Parse (minutes);
110 internal void SetPasswordFormat (string pwdFormat)
112 if (pwdFormat == null) {
114 PasswordFormat = FormsAuthPasswordFormat.Clear;
119 (FormsAuthPasswordFormat) Enum.Parse (typeof (FormsAuthPasswordFormat),
124 internal AuthenticationMode Mode {
126 set { mode = value; }
129 internal string CookieName {
131 if (cookieName == null)
132 cookieName = ".ASPXAUTH";
144 internal string CookiePath {
146 if (cookiePath == null)
159 internal string LoginUrl {
161 if (loginUrl == null)
162 loginUrl = "login.aspx";
174 internal FormsProtectionEnum Protection {
175 get { return protection; }
176 set { protection = value; }
179 internal int Timeout {
180 get { return timeout; }
183 throw new ArgumentException ("Timeout must be > 0", "value");
189 internal FormsAuthPasswordFormat PasswordFormat {
190 get { return pwdFormat; }
191 set { pwdFormat = value; }
194 internal Hashtable CredentialUsers {
196 if (credentialUsers == null)
197 credentialUsers = new Hashtable ();
199 return credentialUsers;
204 internal bool RequireSSL {
205 get { return requireSSL; }
206 set { requireSSL = value; }
209 internal bool SlidingExpiration {
210 get { return slidingExpiration; }
211 set { slidingExpiration = value; }