Skip to content

Commit

Permalink
SEBSP-173, SEBSP-116 minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
anhefti committed Dec 3, 2024
1 parent 3a8b3dd commit fadcf31
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public boolean isInGroup(final ClientConnection clientConnection, final ClientGr
return false;
}

final String name = clientConnection.userSessionId.substring(0, 1);
final String start = group.nameRangeStartLetter != null ? group.nameRangeStartLetter.substring(0, 1) : "A";
final String end = group.nameRangeStartLetter != null ? group.nameRangeEndLetter.substring(0, 1) : "Z";
final String name = clientConnection.userSessionId;
final String start = group.nameRangeStartLetter != null ? group.nameRangeStartLetter : "A";
final String end = group.nameRangeStartLetter != null ? group.nameRangeEndLetter : "Z";

return isInRange(name, start, end);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,11 @@ public PageAction openScreenProctoringTab(
.getAuthorizationContextHolder()
.getAuthorizationContext()
.getUserPassword();
final String body = "username=" + currentUser.get().username
+ "&password=" + userPassword.toString()
+ "&redirect=/gallery-view/" + groupUUID;


final String body = "username=" + Utils.encodeFormURL_UTF_8(currentUser.get().username)
+ "&password=" + Utils.encodeFormURL_UTF_8(userPassword.toString())
+ "&redirect=/gallery-view/" + Utils.encodeFormURL_UTF_8(groupUUID);

// apply jwt token request
final HttpEntity<String> httpEntity = new HttpEntity<>(body, httpHeaders);
final ResponseEntity<String> tokenRequest = restTemplate.exchange(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -71,8 +70,6 @@ public class ScreenProctoringServiceImpl implements ScreenProctoringService {
private final ExamSessionCacheService examSessionCacheService;
private final WebserviceInfo webserviceInfo;
private final WebserviceInfo.ScreenProctoringServiceBundle screenProctoringServiceBundle;
private final SEBClientVersionService sebClientVersionService;
private final List<AllowedSEBVersion> sebMinVersion;

public ScreenProctoringServiceImpl(
final ClientGroupMatcherService clientGroupMatcherService,
Expand All @@ -86,8 +83,7 @@ public ScreenProctoringServiceImpl(
final ExamSessionCacheService examSessionCacheService,
final WebserviceInfo webserviceInfo,
final SEBClientVersionService sebClientVersionService,
final ScreenProctoringAPIBinding screenProctoringAPIBinding,
final @Value("${sebserver.feature.exam.seb.screenProctoring.minsebversions:}") String sebMinVersion) {
final ScreenProctoringAPIBinding screenProctoringAPIBinding) {

this.clientGroupMatcherService = clientGroupMatcherService;
this.clientGroupDAO = clientGroupDAO1;
Expand All @@ -100,23 +96,7 @@ public ScreenProctoringServiceImpl(
this.proctoringSettingsDAO = proctoringSettingsDAO;
this.webserviceInfo = webserviceInfo;
this.screenProctoringServiceBundle = webserviceInfo.getScreenProctoringServiceBundle();
this.sebClientVersionService = sebClientVersionService;
this.screenProctoringAPIBinding = screenProctoringAPIBinding;

if (StringUtils.isNotBlank(sebMinVersion)) {
this.sebMinVersion = new ArrayList<>();
final String[] split = StringUtils.split(sebMinVersion, Constants.LIST_SEPARATOR_CHAR);
for (final String version : split) {
final AllowedSEBVersion allowedSEBVersion = new AllowedSEBVersion(version);
if (allowedSEBVersion.isValidFormat) {
this.sebMinVersion.add(allowedSEBVersion);
} else {
log.warn("No valid SEB version for min SEB Version check on SPS: {}", version);
}
}
} else {
this.sebMinVersion = Collections.emptyList();
}
}

@Override
Expand Down Expand Up @@ -204,7 +184,7 @@ public Result<ScreenProctoringSettings> testSettings(
// find deletion and check possibility (only deletable if no sessions)
if (screenProctoringSettings.collectingStrategy == CollectingStrategy.APPLY_SEB_GROUPS) {
final Map<Long, ScreenProctoringGroup> existing = existingGroups.stream()
.filter(g -> !g.isFallback)
.filter(g -> !BooleanUtils.isTrue(g.isFallback))
.collect(Collectors.toMap( g -> g.sebGroupId, Function.identity()));

Arrays.stream(StringUtils.split(
Expand Down Expand Up @@ -510,18 +490,15 @@ private void closeScreenProctoringSession(final ClientConnectionRecord ccRecord)

private void applyScreenProctoringSession(final ClientConnectionRecord ccRecord) {
try {

// check if SEB client version has already Screen Proctoring
if (!this.sebMinVersion.isEmpty() && !this.sebClientVersionService.checkVersionAndUpdateClientConnection(
ccRecord,
this.sebMinVersion)) {


// check if SEB client version is granted if checked. If not granted, no SPS Session is created
if (ccRecord.getClientVersionGranted() != null && ccRecord.getClientVersionGranted() == 0) {
log.warn("Detected invalid SEB Version for screen proctoring: {}", ccRecord);

this.clientConnectionDAO.markScreenProctoringApplied(
ccRecord.getId(),
ccRecord.getConnectionToken());

return;
}

Expand Down
4 changes: 1 addition & 3 deletions src/main/resources/config/application-ws.properties
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,4 @@ sebserver.feature.exam.seb.screenProctoring.bundled.url=http://sps-webservice:80
sebserver.feature.exam.seb.screenProctoring.bundled.clientId=sebserverClient
sebserver.feature.exam.seb.screenProctoring.bundled.clientPassword=${sps.sebserver.client.secret}
sebserver.feature.exam.seb.screenProctoring.bundled.sebserveraccount.username=SEBServerAPIAccount
sebserver.feature.exam.seb.screenProctoring.bundled.sebserveraccount.password=${sps.sebserver.password}

sebserver.feature.exam.seb.screenProctoring.minsebversions=Win.3.8.min,Mac.3.4.min,iOS.3.4.min
sebserver.feature.exam.seb.screenProctoring.bundled.sebserveraccount.password=${sps.sebserver.password}
4 changes: 2 additions & 2 deletions src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ sebserver.form.validation.fieldError.notNull=This field is mandatory
sebserver.form.validation.fieldError.name.notunique=This name is already in use. Please choose another one.
sebserver.form.validation.fieldError.username.notunique=This Username is already in use. Please choose another one.
sebserver.form.validation.fieldError.email.notunique=A user account with this e-mail address already exists.
sebserver.form.validation.fieldError.password.wrong=The old password is wrong
sebserver.form.validation.fieldError.password.wrong=Your password is wrong
sebserver.form.validation.fieldError.password.mismatch=The retyped password doesn't match the new password
sebserver.form.validation.fieldError.invalidURL=The input does not match the URL pattern
sebserver.form.validation.fieldError.exists=This name already exists. Please choose another one
Expand Down Expand Up @@ -901,7 +901,7 @@ sebserver.exam.proctoring.form.resetOk=Successfully deleted all existing proctor

sebserver.exam.proctoring.collecting.strategy.EXAM=One Group for Exam
sebserver.exam.proctoring.collecting.strategy.EXAM.tooltip=Collect all SEB connection of the exam on one proctoring room
sebserver.exam.proctoring.collecting.strategy.APPLY_SEB_GROUPS=Apply SEB Groups
sebserver.exam.proctoring.collecting.strategy.APPLY_SEB_GROUPS=Apply to SEB Client Groups
sebserver.exam.proctoring.collecting.strategy.APPLY_SEB_GROUPS.tooltip=Apply SEB client connections to respective SEB client groups of the exam
sebserver.exam.proctoring.collecting.strategy.SIZED_ROOMS=Sized Rooms
sebserver.exam.proctoring.collecting.strategy.SIZED_ROOMS.tooltip=Collect all SEB connections in rooms of defined size. If a room is full, SEB server will create a new additional room automatically.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,20 @@ public void test2() {
assertFalse(alphabeticalNameRangeMatcher.isInRange("nn", start1, end1));
assertFalse(alphabeticalNameRangeMatcher.isInRange("NM", start1, end1));

assertFalse(alphabeticalNameRangeMatcher.isInRange("Mbrcel", start1, end1));
}

@Test
public void test3() {
final AlphabeticalNameRangeMatcher alphabeticalNameRangeMatcher = new AlphabeticalNameRangeMatcher();

final String start1 = "Maria";
final String end1 = "Zorro";

assertTrue(alphabeticalNameRangeMatcher.isInRange("Zorro", start1, end1));
assertFalse(alphabeticalNameRangeMatcher.isInRange("Zurro", start1, end1));
assertFalse(alphabeticalNameRangeMatcher.isInRange("Zzzz", start1, end1));
}
}


0 comments on commit fadcf31

Please sign in to comment.