1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.Applications
.PestControl
.Model
18 using System
.Security
.Principal
;
19 using System
.Collections
;
22 public class User
: Identifiable
, IPrincipal
, IIdentity
24 String _name
; String _pass
; String _email
;
26 public User(string name
, string email
, string passwd
)
36 set { _name = value; }
41 get { return _email; }
42 set { _email = value; }
45 public string Password
48 set { _pass = value; }
51 public bool IsInRole(string role
)
56 public IIdentity Identity
61 #region IIdentity Members
63 public bool IsAuthenticated
68 string System
.Security
.Principal
.IIdentity
.Name
73 public string AuthenticationType
75 get { return "custom"; }
82 /// Summary description for UserCollection.
85 public class UserCollection
: ReadOnlyCollectionBase
87 public void Add(User user
)
89 lock (this.InnerList
.SyncRoot
)
95 public User
FindByEmail(String email
)
97 lock (this.InnerList
.SyncRoot
)
99 foreach (User user
in this)
101 if (CaseInsensitiveComparer
.Default
.Compare(user
.Email
, email
) == 0)
111 public bool Authenticate(String email
, String password
)
113 User user
= FindByEmail(email
);
115 if (user
== null) return false;
117 if (user
.Password
.Equals(password
))