From 94aa91d52ec53d157f0fd978fe12bde2631d7bdb Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 19 Dec 2024 09:23:05 +0100 Subject: [PATCH] prevent userSessionName from to get too long (255) --- .../session/impl/SEBClientConnectionServiceImpl.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientConnectionServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientConnectionServiceImpl.java index 261e9d55d..fedfa3989 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientConnectionServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientConnectionServiceImpl.java @@ -844,11 +844,16 @@ private String updateUserSessionId( } // otherwise apply new name - return accountId + + final String userSessionName = accountId + Constants.SPACE + Constants.EMBEDDED_LIST_SEPARATOR + Constants.SPACE + clientConnection.userSessionId; + if (userSessionName.length() > 255) { + return Utils.truncateText(userSessionName, 240); + } else { + return userSessionName; + } } catch (final Exception e) { log.error("Unexpected error while try to update userSessionId for connection: {}", clientConnection, e); return null;