2
0

FormsAuthenticationConfiguration.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. //
  2. // System.Web.Configuration.FormsAuthenticationConfiguration
  3. //
  4. // Authors:
  5. // Lluis Sanchez Gual ([email protected])
  6. // Chris Toshok ([email protected])
  7. //
  8. // (C) 2004-2005 Novell, Inc (http://www.novell.com)
  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. #if NET_2_0
  31. using System.Configuration;
  32. using System.ComponentModel;
  33. namespace System.Web.Configuration
  34. {
  35. public sealed class FormsAuthenticationConfiguration: ConfigurationElement
  36. {
  37. static ConfigurationPropertyCollection properties;
  38. static ConfigurationProperty cookielessProp;
  39. static ConfigurationProperty credentialsProp;
  40. static ConfigurationProperty defaultUrlProp;
  41. static ConfigurationProperty domainProp;
  42. static ConfigurationProperty enableCrossAppRedirectsProp;
  43. static ConfigurationProperty loginUrlProp;
  44. static ConfigurationProperty nameProp;
  45. static ConfigurationProperty pathProp;
  46. static ConfigurationProperty protectionProp;
  47. static ConfigurationProperty requireSSLProp;
  48. static ConfigurationProperty slidingExpirationProp;
  49. static ConfigurationProperty timeoutProp;
  50. static FormsAuthenticationConfiguration ()
  51. {
  52. cookielessProp = new ConfigurationProperty ("cookieless", typeof (HttpCookieMode), HttpCookieMode.UseDeviceProfile);
  53. credentialsProp = new ConfigurationProperty ("credentials", typeof (FormsAuthenticationCredentials), null);
  54. defaultUrlProp = new ConfigurationProperty ("defaultUrl", typeof (string), "default.aspx");
  55. domainProp = new ConfigurationProperty ("domain", typeof (string), "");
  56. enableCrossAppRedirectsProp = new ConfigurationProperty ("enableCrossAppRedirects", typeof (bool), false);
  57. loginUrlProp = new ConfigurationProperty ("loginUrl", typeof (string), "login.aspx");
  58. nameProp = new ConfigurationProperty ("name", typeof (string), ".ASPXAUTH");
  59. pathProp = new ConfigurationProperty ("path", typeof (string), "/");
  60. protectionProp = new ConfigurationProperty ("protection", typeof (FormsProtectionEnum), FormsProtectionEnum.All);
  61. requireSSLProp = new ConfigurationProperty ("requireSSL", typeof (bool), false);
  62. slidingExpirationProp = new ConfigurationProperty ("slidingExpiration", typeof (bool), true);
  63. timeoutProp = new ConfigurationProperty ("timeout", typeof (TimeSpan), TimeSpan.FromMinutes (30));
  64. properties = new ConfigurationPropertyCollection ();
  65. properties.Add (cookielessProp);
  66. properties.Add (credentialsProp);
  67. properties.Add (defaultUrlProp);
  68. properties.Add (domainProp);
  69. properties.Add (enableCrossAppRedirectsProp);
  70. properties.Add (loginUrlProp);
  71. properties.Add (nameProp);
  72. properties.Add (pathProp);
  73. properties.Add (protectionProp);
  74. properties.Add (requireSSLProp);
  75. properties.Add (slidingExpirationProp);
  76. properties.Add (timeoutProp);
  77. }
  78. public FormsAuthenticationConfiguration ()
  79. {
  80. }
  81. [ConfigurationProperty ("cookieless", DefaultValue = "UseDeviceProfile")]
  82. public HttpCookieMode Cookieless {
  83. get { return (HttpCookieMode)base[cookielessProp]; }
  84. set { base[cookielessProp] = value; }
  85. }
  86. [ConfigurationProperty ("credentials")]
  87. public FormsAuthenticationCredentials Credentials {
  88. get { return (FormsAuthenticationCredentials) base[credentialsProp]; }
  89. }
  90. [StringValidator (MinLength = 1)]
  91. [ConfigurationProperty ("defaultUrl", DefaultValue = "default.aspx")]
  92. public string DefaultUrl {
  93. get { return (string) base[defaultUrlProp]; }
  94. set { base[defaultUrlProp] = value; }
  95. }
  96. [ConfigurationProperty ("domain", DefaultValue = "")]
  97. public string Domain {
  98. get { return (string) base[domainProp]; }
  99. set { base[domainProp] = value; }
  100. }
  101. [ConfigurationProperty ("enableCrossAppRedirects", DefaultValue = "False")]
  102. public bool EnableCrossAppRedirects {
  103. get { return (bool) base[enableCrossAppRedirectsProp]; }
  104. set { base[enableCrossAppRedirectsProp] = value; }
  105. }
  106. [StringValidator (MinLength = 1)]
  107. [ConfigurationProperty ("loginUrl", DefaultValue = "login.aspx")]
  108. public string LoginUrl {
  109. get { return (string) base[loginUrlProp]; }
  110. set { base[loginUrlProp] = value; }
  111. }
  112. [StringValidator (MinLength = 1)]
  113. [ConfigurationProperty ("name", DefaultValue = ".ASPXAUTH")]
  114. public string Name {
  115. get { return (string) base[nameProp]; }
  116. set { base[nameProp] = value; }
  117. }
  118. [StringValidator (MinLength = 1)]
  119. [ConfigurationProperty ("path", DefaultValue = "/")]
  120. public string Path {
  121. get { return (string) base[pathProp]; }
  122. set { base[pathProp] = value; }
  123. }
  124. [ConfigurationProperty ("protection", DefaultValue = "All")]
  125. public FormsProtectionEnum Protection {
  126. get { return (FormsProtectionEnum) base[protectionProp]; }
  127. set { base[protectionProp] = value; }
  128. }
  129. [ConfigurationProperty ("requireSSL", DefaultValue = "False")]
  130. public bool RequireSSL {
  131. get { return (bool) base[requireSSLProp]; }
  132. set { base[requireSSLProp] = value; }
  133. }
  134. [ConfigurationProperty ("slidingExpiration", DefaultValue = "True")]
  135. public bool SlidingExpiration {
  136. get { return (bool) base[slidingExpirationProp]; }
  137. set { base[slidingExpirationProp] = value; }
  138. }
  139. [TypeConverter (typeof (TimeSpanMinutesConverter))]
  140. [TimeSpanValidator (MinValueString = "00:00:00")]
  141. [ConfigurationProperty ("timeout", DefaultValue = "00:30:00")]
  142. public TimeSpan Timeout {
  143. get { return (TimeSpan) base[timeoutProp]; }
  144. set { base [timeoutProp] = value; }
  145. }
  146. protected override ConfigurationPropertyCollection Properties {
  147. get { return properties; }
  148. }
  149. #if notyet
  150. [MonoTODO]
  151. protected override ConfigurationElementProperty ElementProperty {
  152. get { throw new NotImplementedException (); }
  153. }
  154. #endif
  155. }
  156. }
  157. #endif