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: MemorySession.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.authentication.sessionmanagers;
09:
10: public class MemorySession {
11: private String mAuthId = null;
12: private long mUserId = -1;
13: private String mHostIp = null;
14: private long mStart = -1;
15: private boolean mRemembered = false;
16:
17: public MemorySession(String authId, long userId, String hostIp,
18: boolean remembered) {
19: setAuthId(authId);
20: setUserId(userId);
21: setHostIp(hostIp);
22: setRemembered(remembered);
23: mStart = System.currentTimeMillis();
24: }
25:
26: public void setAuthId(String authId) {
27: assert authId != null;
28: assert authId.length() > 0;
29:
30: mAuthId = authId;
31: }
32:
33: public String getAuthId() {
34: return mAuthId;
35: }
36:
37: public void setUserId(long userId) {
38: assert userId >= 0;
39:
40: mUserId = userId;
41: }
42:
43: public long getUserId() {
44: return mUserId;
45: }
46:
47: public void setHostIp(String hostIp) {
48: assert hostIp != null;
49: assert hostIp.length() > 0;
50:
51: mHostIp = hostIp;
52: }
53:
54: public String getHostIp() {
55: return mHostIp;
56: }
57:
58: public void setStart(long start) {
59: mStart = start;
60: }
61:
62: public long getStart() {
63: return mStart;
64: }
65:
66: public void setRemembered(boolean remembered) {
67: mRemembered = remembered;
68: }
69:
70: public boolean getRemembered() {
71: return mRemembered;
72: }
73:
74: public int hashCode() {
75: return mAuthId.hashCode();
76: }
77:
78: public boolean equals(Object object) {
79: if (object instanceof MemorySession) {
80: MemorySession other_session = (MemorySession) object;
81: if (null != other_session
82: && other_session.getAuthId().equals(getAuthId())) {
83: return true;
84: }
85: }
86:
87: return false;
88: }
89: }
|