01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.user;
18:
19: /**
20: * A {@link UserId} which represents the id a user would use to authenticate
21: * with the system. Also known as a "Network ID".
22: *
23: * @author rkirkend
24: */
25: public final class AuthenticationUserId implements UserId {
26:
27: private static final long serialVersionUID = -7572471214298368811L;
28:
29: private String authenticationId;
30:
31: public AuthenticationUserId(String authenticationId) {
32: setAuthenticationId(authenticationId);
33: }
34:
35: public AuthenticationUserId() {
36: }
37:
38: public String getId() {
39: return getAuthenticationId();
40: }
41:
42: public String getAuthenticationId() {
43: return authenticationId;
44: }
45:
46: public void setAuthenticationId(String authenticationId) {
47: this .authenticationId = (authenticationId == null ? null
48: : authenticationId.trim());
49: }
50:
51: /**
52: * Returns true if this userId has an empty value. Empty userIds can't be used as keys in a Hash, among other things.
53: *
54: * @return true if this instance doesn't have a value
55: */
56: public boolean isEmpty() {
57: return (authenticationId == null || authenticationId.trim()
58: .length() == 0);
59: }
60:
61: /**
62: * If you make this class non-final, you must rewrite equals to work for subclasses.
63: */
64: public boolean equals(Object obj) {
65:
66: if (obj != null && (obj instanceof AuthenticationUserId)) {
67: AuthenticationUserId a = (AuthenticationUserId) obj;
68:
69: if (getAuthenticationId() == null) {
70: return false;
71: }
72:
73: return authenticationId.equals(a.authenticationId);
74: }
75:
76: return false;
77: }
78:
79: public int hashCode() {
80: return authenticationId == null ? 0 : authenticationId
81: .hashCode();
82: }
83:
84: public String toString() {
85: if (authenticationId == null) {
86: return "authenticationId: null";
87: }
88: return "authenticationId: " + authenticationId;
89: }
90: }
|