Merge remote-tracking branch 'origin/dev-1.2' into development
Conflicts: .github/workflows/buildReporting.yml src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientConnectionServiceImpl.java
This commit is contained in:
commit
2fd3850186
1 changed files with 57 additions and 26 deletions
|
@ -185,22 +185,7 @@ public class SEBClientConnectionServiceImpl implements SEBClientConnectionServic
|
|||
final String clientId) {
|
||||
|
||||
return Result.tryCatch(() -> {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(
|
||||
"SEB client connection, update ClientConnection for "
|
||||
+ "connectionToken {} "
|
||||
+ "institutionId: {}"
|
||||
+ "exam: {} "
|
||||
+ "client address: {} "
|
||||
+ "userSessionId: {}"
|
||||
+ "clientId: {}",
|
||||
connectionToken,
|
||||
institutionId,
|
||||
examId,
|
||||
clientAddress,
|
||||
userSessionId,
|
||||
clientId);
|
||||
}
|
||||
|
||||
|
||||
final ClientConnection clientConnection = getClientConnection(connectionToken);
|
||||
|
||||
|
@ -218,6 +203,23 @@ public class SEBClientConnectionServiceImpl implements SEBClientConnectionServic
|
|||
if (examId != null) {
|
||||
checkExamIntegrity(examId);
|
||||
}
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(
|
||||
"SEB client connection, update ClientConnection for "
|
||||
+ "connectionToken {} "
|
||||
+ "institutionId: {}"
|
||||
+ "exam: {} "
|
||||
+ "client address: {} "
|
||||
+ "userSessionId: {}"
|
||||
+ "clientId: {}",
|
||||
connectionToken,
|
||||
institutionId,
|
||||
examId,
|
||||
clientAddress,
|
||||
userSessionId,
|
||||
clientId);
|
||||
}
|
||||
|
||||
updateUserSessionId(userSessionId, clientConnection, examId);
|
||||
final ClientConnection updatedClientConnection = this.clientConnectionDAO
|
||||
|
@ -265,6 +267,34 @@ public class SEBClientConnectionServiceImpl implements SEBClientConnectionServic
|
|||
|
||||
return Result.tryCatch(() -> {
|
||||
|
||||
ClientConnection clientConnection = getClientConnection(connectionToken);
|
||||
|
||||
// connection integrity check
|
||||
if (clientConnection.status == ConnectionStatus.ACTIVE) {
|
||||
if (clientConnection.clientAddress != null && clientConnection.clientAddress.equals(clientAddress)) {
|
||||
// It seems that this is the same SEB that tries to establish the connection once again.
|
||||
// Just log this and return already established connection
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(
|
||||
"SEB retired to establish an already established client connection. Client adress: {} : {}",
|
||||
clientConnection.clientAddress,
|
||||
clientAddress);
|
||||
}
|
||||
return clientConnection;
|
||||
} else {
|
||||
// It seems that this is a request from an other device then the original
|
||||
log.error("ClientConnection integrity violation: client connection mismatch: {}",
|
||||
clientConnection);
|
||||
throw new IllegalArgumentException(
|
||||
"ClientConnection integrity violation: client connection mismatch");
|
||||
}
|
||||
} else if (!clientConnection.status.clientActiveStatus) {
|
||||
log.error("ClientConnection integrity violation: client connection is not in expected state: {}",
|
||||
clientConnection);
|
||||
throw new IllegalArgumentException(
|
||||
"ClientConnection integrity violation: client connection is not in expected state");
|
||||
}
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(
|
||||
"SEB client connection, establish ClientConnection for "
|
||||
|
@ -281,8 +311,7 @@ public class SEBClientConnectionServiceImpl implements SEBClientConnectionServic
|
|||
userSessionId,
|
||||
clientId);
|
||||
}
|
||||
|
||||
ClientConnection clientConnection = getClientConnection(connectionToken);
|
||||
|
||||
checkInstitutionalIntegrity(institutionId, clientConnection);
|
||||
checkExamIntegrity(examId, clientConnection);
|
||||
clientConnection = updateUserSessionId(userSessionId, clientConnection, examId);
|
||||
|
@ -672,15 +701,17 @@ public class SEBClientConnectionServiceImpl implements SEBClientConnectionServic
|
|||
ClientConnection clientConnection,
|
||||
final Long examId) {
|
||||
|
||||
if (StringUtils.isNotBlank(userSessionId)) {
|
||||
|
||||
if (StringUtils.isNoneBlank(clientConnection.userSessionId)
|
||||
&& clientConnection.userSessionId.contains(userSessionId)) {
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("SEB sent LMS userSessionId but clientConnection has already a userSessionId");
|
||||
if (StringUtils.isNoneBlank(userSessionId)) {
|
||||
if (StringUtils.isNoneBlank(clientConnection.userSessionId)) {
|
||||
if (clientConnection.userSessionId.contains(userSessionId)) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("SEB sent LMS userSessionId but clientConnection has already a userSessionId");
|
||||
}
|
||||
} else {
|
||||
log.warn(
|
||||
"Possible client integrity violation: clientConnection has already a userSessionId: {} : {}",
|
||||
userSessionId, clientConnection.userSessionId);
|
||||
}
|
||||
|
||||
return clientConnection;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue