SEBSERV-228 fixed both re-establishment; with new user id and without
This commit is contained in:
parent
996a3a966f
commit
02dadca67b
1 changed files with 32 additions and 28 deletions
|
@ -294,24 +294,16 @@ public class SEBClientConnectionServiceImpl implements SEBClientConnectionServic
|
||||||
|
|
||||||
// connection integrity check
|
// connection integrity check
|
||||||
if (clientConnection.status == ConnectionStatus.ACTIVE) {
|
if (clientConnection.status == ConnectionStatus.ACTIVE) {
|
||||||
if (StringUtils.isNotBlank(clientConnection.clientAddress) &&
|
// connection already established. Check if IP is the same
|
||||||
(StringUtils.isBlank(clientAddress) || clientConnection.clientAddress.equals(clientAddress))) {
|
if (StringUtils.isNoneBlank(clientAddress) &&
|
||||||
// It seems that this is the same SEB that tries to establish the connection once again.
|
StringUtils.isNotBlank(clientConnection.clientAddress) &&
|
||||||
// Just log this and return already established connection
|
!clientAddress.equals(clientConnection.clientAddress)) {
|
||||||
if (log.isDebugEnabled()) {
|
log.error(
|
||||||
log.debug(
|
"ClientConnection integrity violation: client address mismatch: {}, {}",
|
||||||
"SEB retired to establish an already established client connection. Client adress: {} : {}",
|
clientAddress,
|
||||||
clientConnection.clientAddress,
|
clientConnection.clientAddress);
|
||||||
clientAddress);
|
throw new IllegalArgumentException(
|
||||||
}
|
"ClientConnection integrity violation: client address mismatch");
|
||||||
return clientConnection;
|
|
||||||
} else {
|
|
||||||
// It seems that this is a request from an other device then the original
|
|
||||||
log.warn(
|
|
||||||
"SEB retired to establish an already established client connection with another IP address. Client adress: {} : {}",
|
|
||||||
clientConnection.clientAddress,
|
|
||||||
clientAddress);
|
|
||||||
return clientConnection;
|
|
||||||
}
|
}
|
||||||
} else if (!clientConnection.status.clientActiveStatus) {
|
} else if (!clientConnection.status.clientActiveStatus) {
|
||||||
log.error("ClientConnection integrity violation: client connection is not in expected state: {}",
|
log.error("ClientConnection integrity violation: client connection is not in expected state: {}",
|
||||||
|
@ -342,14 +334,16 @@ public class SEBClientConnectionServiceImpl implements SEBClientConnectionServic
|
||||||
clientConnection = updateUserSessionId(userSessionId, clientConnection, examId);
|
clientConnection = updateUserSessionId(userSessionId, clientConnection, examId);
|
||||||
|
|
||||||
// connection integrity check
|
// connection integrity check
|
||||||
if (clientConnection.status == ConnectionStatus.CONNECTION_REQUESTED) {
|
if (clientConnection.status != ConnectionStatus.ACTIVE) {
|
||||||
log.warn("ClientConnection integrity warning: client connection is not authenticated: {}",
|
if (clientConnection.status == ConnectionStatus.CONNECTION_REQUESTED) {
|
||||||
clientConnection);
|
log.warn("ClientConnection integrity warning: client connection is not authenticated: {}",
|
||||||
} else if (clientConnection.status != ConnectionStatus.AUTHENTICATED) {
|
clientConnection);
|
||||||
log.error("ClientConnection integrity violation: client connection is not in expected state: {}",
|
} else if (clientConnection.status != ConnectionStatus.AUTHENTICATED) {
|
||||||
clientConnection);
|
log.error("ClientConnection integrity violation: client connection is not in expected state: {}",
|
||||||
throw new IllegalArgumentException(
|
clientConnection);
|
||||||
"ClientConnection integrity violation: client connection is not in expected state");
|
throw new IllegalArgumentException(
|
||||||
|
"ClientConnection integrity violation: client connection is not in expected state");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final Boolean proctoringEnabled = this.examAdminService
|
final Boolean proctoringEnabled = this.examAdminService
|
||||||
|
@ -765,24 +759,34 @@ public class SEBClientConnectionServiceImpl implements SEBClientConnectionServic
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("SEB sent LMS userSessionId but clientConnection has already a userSessionId");
|
log.debug("SEB sent LMS userSessionId but clientConnection has already a userSessionId");
|
||||||
}
|
}
|
||||||
|
return clientConnection;
|
||||||
} else {
|
} else {
|
||||||
log.warn(
|
log.warn(
|
||||||
"Possible client integrity violation: clientConnection has already a userSessionId: {} : {}",
|
"Possible client integrity violation: clientConnection has already a userSessionId: {} : {}",
|
||||||
userSessionId, clientConnection.userSessionId);
|
userSessionId, clientConnection.userSessionId);
|
||||||
}
|
}
|
||||||
return clientConnection;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// try to get user account display name
|
// try to get user account display name
|
||||||
String accountId = userSessionId;
|
String accountId = userSessionId;
|
||||||
try {
|
try {
|
||||||
accountId = this.examSessionService
|
final String newAccountId = this.examSessionService
|
||||||
.getRunningExam((clientConnection.examId != null)
|
.getRunningExam((clientConnection.examId != null)
|
||||||
? clientConnection.examId
|
? clientConnection.examId
|
||||||
: examId)
|
: examId)
|
||||||
.flatMap(exam -> this.examSessionService.getLmsAPIService().getLmsAPITemplate(exam.lmsSetupId))
|
.flatMap(exam -> this.examSessionService.getLmsAPIService().getLmsAPITemplate(exam.lmsSetupId))
|
||||||
.map(template -> template.getExamineeName(userSessionId))
|
.map(template -> template.getExamineeName(userSessionId))
|
||||||
.getOr(userSessionId);
|
.getOr(userSessionId);
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(clientConnection.userSessionId)) {
|
||||||
|
accountId = newAccountId +
|
||||||
|
Constants.SPACE +
|
||||||
|
Constants.EMBEDDED_LIST_SEPARATOR +
|
||||||
|
Constants.SPACE +
|
||||||
|
clientConnection.userSessionId;
|
||||||
|
} else {
|
||||||
|
accountId = newAccountId;
|
||||||
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
log.warn("Unexpected error while trying to get user account display name: {}", e.getMessage());
|
log.warn("Unexpected error while trying to get user account display name: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue