summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/imagemaster/session/Session.java
blob: f91a3ae27834464d54114ba15de55ab92176a10e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package org.openslx.imagemaster.session;

import org.openslx.imagemaster.Globals;

/**
 * Simple representation of a user session. Contains user-related data and
 * information on whether the session is still valid.
 * 
 */
public class Session
{
	private static final long TIMEOUT = Long.valueOf( Globals.getSessionTimeoutUser() ) * 1000L;

	private long timeOut = 0;
	private final User user;

	public Session(final User dbuser)
	{
		this.user = dbuser;
		this.timeOut = System.currentTimeMillis() + TIMEOUT;
	}

	public synchronized void refresh()
	{
		if ( timedOut() )
			return; // Don't allow refreshing timed out session
		this.timeOut = System.currentTimeMillis() + TIMEOUT;
	}

	public synchronized boolean timedOut()
	{
		return System.currentTimeMillis() > this.timeOut;
	}

	public String getSatelliteAddress()
	{
		return user.satelliteAddress;
	}

	public String getLogin()
	{
		return user.login;
	}

	public String getFirstName()
	{
		return user.firstName;
	}

	public String getLastName()
	{
		return user.lastName;
	}

	public String getEMail()
	{
		return user.eMail;
	}
	
	public String getOrgenizationId()
	{
		return user.organizationId;
	}

}