Switch to compiler-tester
[mono.git] / mcs / class / System.Web / System.Web.Security / Membership.cs
1 //
2 // System.Web.Security.Membership
3 //
4 // Authors:
5 //      Ben Maurer (bmaurer@users.sourceforge.net)
6 //      Lluis Sanchez Gual (lluis@novell.com)
7 //
8 // (C) 2003 Ben Maurer
9 // (C) 2005 Novell, inc.
10 //
11
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
20 // 
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
23 // 
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 //
32
33 #if NET_2_0
34 using System.Collections;
35 using System.Collections.Specialized;
36 using System.Text;
37
38 namespace System.Web.Security
39 {
40         public abstract class Membership
41         {
42                 private Membership ()
43                 {
44                 }
45                 
46                 public static MembershipUser CreateUser (string username, string password)
47                 {
48                         return CreateUser (username, password, null);
49                 }
50                 
51                 public static MembershipUser CreateUser (string username, string password, string email)
52                 {
53                         MembershipCreateStatus status;
54                         MembershipUser usr = CreateUser (username, password, email, null, null, true, out status);
55                         if (usr == null)
56                                 throw new MembershipCreateUserException (status);
57                         
58                         return usr;
59                 }
60                 
61                 public static MembershipUser CreateUser (string username, string password, string email, string pwdQuestion, string pwdAnswer, bool isApproved, out MembershipCreateStatus status)
62                 {
63                         return Provider.CreateUser (username, password, email, pwdQuestion, pwdAnswer, isApproved, null, out status);
64                 }
65                 
66                 public static MembershipUser CreateUser (string username, string password, string email, string pwdQuestion, string pwdAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
67                 {
68                         return Provider.CreateUser (username, password, email, pwdQuestion, pwdAnswer, isApproved, providerUserKey, out status);
69                 }
70                 
71                 public static bool DeleteUser (string username)
72                 {
73                         return Provider.DeleteUser (username, true);
74                 }
75                 
76                 public static bool DeleteUser (string username, bool deleteAllRelatedData)
77                 {
78                         return Provider.DeleteUser (username, deleteAllRelatedData);
79                 }
80                 
81                 [MonoTODO]
82                 public static string GeneratePassword (int length, int numberOfNonAlphanumericCharacters)
83                 {
84                         throw new NotImplementedException ();
85                 }
86                 
87                 public static MembershipUserCollection GetAllUsers ()
88                 {
89                         int total;
90                         return GetAllUsers (1, int.MaxValue, out total);
91                 }
92                 
93                 public static MembershipUserCollection GetAllUsers (int pageIndex, int pageSize, out int totalRecords)
94                 {
95                         return Provider.GetAllUsers (pageIndex, pageSize, out totalRecords);
96                 }
97                 
98                 public static int GetNumberOfUsersOnline ()
99                 {
100                         return Provider.GetNumberOfUsersOnline ();
101                 }
102                 
103                 public static MembershipUser GetUser ()
104                 {
105                         return GetUser (HttpContext.Current.User.Identity.Name, true);
106                 }
107                 
108                 public static MembershipUser GetUser (bool userIsOnline)
109                 {
110                         return GetUser (HttpContext.Current.User.Identity.Name, userIsOnline);
111                 }
112                 
113                 public static MembershipUser GetUser (string username)
114                 {
115                         return GetUser (username, false);
116                 }
117                 
118                 public static MembershipUser GetUser (string username, bool userIsOnline)
119                 {
120                         return Provider.GetUser (username, userIsOnline);
121                 }
122                 
123                 public static MembershipUser GetUser (object providerUserKey)
124                 {
125                         return GetUser (providerUserKey, false);
126                 }
127                 
128                 public static MembershipUser GetUser (object providerUserKey, bool userIsOnline)
129                 {
130                         return Provider.GetUser (providerUserKey, userIsOnline);
131                 }
132                 
133                 public static string GetUserNameByEmail (string email)
134                 {
135                         return Provider.GetUserNameByEmail (email);
136                 }
137                 
138                 public static void UpdateUser (MembershipUser user)
139                 {
140                         Provider.UpdateUser (user);
141                 }
142                 
143                 public static bool ValidateUser (string username, string password)
144                 {
145                         return Provider.ValidateUser (username, password);
146                 }
147                 
148                 public static MembershipUserCollection FindUsersByEmail (string emailToMatch)
149                 {
150                         int totalRecords;
151                         return Provider.FindUsersByEmail (emailToMatch, 0, int.MaxValue, out totalRecords);
152                 }
153                 
154                 public static MembershipUserCollection FindUsersByEmail (string emailToMatch, int pageIndex, int pageSize, out int totalRecords)
155                 {
156                         return Provider.FindUsersByEmail (emailToMatch, pageIndex, pageSize, out totalRecords);
157                 }
158                 
159                 public static MembershipUserCollection FindUsersByName (string nameToMatch)
160                 {
161                         int totalRecords;
162                         return Provider.FindUsersByName (nameToMatch, 0, int.MaxValue, out totalRecords);
163                 }
164                 
165                 public static MembershipUserCollection FindUsersByName (string nameToMatch, int pageIndex, int pageSize, out int totalRecords)
166                 {
167                         return Provider.FindUsersByName (nameToMatch, pageIndex, pageSize, out totalRecords);
168                 }
169
170                 
171                 
172                 public static string ApplicationName {
173                         get { return Provider.ApplicationName; }
174                         set { Provider.ApplicationName = value; }
175                 }
176                 
177                 public static bool EnablePasswordReset {
178                         get { return Provider.EnablePasswordReset; }
179                 }
180                 
181                 public static bool EnablePasswordRetrieval {
182                         get { return Provider.EnablePasswordRetrieval; }
183                 }
184                 
185                 public static bool RequiresQuestionAndAnswer {
186                         get { return Provider.RequiresQuestionAndAnswer; }
187                 }
188                 
189                 public static int MaxInvalidPasswordAttempts {
190                         get { return Provider.MaxInvalidPasswordAttempts; }
191                 }
192                 
193                 public static int MinRequiredNonAlphanumericCharacters {
194                         get { return Provider.MinRequiredNonAlphanumericCharacters; }
195                 }
196                 
197                 public static int MinRequiredPasswordLength {
198                         get { return Provider.MinRequiredPasswordLength; }
199                 }
200                 
201                 public static int PasswordAttemptWindow {
202                         get { return Provider.PasswordAttemptWindow; }
203                 }
204                 
205                 public static string PasswordStrengthRegularExpression {
206                         get { return Provider.PasswordStrengthRegularExpression; }
207                 }
208                                 
209                 [MonoTODO]
210                 public static MembershipProvider Provider {
211                         get { throw new NotImplementedException (); }
212                 }
213                 
214                 [MonoTODO]
215                 public static MembershipProviderCollection Providers {
216                         get { throw new NotImplementedException (); }
217                 }
218                 
219                 [MonoTODO]
220                 public static int UserIsOnlineTimeWindow {
221                         get { throw new NotImplementedException (); }
222                 }
223                 
224                 public event MembershipValidatePasswordEventHandler ValidatingPassword {
225                         add { Provider.ValidatingPassword += value; }
226                         remove { Provider.ValidatingPassword -= value; }
227                 }
228         }
229 }
230 #endif
231