summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/openslx/imagemaster/localrpc/JsonUser.java10
-rw-r--r--src/main/java/org/openslx/imagemaster/localrpc/NetworkHandler.java2
-rw-r--r--src/main/java/org/openslx/imagemaster/session/Session.java12
-rw-r--r--src/main/java/org/openslx/imagemaster/session/SessionManager.java2
4 files changed, 21 insertions, 5 deletions
diff --git a/src/main/java/org/openslx/imagemaster/localrpc/JsonUser.java b/src/main/java/org/openslx/imagemaster/localrpc/JsonUser.java
index 3dff32f..80a4f53 100644
--- a/src/main/java/org/openslx/imagemaster/localrpc/JsonUser.java
+++ b/src/main/java/org/openslx/imagemaster/localrpc/JsonUser.java
@@ -19,8 +19,9 @@ public class JsonUser
private String lastName = null;
private String mail = null;
private String role = null;
- private String status;
- private String error;
+ private String status = null;
+ private String error = null;
+ private int timeoutSeconds = 0;
private String accessCode;
@@ -54,5 +55,10 @@ public class JsonUser
{
return this.accessCode;
}
+
+ public int timeoutSeconds()
+ {
+ return this.timeoutSeconds;
+ }
}
diff --git a/src/main/java/org/openslx/imagemaster/localrpc/NetworkHandler.java b/src/main/java/org/openslx/imagemaster/localrpc/NetworkHandler.java
index 4416647..ebe6993 100644
--- a/src/main/java/org/openslx/imagemaster/localrpc/NetworkHandler.java
+++ b/src/main/java/org/openslx/imagemaster/localrpc/NetworkHandler.java
@@ -136,7 +136,7 @@ public class NetworkHandler implements Runnable
log.warn( "Invalid or inomplete RPC data (" + payload + ")" );
return "Invalid or incomplete RPC data";
}
- ClientSessionData sd = SessionManager.addSession( new Session( u ), ju.accessCode() );
+ ClientSessionData sd = SessionManager.addSession( new Session( u, ju.timeoutSeconds() * 1000 ), ju.accessCode() );
return "TOKEN:" + sd.authToken + " SESSIONID:" + sd.sessionId;
}
} catch ( Throwable t ) {
diff --git a/src/main/java/org/openslx/imagemaster/session/Session.java b/src/main/java/org/openslx/imagemaster/session/Session.java
index 3cdcd0f..df6dd5c 100644
--- a/src/main/java/org/openslx/imagemaster/session/Session.java
+++ b/src/main/java/org/openslx/imagemaster/session/Session.java
@@ -14,11 +14,19 @@ public class Session
private long timeOut = 0;
private final UserInfo user;
-
+
public Session( final UserInfo dbuser )
{
+ this( dbuser, TIMEOUT );
+ }
+
+ public Session( final UserInfo dbuser, long timeout )
+ {
+ if ( timeout <= 0 ) {
+ timeout = TIMEOUT;
+ }
this.user = dbuser;
- this.timeOut = System.currentTimeMillis() + TIMEOUT;
+ this.timeOut = System.currentTimeMillis() + timeout;
}
public synchronized void refresh()
diff --git a/src/main/java/org/openslx/imagemaster/session/SessionManager.java b/src/main/java/org/openslx/imagemaster/session/SessionManager.java
index a7c7cb9..81b8530 100644
--- a/src/main/java/org/openslx/imagemaster/session/SessionManager.java
+++ b/src/main/java/org/openslx/imagemaster/session/SessionManager.java
@@ -65,6 +65,8 @@ public class SessionManager
public static void addAuthError( TAuthorizationException ex, String accessToken )
{
+ if ( accessToken == null )
+ return;
accessCodes.put( accessToken, new AccessCode( null, ex ) );
}