01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: RoleUserIdentity.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.authentication.credentialsmanagers;
09:
10: public class RoleUserIdentity implements Cloneable {
11: private String mLogin = null;
12: private RoleUserAttributes mAttributes = null;
13:
14: public RoleUserIdentity(String login, RoleUserAttributes attributes) {
15: if (null == login)
16: throw new IllegalArgumentException("login can't be null.");
17: if (0 == login.length())
18: throw new IllegalArgumentException("login can't be empty.");
19: if (null == attributes)
20: throw new IllegalArgumentException(
21: "attributes can't be null.");
22:
23: mLogin = login;
24: mAttributes = attributes;
25: }
26:
27: public String getLogin() {
28: return mLogin;
29: }
30:
31: public RoleUserAttributes getAttributes() {
32: return mAttributes;
33: }
34:
35: public RoleUserIdentity clone() {
36: RoleUserIdentity new_identity = null;
37: try {
38: new_identity = (RoleUserIdentity) super .clone();
39:
40: new_identity.mAttributes = mAttributes.clone();
41: } catch (CloneNotSupportedException e) {
42: new_identity = null;
43: }
44:
45: return new_identity;
46: }
47:
48: public boolean equals(Object other) {
49: if (null == other) {
50: return false;
51: }
52:
53: if (this == other) {
54: return true;
55: }
56:
57: if (!(other instanceof RoleUserIdentity)) {
58: return false;
59: }
60:
61: RoleUserIdentity other_identity = (RoleUserIdentity) other;
62: if (!getLogin().equals(other_identity.getLogin())) {
63: return false;
64: }
65: if (!getAttributes().equals(other_identity.getAttributes())) {
66: return false;
67: }
68:
69: return true;
70: }
71: }
|