1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.talika.tarsis.security;
24
25 import java.io.Serializable;
26
27 import javax.servlet.http.HttpSessionBindingEvent;
28 import javax.servlet.http.HttpSessionBindingListener;
29
30 /**
31 * Implementation of <code>SecuritySession</code> interface.
32 *
33 * @author Jose M. Palomar
34 * @version $Revision: 124 $
35 */
36 public final class SecuritySessionImpl implements SecuritySession, HttpSessionBindingListener, Serializable {
37
38
39 /**
40 * User of session.
41 */
42 private User user;
43
44 /**
45 * Is session valid?.
46 */
47 private boolean valid;
48
49
50 /**
51 * Creates a new <code>SecuritySessionImpl</code>.
52 *
53 * @param user User user of session.
54 */
55 public SecuritySessionImpl(User user) {
56 this.user = user;
57 this.valid = true;
58 }
59
60
61 /**
62 * Returns <code>User</code> of session.
63 *
64 * @return User <code>User</code> of session.
65 * @see org.talika.tarsis.security.SecuritySession#getUser()
66 */
67 public User getUser() {
68 return user;
69 }
70
71 /**
72 * Invalidates session.
73 *
74 * @see org.talika.tarsis.security.SecuritySession#invalidate()
75 */
76 public void invalidate() {
77 this.valid = false;
78 }
79
80 /**
81 * Returns <code>true</code> is session is valid.
82 *
83 * @return boolean <code>true</code> is session is valid.
84 * @see org.talika.tarsis.security.SecuritySession#isValid()
85 */
86 public boolean isValid() {
87 return valid;
88 }
89
90 /**
91 * Notifies the object that it is being bound to a session and identifies the
92 * session. This method do nothing.
93 *
94 * @param httpSessionBindingEvent HttpSessionBindingEvent the event that
95 * identifies the session.
96 * @see javax.servlet.http.HttpSessionBindingListener#valueBound(HttpSessionBindingEvent)
97 */
98 public void valueBound(HttpSessionBindingEvent httpSessionBindingEvent) {
99 }
100
101 /**
102 * Notifies the object that it is being unbound from a session and identifies the
103 * session. Invalidates session when its unbound.
104 *
105 * @param httpSessionBindingEvent HttpSessionBindingEvent the event that
106 * identifies the session.
107 * @see javax.servlet.http.HttpSessionBindingListener#valueUnbound(HttpSessionBindingEvent)
108 */
109 public void valueUnbound(HttpSessionBindingEvent httpSessionBindingEvent) {
110 invalidate();
111 }
112
113 }