bwLehrpool Masterserver
Manages authentication and sharing of virtual machines between participating institutions
Session.java
Go to the documentation of this file.
1 package org.openslx.imagemaster.session;
2 
3 import org.openslx.bwlp.thrift.iface.UserInfo;
5 
11 public class Session
12 {
13  private static final long TIMEOUT = Globals.getSessionTimeoutUser() * 1000L;
14 
15  private long timeOut = 0;
16  private final UserInfo user;
17 
18  public Session( final UserInfo dbuser )
19  {
20  this( dbuser, TIMEOUT );
21  }
22 
23  public Session( final UserInfo dbuser, long timeout )
24  {
25  if ( timeout <= 0 ) {
26  timeout = TIMEOUT;
27  }
28  this.user = dbuser;
29  this.timeOut = System.currentTimeMillis() + timeout;
30  }
31 
32  public synchronized void refresh()
33  {
34  if ( timedOut() )
35  return; // Don't allow refreshing timed out session
36  this.timeOut = System.currentTimeMillis() + TIMEOUT;
37  }
38 
39  public synchronized boolean timedOut()
40  {
41  return this.timeOut == 0 || System.currentTimeMillis() > this.timeOut;
42  }
43 
44  public synchronized void invalidate()
45  {
46  this.timeOut = 0;
47  }
48 
49  public String getLogin()
50  {
51  return user.userId;
52  }
53 
54  public String getFirstName()
55  {
56  return user.firstName;
57  }
58 
59  public String getLastName()
60  {
61  return user.lastName;
62  }
63 
64  public String getEMail()
65  {
66  return user.eMail;
67  }
68 
69  public String getOrgenizationId()
70  {
71  return user.organizationId;
72  }
73 
74  public UserInfo getUserInfo()
75  {
76  return user;
77  }
78 
79 }
Session(final UserInfo dbuser)
Definition: Session.java:18
Session(final UserInfo dbuser, long timeout)
Definition: Session.java:23
synchronized boolean timedOut()
Definition: Session.java:39
Class to hold global constants and properties from 'config/global.properties'.
Definition: Globals.java:16
static int getSessionTimeoutUser()
Definition: Globals.java:80
Simple representation of a user session.
Definition: Session.java:11