Add licensing info
[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 //
7 // (C) 2003 Ben Maurer
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 #if NET_2_0
32 using System.Collections;
33 using System.Collections.Specialized;
34 using System.Text;
35
36 namespace System.Web.Security {
37         public sealed class Membership {
38                 
39                 public static MembershipUser CreateUser (string username, string password)
40                 {
41                         return CreateUser (username, password, null);
42                 }
43                 
44                 public static MembershipUser CreateUser (string username, string password, string email)
45                 {
46                         MembershipCreateStatus status;
47                         MembershipUser usr = CreateUser (username, password, email, out status);
48                         if (usr == null)
49                                 throw new MembershipCreateUserException (status);
50                         
51                         return usr;
52                 }
53                 
54                 public static MembershipUser CreateUser (string username, string password, string email, out MembershipCreateStatus status)
55                 {
56                         return Provider.CreateUser (username, password, email, out status);
57                 }
58                 
59                 public static bool DeleteUser (string username)
60                 {
61                         return Provider.DeleteUser (username);
62                 }
63                 
64                 [MonoTODO]
65                 public static string GeneratePassword (int length)
66                 {
67                         throw new NotImplementedException ();
68                 }
69                 
70                 public static MembershipUserCollection GetAllUsers ()
71                 {
72                         return Provider.GetAllUsers ();
73                 }
74                 
75                 public static int GetNumberOfUsersOnline ()
76                 {
77                         return Provider.GetNumberOfUsersOnline ();
78                 }
79                 
80                 public static MembershipUser GetUser ()
81                 {
82                         return GetUser (HttpContext.Current.User.Identity.Name, true);
83                 }
84                 
85                 public static MembershipUser GetUser (bool userIsOnline)
86                 {
87                         return GetUser (HttpContext.Current.User.Identity.Name, userIsOnline);
88                 }
89                 
90                 public static MembershipUser GetUser (string username)
91                 {
92                         return GetUser (username, false);
93                 }
94                 
95                 public static MembershipUser GetUser (string username, bool userIsOnline)
96                 {
97                         return Provider.GetUser (username, userIsOnline);
98                 }
99                 
100                 public static string GetUserNameByEmail (string email)
101                 {
102                         return Provider.GetUserNameByEmail (email);
103                 }
104                 
105                 public static void UpdateUser (MembershipUser user)
106                 {
107                         Provider.UpdateUser (user);
108                 }
109                 
110                 public static bool ValidateUser (string username, string password)
111                 {
112                         return Provider.ValidateUser (username, password);
113                 }
114                 
115                 public static string ApplicationName {
116                         get { return Provider.ApplicationName; }
117                         set { Provider.ApplicationName = value; }
118                 }
119                 
120                 public static bool EnablePasswordReset {
121                         get { return Provider.EnablePasswordReset; }
122                 }
123                 
124                 public static bool EnablePasswordRetrieval {
125                         get { return Provider.EnablePasswordRetrieval; }
126                 }
127                 
128                 public static bool RequiresQuestionAndAnswer {
129                         get { return Provider.RequiresQuestionAndAnswer; }
130                 }
131                 
132                 [MonoTODO]
133                 public static IMembershipProvider Provider {
134                         get { throw new NotImplementedException (); }
135                 }
136                 
137                 [MonoTODO]
138                 public static MembershipProviderCollection Providers {
139                         get { throw new NotImplementedException (); }
140                 }
141                 
142                 [MonoTODO]
143                 public static int UserIsOnlineTimeWindow {
144                         get { throw new NotImplementedException (); }
145                 }
146         }
147 }
148 #endif
149