01: /*
02: * Copyright 2003-2006 Rick Knowles <winstone-devel at lists sourceforge net>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: */
07: package winstone;
08:
09: import java.io.Serializable;
10: import java.security.Principal;
11: import java.util.List;
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, Serializable {
21: private String userName;
22: private String password;
23: private List roles;
24: private String authenticationType;
25:
26: /**
27: * Constructor
28: */
29: public AuthenticationPrincipal(String userName, String password,
30: List roles) {
31: this .userName = userName;
32: this .password = password;
33: this .roles = roles;
34: }
35:
36: public String getName() {
37: return this .userName;
38: }
39:
40: public String getPassword() {
41: return this .password;
42: }
43:
44: public String getAuthType() {
45: return this .authenticationType;
46: }
47:
48: public void setAuthType(String authType) {
49: this .authenticationType = authType;
50: }
51:
52: /**
53: * Searches for the requested role in this user's roleset.
54: */
55: public boolean isUserIsInRole(String role) {
56: if (this .roles == null)
57: return false;
58: else if (role == null)
59: return false;
60: else
61: return this.roles.contains(role);
62: }
63: }
|