01: /*
02: * BEGIN_HEADER - DO NOT EDIT
03: *
04: * The contents of this file are subject to the terms
05: * of the Common Development and Distribution License
06: * (the "License"). You may not use this file except
07: * in compliance with the License.
08: *
09: * You can obtain a copy of the license at
10: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
11: * See the License for the specific language governing
12: * permissions and limitations under the License.
13: *
14: * When distributing Covered Code, include this CDDL
15: * HEADER in each file and include the License file at
16: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
17: * If applicable add the following below this CDDL HEADER,
18: * with the fields enclosed by brackets "[]" replaced with
19: * your own identifying information: Portions Copyright
20: * [year] [name of copyright owner]
21: */
22:
23: /*
24: * @(#)UserPrincipal.java
25: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
26: *
27: * END_HEADER - DO NOT EDIT
28: */
29: package com.sun.jbi.security.auth;
30:
31: import java.security.Principal;
32:
33: /**
34: * A Simple User Principal.
35: *
36: * @author Sun Microsystems, Inc.
37: */
38: public class UserPrincipal implements Principal, java.io.Serializable {
39: /**
40: * The Principal name.
41: */
42: private String mName;
43:
44: /**
45: * Create a UserPrincipal with the user name.
46: *
47: * @param name the username for this user.
48: */
49: public UserPrincipal(String name) {
50: mName = name;
51: }
52:
53: /**
54: *
55: * @return the username of this Principal
56: */
57: public String getName() {
58: return mName;
59: }
60:
61: /**
62: *
63: * @return a string representation of this UserPrincipal.
64: */
65: public String toString() {
66: return (this .getClass().getName() + ":" + mName);
67: }
68:
69: /**
70: * Compares the specified Object with this UserPrincipal
71: * for equality. Returns true if the given object is also a
72: * UserPrincipal instance and the two UserPrincipals have
73: * the same username.
74: * @param obj Object to be compared for equality with this
75: * UserPrincipal.
76: * @return true if the specified Object is equal equal to this
77: * UserPrincipal.
78: */
79: public boolean equals(Object obj) {
80: if (obj == null) {
81: return false;
82: }
83: if (!(obj instanceof UserPrincipal)) {
84: return false;
85: }
86:
87: return (getName().equals(((UserPrincipal) obj).getName()));
88: }
89:
90: /**
91: *
92: * @return a hash code for this UserPrincipal.
93: */
94: public int hashCode() {
95: return mName.hashCode();
96: }
97: }
|