KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > winstone > AuthenticationPrincipal


1 /*
2  * Copyright 2003-2006 Rick Knowles <winstone-devel at lists sourceforge net>
3  * Distributed under the terms of either:
4  * - the common development and distribution license (CDDL), v1.0; or
5  * - the GNU Lesser General Public License, v2.1 or later
6  */

7 package winstone;
8
9 import java.io.Serializable JavaDoc;
10 import java.security.Principal JavaDoc;
11 import java.util.List JavaDoc;
12
13 /**
14  * Implements the principal method - basically just a way of identifying an
15  * authenticated user.
16  *
17  * @author <a HREF="mailto:rick_knowles@hotmail.com">Rick Knowles</a>
18  * @version $Id: AuthenticationPrincipal.java,v 1.2 2006/02/28 07:32:47 rickknowles Exp $
19  */

20 public class AuthenticationPrincipal implements Principal JavaDoc, Serializable JavaDoc {
21     private String JavaDoc userName;
22     private String JavaDoc password;
23     private List JavaDoc roles;
24     private String JavaDoc authenticationType;
25
26     /**
27      * Constructor
28      */

29     public AuthenticationPrincipal(String JavaDoc userName, String JavaDoc password, List JavaDoc roles) {
30         this.userName = userName;
31         this.password = password;
32         this.roles = roles;
33     }
34
35     public String JavaDoc getName() {
36         return this.userName;
37     }
38
39     public String JavaDoc getPassword() {
40         return this.password;
41     }
42
43     public String JavaDoc getAuthType() {
44         return this.authenticationType;
45     }
46
47     public void setAuthType(String JavaDoc authType) {
48         this.authenticationType = authType;
49     }
50
51     /**
52      * Searches for the requested role in this user's roleset.
53      */

54     public boolean isUserIsInRole(String JavaDoc role) {
55         if (this.roles == null)
56             return false;
57         else if (role == null)
58             return false;
59         else
60             return this.roles.contains(role);
61     }
62 }
63
Popular Tags