01: /*
02: * Copyright (C) The MX4J Contributors.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the MX4J License version 1.0.
06: * See the terms of the MX4J License in the documentation provided with this software.
07: */
08:
09: package javax.management.remote;
10:
11: import java.io.Serializable;
12: import java.security.Principal;
13:
14: /**
15: * @version $Revision: 1.6 $
16: */
17: public class JMXPrincipal implements Principal, Serializable {
18: /**
19: * @serial The name of this principal
20: */
21: private String name;
22:
23: public JMXPrincipal(String name) {
24: if (name == null)
25: throw new NullPointerException(
26: "Principal name cannot be null");
27: this .name = name;
28: }
29:
30: public String getName() {
31: return name;
32: }
33:
34: public int hashCode() {
35: return getName().hashCode();
36: }
37:
38: public boolean equals(Object obj) {
39: if (obj == null)
40: return false;
41: if (obj == this )
42: return true;
43:
44: try {
45: JMXPrincipal other = (JMXPrincipal) obj;
46: return getName().equals(other.getName());
47: } catch (ClassCastException x) {
48: }
49: return false;
50: }
51:
52: public String toString() {
53: return getName();
54: }
55: }
|