01: /*
02: * (C) Copyright 2000 - 2003 Nabh Information Systems, Inc.
03: *
04: * This program is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU General Public License
06: * as published by the Free Software Foundation; either version 2
07: * of the License, or (at your option) any later version.
08: *
09: * This program is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with this program; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: *
18: */
19:
20: package com.nabhinc.portal.spi.impl.jaas;
21:
22: import java.io.Serializable;
23: import java.security.Principal;
24:
25: /**
26: * Role Principal.
27: *
28: * @author Padmanabh Dabke
29: * (c) 2003 Nabh Information Systems, Inc. All Rights Reserved.
30: */
31: public class RolePrincipal implements Principal, Serializable {
32:
33: /**
34: *
35: */
36: private static final long serialVersionUID = 1L;
37: private String name;
38:
39: /**
40: * Default constructor is private.
41: */
42: private RolePrincipal() {
43: }
44:
45: /**
46: * Constructor
47: */
48: public RolePrincipal(String name) {
49: this .name = name;
50: }
51:
52: /**
53: * Returns the name of this principal.
54: *
55: * @return the name of this principal.
56: */
57: public String getName() {
58: return name;
59: }
60:
61: /**
62: * Compares this principal to the specified object.
63: *
64: * @param obj object to compare with.
65: * @return true if the object passed in is a SimplePrincipal with the same name.
66: */
67: public boolean equals(Object obj) {
68: if (obj == null)
69: return false;
70:
71: if (obj instanceof RolePrincipal) {
72: return name.equals(((RolePrincipal) obj).getName());
73: }
74: return false;
75: }
76:
77: /**
78: * Returns a string representation of this principal.
79: * @return a string representation of this principal.
80: */
81: public String toString() {
82: return "RolePrincipal[name = \'" + name + "\']";
83: }
84:
85: /**
86: * Returns a hashcode for this principal.
87: * @return a hashcode for this principal.
88: */
89: public int hashCode() {
90: return name.hashCode();
91: }
92: }
|