01: /*
02: * CoadunationSecurity: This library contains extra security related classes.
03: * Copyright (C) 2007 Rift IT Contracting
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18: *
19: * BasicPrincipal.java
20: */
21:
22: // package path
23: package com.rift.coad.security;
24:
25: // imports
26: import java.security.Principal;
27: import java.io.Serializable;
28:
29: /**
30: * This object is responsible for storing the principal information.
31: *
32: * @author brett
33: */
34: public class BasicPrincipal implements Principal, Serializable {
35:
36: // private member variables
37: private String name = null;
38:
39: /**
40: * Creates a new instance of BasicPrincipal
41: *
42: * @param name The name of this principal
43: */
44: public BasicPrincipal(String name) {
45: this .name = name;
46: }
47:
48: /**
49: * This method returns the name of the principal
50: */
51: public String getName() {
52: return name;
53: }
54:
55: /**
56: * This method returns true if the objects are the same type and contain the
57: * same value.
58: *
59: * @return TRUE if equal.
60: * @param value The value to perform the comparison on.
61: */
62: public boolean equals(Object value) {
63: if ((value instanceof BasicPrincipal)
64: && ((BasicPrincipal) value).getName().equals(name)) {
65: return true;
66: }
67: return false;
68:
69: }
70:
71: /**
72: * This method returns the hash code of this item.
73: */
74: public int hashCode() {
75: if (name == null) {
76: return 0;
77: }
78: return name.hashCode();
79: }
80:
81: /**
82: * This method returns the string value of this object.
83: */
84: public String toString() {
85: return name;
86: }
87: }
|