Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AuthenticationUserId |
|
| 2.111111111111111;2.111 |
1 | /* | |
2 | * Copyright 2005-2008 The Kuali Foundation | |
3 | * | |
4 | * | |
5 | * Licensed under the Educational Community License, Version 2.0 (the "License"); | |
6 | * you may not use this file except in compliance with the License. | |
7 | * You may obtain a copy of the License at | |
8 | * | |
9 | * http://www.opensource.org/licenses/ecl2.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 org.kuali.rice.kew.user; | |
18 | ||
19 | import org.kuali.rice.kew.identity.PrincipalName; | |
20 | ||
21 | /** | |
22 | * A {@link UserId} which represents the id a user would use to authenticate | |
23 | * with the system. Also known as a "Network ID". | |
24 | * | |
25 | * @deprecated use {@link PrincipalName} instead | |
26 | * | |
27 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
28 | */ | |
29 | public class AuthenticationUserId implements UserId { | |
30 | ||
31 | private static final long serialVersionUID = -7572471214298368811L; | |
32 | ||
33 | private String authenticationId; | |
34 | ||
35 | 0 | public AuthenticationUserId(String authenticationId) { |
36 | 0 | setAuthenticationId(authenticationId); |
37 | 0 | } |
38 | ||
39 | 0 | public AuthenticationUserId() { |
40 | 0 | } |
41 | ||
42 | public String getId() { | |
43 | 0 | return getAuthenticationId(); |
44 | } | |
45 | ||
46 | public String getAuthenticationId() { | |
47 | 0 | return authenticationId; |
48 | } | |
49 | ||
50 | public void setAuthenticationId(String authenticationId) { | |
51 | 0 | this.authenticationId = (authenticationId == null ? null : authenticationId.trim()); |
52 | 0 | } |
53 | ||
54 | /** | |
55 | * Returns true if this userId has an empty value. Empty userIds can't be used as keys in a Hash, among other things. | |
56 | * | |
57 | * @return true if this instance doesn't have a value | |
58 | */ | |
59 | public boolean isEmpty() { | |
60 | 0 | return (authenticationId == null || authenticationId.trim().length() == 0); |
61 | } | |
62 | ||
63 | ||
64 | ||
65 | /** | |
66 | * If you make this class non-final, you must rewrite equals to work for subclasses. | |
67 | */ | |
68 | public boolean equals(Object obj) { | |
69 | ||
70 | 0 | if (obj != null && (obj instanceof AuthenticationUserId)) { |
71 | 0 | AuthenticationUserId a = (AuthenticationUserId) obj; |
72 | ||
73 | 0 | if (getAuthenticationId() == null) { |
74 | 0 | return false; |
75 | } | |
76 | ||
77 | 0 | return authenticationId.equals(a.authenticationId); |
78 | } | |
79 | ||
80 | 0 | return false; |
81 | } | |
82 | ||
83 | public int hashCode() { | |
84 | 0 | return authenticationId == null ? 0 : authenticationId.hashCode(); |
85 | } | |
86 | ||
87 | public String toString() { | |
88 | 0 | if (authenticationId == null) { |
89 | 0 | return "authenticationId: null"; |
90 | } | |
91 | 0 | return "authenticationId: " + authenticationId; |
92 | } | |
93 | } |