code fixes

This commit is contained in:
anhefti 2022-08-31 09:02:17 +02:00
parent 7fdff4e2df
commit cfec81b2f7
4 changed files with 5 additions and 14 deletions

View file

@ -116,7 +116,7 @@ public class SEBClientConnectionServiceImpl implements SEBClientConnectionServic
return Result.tryCatch(() -> { return Result.tryCatch(() -> {
final SEBClientConfig clientConfig = this.sebClientConfigDAO final SEBClientConfig clientConfig = principal == null ? null : this.sebClientConfigDAO
.byClientName(principal.getName()) .byClientName(principal.getName())
.getOr(null); .getOr(null);

View file

@ -738,7 +738,7 @@ public class ZoomProctoringService implements ExamProctoringService {
final String ts = Long.toString(System.currentTimeMillis() - 30000); final String ts = Long.toString(System.currentTimeMillis() - 30000);
final String msg = String.format("%s%s%s%d", apiKey, meetingId, ts, status); final String msg = String.format("%s%s%s%d", apiKey, meetingId, ts, status);
hasher.init(new SecretKeySpec(decryptedSecret.toString().getBytes(), "HmacSHA256")); hasher.init(new SecretKeySpec(Utils.toByteArray(decryptedSecret), "HmacSHA256"));
final String message = Base64.getEncoder().encodeToString(msg.getBytes()); final String message = Base64.getEncoder().encodeToString(msg.getBytes());
final byte[] hash = hasher.doFinal(message.getBytes()); final byte[] hash = hasher.doFinal(message.getBytes());

View file

@ -323,7 +323,7 @@ public class ClientConnectionController extends ReadonlyEntityController<ClientC
final int result = indicatorValue1.compareTo(indicatorValue2); final int result = indicatorValue1.compareTo(indicatorValue2);
return (this.clientConnectionComparator.descending) ? -result : result; return (this.clientConnectionComparator.descending) ? -result : result;
} catch (final Exception e) { } catch (final Exception e) {
this.clientConnectionComparator.compare(cc1.clientConnection, cc2.clientConnection); return this.clientConnectionComparator.compare(cc1.clientConnection, cc2.clientConnection);
} }
} }

View file

@ -9,6 +9,7 @@
package ch.ethz.seb.sebserver.webservice.weblayer.api; package ch.ethz.seb.sebserver.webservice.weblayer.api;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.security.Principal; import java.security.Principal;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@ -299,19 +300,9 @@ public class ExamAPI_V1_Controller {
public void ping(final HttpServletRequest request, final HttpServletResponse response) { public void ping(final HttpServletRequest request, final HttpServletResponse response) {
final String connectionToken = request.getHeader(API.EXAM_API_SEB_CONNECTION_TOKEN); final String connectionToken = request.getHeader(API.EXAM_API_SEB_CONNECTION_TOKEN);
//final String timeStampString = request.getParameter(API.EXAM_API_PING_TIMESTAMP);
final String pingNumString = request.getParameter(API.EXAM_API_PING_NUMBER); final String pingNumString = request.getParameter(API.EXAM_API_PING_NUMBER);
final String instructionConfirm = request.getParameter(API.EXAM_API_PING_INSTRUCTION_CONFIRM); final String instructionConfirm = request.getParameter(API.EXAM_API_PING_INSTRUCTION_CONFIRM);
// long pingTime;
// try {
// pingTime = Long.parseLong(timeStampString);
// } catch (final Exception e) {
// log.error("Invalid ping request: {}", connectionToken);
// response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
// return;
// }
final String instruction = this.sebClientConnectionService final String instruction = this.sebClientConnectionService
.notifyPing( .notifyPing(
connectionToken, connectionToken,
@ -324,7 +315,7 @@ public class ExamAPI_V1_Controller {
} else { } else {
try { try {
response.setStatus(HttpStatus.OK.value()); response.setStatus(HttpStatus.OK.value());
response.getOutputStream().write(instruction.getBytes()); response.getOutputStream().write(instruction.getBytes(StandardCharsets.UTF_8));
} catch (final IOException e) { } catch (final IOException e) {
log.error("Failed to send instruction as response: {}", connectionToken, e); log.error("Failed to send instruction as response: {}", connectionToken, e);
} }