01: // PrincipalImpl.java
02: // $Id: PrincipalImpl.java,v 1.3 2000/08/16 21:37:45 ylafon Exp $
03: // (c) COPYRIGHT MIT, INRIA and Keio, 1999.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05: package org.w3c.jigsaw.servlet;
06:
07: import java.security.Principal;
08:
09: /**
10: * @version $Revision: 1.3 $
11: * @author Benoît Mahé (bmahe@w3.org)
12: */
13: public class PrincipalImpl implements Principal {
14:
15: protected String name;
16:
17: /**
18: * Compares this principal to the specified object. Returns true
19: * if the object passed in matches the principal represented by
20: * the implementation of this interface.
21: *
22: * @param another principal to compare with.
23: *
24: * @return true if the principal passed in is the same as that
25: * encapsulated by this principal, and false otherwise.
26: */
27: public boolean equals(Object another) {
28: return ((Principal) another).getName().equalsIgnoreCase(name);
29: }
30:
31: /**
32: * Returns a string representation of this principal.
33: *
34: * @return a string representation of this principal.
35: */
36: public String toString() {
37: return name;
38: }
39:
40: /**
41: * Returns a hashcode for this principal.
42: *
43: * @return a hashcode for this principal.
44: */
45: public int hashCode() {
46: return name.hashCode();
47: }
48:
49: /**
50: * Returns the name of this principal.
51: *
52: * @return the name of this principal.
53: */
54: public String getName() {
55: return name;
56: }
57:
58: public PrincipalImpl(String name) {
59: this.name = name;
60: }
61:
62: }
|