01: /*
02: * JOSSO: Java Open Single Sign-On
03: *
04: * Copyright 2004-2008, Atricore, Inc.
05: *
06: * This is free software; you can redistribute it and/or modify it
07: * under the terms of the GNU Lesser General Public License as
08: * published by the Free Software Foundation; either version 2.1 of
09: * the License, or (at your option) any later version.
10: *
11: * This software is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this software; if not, write to the Free
18: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20: */
21: package org.josso.gateway.identity.service.store;
22:
23: import org.josso.auth.CredentialKey;
24:
25: /**
26: * Thjis simple UserKey uses a String as identifier.
27: *
28: * @author <a href="mailto:sgonzalez@josso.org">Sebastian Gonzalez Oyuela</a>
29: * @version $Id: SimpleUserKey.java 508 2008-02-18 13:32:29Z sgonzalez $
30: */
31: public class SimpleUserKey implements UserKey, CredentialKey {
32:
33: private String _id;
34:
35: public SimpleUserKey(String id) {
36: _id = id;
37: }
38:
39: public String getId() {
40: return _id;
41: }
42:
43: /**
44: * Compare this SimpleUserKey name against another SimpleUserKey name
45: *
46: * @return true if name equals another.getId()
47: */
48: public boolean equals(Object another) {
49: if (!(another instanceof SimpleUserKey))
50: return false;
51:
52: String anotherId = ((SimpleUserKey) another).getId();
53:
54: boolean equals = false;
55: if (_id == null) {
56: equals = anotherId == null;
57: } else {
58: equals = _id.equals(anotherId);
59: }
60:
61: return equals;
62: }
63:
64: /**
65: * Returns the hashcode of the name
66: *
67: *
68: */
69: public int hashCode() {
70: return (_id == null ? 0 : _id.hashCode());
71: }
72:
73: public String toString() {
74: return _id;
75: }
76: }
|