code cleanup Seb -> SEB
This commit is contained in:
parent
9b6660eea9
commit
20c08e5db4
84 changed files with 663 additions and 670 deletions
|
@ -43,7 +43,7 @@ public class SEBServerInit {
|
||||||
INIT_LOGGER.info("----> |___/|___||___/ |___/\\___||_| \\_/ \\___||_| ");
|
INIT_LOGGER.info("----> |___/|___||___/ |___/\\___||_| \\_/ \\___||_| ");
|
||||||
INIT_LOGGER.info("---->");
|
INIT_LOGGER.info("---->");
|
||||||
INIT_LOGGER.info("---->");
|
INIT_LOGGER.info("---->");
|
||||||
INIT_LOGGER.info("----> Version: {}", this.webserviceInfo.getSebServerVersion());
|
INIT_LOGGER.info("----> Version: {}", this.webserviceInfo.getSEBServerVersion());
|
||||||
INIT_LOGGER.info("---->");
|
INIT_LOGGER.info("---->");
|
||||||
INIT_LOGGER.info("----> Active profiles: {}", Arrays.toString(this.environment.getActiveProfiles()));
|
INIT_LOGGER.info("----> Active profiles: {}", Arrays.toString(this.environment.getActiveProfiles()));
|
||||||
INIT_LOGGER.info("---->");
|
INIT_LOGGER.info("---->");
|
||||||
|
|
|
@ -179,7 +179,6 @@ public final class Exam implements GrantEntity {
|
||||||
EXAM.ATTR_STATUS,
|
EXAM.ATTR_STATUS,
|
||||||
ExamStatus.class,
|
ExamStatus.class,
|
||||||
getStatusFromDate(this.startTime, this.endTime));
|
getStatusFromDate(this.startTime, this.endTime));
|
||||||
// this.lmsSebRestriction = mapper.getBoolean(EXAM.ATTR_LMS_SEB_RESTRICTION);
|
|
||||||
this.browserExamKeys = mapper.getString(EXAM.ATTR_BROWSER_KEYS);
|
this.browserExamKeys = mapper.getString(EXAM.ATTR_BROWSER_KEYS);
|
||||||
this.active = mapper.getBoolean(EXAM.ATTR_ACTIVE);
|
this.active = mapper.getBoolean(EXAM.ATTR_ACTIVE);
|
||||||
this.supporter = mapper.getStringSet(EXAM.ATTR_SUPPORTER);
|
this.supporter = mapper.getStringSet(EXAM.ATTR_SUPPORTER);
|
||||||
|
|
|
@ -25,7 +25,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import ch.ethz.seb.sebserver.gbl.Constants;
|
import ch.ethz.seb.sebserver.gbl.Constants;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||||
|
|
||||||
public class OpenEdxSebRestriction {
|
public class OpenEdxSEBRestriction {
|
||||||
|
|
||||||
public static final String ATTR_USER_BANNING_ENABLED = "USER_BANNING_ENABLED";
|
public static final String ATTR_USER_BANNING_ENABLED = "USER_BANNING_ENABLED";
|
||||||
public static final String ATTR_PERMISSION_COMPONENTS = "PERMISSION_COMPONENTS";
|
public static final String ATTR_PERMISSION_COMPONENTS = "PERMISSION_COMPONENTS";
|
||||||
|
@ -96,7 +96,7 @@ public class OpenEdxSebRestriction {
|
||||||
public final Boolean banningEnabled;
|
public final Boolean banningEnabled;
|
||||||
|
|
||||||
@JsonCreator
|
@JsonCreator
|
||||||
OpenEdxSebRestriction(
|
OpenEdxSEBRestriction(
|
||||||
@JsonProperty(ATTR_CONFIG_KEYS) final Collection<String> configKeys,
|
@JsonProperty(ATTR_CONFIG_KEYS) final Collection<String> configKeys,
|
||||||
@JsonProperty(ATTR_BROWSER_KEYS) final Collection<String> browserExamKeys,
|
@JsonProperty(ATTR_BROWSER_KEYS) final Collection<String> browserExamKeys,
|
||||||
@JsonProperty(ATTR_WHITELIST_PATHS) final Collection<String> whiteListPaths,
|
@JsonProperty(ATTR_WHITELIST_PATHS) final Collection<String> whiteListPaths,
|
||||||
|
@ -155,7 +155,7 @@ public class OpenEdxSebRestriction {
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static OpenEdxSebRestriction from(final SebRestriction sebRestrictionData) {
|
public static OpenEdxSEBRestriction from(final SEBRestriction sebRestrictionData) {
|
||||||
|
|
||||||
final String whiteListPathsString = sebRestrictionData.additionalProperties
|
final String whiteListPathsString = sebRestrictionData.additionalProperties
|
||||||
.get(ATTR_WHITELIST_PATHS);
|
.get(ATTR_WHITELIST_PATHS);
|
||||||
|
@ -200,7 +200,7 @@ public class OpenEdxSebRestriction {
|
||||||
permissionComponents = Utils.immutableCollectionOf(defaultPermissions);
|
permissionComponents = Utils.immutableCollectionOf(defaultPermissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new OpenEdxSebRestriction(
|
return new OpenEdxSEBRestriction(
|
||||||
sebRestrictionData.configKeys,
|
sebRestrictionData.configKeys,
|
||||||
sebRestrictionData.browserExamKeys,
|
sebRestrictionData.browserExamKeys,
|
||||||
whiteListPaths,
|
whiteListPaths,
|
|
@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gbl.model.Entity;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||||
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class SebRestriction implements Entity {
|
public final class SEBRestriction implements Entity {
|
||||||
|
|
||||||
public static final String ATTR_BROWSER_KEYS = "browserExamKeys";
|
public static final String ATTR_BROWSER_KEYS = "browserExamKeys";
|
||||||
public static final String ATTR_CONFIG_KEYS = "configKeys";
|
public static final String ATTR_CONFIG_KEYS = "configKeys";
|
||||||
|
@ -42,7 +42,7 @@ public final class SebRestriction implements Entity {
|
||||||
public final Map<String, String> additionalProperties;
|
public final Map<String, String> additionalProperties;
|
||||||
|
|
||||||
@JsonCreator
|
@JsonCreator
|
||||||
public SebRestriction(
|
public SEBRestriction(
|
||||||
@JsonProperty(Domain.EXAM.ATTR_ID) final Long examId,
|
@JsonProperty(Domain.EXAM.ATTR_ID) final Long examId,
|
||||||
@JsonProperty(ATTR_CONFIG_KEYS) final Collection<String> configKeys,
|
@JsonProperty(ATTR_CONFIG_KEYS) final Collection<String> configKeys,
|
||||||
@JsonProperty(ATTR_BROWSER_KEYS) final Collection<String> browserExamKeys,
|
@JsonProperty(ATTR_BROWSER_KEYS) final Collection<String> browserExamKeys,
|
||||||
|
@ -107,7 +107,7 @@ public final class SebRestriction implements Entity {
|
||||||
return false;
|
return false;
|
||||||
if (getClass() != obj.getClass())
|
if (getClass() != obj.getClass())
|
||||||
return false;
|
return false;
|
||||||
final SebRestriction other = (SebRestriction) obj;
|
final SEBRestriction other = (SEBRestriction) obj;
|
||||||
if (this.additionalProperties == null) {
|
if (this.additionalProperties == null) {
|
||||||
if (other.additionalProperties != null)
|
if (other.additionalProperties != null)
|
||||||
return false;
|
return false;
|
||||||
|
@ -129,7 +129,7 @@ public final class SebRestriction implements Entity {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final StringBuilder builder = new StringBuilder();
|
final StringBuilder builder = new StringBuilder();
|
||||||
builder.append("SebRestriction [examId=");
|
builder.append("SEBRestriction [examId=");
|
||||||
builder.append(this.examId);
|
builder.append(this.examId);
|
||||||
builder.append(", configKeys=");
|
builder.append(", configKeys=");
|
||||||
builder.append(this.configKeys);
|
builder.append(this.configKeys);
|
||||||
|
@ -141,32 +141,32 @@ public final class SebRestriction implements Entity {
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SebRestriction from(final Long examId, final OpenEdxSebRestriction edxData) {
|
public static SEBRestriction from(final Long examId, final OpenEdxSEBRestriction edxData) {
|
||||||
final Map<String, String> attrs = new HashMap<>();
|
final Map<String, String> attrs = new HashMap<>();
|
||||||
|
|
||||||
if (!CollectionUtils.isEmpty(edxData.whiteListPaths)) {
|
if (!CollectionUtils.isEmpty(edxData.whiteListPaths)) {
|
||||||
attrs.put(
|
attrs.put(
|
||||||
OpenEdxSebRestriction.ATTR_WHITELIST_PATHS,
|
OpenEdxSEBRestriction.ATTR_WHITELIST_PATHS,
|
||||||
StringUtils.join(edxData.whiteListPaths, Constants.LIST_SEPARATOR_CHAR));
|
StringUtils.join(edxData.whiteListPaths, Constants.LIST_SEPARATOR_CHAR));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CollectionUtils.isEmpty(edxData.blacklistChapters)) {
|
if (!CollectionUtils.isEmpty(edxData.blacklistChapters)) {
|
||||||
attrs.put(
|
attrs.put(
|
||||||
OpenEdxSebRestriction.ATTR_BLACKLIST_CHAPTERS,
|
OpenEdxSEBRestriction.ATTR_BLACKLIST_CHAPTERS,
|
||||||
StringUtils.join(edxData.blacklistChapters, Constants.LIST_SEPARATOR_CHAR));
|
StringUtils.join(edxData.blacklistChapters, Constants.LIST_SEPARATOR_CHAR));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CollectionUtils.isEmpty(edxData.permissionComponents)) {
|
if (!CollectionUtils.isEmpty(edxData.permissionComponents)) {
|
||||||
attrs.put(
|
attrs.put(
|
||||||
OpenEdxSebRestriction.ATTR_PERMISSION_COMPONENTS,
|
OpenEdxSEBRestriction.ATTR_PERMISSION_COMPONENTS,
|
||||||
StringUtils.join(edxData.permissionComponents, Constants.LIST_SEPARATOR_CHAR));
|
StringUtils.join(edxData.permissionComponents, Constants.LIST_SEPARATOR_CHAR));
|
||||||
}
|
}
|
||||||
|
|
||||||
attrs.put(
|
attrs.put(
|
||||||
OpenEdxSebRestriction.ATTR_USER_BANNING_ENABLED,
|
OpenEdxSEBRestriction.ATTR_USER_BANNING_ENABLED,
|
||||||
(edxData.banningEnabled) ? Constants.TRUE_STRING : Constants.FALSE_STRING);
|
(edxData.banningEnabled) ? Constants.TRUE_STRING : Constants.FALSE_STRING);
|
||||||
|
|
||||||
return new SebRestriction(
|
return new SEBRestriction(
|
||||||
examId,
|
examId,
|
||||||
edxData.configKeys,
|
edxData.configKeys,
|
||||||
edxData.browserExamKeys,
|
edxData.browserExamKeys,
|
|
@ -28,7 +28,7 @@ import ch.ethz.seb.sebserver.gbl.model.Domain.SEB_CLIENT_CONFIGURATION;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.Entity;
|
import ch.ethz.seb.sebserver.gbl.model.Entity;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.GrantEntity;
|
import ch.ethz.seb.sebserver.gbl.model.GrantEntity;
|
||||||
|
|
||||||
public final class SebClientConfig implements GrantEntity, Activatable {
|
public final class SEBClientConfig implements GrantEntity, Activatable {
|
||||||
|
|
||||||
public static final String ATTR_CONFIG_PURPOSE = "sebConfigPurpose";
|
public static final String ATTR_CONFIG_PURPOSE = "sebConfigPurpose";
|
||||||
public static final String ATTR_FALLBACK = "sebServerFallback ";
|
public static final String ATTR_FALLBACK = "sebServerFallback ";
|
||||||
|
@ -106,7 +106,7 @@ public final class SebClientConfig implements GrantEntity, Activatable {
|
||||||
public final Boolean active;
|
public final Boolean active;
|
||||||
|
|
||||||
@JsonCreator
|
@JsonCreator
|
||||||
public SebClientConfig(
|
public SEBClientConfig(
|
||||||
@JsonProperty(SEB_CLIENT_CONFIGURATION.ATTR_ID) final Long id,
|
@JsonProperty(SEB_CLIENT_CONFIGURATION.ATTR_ID) final Long id,
|
||||||
@JsonProperty(SEB_CLIENT_CONFIGURATION.ATTR_INSTITUTION_ID) final Long institutionId,
|
@JsonProperty(SEB_CLIENT_CONFIGURATION.ATTR_INSTITUTION_ID) final Long institutionId,
|
||||||
@JsonProperty(SEB_CLIENT_CONFIGURATION.ATTR_NAME) final String name,
|
@JsonProperty(SEB_CLIENT_CONFIGURATION.ATTR_NAME) final String name,
|
||||||
|
@ -144,7 +144,7 @@ public final class SebClientConfig implements GrantEntity, Activatable {
|
||||||
this.active = active;
|
this.active = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SebClientConfig(final Long institutionId, final POSTMapper postParams) {
|
public SEBClientConfig(final Long institutionId, final POSTMapper postParams) {
|
||||||
this.id = null;
|
this.id = null;
|
||||||
this.institutionId = institutionId;
|
this.institutionId = institutionId;
|
||||||
this.name = postParams.getString(Domain.SEB_CLIENT_CONFIGURATION.ATTR_NAME);
|
this.name = postParams.getString(Domain.SEB_CLIENT_CONFIGURATION.ATTR_NAME);
|
||||||
|
@ -271,7 +271,7 @@ public final class SebClientConfig implements GrantEntity, Activatable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final StringBuilder sb = new StringBuilder("SebClientConfig{");
|
final StringBuilder sb = new StringBuilder("SEBClientConfig{");
|
||||||
sb.append("id=").append(this.id);
|
sb.append("id=").append(this.id);
|
||||||
sb.append(", institutionId=").append(this.institutionId);
|
sb.append(", institutionId=").append(this.institutionId);
|
||||||
sb.append(", name='").append(this.name).append('\'');
|
sb.append(", name='").append(this.name).append('\'');
|
||||||
|
@ -293,7 +293,7 @@ public final class SebClientConfig implements GrantEntity, Activatable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Entity printSecureCopy() {
|
public Entity printSecureCopy() {
|
||||||
return new SebClientConfig(
|
return new SEBClientConfig(
|
||||||
this.id,
|
this.id,
|
||||||
this.institutionId,
|
this.institutionId,
|
||||||
this.name,
|
this.name,
|
||||||
|
@ -313,8 +313,8 @@ public final class SebClientConfig implements GrantEntity, Activatable {
|
||||||
this.active);
|
this.active);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SebClientConfig createNew(final Long institutionId) {
|
public static SEBClientConfig createNew(final Long institutionId) {
|
||||||
return new SebClientConfig(
|
return new SEBClientConfig(
|
||||||
null,
|
null,
|
||||||
institutionId,
|
institutionId,
|
||||||
null,
|
null,
|
|
@ -141,7 +141,7 @@ public class ConfigTemplateForm implements TemplateComposer {
|
||||||
formContext.getParent(),
|
formContext.getParent(),
|
||||||
titleKey);
|
titleKey);
|
||||||
|
|
||||||
// The SebClientConfig form
|
// The SEBClientConfig form
|
||||||
final FormHandle<ConfigurationNode> formHandle = this.pageService.formBuilder(
|
final FormHandle<ConfigurationNode> formHandle = this.pageService.formBuilder(
|
||||||
formContext.copyOf(content))
|
formContext.copyOf(content))
|
||||||
.readonly(isReadonly)
|
.readonly(isReadonly)
|
||||||
|
@ -292,7 +292,7 @@ public class ConfigTemplateForm implements TemplateComposer {
|
||||||
|
|
||||||
.newAction(ActionDefinition.SEB_EXAM_CONFIG_TEMPLATE_CREATE_CONFIG)
|
.newAction(ActionDefinition.SEB_EXAM_CONFIG_TEMPLATE_CREATE_CONFIG)
|
||||||
.withEntityKey(entityKey)
|
.withEntityKey(entityKey)
|
||||||
.withExec(SebExamConfigCreationPopup.configCreationFunction(
|
.withExec(SEBExamConfigCreationPopup.configCreationFunction(
|
||||||
this.pageService,
|
this.pageService,
|
||||||
pageContext
|
pageContext
|
||||||
.withAttribute(
|
.withAttribute(
|
||||||
|
|
|
@ -62,10 +62,10 @@ import ch.ethz.seb.sebserver.gui.service.page.TemplateComposer;
|
||||||
import ch.ethz.seb.sebserver.gui.service.page.event.ActionEvent;
|
import ch.ethz.seb.sebserver.gui.service.page.event.ActionEvent;
|
||||||
import ch.ethz.seb.sebserver.gui.service.page.impl.PageAction;
|
import ch.ethz.seb.sebserver.gui.service.page.impl.PageAction;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.download.DownloadService;
|
import ch.ethz.seb.sebserver.gui.service.remote.download.DownloadService;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.download.SebExamConfigDownload;
|
import ch.ethz.seb.sebserver.gui.service.remote.download.SEBExamConfigDownload;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.CheckExamConsistency;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.CheckExamConsistency;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.CheckSebRestriction;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.CheckSEBRestriction;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.DeleteExamConfigMapping;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.DeleteExamConfigMapping;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.DeleteIndicator;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.DeleteIndicator;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetExam;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetExam;
|
||||||
|
@ -248,9 +248,9 @@ public class ExamForm implements TemplateComposer {
|
||||||
final boolean editable = examStatus == ExamStatus.UP_COMING
|
final boolean editable = examStatus == ExamStatus.UP_COMING
|
||||||
|| examStatus == ExamStatus.RUNNING
|
|| examStatus == ExamStatus.RUNNING
|
||||||
&& currentUser.get().hasRole(UserRole.EXAM_ADMIN);
|
&& currentUser.get().hasRole(UserRole.EXAM_ADMIN);
|
||||||
final boolean sebRestrictionAvailable = testSebRestrictionAPI(exam);
|
final boolean sebRestrictionAvailable = testSEBRestrictionAPI(exam);
|
||||||
final boolean isRestricted = readonly && sebRestrictionAvailable && this.restService
|
final boolean isRestricted = readonly && sebRestrictionAvailable && this.restService
|
||||||
.getBuilder(CheckSebRestriction.class)
|
.getBuilder(CheckSEBRestriction.class)
|
||||||
.withURIVariable(API.PARAM_MODEL_ID, exam.getModelId())
|
.withURIVariable(API.PARAM_MODEL_ID, exam.getModelId())
|
||||||
.call()
|
.call()
|
||||||
.onError(e -> log.error("Unexpected error while trying to verify seb restriction settings: ", e))
|
.onError(e -> log.error("Unexpected error while trying to verify seb restriction settings: ", e))
|
||||||
|
@ -393,9 +393,9 @@ public class ExamForm implements TemplateComposer {
|
||||||
|
|
||||||
.newAction(ActionDefinition.EXAM_MODIFY_SEB_RESTRICTION_DETAILS)
|
.newAction(ActionDefinition.EXAM_MODIFY_SEB_RESTRICTION_DETAILS)
|
||||||
.withEntityKey(entityKey)
|
.withEntityKey(entityKey)
|
||||||
.withExec(ExamSebRestrictionSettings.settingsFunction(this.pageService))
|
.withExec(ExamSEBRestrictionSettings.settingsFunction(this.pageService))
|
||||||
.withAttribute(
|
.withAttribute(
|
||||||
ExamSebRestrictionSettings.PAGE_CONTEXT_ATTR_LMS_TYPE,
|
ExamSEBRestrictionSettings.PAGE_CONTEXT_ATTR_LMS_TYPE,
|
||||||
this.restService.getBuilder(GetLmsSetup.class)
|
this.restService.getBuilder(GetLmsSetup.class)
|
||||||
.withURIVariable(API.PARAM_MODEL_ID, String.valueOf(exam.lmsSetupId))
|
.withURIVariable(API.PARAM_MODEL_ID, String.valueOf(exam.lmsSetupId))
|
||||||
.call()
|
.call()
|
||||||
|
@ -406,13 +406,13 @@ public class ExamForm implements TemplateComposer {
|
||||||
|
|
||||||
.newAction(ActionDefinition.EXAM_ENABLE_SEB_RESTRICTION)
|
.newAction(ActionDefinition.EXAM_ENABLE_SEB_RESTRICTION)
|
||||||
.withEntityKey(entityKey)
|
.withEntityKey(entityKey)
|
||||||
.withExec(action -> ExamSebRestrictionSettings.setSebRestriction(action, true, this.restService))
|
.withExec(action -> ExamSEBRestrictionSettings.setSEBRestriction(action, true, this.restService))
|
||||||
.publishIf(() -> sebRestrictionAvailable && readonly && modifyGrant && !importFromQuizData
|
.publishIf(() -> sebRestrictionAvailable && readonly && modifyGrant && !importFromQuizData
|
||||||
&& BooleanUtils.isFalse(isRestricted))
|
&& BooleanUtils.isFalse(isRestricted))
|
||||||
|
|
||||||
.newAction(ActionDefinition.EXAM_DISABLE_SEB_RESTRICTION)
|
.newAction(ActionDefinition.EXAM_DISABLE_SEB_RESTRICTION)
|
||||||
.withEntityKey(entityKey)
|
.withEntityKey(entityKey)
|
||||||
.withExec(action -> ExamSebRestrictionSettings.setSebRestriction(action, false, this.restService))
|
.withExec(action -> ExamSEBRestrictionSettings.setSEBRestriction(action, false, this.restService))
|
||||||
.publishIf(() -> sebRestrictionAvailable && readonly && modifyGrant && !importFromQuizData
|
.publishIf(() -> sebRestrictionAvailable && readonly && modifyGrant && !importFromQuizData
|
||||||
&& BooleanUtils.isTrue(isRestricted));
|
&& BooleanUtils.isTrue(isRestricted));
|
||||||
|
|
||||||
|
@ -583,14 +583,14 @@ public class ExamForm implements TemplateComposer {
|
||||||
private PageAction importExam(
|
private PageAction importExam(
|
||||||
final PageAction action,
|
final PageAction action,
|
||||||
final FormHandle<Exam> formHandle,
|
final FormHandle<Exam> formHandle,
|
||||||
final boolean applySebRestriction) {
|
final boolean applySEBRestriction) {
|
||||||
|
|
||||||
// process normal save first
|
// process normal save first
|
||||||
final PageAction processFormSave = formHandle.processFormSave(action);
|
final PageAction processFormSave = formHandle.processFormSave(action);
|
||||||
|
|
||||||
// when okay and the exam sebRestriction is true
|
// when okay and the exam sebRestriction is true
|
||||||
if (applySebRestriction) {
|
if (applySEBRestriction) {
|
||||||
ExamSebRestrictionSettings.setSebRestriction(
|
ExamSEBRestrictionSettings.setSEBRestriction(
|
||||||
processFormSave,
|
processFormSave,
|
||||||
true,
|
true,
|
||||||
this.restService,
|
this.restService,
|
||||||
|
@ -600,7 +600,7 @@ public class ExamForm implements TemplateComposer {
|
||||||
return processFormSave;
|
return processFormSave;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean testSebRestrictionAPI(final Exam exam) {
|
private boolean testSEBRestrictionAPI(final Exam exam) {
|
||||||
return this.restService.getBuilder(GetLmsSetup.class)
|
return this.restService.getBuilder(GetLmsSetup.class)
|
||||||
.withURIVariable(API.PARAM_MODEL_ID, String.valueOf(exam.lmsSetupId))
|
.withURIVariable(API.PARAM_MODEL_ID, String.valueOf(exam.lmsSetupId))
|
||||||
.call()
|
.call()
|
||||||
|
@ -656,7 +656,7 @@ public class ExamForm implements TemplateComposer {
|
||||||
final String downloadURL = this.downloadService.createDownloadURL(
|
final String downloadURL = this.downloadService.createDownloadURL(
|
||||||
selection.modelId,
|
selection.modelId,
|
||||||
action.pageContext().getParentEntityKey().modelId,
|
action.pageContext().getParentEntityKey().modelId,
|
||||||
SebExamConfigDownload.class,
|
SEBExamConfigDownload.class,
|
||||||
this.downloadFileName);
|
this.downloadFileName);
|
||||||
urlLauncher.openURL(downloadURL);
|
urlLauncher.openURL(downloadURL);
|
||||||
}
|
}
|
||||||
|
@ -701,7 +701,7 @@ public class ExamForm implements TemplateComposer {
|
||||||
final EntityKey examConfigMappingKey = action.getSingleSelection();
|
final EntityKey examConfigMappingKey = action.getSingleSelection();
|
||||||
if (examConfigMappingKey != null) {
|
if (examConfigMappingKey != null) {
|
||||||
action.withEntityKey(examConfigMappingKey);
|
action.withEntityKey(examConfigMappingKey);
|
||||||
return SebExamConfigForm
|
return SEBExamConfigForm
|
||||||
.getConfigKeyFunction(this.pageService)
|
.getConfigKeyFunction(this.pageService)
|
||||||
.apply(action);
|
.apply(action);
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ public class ExamList implements TemplateComposer {
|
||||||
final PageActionBuilder actionBuilder = this.pageService
|
final PageActionBuilder actionBuilder = this.pageService
|
||||||
.pageActionBuilder(pageContext.clearEntityKeys());
|
.pageActionBuilder(pageContext.clearEntityKeys());
|
||||||
|
|
||||||
final BooleanSupplier isSebAdmin =
|
final BooleanSupplier isSEBAdmin =
|
||||||
() -> currentUser.get().hasRole(UserRole.SEB_SERVER_ADMIN);
|
() -> currentUser.get().hasRole(UserRole.SEB_SERVER_ADMIN);
|
||||||
|
|
||||||
final Function<String, String> institutionNameFunction =
|
final Function<String, String> institutionNameFunction =
|
||||||
|
@ -150,7 +150,7 @@ public class ExamList implements TemplateComposer {
|
||||||
.withStaticFilter(Exam.FILTER_ATTR_ACTIVE, Constants.TRUE_STRING)
|
.withStaticFilter(Exam.FILTER_ATTR_ACTIVE, Constants.TRUE_STRING)
|
||||||
|
|
||||||
.withColumnIf(
|
.withColumnIf(
|
||||||
isSebAdmin,
|
isSEBAdmin,
|
||||||
() -> new ColumnDefinition<Exam>(
|
() -> new ColumnDefinition<Exam>(
|
||||||
Domain.EXAM.ATTR_INSTITUTION_ID,
|
Domain.EXAM.ATTR_INSTITUTION_ID,
|
||||||
COLUMN_TITLE_INSTITUTION_KEY,
|
COLUMN_TITLE_INSTITUTION_KEY,
|
||||||
|
|
|
@ -25,8 +25,8 @@ import ch.ethz.seb.sebserver.gbl.Constants;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.API;
|
import ch.ethz.seb.sebserver.gbl.api.API;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.EntityKey;
|
import ch.ethz.seb.sebserver.gbl.model.EntityKey;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Chapters;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Chapters;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSebRestriction;
|
import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSEBRestriction;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.SebRestriction;
|
import ch.ethz.seb.sebserver.gbl.model.exam.SEBRestriction;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Tuple;
|
import ch.ethz.seb.sebserver.gbl.util.Tuple;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||||
|
@ -41,13 +41,13 @@ import ch.ethz.seb.sebserver.gui.service.page.PageService;
|
||||||
import ch.ethz.seb.sebserver.gui.service.page.impl.ModalInputDialog;
|
import ch.ethz.seb.sebserver.gui.service.page.impl.ModalInputDialog;
|
||||||
import ch.ethz.seb.sebserver.gui.service.page.impl.PageAction;
|
import ch.ethz.seb.sebserver.gui.service.page.impl.PageAction;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.ActivateSebRestriction;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.ActivateSEBRestriction;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.DeactivateSebRestriction;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.DeactivateSEBRestriction;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetCourseChapters;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetCourseChapters;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetSebRestriction;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetSEBRestriction;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.SaveSebRestriction;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.SaveSEBRestriction;
|
||||||
|
|
||||||
public class ExamSebRestrictionSettings {
|
public class ExamSEBRestrictionSettings {
|
||||||
|
|
||||||
private final static LocTextKey SEB_RESTRICTION_ERROR =
|
private final static LocTextKey SEB_RESTRICTION_ERROR =
|
||||||
new LocTextKey("sebserver.error.exam.seb.restriction");
|
new LocTextKey("sebserver.error.exam.seb.restriction");
|
||||||
|
@ -85,7 +85,7 @@ public class ExamSebRestrictionSettings {
|
||||||
.setDialogWidth(740)
|
.setDialogWidth(740)
|
||||||
.setDialogHeight(400);
|
.setDialogHeight(400);
|
||||||
|
|
||||||
final SebRestrictionPropertiesForm bindFormContext = new SebRestrictionPropertiesForm(
|
final SEBRestrictionPropertiesForm bindFormContext = new SEBRestrictionPropertiesForm(
|
||||||
pageService,
|
pageService,
|
||||||
action.pageContext());
|
action.pageContext());
|
||||||
|
|
||||||
|
@ -117,30 +117,30 @@ public class ExamSebRestrictionSettings {
|
||||||
|
|
||||||
final EntityKey entityKey = pageContext.getEntityKey();
|
final EntityKey entityKey = pageContext.getEntityKey();
|
||||||
final LmsType lmsType = getLmsType(pageContext);
|
final LmsType lmsType = getLmsType(pageContext);
|
||||||
SebRestriction bodyValue = null;
|
SEBRestriction bodyValue = null;
|
||||||
try {
|
try {
|
||||||
final Form form = formHandle.getForm();
|
final Form form = formHandle.getForm();
|
||||||
final Collection<String> browserKeys = Utils.getListOfLines(
|
final Collection<String> browserKeys = Utils.getListOfLines(
|
||||||
form.getFieldValue(SebRestriction.ATTR_BROWSER_KEYS));
|
form.getFieldValue(SEBRestriction.ATTR_BROWSER_KEYS));
|
||||||
|
|
||||||
final Map<String, String> additionalAttributes = new HashMap<>();
|
final Map<String, String> additionalAttributes = new HashMap<>();
|
||||||
if (lmsType == LmsType.OPEN_EDX) {
|
if (lmsType == LmsType.OPEN_EDX) {
|
||||||
additionalAttributes.put(
|
additionalAttributes.put(
|
||||||
OpenEdxSebRestriction.ATTR_PERMISSION_COMPONENTS,
|
OpenEdxSEBRestriction.ATTR_PERMISSION_COMPONENTS,
|
||||||
form.getFieldValue(OpenEdxSebRestriction.ATTR_PERMISSION_COMPONENTS));
|
form.getFieldValue(OpenEdxSEBRestriction.ATTR_PERMISSION_COMPONENTS));
|
||||||
additionalAttributes.put(
|
additionalAttributes.put(
|
||||||
OpenEdxSebRestriction.ATTR_WHITELIST_PATHS,
|
OpenEdxSEBRestriction.ATTR_WHITELIST_PATHS,
|
||||||
form.getFieldValue(OpenEdxSebRestriction.ATTR_WHITELIST_PATHS));
|
form.getFieldValue(OpenEdxSEBRestriction.ATTR_WHITELIST_PATHS));
|
||||||
additionalAttributes.put(
|
additionalAttributes.put(
|
||||||
OpenEdxSebRestriction.ATTR_USER_BANNING_ENABLED,
|
OpenEdxSEBRestriction.ATTR_USER_BANNING_ENABLED,
|
||||||
form.getFieldValue(OpenEdxSebRestriction.ATTR_USER_BANNING_ENABLED));
|
form.getFieldValue(OpenEdxSEBRestriction.ATTR_USER_BANNING_ENABLED));
|
||||||
additionalAttributes.put(
|
additionalAttributes.put(
|
||||||
OpenEdxSebRestriction.ATTR_BLACKLIST_CHAPTERS,
|
OpenEdxSEBRestriction.ATTR_BLACKLIST_CHAPTERS,
|
||||||
Utils.convertCarriageReturnToListSeparator(
|
Utils.convertCarriageReturnToListSeparator(
|
||||||
form.getFieldValue(OpenEdxSebRestriction.ATTR_BLACKLIST_CHAPTERS)));
|
form.getFieldValue(OpenEdxSEBRestriction.ATTR_BLACKLIST_CHAPTERS)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bodyValue = new SebRestriction(
|
bodyValue = new SEBRestriction(
|
||||||
Long.parseLong(entityKey.modelId),
|
Long.parseLong(entityKey.modelId),
|
||||||
null,
|
null,
|
||||||
browserKeys,
|
browserKeys,
|
||||||
|
@ -152,7 +152,7 @@ public class ExamSebRestrictionSettings {
|
||||||
|
|
||||||
return !pageService
|
return !pageService
|
||||||
.getRestService()
|
.getRestService()
|
||||||
.getBuilder(SaveSebRestriction.class)
|
.getBuilder(SaveSEBRestriction.class)
|
||||||
.withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId)
|
.withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId)
|
||||||
.withBody(bodyValue)
|
.withBody(bodyValue)
|
||||||
.call()
|
.call()
|
||||||
|
@ -160,13 +160,13 @@ public class ExamSebRestrictionSettings {
|
||||||
.hasError();
|
.hasError();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class SebRestrictionPropertiesForm
|
private static final class SEBRestrictionPropertiesForm
|
||||||
implements ModalInputDialogComposer<FormHandle<?>> {
|
implements ModalInputDialogComposer<FormHandle<?>> {
|
||||||
|
|
||||||
private final PageService pageService;
|
private final PageService pageService;
|
||||||
private final PageContext pageContext;
|
private final PageContext pageContext;
|
||||||
|
|
||||||
protected SebRestrictionPropertiesForm(
|
protected SEBRestrictionPropertiesForm(
|
||||||
final PageService pageService,
|
final PageService pageService,
|
||||||
final PageContext pageContext) {
|
final PageContext pageContext) {
|
||||||
|
|
||||||
|
@ -188,8 +188,8 @@ public class ExamSebRestrictionSettings {
|
||||||
.getWidgetFactory()
|
.getWidgetFactory()
|
||||||
.createPopupScrollComposite(parent);
|
.createPopupScrollComposite(parent);
|
||||||
|
|
||||||
final SebRestriction sebRestriction = restService
|
final SEBRestriction sebRestriction = restService
|
||||||
.getBuilder(GetSebRestriction.class)
|
.getBuilder(GetSEBRestriction.class)
|
||||||
.withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId)
|
.withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId)
|
||||||
.call()
|
.call()
|
||||||
.getOrThrow();
|
.getOrThrow();
|
||||||
|
@ -205,7 +205,7 @@ public class ExamSebRestrictionSettings {
|
||||||
.copyOf(content)
|
.copyOf(content)
|
||||||
.clearEntityKeys();
|
.clearEntityKeys();
|
||||||
|
|
||||||
final FormHandle<SebRestriction> formHandle = this.pageService.formBuilder(
|
final FormHandle<SEBRestriction> formHandle = this.pageService.formBuilder(
|
||||||
formContext)
|
formContext)
|
||||||
.withDefaultSpanInput(6)
|
.withDefaultSpanInput(6)
|
||||||
.withEmptyCellSeparation(false)
|
.withEmptyCellSeparation(false)
|
||||||
|
@ -220,14 +220,14 @@ public class ExamSebRestrictionSettings {
|
||||||
.readonly(true))
|
.readonly(true))
|
||||||
|
|
||||||
.addField(FormBuilder.text(
|
.addField(FormBuilder.text(
|
||||||
SebRestriction.ATTR_CONFIG_KEYS,
|
SEBRestriction.ATTR_CONFIG_KEYS,
|
||||||
SEB_RESTRICTION_FORM_CONFIG_KEYS,
|
SEB_RESTRICTION_FORM_CONFIG_KEYS,
|
||||||
StringUtils.join(sebRestriction.getConfigKeys(), Constants.CARRIAGE_RETURN))
|
StringUtils.join(sebRestriction.getConfigKeys(), Constants.CARRIAGE_RETURN))
|
||||||
.asArea(50)
|
.asArea(50)
|
||||||
.readonly(true))
|
.readonly(true))
|
||||||
|
|
||||||
.addField(FormBuilder.text(
|
.addField(FormBuilder.text(
|
||||||
SebRestriction.ATTR_BROWSER_KEYS,
|
SEBRestriction.ATTR_BROWSER_KEYS,
|
||||||
SEB_RESTRICTION_FORM_BROWSER_KEYS,
|
SEB_RESTRICTION_FORM_BROWSER_KEYS,
|
||||||
StringUtils.join(sebRestriction.getBrowserExamKeys(), Constants.CARRIAGE_RETURN))
|
StringUtils.join(sebRestriction.getBrowserExamKeys(), Constants.CARRIAGE_RETURN))
|
||||||
.asArea())
|
.asArea())
|
||||||
|
@ -235,31 +235,31 @@ public class ExamSebRestrictionSettings {
|
||||||
.addFieldIf(
|
.addFieldIf(
|
||||||
() -> lmsType == LmsType.OPEN_EDX,
|
() -> lmsType == LmsType.OPEN_EDX,
|
||||||
() -> FormBuilder.multiCheckboxSelection(
|
() -> FormBuilder.multiCheckboxSelection(
|
||||||
OpenEdxSebRestriction.ATTR_WHITELIST_PATHS,
|
OpenEdxSEBRestriction.ATTR_WHITELIST_PATHS,
|
||||||
SEB_RESTRICTION_FORM_EDX_WHITE_LIST_PATHS,
|
SEB_RESTRICTION_FORM_EDX_WHITE_LIST_PATHS,
|
||||||
sebRestriction.getAdditionalProperties()
|
sebRestriction.getAdditionalProperties()
|
||||||
.get(OpenEdxSebRestriction.ATTR_WHITELIST_PATHS),
|
.get(OpenEdxSEBRestriction.ATTR_WHITELIST_PATHS),
|
||||||
resourceService::sebRestrictionWhiteListResources))
|
resourceService::sebRestrictionWhiteListResources))
|
||||||
|
|
||||||
.addFieldIf(
|
.addFieldIf(
|
||||||
() -> chapters == null && lmsType == LmsType.OPEN_EDX,
|
() -> chapters == null && lmsType == LmsType.OPEN_EDX,
|
||||||
() -> FormBuilder.text(
|
() -> FormBuilder.text(
|
||||||
OpenEdxSebRestriction.ATTR_BLACKLIST_CHAPTERS,
|
OpenEdxSEBRestriction.ATTR_BLACKLIST_CHAPTERS,
|
||||||
SEB_RESTRICTION_FORM_EDX_BLACKLIST_CHAPTERS,
|
SEB_RESTRICTION_FORM_EDX_BLACKLIST_CHAPTERS,
|
||||||
Utils.convertListSeparatorToCarriageReturn(
|
Utils.convertListSeparatorToCarriageReturn(
|
||||||
sebRestriction
|
sebRestriction
|
||||||
.getAdditionalProperties()
|
.getAdditionalProperties()
|
||||||
.get(OpenEdxSebRestriction.ATTR_BLACKLIST_CHAPTERS)))
|
.get(OpenEdxSEBRestriction.ATTR_BLACKLIST_CHAPTERS)))
|
||||||
.asArea())
|
.asArea())
|
||||||
|
|
||||||
.addFieldIf(
|
.addFieldIf(
|
||||||
() -> chapters != null && lmsType == LmsType.OPEN_EDX,
|
() -> chapters != null && lmsType == LmsType.OPEN_EDX,
|
||||||
() -> FormBuilder.multiCheckboxSelection(
|
() -> FormBuilder.multiCheckboxSelection(
|
||||||
OpenEdxSebRestriction.ATTR_BLACKLIST_CHAPTERS,
|
OpenEdxSEBRestriction.ATTR_BLACKLIST_CHAPTERS,
|
||||||
SEB_RESTRICTION_FORM_EDX_BLACKLIST_CHAPTERS,
|
SEB_RESTRICTION_FORM_EDX_BLACKLIST_CHAPTERS,
|
||||||
sebRestriction
|
sebRestriction
|
||||||
.getAdditionalProperties()
|
.getAdditionalProperties()
|
||||||
.get(OpenEdxSebRestriction.ATTR_BLACKLIST_CHAPTERS),
|
.get(OpenEdxSEBRestriction.ATTR_BLACKLIST_CHAPTERS),
|
||||||
() -> chapters.chapters
|
() -> chapters.chapters
|
||||||
.stream()
|
.stream()
|
||||||
.map(chapter -> new Tuple<>(chapter.id, chapter.name))
|
.map(chapter -> new Tuple<>(chapter.id, chapter.name))
|
||||||
|
@ -268,20 +268,20 @@ public class ExamSebRestrictionSettings {
|
||||||
.addFieldIf(
|
.addFieldIf(
|
||||||
() -> lmsType == LmsType.OPEN_EDX,
|
() -> lmsType == LmsType.OPEN_EDX,
|
||||||
() -> FormBuilder.multiCheckboxSelection(
|
() -> FormBuilder.multiCheckboxSelection(
|
||||||
OpenEdxSebRestriction.ATTR_PERMISSION_COMPONENTS,
|
OpenEdxSEBRestriction.ATTR_PERMISSION_COMPONENTS,
|
||||||
SEB_RESTRICTION_FORM_EDX_PERMISSIONS,
|
SEB_RESTRICTION_FORM_EDX_PERMISSIONS,
|
||||||
sebRestriction.getAdditionalProperties()
|
sebRestriction.getAdditionalProperties()
|
||||||
.get(OpenEdxSebRestriction.ATTR_PERMISSION_COMPONENTS),
|
.get(OpenEdxSEBRestriction.ATTR_PERMISSION_COMPONENTS),
|
||||||
resourceService::sebRestrictionPermissionResources))
|
resourceService::sebRestrictionPermissionResources))
|
||||||
|
|
||||||
.addFieldIf(
|
.addFieldIf(
|
||||||
() -> lmsType == LmsType.OPEN_EDX,
|
() -> lmsType == LmsType.OPEN_EDX,
|
||||||
() -> FormBuilder.checkbox(
|
() -> FormBuilder.checkbox(
|
||||||
OpenEdxSebRestriction.ATTR_USER_BANNING_ENABLED,
|
OpenEdxSEBRestriction.ATTR_USER_BANNING_ENABLED,
|
||||||
SEB_RESTRICTION_FORM_EDX_USER_BANNING_ENABLED,
|
SEB_RESTRICTION_FORM_EDX_USER_BANNING_ENABLED,
|
||||||
sebRestriction
|
sebRestriction
|
||||||
.getAdditionalProperties()
|
.getAdditionalProperties()
|
||||||
.get(OpenEdxSebRestriction.ATTR_USER_BANNING_ENABLED)))
|
.get(OpenEdxSEBRestriction.ATTR_USER_BANNING_ENABLED)))
|
||||||
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -298,27 +298,27 @@ public class ExamSebRestrictionSettings {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PageAction setSebRestriction(
|
public static PageAction setSEBRestriction(
|
||||||
final PageAction action,
|
final PageAction action,
|
||||||
final boolean activateRestriction,
|
final boolean activateRestriction,
|
||||||
final RestService restService) {
|
final RestService restService) {
|
||||||
|
|
||||||
return setSebRestriction(
|
return setSEBRestriction(
|
||||||
action,
|
action,
|
||||||
activateRestriction,
|
activateRestriction,
|
||||||
restService,
|
restService,
|
||||||
error -> action.pageContext().notifyError(SEB_RESTRICTION_ERROR, error));
|
error -> action.pageContext().notifyError(SEB_RESTRICTION_ERROR, error));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PageAction setSebRestriction(
|
public static PageAction setSEBRestriction(
|
||||||
final PageAction action,
|
final PageAction action,
|
||||||
final boolean activateRestriction,
|
final boolean activateRestriction,
|
||||||
final RestService restService,
|
final RestService restService,
|
||||||
final Consumer<Exception> errorHandler) {
|
final Consumer<Exception> errorHandler) {
|
||||||
|
|
||||||
restService.getBuilder((activateRestriction)
|
restService.getBuilder((activateRestriction)
|
||||||
? ActivateSebRestriction.class
|
? ActivateSEBRestriction.class
|
||||||
: DeactivateSebRestriction.class)
|
: DeactivateSEBRestriction.class)
|
||||||
.withURIVariable(
|
.withURIVariable(
|
||||||
API.PARAM_MODEL_ID,
|
API.PARAM_MODEL_ID,
|
||||||
action.getEntityKey().modelId)
|
action.getEntityKey().modelId)
|
|
@ -84,7 +84,7 @@ public class MonitoringClientConnection implements TemplateComposer {
|
||||||
private final ResourceService resourceService;
|
private final ResourceService resourceService;
|
||||||
private final I18nSupport i18nSupport;
|
private final I18nSupport i18nSupport;
|
||||||
private final InstructionProcessor instructionProcessor;
|
private final InstructionProcessor instructionProcessor;
|
||||||
private final SebClientLogDetailsPopup sebClientLogDetailsPopup;
|
private final SEBClientLogDetailsPopup sebClientLogDetailsPopup;
|
||||||
private final long pollInterval;
|
private final long pollInterval;
|
||||||
private final int pageSize;
|
private final int pageSize;
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ public class MonitoringClientConnection implements TemplateComposer {
|
||||||
final PageService pageService,
|
final PageService pageService,
|
||||||
final ResourceService resourceService,
|
final ResourceService resourceService,
|
||||||
final InstructionProcessor instructionProcessor,
|
final InstructionProcessor instructionProcessor,
|
||||||
final SebClientLogDetailsPopup sebClientLogDetailsPopup,
|
final SEBClientLogDetailsPopup sebClientLogDetailsPopup,
|
||||||
@Value("${sebserver.gui.webservice.poll-interval:500}") final long pollInterval,
|
@Value("${sebserver.gui.webservice.poll-interval:500}") final long pollInterval,
|
||||||
@Value("${sebserver.gui.list.page.size:20}") final Integer pageSize) {
|
@Value("${sebserver.gui.list.page.size:20}") final Integer pageSize) {
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ public class MonitoringClientConnection implements TemplateComposer {
|
||||||
.newAction(ActionDefinition.MONITOR_EXAM_CLIENT_CONNECTION_QUIT)
|
.newAction(ActionDefinition.MONITOR_EXAM_CLIENT_CONNECTION_QUIT)
|
||||||
.withConfirm(() -> CONFIRM_QUIT)
|
.withConfirm(() -> CONFIRM_QUIT)
|
||||||
.withExec(action -> {
|
.withExec(action -> {
|
||||||
this.instructionProcessor.propagateSebQuitInstruction(
|
this.instructionProcessor.propagateSEBQuitInstruction(
|
||||||
exam.id,
|
exam.id,
|
||||||
connectionToken,
|
connectionToken,
|
||||||
pageContext);
|
pageContext);
|
||||||
|
|
|
@ -181,7 +181,7 @@ public class MonitoringRunningExam implements TemplateComposer {
|
||||||
.newAction(ActionDefinition.MONITOR_EXAM_QUIT_ALL)
|
.newAction(ActionDefinition.MONITOR_EXAM_QUIT_ALL)
|
||||||
.withEntityKey(entityKey)
|
.withEntityKey(entityKey)
|
||||||
.withConfirm(() -> CONFIRM_QUIT_ALL)
|
.withConfirm(() -> CONFIRM_QUIT_ALL)
|
||||||
.withExec(action -> this.quitSebClients(action, clientTable, true))
|
.withExec(action -> this.quitSEBClients(action, clientTable, true))
|
||||||
.noEventPropagation()
|
.noEventPropagation()
|
||||||
.publishIf(privilege)
|
.publishIf(privilege)
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ public class MonitoringRunningExam implements TemplateComposer {
|
||||||
.withConfirm(() -> CONFIRM_QUIT_SELECTED)
|
.withConfirm(() -> CONFIRM_QUIT_SELECTED)
|
||||||
.withSelect(
|
.withSelect(
|
||||||
() -> this.selectionForQuitInstruction(clientTable),
|
() -> this.selectionForQuitInstruction(clientTable),
|
||||||
action -> this.quitSebClients(action, clientTable, false),
|
action -> this.quitSEBClients(action, clientTable, false),
|
||||||
EMPTY_ACTIVE_SELECTION_TEXT_KEY)
|
EMPTY_ACTIVE_SELECTION_TEXT_KEY)
|
||||||
.noEventPropagation()
|
.noEventPropagation()
|
||||||
.publishIf(privilege, false)
|
.publishIf(privilege, false)
|
||||||
|
@ -200,7 +200,7 @@ public class MonitoringRunningExam implements TemplateComposer {
|
||||||
.withConfirm(() -> CONFIRM_DISABLE_SELECTED)
|
.withConfirm(() -> CONFIRM_DISABLE_SELECTED)
|
||||||
.withSelect(
|
.withSelect(
|
||||||
clientTable::getSelection,
|
clientTable::getSelection,
|
||||||
action -> this.disableSebClients(action, clientTable, false),
|
action -> this.disableSEBClients(action, clientTable, false),
|
||||||
EMPTY_SELECTION_TEXT_KEY)
|
EMPTY_SELECTION_TEXT_KEY)
|
||||||
.noEventPropagation()
|
.noEventPropagation()
|
||||||
.publishIf(privilege, false);
|
.publishIf(privilege, false);
|
||||||
|
@ -311,12 +311,12 @@ public class MonitoringRunningExam implements TemplateComposer {
|
||||||
return clientTable.getSelection();
|
return clientTable.getSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
private PageAction quitSebClients(
|
private PageAction quitSEBClients(
|
||||||
final PageAction action,
|
final PageAction action,
|
||||||
final ClientConnectionTable clientTable,
|
final ClientConnectionTable clientTable,
|
||||||
final boolean all) {
|
final boolean all) {
|
||||||
|
|
||||||
this.instructionProcessor.propagateSebQuitInstruction(
|
this.instructionProcessor.propagateSEBQuitInstruction(
|
||||||
clientTable.getExam().id,
|
clientTable.getExam().id,
|
||||||
statesPredicate -> clientTable.getConnectionTokens(
|
statesPredicate -> clientTable.getConnectionTokens(
|
||||||
statesPredicate,
|
statesPredicate,
|
||||||
|
@ -328,7 +328,7 @@ public class MonitoringRunningExam implements TemplateComposer {
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PageAction disableSebClients(
|
private PageAction disableSEBClients(
|
||||||
final PageAction action,
|
final PageAction action,
|
||||||
final ClientConnectionTable clientTable,
|
final ClientConnectionTable clientTable,
|
||||||
final boolean all) {
|
final boolean all) {
|
||||||
|
|
|
@ -150,7 +150,7 @@ public class QuizLookupList implements TemplateComposer {
|
||||||
final PageActionBuilder actionBuilder =
|
final PageActionBuilder actionBuilder =
|
||||||
this.pageService.pageActionBuilder(pageContext.clearEntityKeys());
|
this.pageService.pageActionBuilder(pageContext.clearEntityKeys());
|
||||||
|
|
||||||
final BooleanSupplier isSebAdmin =
|
final BooleanSupplier isSEBAdmin =
|
||||||
() -> currentUser.get().hasRole(UserRole.SEB_SERVER_ADMIN);
|
() -> currentUser.get().hasRole(UserRole.SEB_SERVER_ADMIN);
|
||||||
|
|
||||||
final Function<String, String> institutionNameFunction =
|
final Function<String, String> institutionNameFunction =
|
||||||
|
@ -163,7 +163,7 @@ public class QuizLookupList implements TemplateComposer {
|
||||||
.withPaging(this.pageSize)
|
.withPaging(this.pageSize)
|
||||||
|
|
||||||
.withColumnIf(
|
.withColumnIf(
|
||||||
isSebAdmin,
|
isSEBAdmin,
|
||||||
() -> new ColumnDefinition<QuizData>(
|
() -> new ColumnDefinition<QuizData>(
|
||||||
QuizData.QUIZ_ATTR_INSTITUTION_ID,
|
QuizData.QUIZ_ATTR_INSTITUTION_ID,
|
||||||
INSTITUTION_TEXT_KEY,
|
INSTITUTION_TEXT_KEY,
|
||||||
|
|
|
@ -8,8 +8,10 @@
|
||||||
|
|
||||||
package ch.ethz.seb.sebserver.gui.content;
|
package ch.ethz.seb.sebserver.gui.content;
|
||||||
|
|
||||||
import ch.ethz.seb.sebserver.gbl.Constants;
|
import java.util.Arrays;
|
||||||
import ch.ethz.seb.sebserver.gui.service.page.PageMessageException;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.eclipse.rap.rwt.RWT;
|
import org.eclipse.rap.rwt.RWT;
|
||||||
|
@ -21,11 +23,12 @@ import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import ch.ethz.seb.sebserver.gbl.Constants;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.API;
|
import ch.ethz.seb.sebserver.gbl.api.API;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.Domain;
|
import ch.ethz.seb.sebserver.gbl.model.Domain;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.EntityKey;
|
import ch.ethz.seb.sebserver.gbl.model.EntityKey;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.user.UserInfo;
|
import ch.ethz.seb.sebserver.gbl.model.user.UserInfo;
|
||||||
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
||||||
import ch.ethz.seb.sebserver.gui.content.action.ActionDefinition;
|
import ch.ethz.seb.sebserver.gui.content.action.ActionDefinition;
|
||||||
|
@ -34,10 +37,11 @@ import ch.ethz.seb.sebserver.gui.form.FormHandle;
|
||||||
import ch.ethz.seb.sebserver.gui.service.i18n.I18nSupport;
|
import ch.ethz.seb.sebserver.gui.service.i18n.I18nSupport;
|
||||||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||||
import ch.ethz.seb.sebserver.gui.service.page.PageContext;
|
import ch.ethz.seb.sebserver.gui.service.page.PageContext;
|
||||||
|
import ch.ethz.seb.sebserver.gui.service.page.PageMessageException;
|
||||||
import ch.ethz.seb.sebserver.gui.service.page.PageService;
|
import ch.ethz.seb.sebserver.gui.service.page.PageService;
|
||||||
import ch.ethz.seb.sebserver.gui.service.page.TemplateComposer;
|
import ch.ethz.seb.sebserver.gui.service.page.TemplateComposer;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.download.DownloadService;
|
import ch.ethz.seb.sebserver.gui.service.remote.download.DownloadService;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.download.SebClientConfigDownload;
|
import ch.ethz.seb.sebserver.gui.service.remote.download.SEBClientConfigDownload;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.clientconfig.ActivateClientConfig;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.clientconfig.ActivateClientConfig;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.clientconfig.DeactivateClientConfig;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.clientconfig.DeactivateClientConfig;
|
||||||
|
@ -48,14 +52,10 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser.EntityGrantCheck;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser.EntityGrantCheck;
|
||||||
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory;
|
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@GuiProfile
|
@GuiProfile
|
||||||
public class SebClientConfigForm implements TemplateComposer {
|
public class SEBClientConfigForm implements TemplateComposer {
|
||||||
|
|
||||||
private static final LocTextKey FORM_TITLE_NEW =
|
private static final LocTextKey FORM_TITLE_NEW =
|
||||||
new LocTextKey("sebserver.clientconfig.form.title.new");
|
new LocTextKey("sebserver.clientconfig.form.title.new");
|
||||||
|
@ -94,15 +94,14 @@ public class SebClientConfigForm implements TemplateComposer {
|
||||||
new LocTextKey("sebserver.clientconfig.form.encryptSecret.confirm");
|
new LocTextKey("sebserver.clientconfig.form.encryptSecret.confirm");
|
||||||
|
|
||||||
private static final Set<String> FALLBACK_ATTRIBUTES = new HashSet<>(Arrays.asList(
|
private static final Set<String> FALLBACK_ATTRIBUTES = new HashSet<>(Arrays.asList(
|
||||||
SebClientConfig.ATTR_FALLBACK_START_URL,
|
SEBClientConfig.ATTR_FALLBACK_START_URL,
|
||||||
SebClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL,
|
SEBClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL,
|
||||||
SebClientConfig.ATTR_FALLBACK_ATTEMPTS,
|
SEBClientConfig.ATTR_FALLBACK_ATTEMPTS,
|
||||||
SebClientConfig.ATTR_FALLBACK_TIMEOUT,
|
SEBClientConfig.ATTR_FALLBACK_TIMEOUT,
|
||||||
SebClientConfig.ATTR_FALLBACK_PASSWORD,
|
SEBClientConfig.ATTR_FALLBACK_PASSWORD,
|
||||||
SebClientConfig.ATTR_FALLBACK_PASSWORD_CONFIRM,
|
SEBClientConfig.ATTR_FALLBACK_PASSWORD_CONFIRM,
|
||||||
SebClientConfig.ATTR_QUIT_PASSWORD,
|
SEBClientConfig.ATTR_QUIT_PASSWORD,
|
||||||
SebClientConfig.ATTR_QUIT_PASSWORD_CONFIRM
|
SEBClientConfig.ATTR_QUIT_PASSWORD_CONFIRM));
|
||||||
));
|
|
||||||
|
|
||||||
private static final String FALLBACK_DEFAULT_TIME = String.valueOf(2 * Constants.MINUTE_IN_MILLIS);
|
private static final String FALLBACK_DEFAULT_TIME = String.valueOf(2 * Constants.MINUTE_IN_MILLIS);
|
||||||
private static final String FALLBACK_DEFAULT_ATTEMPTS = String.valueOf(5);
|
private static final String FALLBACK_DEFAULT_ATTEMPTS = String.valueOf(5);
|
||||||
|
@ -114,7 +113,7 @@ public class SebClientConfigForm implements TemplateComposer {
|
||||||
private final DownloadService downloadService;
|
private final DownloadService downloadService;
|
||||||
private final String downloadFileName;
|
private final String downloadFileName;
|
||||||
|
|
||||||
protected SebClientConfigForm(
|
protected SEBClientConfigForm(
|
||||||
final PageService pageService,
|
final PageService pageService,
|
||||||
final RestService restService,
|
final RestService restService,
|
||||||
final CurrentUser currentUser,
|
final CurrentUser currentUser,
|
||||||
|
@ -140,8 +139,8 @@ public class SebClientConfigForm implements TemplateComposer {
|
||||||
final boolean isNew = entityKey == null;
|
final boolean isNew = entityKey == null;
|
||||||
|
|
||||||
// get data or create new. Handle error if happen
|
// get data or create new. Handle error if happen
|
||||||
final SebClientConfig clientConfig = (isNew)
|
final SEBClientConfig clientConfig = (isNew)
|
||||||
? SebClientConfig.createNew((parentEntityKey != null)
|
? SEBClientConfig.createNew((parentEntityKey != null)
|
||||||
? Long.valueOf(parentEntityKey.modelId)
|
? Long.valueOf(parentEntityKey.modelId)
|
||||||
: user.institutionId)
|
: user.institutionId)
|
||||||
: this.restService
|
: this.restService
|
||||||
|
@ -167,8 +166,8 @@ public class SebClientConfigForm implements TemplateComposer {
|
||||||
formContext.getParent(),
|
formContext.getParent(),
|
||||||
titleKey);
|
titleKey);
|
||||||
|
|
||||||
// The SebClientConfig form
|
// The SEBClientConfig form
|
||||||
final FormHandle<SebClientConfig> formHandle = this.pageService.formBuilder(
|
final FormHandle<SEBClientConfig> formHandle = this.pageService.formBuilder(
|
||||||
formContext.copyOf(content))
|
formContext.copyOf(content))
|
||||||
.readonly(isReadonly)
|
.readonly(isReadonly)
|
||||||
.putStaticValueIf(() -> !isNew,
|
.putStaticValueIf(() -> !isNew,
|
||||||
|
@ -192,12 +191,12 @@ public class SebClientConfigForm implements TemplateComposer {
|
||||||
.mandatory(!isReadonly))
|
.mandatory(!isReadonly))
|
||||||
|
|
||||||
.addField(FormBuilder.singleSelection(
|
.addField(FormBuilder.singleSelection(
|
||||||
SebClientConfig.ATTR_CONFIG_PURPOSE,
|
SEBClientConfig.ATTR_CONFIG_PURPOSE,
|
||||||
CLIENT_PURPOSE_TEXT_KEY,
|
CLIENT_PURPOSE_TEXT_KEY,
|
||||||
clientConfig.configPurpose != null
|
clientConfig.configPurpose != null
|
||||||
? clientConfig.configPurpose.name()
|
? clientConfig.configPurpose.name()
|
||||||
: SebClientConfig.ConfigPurpose.START_EXAM.name(),
|
: SEBClientConfig.ConfigPurpose.START_EXAM.name(),
|
||||||
() -> pageService.getResourceService().sebClientConfigPurposeResources())
|
() -> this.pageService.getResourceService().sebClientConfigPurposeResources())
|
||||||
.mandatory(!isReadonly))
|
.mandatory(!isReadonly))
|
||||||
|
|
||||||
.withDefaultSpanInput(3)
|
.withDefaultSpanInput(3)
|
||||||
|
@ -210,21 +209,20 @@ public class SebClientConfigForm implements TemplateComposer {
|
||||||
.addFieldIf(
|
.addFieldIf(
|
||||||
() -> !isReadonly,
|
() -> !isReadonly,
|
||||||
() -> FormBuilder.password(
|
() -> FormBuilder.password(
|
||||||
SebClientConfig.ATTR_ENCRYPT_SECRET_CONFIRM,
|
SEBClientConfig.ATTR_ENCRYPT_SECRET_CONFIRM,
|
||||||
FORM_CONFIRM_ENCRYPT_SECRET_TEXT_KEY,
|
FORM_CONFIRM_ENCRYPT_SECRET_TEXT_KEY,
|
||||||
clientConfig.getEncryptSecret()))
|
clientConfig.getEncryptSecret()))
|
||||||
|
|
||||||
.addField(FormBuilder.checkbox(
|
.addField(FormBuilder.checkbox(
|
||||||
SebClientConfig.ATTR_FALLBACK,
|
SEBClientConfig.ATTR_FALLBACK,
|
||||||
FALLBACK_TEXT_KEY,
|
FALLBACK_TEXT_KEY,
|
||||||
clientConfig.fallback != null
|
clientConfig.fallback != null
|
||||||
? clientConfig.fallback.toString()
|
? clientConfig.fallback.toString()
|
||||||
: Constants.FALSE_STRING)
|
: Constants.FALSE_STRING))
|
||||||
)
|
|
||||||
|
|
||||||
.withDefaultSpanInput(5)
|
.withDefaultSpanInput(5)
|
||||||
.addField(FormBuilder.text(
|
.addField(FormBuilder.text(
|
||||||
SebClientConfig.ATTR_FALLBACK_START_URL,
|
SEBClientConfig.ATTR_FALLBACK_START_URL,
|
||||||
FALLBACK_URL_TEXT_KEY,
|
FALLBACK_URL_TEXT_KEY,
|
||||||
clientConfig.fallbackStartURL)
|
clientConfig.fallbackStartURL)
|
||||||
.mandatory(!isReadonly))
|
.mandatory(!isReadonly))
|
||||||
|
@ -232,7 +230,7 @@ public class SebClientConfigForm implements TemplateComposer {
|
||||||
.withDefaultSpanEmptyCell(1)
|
.withDefaultSpanEmptyCell(1)
|
||||||
.withDefaultSpanInput(2)
|
.withDefaultSpanInput(2)
|
||||||
.addField(FormBuilder.text(
|
.addField(FormBuilder.text(
|
||||||
SebClientConfig.ATTR_FALLBACK_ATTEMPTS,
|
SEBClientConfig.ATTR_FALLBACK_ATTEMPTS,
|
||||||
FALLBACK_ATTEMPTS_TEXT_KEY,
|
FALLBACK_ATTEMPTS_TEXT_KEY,
|
||||||
clientConfig.fallbackAttempts != null
|
clientConfig.fallbackAttempts != null
|
||||||
? String.valueOf(clientConfig.fallbackAttempts)
|
? String.valueOf(clientConfig.fallbackAttempts)
|
||||||
|
@ -244,7 +242,7 @@ public class SebClientConfigForm implements TemplateComposer {
|
||||||
.withEmptyCellSeparation(false)
|
.withEmptyCellSeparation(false)
|
||||||
.withDefaultSpanLabel(1)
|
.withDefaultSpanLabel(1)
|
||||||
.addField(FormBuilder.text(
|
.addField(FormBuilder.text(
|
||||||
SebClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL,
|
SEBClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL,
|
||||||
FALLBACK_ATTEMPT_INTERVAL_TEXT_KEY,
|
FALLBACK_ATTEMPT_INTERVAL_TEXT_KEY,
|
||||||
clientConfig.fallbackAttemptInterval != null
|
clientConfig.fallbackAttemptInterval != null
|
||||||
? String.valueOf(clientConfig.fallbackAttemptInterval)
|
? String.valueOf(clientConfig.fallbackAttemptInterval)
|
||||||
|
@ -256,7 +254,7 @@ public class SebClientConfigForm implements TemplateComposer {
|
||||||
.withDefaultSpanEmptyCell(1)
|
.withDefaultSpanEmptyCell(1)
|
||||||
.withDefaultSpanLabel(2)
|
.withDefaultSpanLabel(2)
|
||||||
.addField(FormBuilder.text(
|
.addField(FormBuilder.text(
|
||||||
SebClientConfig.ATTR_FALLBACK_TIMEOUT,
|
SEBClientConfig.ATTR_FALLBACK_TIMEOUT,
|
||||||
FALLBACK_TIMEOUT_TEXT_KEY,
|
FALLBACK_TIMEOUT_TEXT_KEY,
|
||||||
clientConfig.fallbackTimeout != null
|
clientConfig.fallbackTimeout != null
|
||||||
? String.valueOf(clientConfig.fallbackTimeout)
|
? String.valueOf(clientConfig.fallbackTimeout)
|
||||||
|
@ -269,14 +267,14 @@ public class SebClientConfigForm implements TemplateComposer {
|
||||||
.withDefaultSpanInput(2)
|
.withDefaultSpanInput(2)
|
||||||
.withDefaultSpanLabel(2)
|
.withDefaultSpanLabel(2)
|
||||||
.addField(FormBuilder.password(
|
.addField(FormBuilder.password(
|
||||||
SebClientConfig.ATTR_FALLBACK_PASSWORD,
|
SEBClientConfig.ATTR_FALLBACK_PASSWORD,
|
||||||
FALLBACK_PASSWORD_TEXT_KEY,
|
FALLBACK_PASSWORD_TEXT_KEY,
|
||||||
clientConfig.getFallbackPassword()))
|
clientConfig.getFallbackPassword()))
|
||||||
|
|
||||||
.withEmptyCellSeparation(false)
|
.withEmptyCellSeparation(false)
|
||||||
.withDefaultSpanLabel(1)
|
.withDefaultSpanLabel(1)
|
||||||
.addField(FormBuilder.password(
|
.addField(FormBuilder.password(
|
||||||
SebClientConfig.ATTR_QUIT_PASSWORD,
|
SEBClientConfig.ATTR_QUIT_PASSWORD,
|
||||||
QUIT_PASSWORD_TEXT_KEY,
|
QUIT_PASSWORD_TEXT_KEY,
|
||||||
clientConfig.getQuitPassword()))
|
clientConfig.getQuitPassword()))
|
||||||
|
|
||||||
|
@ -287,7 +285,7 @@ public class SebClientConfigForm implements TemplateComposer {
|
||||||
.addFieldIf(
|
.addFieldIf(
|
||||||
() -> !isReadonly,
|
() -> !isReadonly,
|
||||||
() -> FormBuilder.password(
|
() -> FormBuilder.password(
|
||||||
SebClientConfig.ATTR_FALLBACK_PASSWORD_CONFIRM,
|
SEBClientConfig.ATTR_FALLBACK_PASSWORD_CONFIRM,
|
||||||
FALLBACK_PASSWORD_CONFIRM_TEXT_KEY,
|
FALLBACK_PASSWORD_CONFIRM_TEXT_KEY,
|
||||||
clientConfig.getFallbackPasswordConfirm()))
|
clientConfig.getFallbackPasswordConfirm()))
|
||||||
|
|
||||||
|
@ -296,33 +294,29 @@ public class SebClientConfigForm implements TemplateComposer {
|
||||||
.addFieldIf(
|
.addFieldIf(
|
||||||
() -> !isReadonly,
|
() -> !isReadonly,
|
||||||
() -> FormBuilder.password(
|
() -> FormBuilder.password(
|
||||||
SebClientConfig.ATTR_QUIT_PASSWORD_CONFIRM,
|
SEBClientConfig.ATTR_QUIT_PASSWORD_CONFIRM,
|
||||||
QUIT_PASSWORD_CONFIRM_TEXT_KEY,
|
QUIT_PASSWORD_CONFIRM_TEXT_KEY,
|
||||||
clientConfig.getQuitPasswordConfirm()))
|
clientConfig.getQuitPasswordConfirm()))
|
||||||
|
|
||||||
|
|
||||||
.buildFor((isNew)
|
.buildFor((isNew)
|
||||||
? this.restService.getRestCall(NewClientConfig.class)
|
? this.restService.getRestCall(NewClientConfig.class)
|
||||||
: this.restService.getRestCall(SaveClientConfig.class));
|
: this.restService.getRestCall(SaveClientConfig.class));
|
||||||
|
|
||||||
formHandle.process(
|
formHandle.process(
|
||||||
FALLBACK_ATTRIBUTES::contains,
|
FALLBACK_ATTRIBUTES::contains,
|
||||||
ffa -> ffa.setVisible(BooleanUtils.isTrue(clientConfig.fallback))
|
ffa -> ffa.setVisible(BooleanUtils.isTrue(clientConfig.fallback)));
|
||||||
);
|
|
||||||
|
|
||||||
formHandle.getForm().getFieldInput(SebClientConfig.ATTR_FALLBACK)
|
formHandle.getForm().getFieldInput(SEBClientConfig.ATTR_FALLBACK)
|
||||||
.addListener(SWT.Selection, event -> formHandle.process(
|
.addListener(SWT.Selection, event -> formHandle.process(
|
||||||
FALLBACK_ATTRIBUTES::contains,
|
FALLBACK_ATTRIBUTES::contains,
|
||||||
ffa -> {
|
ffa -> {
|
||||||
boolean selected = ((Button) event.widget).getSelection();
|
final boolean selected = ((Button) event.widget).getSelection();
|
||||||
ffa.setVisible(selected);
|
ffa.setVisible(selected);
|
||||||
if (!selected && ffa.hasError()) {
|
if (!selected && ffa.hasError()) {
|
||||||
ffa.resetError();
|
ffa.resetError();
|
||||||
ffa.setStringValue(StringUtils.EMPTY);
|
ffa.setStringValue(StringUtils.EMPTY);
|
||||||
}
|
}
|
||||||
}
|
}));
|
||||||
));
|
|
||||||
|
|
||||||
|
|
||||||
final UrlLauncher urlLauncher = RWT.getClient().getService(UrlLauncher.class);
|
final UrlLauncher urlLauncher = RWT.getClient().getService(UrlLauncher.class);
|
||||||
this.pageService.pageActionBuilder(formContext.clearEntityKeys())
|
this.pageService.pageActionBuilder(formContext.clearEntityKeys())
|
||||||
|
@ -339,7 +333,7 @@ public class SebClientConfigForm implements TemplateComposer {
|
||||||
.withExec(action -> {
|
.withExec(action -> {
|
||||||
final String downloadURL = this.downloadService.createDownloadURL(
|
final String downloadURL = this.downloadService.createDownloadURL(
|
||||||
entityKey.modelId,
|
entityKey.modelId,
|
||||||
SebClientConfigDownload.class,
|
SEBClientConfigDownload.class,
|
||||||
this.downloadFileName);
|
this.downloadFileName);
|
||||||
urlLauncher.openURL(downloadURL);
|
urlLauncher.openURL(downloadURL);
|
||||||
return action;
|
return action;
|
||||||
|
@ -375,11 +369,11 @@ public class SebClientConfigForm implements TemplateComposer {
|
||||||
.publishIf(() -> !isReadonly);
|
.publishIf(() -> !isReadonly);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkNaturalNumber(String value) {
|
private void checkNaturalNumber(final String value) {
|
||||||
if (StringUtils.isBlank(value)) {
|
if (StringUtils.isBlank(value)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long num = Long.parseLong(value);
|
final long num = Long.parseLong(value);
|
||||||
if (num < 0) {
|
if (num < 0) {
|
||||||
throw new PageMessageException("Number must be positive");
|
throw new PageMessageException("Number must be positive");
|
||||||
}
|
}
|
|
@ -21,7 +21,7 @@ import ch.ethz.seb.sebserver.gbl.Constants;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.Domain;
|
import ch.ethz.seb.sebserver.gbl.model.Domain;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.Entity;
|
import ch.ethz.seb.sebserver.gbl.model.Entity;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.user.UserInfo;
|
import ch.ethz.seb.sebserver.gbl.model.user.UserInfo;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.user.UserRole;
|
import ch.ethz.seb.sebserver.gbl.model.user.UserRole;
|
||||||
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
||||||
|
@ -46,7 +46,7 @@ import ch.ethz.seb.sebserver.gui.table.TableFilter.CriteriaType;
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@GuiProfile
|
@GuiProfile
|
||||||
public class SebClientConfigList implements TemplateComposer {
|
public class SEBClientConfigList implements TemplateComposer {
|
||||||
|
|
||||||
private static final LocTextKey NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUTION =
|
private static final LocTextKey NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUTION =
|
||||||
new LocTextKey("sebserver.clientconfig.list.action.no.modify.privilege");
|
new LocTextKey("sebserver.clientconfig.list.action.no.modify.privilege");
|
||||||
|
@ -69,7 +69,7 @@ public class SebClientConfigList implements TemplateComposer {
|
||||||
private final TableFilterAttribute dateFilter =
|
private final TableFilterAttribute dateFilter =
|
||||||
new TableFilterAttribute(
|
new TableFilterAttribute(
|
||||||
CriteriaType.DATE,
|
CriteriaType.DATE,
|
||||||
SebClientConfig.FILTER_ATTR_CREATION_DATE,
|
SEBClientConfig.FILTER_ATTR_CREATION_DATE,
|
||||||
DateTime.now(DateTimeZone.UTC)
|
DateTime.now(DateTimeZone.UTC)
|
||||||
.minusYears(1)
|
.minusYears(1)
|
||||||
.toString(Constants.DEFAULT_DATE_TIME_FORMAT));
|
.toString(Constants.DEFAULT_DATE_TIME_FORMAT));
|
||||||
|
@ -81,7 +81,7 @@ public class SebClientConfigList implements TemplateComposer {
|
||||||
private final ResourceService resourceService;
|
private final ResourceService resourceService;
|
||||||
private final int pageSize;
|
private final int pageSize;
|
||||||
|
|
||||||
protected SebClientConfigList(
|
protected SEBClientConfigList(
|
||||||
final PageService pageService,
|
final PageService pageService,
|
||||||
final RestService restService,
|
final RestService restService,
|
||||||
final CurrentUser currentUser,
|
final CurrentUser currentUser,
|
||||||
|
@ -117,7 +117,7 @@ public class SebClientConfigList implements TemplateComposer {
|
||||||
this.pageService.pageActionBuilder(pageContext.clearEntityKeys());
|
this.pageService.pageActionBuilder(pageContext.clearEntityKeys());
|
||||||
|
|
||||||
// table
|
// table
|
||||||
final EntityTable<SebClientConfig> table =
|
final EntityTable<SEBClientConfig> table =
|
||||||
this.pageService.entityTableBuilder(this.restService.getRestCall(GetClientConfigPage.class))
|
this.pageService.entityTableBuilder(this.restService.getRestCall(GetClientConfigPage.class))
|
||||||
.withEmptyMessage(EMPTY_LIST_TEXT_KEY)
|
.withEmptyMessage(EMPTY_LIST_TEXT_KEY)
|
||||||
.withPaging(this.pageSize)
|
.withPaging(this.pageSize)
|
||||||
|
@ -131,7 +131,7 @@ public class SebClientConfigList implements TemplateComposer {
|
||||||
.withColumn(new ColumnDefinition<>(
|
.withColumn(new ColumnDefinition<>(
|
||||||
Domain.SEB_CLIENT_CONFIGURATION.ATTR_NAME,
|
Domain.SEB_CLIENT_CONFIGURATION.ATTR_NAME,
|
||||||
NAME_TEXT_KEY,
|
NAME_TEXT_KEY,
|
||||||
SebClientConfig::getName)
|
SEBClientConfig::getName)
|
||||||
.withFilter(this.nameFilter)
|
.withFilter(this.nameFilter)
|
||||||
.sortable())
|
.sortable())
|
||||||
.withColumn(new ColumnDefinition<>(
|
.withColumn(new ColumnDefinition<>(
|
||||||
|
@ -139,13 +139,13 @@ public class SebClientConfigList implements TemplateComposer {
|
||||||
new LocTextKey(
|
new LocTextKey(
|
||||||
"sebserver.clientconfig.list.column.date",
|
"sebserver.clientconfig.list.column.date",
|
||||||
i18nSupport.getUsersTimeZoneTitleSuffix()),
|
i18nSupport.getUsersTimeZoneTitleSuffix()),
|
||||||
SebClientConfig::getDate)
|
SEBClientConfig::getDate)
|
||||||
.withFilter(this.dateFilter)
|
.withFilter(this.dateFilter)
|
||||||
.sortable())
|
.sortable())
|
||||||
.withColumn(new ColumnDefinition<>(
|
.withColumn(new ColumnDefinition<>(
|
||||||
Domain.SEB_CLIENT_CONFIGURATION.ATTR_ACTIVE,
|
Domain.SEB_CLIENT_CONFIGURATION.ATTR_ACTIVE,
|
||||||
ACTIVE_TEXT_KEY,
|
ACTIVE_TEXT_KEY,
|
||||||
this.pageService.getResourceService().<SebClientConfig> localizedActivityFunction())
|
this.pageService.getResourceService().<SEBClientConfig> localizedActivityFunction())
|
||||||
.withFilter(this.activityFilter)
|
.withFilter(this.activityFilter)
|
||||||
.sortable())
|
.sortable())
|
||||||
.withDefaultAction(pageActionBuilder
|
.withDefaultAction(pageActionBuilder
|
||||||
|
@ -190,7 +190,7 @@ public class SebClientConfigList implements TemplateComposer {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Function<SebClientConfig, String> clientConfigInstitutionNameFunction(
|
private static Function<SEBClientConfig, String> clientConfigInstitutionNameFunction(
|
||||||
final ResourceService resourceService) {
|
final ResourceService resourceService) {
|
||||||
|
|
||||||
return config -> resourceService.getInstitutionNameFunction()
|
return config -> resourceService.getInstitutionNameFunction()
|
|
@ -37,9 +37,9 @@ import org.springframework.stereotype.Component;
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@GuiProfile
|
@GuiProfile
|
||||||
public class SebClientLogDetailsPopup {
|
public class SEBClientLogDetailsPopup {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(SebClientLogDetailsPopup.class);
|
private static final Logger log = LoggerFactory.getLogger(SEBClientLogDetailsPopup.class);
|
||||||
|
|
||||||
private static final LocTextKey DETAILS_TITLE_TEXT_KEY =
|
private static final LocTextKey DETAILS_TITLE_TEXT_KEY =
|
||||||
new LocTextKey("sebserver.seblogs.details.title");
|
new LocTextKey("sebserver.seblogs.details.title");
|
||||||
|
@ -86,7 +86,7 @@ public class SebClientLogDetailsPopup {
|
||||||
private final I18nSupport i18nSupport;
|
private final I18nSupport i18nSupport;
|
||||||
private final WidgetFactory widgetFactory;
|
private final WidgetFactory widgetFactory;
|
||||||
|
|
||||||
public SebClientLogDetailsPopup(
|
public SEBClientLogDetailsPopup(
|
||||||
final PageService pageService,
|
final PageService pageService,
|
||||||
final WidgetFactory widgetFactory) {
|
final WidgetFactory widgetFactory) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ import ch.ethz.seb.sebserver.gui.widget.WidgetFactory;
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@GuiProfile
|
@GuiProfile
|
||||||
public class SebClientLogs implements TemplateComposer {
|
public class SEBClientLogs implements TemplateComposer {
|
||||||
|
|
||||||
private static final LocTextKey TITLE_TEXT_KEY =
|
private static final LocTextKey TITLE_TEXT_KEY =
|
||||||
new LocTextKey("sebserver.seblogs.list.title");
|
new LocTextKey("sebserver.seblogs.list.title");
|
||||||
|
@ -70,12 +70,12 @@ public class SebClientLogs implements TemplateComposer {
|
||||||
private final ResourceService resourceService;
|
private final ResourceService resourceService;
|
||||||
private final RestService restService;
|
private final RestService restService;
|
||||||
private final I18nSupport i18nSupport;
|
private final I18nSupport i18nSupport;
|
||||||
private final SebClientLogDetailsPopup sebClientLogDetailsPopup;
|
private final SEBClientLogDetailsPopup sebClientLogDetailsPopup;
|
||||||
private final int pageSize;
|
private final int pageSize;
|
||||||
|
|
||||||
public SebClientLogs(
|
public SEBClientLogs(
|
||||||
final PageService pageService,
|
final PageService pageService,
|
||||||
final SebClientLogDetailsPopup sebClientLogDetailsPopup,
|
final SEBClientLogDetailsPopup sebClientLogDetailsPopup,
|
||||||
@Value("${sebserver.gui.list.page.size:20}") final Integer pageSize) {
|
@Value("${sebserver.gui.list.page.size:20}") final Integer pageSize) {
|
||||||
|
|
||||||
this.pageService = pageService;
|
this.pageService = pageService;
|
|
@ -35,7 +35,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.CopyConfiguration;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.CopyConfiguration;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.NewExamConfig;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.NewExamConfig;
|
||||||
|
|
||||||
final class SebExamConfigCreationPopup {
|
final class SEBExamConfigCreationPopup {
|
||||||
|
|
||||||
static final LocTextKey FORM_COPY_TEXT_KEY =
|
static final LocTextKey FORM_COPY_TEXT_KEY =
|
||||||
new LocTextKey("sebserver.examconfig.action.copy.dialog");
|
new LocTextKey("sebserver.examconfig.action.copy.dialog");
|
||||||
|
@ -174,16 +174,16 @@ final class SebExamConfigCreationPopup {
|
||||||
entityKey.getModelId())
|
entityKey.getModelId())
|
||||||
.addField(FormBuilder.text(
|
.addField(FormBuilder.text(
|
||||||
Domain.CONFIGURATION_NODE.ATTR_NAME,
|
Domain.CONFIGURATION_NODE.ATTR_NAME,
|
||||||
SebExamConfigForm.FORM_NAME_TEXT_KEY))
|
SEBExamConfigForm.FORM_NAME_TEXT_KEY))
|
||||||
.addField(FormBuilder.text(
|
.addField(FormBuilder.text(
|
||||||
Domain.CONFIGURATION_NODE.ATTR_DESCRIPTION,
|
Domain.CONFIGURATION_NODE.ATTR_DESCRIPTION,
|
||||||
SebExamConfigForm.FORM_DESCRIPTION_TEXT_KEY)
|
SEBExamConfigForm.FORM_DESCRIPTION_TEXT_KEY)
|
||||||
.asArea())
|
.asArea())
|
||||||
.addFieldIf(
|
.addFieldIf(
|
||||||
() -> !this.copyAsTemplate && !this.createFromTemplate,
|
() -> !this.copyAsTemplate && !this.createFromTemplate,
|
||||||
() -> FormBuilder.checkbox(
|
() -> FormBuilder.checkbox(
|
||||||
ConfigCreationInfo.ATTR_COPY_WITH_HISTORY,
|
ConfigCreationInfo.ATTR_COPY_WITH_HISTORY,
|
||||||
SebExamConfigForm.FORM_HISTORY_TEXT_KEY))
|
SEBExamConfigForm.FORM_HISTORY_TEXT_KEY))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
return () -> formHandle;
|
return () -> formHandle;
|
|
@ -49,7 +49,7 @@ import ch.ethz.seb.sebserver.gui.service.page.TemplateComposer;
|
||||||
import ch.ethz.seb.sebserver.gui.service.page.impl.ModalInputDialog;
|
import ch.ethz.seb.sebserver.gui.service.page.impl.ModalInputDialog;
|
||||||
import ch.ethz.seb.sebserver.gui.service.page.impl.PageAction;
|
import ch.ethz.seb.sebserver.gui.service.page.impl.PageAction;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.download.DownloadService;
|
import ch.ethz.seb.sebserver.gui.service.remote.download.DownloadService;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.download.SebExamConfigPlaintextDownload;
|
import ch.ethz.seb.sebserver.gui.service.remote.download.SEBExamConfigPlaintextDownload;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetExamConfigMappingNames;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetExamConfigMappingNames;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetExamConfigMappingsPage;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetExamConfigMappingsPage;
|
||||||
|
@ -67,7 +67,7 @@ import ch.ethz.seb.sebserver.gui.widget.WidgetFactory.CustomVariant;
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@GuiProfile
|
@GuiProfile
|
||||||
public class SebExamConfigForm implements TemplateComposer {
|
public class SEBExamConfigForm implements TemplateComposer {
|
||||||
|
|
||||||
static final LocTextKey FORM_TITLE_NEW =
|
static final LocTextKey FORM_TITLE_NEW =
|
||||||
new LocTextKey("sebserver.examconfig.form.title.new");
|
new LocTextKey("sebserver.examconfig.form.title.new");
|
||||||
|
@ -107,7 +107,7 @@ public class SebExamConfigForm implements TemplateComposer {
|
||||||
private final DownloadService downloadService;
|
private final DownloadService downloadService;
|
||||||
private final String downloadFileName;
|
private final String downloadFileName;
|
||||||
|
|
||||||
protected SebExamConfigForm(
|
protected SEBExamConfigForm(
|
||||||
final PageService pageService,
|
final PageService pageService,
|
||||||
final CurrentUser currentUser,
|
final CurrentUser currentUser,
|
||||||
final DownloadService downloadService,
|
final DownloadService downloadService,
|
||||||
|
@ -228,7 +228,7 @@ public class SebExamConfigForm implements TemplateComposer {
|
||||||
|
|
||||||
.newAction(ActionDefinition.SEB_EXAM_CONFIG_COPY_CONFIG)
|
.newAction(ActionDefinition.SEB_EXAM_CONFIG_COPY_CONFIG)
|
||||||
.withEntityKey(entityKey)
|
.withEntityKey(entityKey)
|
||||||
.withExec(SebExamConfigCreationPopup.configCreationFunction(
|
.withExec(SEBExamConfigCreationPopup.configCreationFunction(
|
||||||
this.pageService,
|
this.pageService,
|
||||||
actionContext
|
actionContext
|
||||||
.withEntityKey(entityKey)
|
.withEntityKey(entityKey)
|
||||||
|
@ -243,7 +243,7 @@ public class SebExamConfigForm implements TemplateComposer {
|
||||||
|
|
||||||
.newAction(ActionDefinition.SEA_EXAM_CONFIG_COPY_CONFIG_AS_TEMPLATE)
|
.newAction(ActionDefinition.SEA_EXAM_CONFIG_COPY_CONFIG_AS_TEMPLATE)
|
||||||
.withEntityKey(entityKey)
|
.withEntityKey(entityKey)
|
||||||
.withExec(SebExamConfigCreationPopup.configCreationFunction(
|
.withExec(SEBExamConfigCreationPopup.configCreationFunction(
|
||||||
this.pageService,
|
this.pageService,
|
||||||
pageContext.withAttribute(
|
pageContext.withAttribute(
|
||||||
PageContext.AttributeKeys.COPY_AS_TEMPLATE,
|
PageContext.AttributeKeys.COPY_AS_TEMPLATE,
|
||||||
|
@ -256,7 +256,7 @@ public class SebExamConfigForm implements TemplateComposer {
|
||||||
.withExec(action -> {
|
.withExec(action -> {
|
||||||
final String downloadURL = this.downloadService.createDownloadURL(
|
final String downloadURL = this.downloadService.createDownloadURL(
|
||||||
entityKey.modelId,
|
entityKey.modelId,
|
||||||
SebExamConfigPlaintextDownload.class,
|
SEBExamConfigPlaintextDownload.class,
|
||||||
this.downloadFileName);
|
this.downloadFileName);
|
||||||
urlLauncher.openURL(downloadURL);
|
urlLauncher.openURL(downloadURL);
|
||||||
return action;
|
return action;
|
||||||
|
@ -266,13 +266,13 @@ public class SebExamConfigForm implements TemplateComposer {
|
||||||
|
|
||||||
.newAction(ActionDefinition.SEB_EXAM_CONFIG_GET_CONFIG_KEY)
|
.newAction(ActionDefinition.SEB_EXAM_CONFIG_GET_CONFIG_KEY)
|
||||||
.withEntityKey(entityKey)
|
.withEntityKey(entityKey)
|
||||||
.withExec(SebExamConfigForm.getConfigKeyFunction(this.pageService))
|
.withExec(SEBExamConfigForm.getConfigKeyFunction(this.pageService))
|
||||||
.noEventPropagation()
|
.noEventPropagation()
|
||||||
.publishIf(() -> modifyGrant && isReadonly)
|
.publishIf(() -> modifyGrant && isReadonly)
|
||||||
|
|
||||||
.newAction(ActionDefinition.SEB_EXAM_CONFIG_IMPORT_TO_EXISTING_CONFIG)
|
.newAction(ActionDefinition.SEB_EXAM_CONFIG_IMPORT_TO_EXISTING_CONFIG)
|
||||||
.withEntityKey(entityKey)
|
.withEntityKey(entityKey)
|
||||||
.withExec(SebExamConfigImportPopup.importFunction(this.pageService, false))
|
.withExec(SEBExamConfigImportPopup.importFunction(this.pageService, false))
|
||||||
.noEventPropagation()
|
.noEventPropagation()
|
||||||
.publishIf(() -> modifyGrant && isReadonly && !isAttachedToExam)
|
.publishIf(() -> modifyGrant && isReadonly && !isAttachedToExam)
|
||||||
|
|
|
@ -49,9 +49,9 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.Im
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.ImportNewExamConfig;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.ImportNewExamConfig;
|
||||||
import ch.ethz.seb.sebserver.gui.widget.FileUploadSelection;
|
import ch.ethz.seb.sebserver.gui.widget.FileUploadSelection;
|
||||||
|
|
||||||
final class SebExamConfigImportPopup {
|
final class SEBExamConfigImportPopup {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(SebExamConfigImportPopup.class);
|
private static final Logger log = LoggerFactory.getLogger(SEBExamConfigImportPopup.class);
|
||||||
|
|
||||||
private final static PageMessageException MISSING_PASSWORD = new PageMessageException(
|
private final static PageMessageException MISSING_PASSWORD = new PageMessageException(
|
||||||
new LocTextKey("sebserver.examconfig.action.import.missing-password"));
|
new LocTextKey("sebserver.examconfig.action.import.missing-password"));
|
||||||
|
@ -74,7 +74,7 @@ final class SebExamConfigImportPopup {
|
||||||
newConfig);
|
newConfig);
|
||||||
|
|
||||||
dialog.open(
|
dialog.open(
|
||||||
SebExamConfigForm.FORM_IMPORT_TEXT_KEY,
|
SEBExamConfigForm.FORM_IMPORT_TEXT_KEY,
|
||||||
(Predicate<FormHandle<ConfigurationNode>>) formHandle -> doImport(
|
(Predicate<FormHandle<ConfigurationNode>>) formHandle -> doImport(
|
||||||
pageService,
|
pageService,
|
||||||
formHandle,
|
formHandle,
|
||||||
|
@ -181,7 +181,7 @@ final class SebExamConfigImportPopup {
|
||||||
.call();
|
.call();
|
||||||
|
|
||||||
if (!configuration.hasError()) {
|
if (!configuration.hasError()) {
|
||||||
context.publishInfo(SebExamConfigForm.FORM_IMPORT_CONFIRM_TEXT_KEY);
|
context.publishInfo(SEBExamConfigForm.FORM_IMPORT_CONFIRM_TEXT_KEY);
|
||||||
if (newConfig) {
|
if (newConfig) {
|
||||||
|
|
||||||
final PageAction action = pageService.pageActionBuilder(context)
|
final PageAction action = pageService.pageActionBuilder(context)
|
||||||
|
@ -214,7 +214,7 @@ final class SebExamConfigImportPopup {
|
||||||
}
|
}
|
||||||
|
|
||||||
formHandle.getContext().notifyError(
|
formHandle.getContext().notifyError(
|
||||||
SebExamConfigForm.FORM_TITLE,
|
SEBExamConfigForm.FORM_TITLE,
|
||||||
configuration.getError());
|
configuration.getError());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ final class SebExamConfigImportPopup {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
formHandle.getContext().notifyError(SebExamConfigForm.FORM_TITLE, e);
|
formHandle.getContext().notifyError(SEBExamConfigForm.FORM_TITLE, e);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -264,7 +264,7 @@ final class SebExamConfigImportPopup {
|
||||||
.readonly(false)
|
.readonly(false)
|
||||||
.addField(FormBuilder.fileUpload(
|
.addField(FormBuilder.fileUpload(
|
||||||
API.IMPORT_FILE_ATTR_NAME,
|
API.IMPORT_FILE_ATTR_NAME,
|
||||||
SebExamConfigForm.FORM_IMPORT_SELECT_TEXT_KEY,
|
SEBExamConfigForm.FORM_IMPORT_SELECT_TEXT_KEY,
|
||||||
null,
|
null,
|
||||||
API.SEB_FILE_EXTENSION))
|
API.SEB_FILE_EXTENSION))
|
||||||
|
|
||||||
|
@ -272,24 +272,24 @@ final class SebExamConfigImportPopup {
|
||||||
() -> this.newConfig,
|
() -> this.newConfig,
|
||||||
() -> FormBuilder.text(
|
() -> FormBuilder.text(
|
||||||
Domain.CONFIGURATION_NODE.ATTR_NAME,
|
Domain.CONFIGURATION_NODE.ATTR_NAME,
|
||||||
SebExamConfigForm.FORM_NAME_TEXT_KEY))
|
SEBExamConfigForm.FORM_NAME_TEXT_KEY))
|
||||||
.addFieldIf(
|
.addFieldIf(
|
||||||
() -> this.newConfig,
|
() -> this.newConfig,
|
||||||
() -> FormBuilder.text(
|
() -> FormBuilder.text(
|
||||||
Domain.CONFIGURATION_NODE.ATTR_DESCRIPTION,
|
Domain.CONFIGURATION_NODE.ATTR_DESCRIPTION,
|
||||||
SebExamConfigForm.FORM_DESCRIPTION_TEXT_KEY)
|
SEBExamConfigForm.FORM_DESCRIPTION_TEXT_KEY)
|
||||||
.asArea())
|
.asArea())
|
||||||
.addFieldIf(
|
.addFieldIf(
|
||||||
() -> this.newConfig && !examConfigTemplateResources.isEmpty(),
|
() -> this.newConfig && !examConfigTemplateResources.isEmpty(),
|
||||||
() -> FormBuilder.singleSelection(
|
() -> FormBuilder.singleSelection(
|
||||||
Domain.CONFIGURATION_NODE.ATTR_TEMPLATE_ID,
|
Domain.CONFIGURATION_NODE.ATTR_TEMPLATE_ID,
|
||||||
SebExamConfigForm.FORM_TEMPLATE_TEXT_KEY,
|
SEBExamConfigForm.FORM_TEMPLATE_TEXT_KEY,
|
||||||
null,
|
null,
|
||||||
resourceService::getExamConfigTemplateResources))
|
resourceService::getExamConfigTemplateResources))
|
||||||
|
|
||||||
.addField(FormBuilder.text(
|
.addField(FormBuilder.text(
|
||||||
API.IMPORT_PASSWORD_ATTR_NAME,
|
API.IMPORT_PASSWORD_ATTR_NAME,
|
||||||
SebExamConfigForm.FORM_IMPORT_PASSWORD_TEXT_KEY,
|
SEBExamConfigForm.FORM_IMPORT_PASSWORD_TEXT_KEY,
|
||||||
"").asPasswordField())
|
"").asPasswordField())
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -41,7 +41,7 @@ import ch.ethz.seb.sebserver.gui.widget.WidgetFactory;
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@GuiProfile
|
@GuiProfile
|
||||||
public class SebExamConfigList implements TemplateComposer {
|
public class SEBExamConfigList implements TemplateComposer {
|
||||||
|
|
||||||
private static final LocTextKey NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUTION =
|
private static final LocTextKey NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUTION =
|
||||||
new LocTextKey("sebserver.examconfig.list.action.no.modify.privilege");
|
new LocTextKey("sebserver.examconfig.list.action.no.modify.privilege");
|
||||||
|
@ -73,7 +73,7 @@ public class SebExamConfigList implements TemplateComposer {
|
||||||
private final ResourceService resourceService;
|
private final ResourceService resourceService;
|
||||||
private final int pageSize;
|
private final int pageSize;
|
||||||
|
|
||||||
protected SebExamConfigList(
|
protected SEBExamConfigList(
|
||||||
final PageService pageService,
|
final PageService pageService,
|
||||||
final RestService restService,
|
final RestService restService,
|
||||||
final CurrentUser currentUser,
|
final CurrentUser currentUser,
|
||||||
|
@ -172,7 +172,7 @@ public class SebExamConfigList implements TemplateComposer {
|
||||||
.newAction(ActionDefinition.SEB_EXAM_CONFIG_IMPORT_TO_NEW_CONFIG)
|
.newAction(ActionDefinition.SEB_EXAM_CONFIG_IMPORT_TO_NEW_CONFIG)
|
||||||
.withSelect(
|
.withSelect(
|
||||||
configTable.getGrantedSelection(this.currentUser, NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUTION),
|
configTable.getGrantedSelection(this.currentUser, NO_MODIFY_PRIVILEGE_ON_OTHER_INSTITUTION),
|
||||||
SebExamConfigImportPopup.importFunction(this.pageService, true),
|
SEBExamConfigImportPopup.importFunction(this.pageService, true),
|
||||||
EMPTY_SELECTION_TEXT_KEY)
|
EMPTY_SELECTION_TEXT_KEY)
|
||||||
.noEventPropagation()
|
.noEventPropagation()
|
||||||
.publishIf(examConfigGrant::im);
|
.publishIf(examConfigGrant::im);
|
|
@ -47,7 +47,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.GetConfigurations;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.GetConfigurations;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.GetExamConfigNode;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.GetExamConfigNode;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfigHistory;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfigHistory;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SebExamConfigUndo;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SEBExamConfigUndo;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser.GrantCheck;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser.GrantCheck;
|
||||||
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory;
|
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory;
|
||||||
|
@ -55,9 +55,9 @@ import ch.ethz.seb.sebserver.gui.widget.WidgetFactory;
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@GuiProfile
|
@GuiProfile
|
||||||
public class SebSettingsForm implements TemplateComposer {
|
public class SEBSettingsForm implements TemplateComposer {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(SebSettingsForm.class);
|
private static final Logger log = LoggerFactory.getLogger(SEBSettingsForm.class);
|
||||||
|
|
||||||
private static final String VIEW_TEXT_KEY_PREFIX =
|
private static final String VIEW_TEXT_KEY_PREFIX =
|
||||||
"sebserver.examconfig.props.form.views.";
|
"sebserver.examconfig.props.form.views.";
|
||||||
|
@ -76,7 +76,7 @@ public class SebSettingsForm implements TemplateComposer {
|
||||||
private final CurrentUser currentUser;
|
private final CurrentUser currentUser;
|
||||||
private final ExamConfigurationService examConfigurationService;
|
private final ExamConfigurationService examConfigurationService;
|
||||||
|
|
||||||
protected SebSettingsForm(
|
protected SEBSettingsForm(
|
||||||
final PageService pageService,
|
final PageService pageService,
|
||||||
final RestService restService,
|
final RestService restService,
|
||||||
final CurrentUser currentUser,
|
final CurrentUser currentUser,
|
||||||
|
@ -178,7 +178,7 @@ public class SebSettingsForm implements TemplateComposer {
|
||||||
.newAction(ActionDefinition.SEB_EXAM_CONFIG_UNDO)
|
.newAction(ActionDefinition.SEB_EXAM_CONFIG_UNDO)
|
||||||
.withEntityKey(entityKey)
|
.withEntityKey(entityKey)
|
||||||
.withExec(action -> {
|
.withExec(action -> {
|
||||||
this.restService.getBuilder(SebExamConfigUndo.class)
|
this.restService.getBuilder(SEBExamConfigUndo.class)
|
||||||
.withURIVariable(API.PARAM_MODEL_ID, configuration.getModelId())
|
.withURIVariable(API.PARAM_MODEL_ID, configuration.getModelId())
|
||||||
.call()
|
.call()
|
||||||
.getOrThrow();
|
.getOrThrow();
|
||||||
|
@ -192,7 +192,7 @@ public class SebSettingsForm implements TemplateComposer {
|
||||||
|
|
||||||
.newAction(ActionDefinition.SEA_EXAM_CONFIG_COPY_CONFIG_AS_TEMPLATE)
|
.newAction(ActionDefinition.SEA_EXAM_CONFIG_COPY_CONFIG_AS_TEMPLATE)
|
||||||
.withEntityKey(entityKey)
|
.withEntityKey(entityKey)
|
||||||
.withExec(SebExamConfigCreationPopup.configCreationFunction(
|
.withExec(SEBExamConfigCreationPopup.configCreationFunction(
|
||||||
this.pageService,
|
this.pageService,
|
||||||
pageContext
|
pageContext
|
||||||
.withAttribute(
|
.withAttribute(
|
||||||
|
@ -214,7 +214,7 @@ public class SebSettingsForm implements TemplateComposer {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
log.error("Unexpected error while trying to fetch exam configuration data and create views", e);
|
log.error("Unexpected error while trying to fetch exam configuration data and create views", e);
|
||||||
pageContext.notifyError(SebExamConfigForm.FORM_TITLE, e);
|
pageContext.notifyError(SEBExamConfigForm.FORM_TITLE, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,7 @@ public class UserActivityLogs implements TemplateComposer {
|
||||||
.clearEntityKeys()
|
.clearEntityKeys()
|
||||||
.clearAttributes());
|
.clearAttributes());
|
||||||
|
|
||||||
final BooleanSupplier isSebAdmin =
|
final BooleanSupplier isSEBAdmin =
|
||||||
() -> currentUser.get().hasRole(UserRole.SEB_SERVER_ADMIN);
|
() -> currentUser.get().hasRole(UserRole.SEB_SERVER_ADMIN);
|
||||||
|
|
||||||
final Function<UserActivityLog, String> institutionNameFunction =
|
final Function<UserActivityLog, String> institutionNameFunction =
|
||||||
|
@ -159,7 +159,7 @@ public class UserActivityLogs implements TemplateComposer {
|
||||||
.withPaging(this.pageSize)
|
.withPaging(this.pageSize)
|
||||||
|
|
||||||
.withColumnIf(
|
.withColumnIf(
|
||||||
isSebAdmin,
|
isSEBAdmin,
|
||||||
() -> new ColumnDefinition<>(
|
() -> new ColumnDefinition<>(
|
||||||
UserActivityLog.FILTER_ATTR_INSTITUTION,
|
UserActivityLog.FILTER_ATTR_INSTITUTION,
|
||||||
INSTITUTION_TEXT_KEY,
|
INSTITUTION_TEXT_KEY,
|
||||||
|
|
|
@ -296,12 +296,12 @@ public class ActivitiesPane implements TemplateComposer {
|
||||||
// ---- MONITORING ---------------------------------------------------------------------
|
// ---- MONITORING ---------------------------------------------------------------------
|
||||||
|
|
||||||
final boolean isSupporter = this.currentUser.get().hasAnyRole(UserRole.EXAM_SUPPORTER);
|
final boolean isSupporter = this.currentUser.get().hasAnyRole(UserRole.EXAM_SUPPORTER);
|
||||||
final boolean viewSebClientLogs = this.currentUser.hasInstitutionalPrivilege(
|
final boolean viewSEBClientLogs = this.currentUser.hasInstitutionalPrivilege(
|
||||||
PrivilegeType.READ,
|
PrivilegeType.READ,
|
||||||
EntityType.EXAM) ||
|
EntityType.EXAM) ||
|
||||||
this.currentUser.get().hasRole(UserRole.EXAM_SUPPORTER);
|
this.currentUser.get().hasRole(UserRole.EXAM_SUPPORTER);
|
||||||
|
|
||||||
if (isSupporter || viewSebClientLogs) {
|
if (isSupporter || viewSEBClientLogs) {
|
||||||
// Monitoring
|
// Monitoring
|
||||||
final TreeItem monitoring = this.widgetFactory.treeItemLocalized(
|
final TreeItem monitoring = this.widgetFactory.treeItemLocalized(
|
||||||
navigation,
|
navigation,
|
||||||
|
@ -320,7 +320,7 @@ public class ActivitiesPane implements TemplateComposer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SEB Client Logs
|
// SEB Client Logs
|
||||||
if (viewSebClientLogs) {
|
if (viewSEBClientLogs) {
|
||||||
final TreeItem sebLogs = (isSupporter)
|
final TreeItem sebLogs = (isSupporter)
|
||||||
? this.widgetFactory.treeItemLocalized(
|
? this.widgetFactory.treeItemLocalized(
|
||||||
monitoring,
|
monitoring,
|
||||||
|
|
|
@ -22,12 +22,12 @@ import ch.ethz.seb.sebserver.gui.content.MonitoringClientConnection;
|
||||||
import ch.ethz.seb.sebserver.gui.content.MonitoringRunningExam;
|
import ch.ethz.seb.sebserver.gui.content.MonitoringRunningExam;
|
||||||
import ch.ethz.seb.sebserver.gui.content.MonitoringRunningExamList;
|
import ch.ethz.seb.sebserver.gui.content.MonitoringRunningExamList;
|
||||||
import ch.ethz.seb.sebserver.gui.content.QuizLookupList;
|
import ch.ethz.seb.sebserver.gui.content.QuizLookupList;
|
||||||
import ch.ethz.seb.sebserver.gui.content.SebClientConfigForm;
|
import ch.ethz.seb.sebserver.gui.content.SEBClientConfigForm;
|
||||||
import ch.ethz.seb.sebserver.gui.content.SebClientConfigList;
|
import ch.ethz.seb.sebserver.gui.content.SEBClientConfigList;
|
||||||
import ch.ethz.seb.sebserver.gui.content.SebClientLogs;
|
import ch.ethz.seb.sebserver.gui.content.SEBClientLogs;
|
||||||
import ch.ethz.seb.sebserver.gui.content.SebExamConfigList;
|
import ch.ethz.seb.sebserver.gui.content.SEBExamConfigList;
|
||||||
import ch.ethz.seb.sebserver.gui.content.SebExamConfigForm;
|
import ch.ethz.seb.sebserver.gui.content.SEBExamConfigForm;
|
||||||
import ch.ethz.seb.sebserver.gui.content.SebSettingsForm;
|
import ch.ethz.seb.sebserver.gui.content.SEBSettingsForm;
|
||||||
import ch.ethz.seb.sebserver.gui.content.UserAccountChangePasswordForm;
|
import ch.ethz.seb.sebserver.gui.content.UserAccountChangePasswordForm;
|
||||||
import ch.ethz.seb.sebserver.gui.content.UserAccountForm;
|
import ch.ethz.seb.sebserver.gui.content.UserAccountForm;
|
||||||
import ch.ethz.seb.sebserver.gui.content.UserAccountList;
|
import ch.ethz.seb.sebserver.gui.content.UserAccountList;
|
||||||
|
@ -59,15 +59,15 @@ public enum PageStateDefinitionImpl implements PageStateDefinition {
|
||||||
EXAM_EDIT(Type.FORM_EDIT, ExamForm.class, ActivityDefinition.EXAM),
|
EXAM_EDIT(Type.FORM_EDIT, ExamForm.class, ActivityDefinition.EXAM),
|
||||||
INDICATOR_EDIT(Type.FORM_EDIT, IndicatorForm.class, ActivityDefinition.EXAM),
|
INDICATOR_EDIT(Type.FORM_EDIT, IndicatorForm.class, ActivityDefinition.EXAM),
|
||||||
|
|
||||||
SEB_CLIENT_CONFIG_LIST(Type.LIST_VIEW, SebClientConfigList.class, ActivityDefinition.SEB_CLIENT_CONFIG),
|
SEB_CLIENT_CONFIG_LIST(Type.LIST_VIEW, SEBClientConfigList.class, ActivityDefinition.SEB_CLIENT_CONFIG),
|
||||||
SEB_CLIENT_CONFIG_VIEW(Type.FORM_VIEW, SebClientConfigForm.class, ActivityDefinition.SEB_CLIENT_CONFIG),
|
SEB_CLIENT_CONFIG_VIEW(Type.FORM_VIEW, SEBClientConfigForm.class, ActivityDefinition.SEB_CLIENT_CONFIG),
|
||||||
SEB_CLIENT_CONFIG_EDIT(Type.FORM_EDIT, SebClientConfigForm.class, ActivityDefinition.SEB_CLIENT_CONFIG),
|
SEB_CLIENT_CONFIG_EDIT(Type.FORM_EDIT, SEBClientConfigForm.class, ActivityDefinition.SEB_CLIENT_CONFIG),
|
||||||
|
|
||||||
SEB_EXAM_CONFIG_LIST(Type.LIST_VIEW, SebExamConfigList.class, ActivityDefinition.SEB_EXAM_CONFIG),
|
SEB_EXAM_CONFIG_LIST(Type.LIST_VIEW, SEBExamConfigList.class, ActivityDefinition.SEB_EXAM_CONFIG),
|
||||||
SEB_EXAM_CONFIG_PROP_VIEW(Type.FORM_VIEW, SebExamConfigForm.class, ActivityDefinition.SEB_EXAM_CONFIG),
|
SEB_EXAM_CONFIG_PROP_VIEW(Type.FORM_VIEW, SEBExamConfigForm.class, ActivityDefinition.SEB_EXAM_CONFIG),
|
||||||
SEB_EXAM_CONFIG_PROP_EDIT(Type.FORM_EDIT, SebExamConfigForm.class, ActivityDefinition.SEB_EXAM_CONFIG),
|
SEB_EXAM_CONFIG_PROP_EDIT(Type.FORM_EDIT, SEBExamConfigForm.class, ActivityDefinition.SEB_EXAM_CONFIG),
|
||||||
SEB_EXAM_CONFIG_EDIT(Type.FORM_IN_TIME_EDIT, SebSettingsForm.class, ActivityDefinition.SEB_EXAM_CONFIG),
|
SEB_EXAM_CONFIG_EDIT(Type.FORM_IN_TIME_EDIT, SEBSettingsForm.class, ActivityDefinition.SEB_EXAM_CONFIG),
|
||||||
SEB_EXAM_CONFIG_VIEW(Type.FORM_VIEW, SebSettingsForm.class, ActivityDefinition.SEB_EXAM_CONFIG),
|
SEB_EXAM_CONFIG_VIEW(Type.FORM_VIEW, SEBSettingsForm.class, ActivityDefinition.SEB_EXAM_CONFIG),
|
||||||
|
|
||||||
SEB_EXAM_CONFIG_TEMPLATE_LIST(Type.LIST_VIEW, ConfigTemplateList.class,
|
SEB_EXAM_CONFIG_TEMPLATE_LIST(Type.LIST_VIEW, ConfigTemplateList.class,
|
||||||
ActivityDefinition.SEB_EXAM_CONFIG_TEMPLATE),
|
ActivityDefinition.SEB_EXAM_CONFIG_TEMPLATE),
|
||||||
|
@ -85,7 +85,7 @@ public enum PageStateDefinitionImpl implements PageStateDefinition {
|
||||||
MONITORING_CLIENT_CONNECTION(Type.FORM_VIEW, MonitoringClientConnection.class, ActivityDefinition.MONITORING_EXAMS),
|
MONITORING_CLIENT_CONNECTION(Type.FORM_VIEW, MonitoringClientConnection.class, ActivityDefinition.MONITORING_EXAMS),
|
||||||
|
|
||||||
USER_ACTIVITY_LOGS(Type.LIST_VIEW, UserActivityLogs.class, ActivityDefinition.USER_ACTIVITY_LOGS),
|
USER_ACTIVITY_LOGS(Type.LIST_VIEW, UserActivityLogs.class, ActivityDefinition.USER_ACTIVITY_LOGS),
|
||||||
SEB_CLIENT_LOGS(Type.LIST_VIEW, SebClientLogs.class, ActivityDefinition.SEB_CLIENT_LOGS)
|
SEB_CLIENT_LOGS(Type.LIST_VIEW, SEBClientLogs.class, ActivityDefinition.SEB_CLIENT_LOGS)
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Tuple3;
|
import ch.ethz.seb.sebserver.gbl.util.Tuple3;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -40,8 +40,8 @@ import ch.ethz.seb.sebserver.gbl.model.exam.Exam.ExamStatus;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Exam.ExamType;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Exam.ExamType;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.ExamConfigurationMap;
|
import ch.ethz.seb.sebserver.gbl.model.exam.ExamConfigurationMap;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator.IndicatorType;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator.IndicatorType;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSebRestriction.PermissionComponent;
|
import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSEBRestriction.PermissionComponent;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSebRestriction.WhiteListPath;
|
import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSEBRestriction.WhiteListPath;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.AttributeType;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.AttributeType;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationNode;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationNode;
|
||||||
|
@ -658,7 +658,7 @@ public class ResourceService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Tuple<String>> sebClientConfigPurposeResources() {
|
public List<Tuple<String>> sebClientConfigPurposeResources() {
|
||||||
return Arrays.stream(SebClientConfig.ConfigPurpose.values())
|
return Arrays.stream(SEBClientConfig.ConfigPurpose.values())
|
||||||
.map(type -> new Tuple3<>(
|
.map(type -> new Tuple3<>(
|
||||||
type.name(),
|
type.name(),
|
||||||
this.i18nSupport.getText(SEB_CLIENT_CONFIG_PURPOSE_PREFIX + type.name()),
|
this.i18nSupport.getText(SEB_CLIENT_CONFIG_PURPOSE_PREFIX + type.name()),
|
||||||
|
|
|
@ -27,14 +27,14 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.clientconfig.
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@GuiProfile
|
@GuiProfile
|
||||||
public class SebClientConfigDownload extends AbstractDownloadServiceHandler {
|
public class SEBClientConfigDownload extends AbstractDownloadServiceHandler {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(SebClientConfigDownload.class);
|
private static final Logger log = LoggerFactory.getLogger(SEBClientConfigDownload.class);
|
||||||
|
|
||||||
private final RestService restService;
|
private final RestService restService;
|
||||||
public final String downloadFileName;
|
public final String downloadFileName;
|
||||||
|
|
||||||
protected SebClientConfigDownload(
|
protected SEBClientConfigDownload(
|
||||||
final RestService restService,
|
final RestService restService,
|
||||||
@Value("${sebserver.gui.seb.client.config.download.filename}") final String downloadFileName) {
|
@Value("${sebserver.gui.seb.client.config.download.filename}") final String downloadFileName) {
|
||||||
|
|
|
@ -26,13 +26,13 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.ExportExamCo
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@GuiProfile
|
@GuiProfile
|
||||||
public class SebExamConfigDownload extends AbstractDownloadServiceHandler {
|
public class SEBExamConfigDownload extends AbstractDownloadServiceHandler {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(SebExamConfigDownload.class);
|
private static final Logger log = LoggerFactory.getLogger(SEBExamConfigDownload.class);
|
||||||
|
|
||||||
private final RestService restService;
|
private final RestService restService;
|
||||||
|
|
||||||
protected SebExamConfigDownload(final RestService restService) {
|
protected SEBExamConfigDownload(final RestService restService) {
|
||||||
this.restService = restService;
|
this.restService = restService;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,13 +26,13 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.Ex
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@GuiProfile
|
@GuiProfile
|
||||||
public class SebExamConfigPlaintextDownload extends AbstractDownloadServiceHandler {
|
public class SEBExamConfigPlaintextDownload extends AbstractDownloadServiceHandler {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(SebExamConfigPlaintextDownload.class);
|
private static final Logger log = LoggerFactory.getLogger(SEBExamConfigPlaintextDownload.class);
|
||||||
|
|
||||||
private final RestService restService;
|
private final RestService restService;
|
||||||
|
|
||||||
protected SebExamConfigPlaintextDownload(final RestService restService) {
|
protected SEBExamConfigPlaintextDownload(final RestService restService) {
|
||||||
this.restService = restService;
|
this.restService = restService;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,9 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@GuiProfile
|
@GuiProfile
|
||||||
public class ActivateSebRestriction extends RestCall<Exam> {
|
public class ActivateSEBRestriction extends RestCall<Exam> {
|
||||||
|
|
||||||
public ActivateSebRestriction() {
|
public ActivateSEBRestriction() {
|
||||||
super(new TypeKey<>(
|
super(new TypeKey<>(
|
||||||
CallType.ACTIVATION_ACTIVATE,
|
CallType.ACTIVATION_ACTIVATE,
|
||||||
EntityType.EXAM_SEB_RESTRICTION,
|
EntityType.EXAM_SEB_RESTRICTION,
|
|
@ -23,9 +23,9 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@GuiProfile
|
@GuiProfile
|
||||||
public class CheckSebRestriction extends RestCall<Boolean> {
|
public class CheckSEBRestriction extends RestCall<Boolean> {
|
||||||
|
|
||||||
public CheckSebRestriction() {
|
public CheckSEBRestriction() {
|
||||||
super(new TypeKey<>(
|
super(new TypeKey<>(
|
||||||
CallType.UNDEFINED,
|
CallType.UNDEFINED,
|
||||||
EntityType.EXAM_SEB_RESTRICTION,
|
EntityType.EXAM_SEB_RESTRICTION,
|
|
@ -24,9 +24,9 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@GuiProfile
|
@GuiProfile
|
||||||
public class DeactivateSebRestriction extends RestCall<Exam> {
|
public class DeactivateSEBRestriction extends RestCall<Exam> {
|
||||||
|
|
||||||
public DeactivateSebRestriction() {
|
public DeactivateSEBRestriction() {
|
||||||
super(new TypeKey<>(
|
super(new TypeKey<>(
|
||||||
CallType.ACTIVATION_DEACTIVATE,
|
CallType.ACTIVATION_DEACTIVATE,
|
||||||
EntityType.EXAM_SEB_RESTRICTION,
|
EntityType.EXAM_SEB_RESTRICTION,
|
|
@ -17,20 +17,20 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
|
||||||
import ch.ethz.seb.sebserver.gbl.api.API;
|
import ch.ethz.seb.sebserver.gbl.api.API;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.SebRestriction;
|
import ch.ethz.seb.sebserver.gbl.model.exam.SEBRestriction;
|
||||||
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@GuiProfile
|
@GuiProfile
|
||||||
public class GetSebRestriction extends RestCall<SebRestriction> {
|
public class GetSEBRestriction extends RestCall<SEBRestriction> {
|
||||||
|
|
||||||
public GetSebRestriction() {
|
public GetSEBRestriction() {
|
||||||
super(new TypeKey<>(
|
super(new TypeKey<>(
|
||||||
CallType.GET_SINGLE,
|
CallType.GET_SINGLE,
|
||||||
EntityType.EXAM_SEB_RESTRICTION,
|
EntityType.EXAM_SEB_RESTRICTION,
|
||||||
new TypeReference<SebRestriction>() {
|
new TypeReference<SEBRestriction>() {
|
||||||
}),
|
}),
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
MediaType.APPLICATION_JSON_UTF8,
|
MediaType.APPLICATION_JSON_UTF8,
|
|
@ -24,9 +24,9 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@GuiProfile
|
@GuiProfile
|
||||||
public class SaveSebRestriction extends RestCall<Exam> {
|
public class SaveSEBRestriction extends RestCall<Exam> {
|
||||||
|
|
||||||
public SaveSebRestriction() {
|
public SaveSEBRestriction() {
|
||||||
super(new TypeKey<>(
|
super(new TypeKey<>(
|
||||||
CallType.GET_SINGLE,
|
CallType.GET_SINGLE,
|
||||||
EntityType.EXAM_SEB_RESTRICTION,
|
EntityType.EXAM_SEB_RESTRICTION,
|
|
@ -17,20 +17,20 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
|
||||||
import ch.ethz.seb.sebserver.gbl.api.API;
|
import ch.ethz.seb.sebserver.gbl.api.API;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig;
|
||||||
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@GuiProfile
|
@GuiProfile
|
||||||
public class GetClientConfig extends RestCall<SebClientConfig> {
|
public class GetClientConfig extends RestCall<SEBClientConfig> {
|
||||||
|
|
||||||
public GetClientConfig() {
|
public GetClientConfig() {
|
||||||
super(new TypeKey<>(
|
super(new TypeKey<>(
|
||||||
CallType.GET_SINGLE,
|
CallType.GET_SINGLE,
|
||||||
EntityType.SEB_CLIENT_CONFIGURATION,
|
EntityType.SEB_CLIENT_CONFIGURATION,
|
||||||
new TypeReference<SebClientConfig>() {
|
new TypeReference<SEBClientConfig>() {
|
||||||
}),
|
}),
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
MediaType.APPLICATION_FORM_URLENCODED,
|
MediaType.APPLICATION_FORM_URLENCODED,
|
||||||
|
|
|
@ -18,20 +18,20 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.API;
|
import ch.ethz.seb.sebserver.gbl.api.API;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.Page;
|
import ch.ethz.seb.sebserver.gbl.model.Page;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig;
|
||||||
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@GuiProfile
|
@GuiProfile
|
||||||
public class GetClientConfigPage extends RestCall<Page<SebClientConfig>> {
|
public class GetClientConfigPage extends RestCall<Page<SEBClientConfig>> {
|
||||||
|
|
||||||
public GetClientConfigPage() {
|
public GetClientConfigPage() {
|
||||||
super(new TypeKey<>(
|
super(new TypeKey<>(
|
||||||
CallType.GET_PAGE,
|
CallType.GET_PAGE,
|
||||||
EntityType.SEB_CLIENT_CONFIGURATION,
|
EntityType.SEB_CLIENT_CONFIGURATION,
|
||||||
new TypeReference<Page<SebClientConfig>>() {
|
new TypeReference<Page<SEBClientConfig>>() {
|
||||||
}),
|
}),
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
MediaType.APPLICATION_FORM_URLENCODED,
|
MediaType.APPLICATION_FORM_URLENCODED,
|
||||||
|
|
|
@ -17,20 +17,20 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
|
||||||
import ch.ethz.seb.sebserver.gbl.api.API;
|
import ch.ethz.seb.sebserver.gbl.api.API;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig;
|
||||||
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@GuiProfile
|
@GuiProfile
|
||||||
public class NewClientConfig extends RestCall<SebClientConfig> {
|
public class NewClientConfig extends RestCall<SEBClientConfig> {
|
||||||
|
|
||||||
public NewClientConfig() {
|
public NewClientConfig() {
|
||||||
super(new TypeKey<>(
|
super(new TypeKey<>(
|
||||||
CallType.NEW,
|
CallType.NEW,
|
||||||
EntityType.SEB_CLIENT_CONFIGURATION,
|
EntityType.SEB_CLIENT_CONFIGURATION,
|
||||||
new TypeReference<SebClientConfig>() {
|
new TypeReference<SEBClientConfig>() {
|
||||||
}),
|
}),
|
||||||
HttpMethod.POST,
|
HttpMethod.POST,
|
||||||
MediaType.APPLICATION_FORM_URLENCODED,
|
MediaType.APPLICATION_FORM_URLENCODED,
|
||||||
|
|
|
@ -17,20 +17,20 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
|
||||||
import ch.ethz.seb.sebserver.gbl.api.API;
|
import ch.ethz.seb.sebserver.gbl.api.API;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig;
|
||||||
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@GuiProfile
|
@GuiProfile
|
||||||
public class SaveClientConfig extends RestCall<SebClientConfig> {
|
public class SaveClientConfig extends RestCall<SEBClientConfig> {
|
||||||
|
|
||||||
public SaveClientConfig() {
|
public SaveClientConfig() {
|
||||||
super(new TypeKey<>(
|
super(new TypeKey<>(
|
||||||
CallType.SAVE,
|
CallType.SAVE,
|
||||||
EntityType.SEB_CLIENT_CONFIGURATION,
|
EntityType.SEB_CLIENT_CONFIGURATION,
|
||||||
new TypeReference<SebClientConfig>() {
|
new TypeReference<SEBClientConfig>() {
|
||||||
}),
|
}),
|
||||||
HttpMethod.PUT,
|
HttpMethod.PUT,
|
||||||
MediaType.APPLICATION_JSON_UTF8,
|
MediaType.APPLICATION_JSON_UTF8,
|
||||||
|
|
|
@ -24,9 +24,9 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@GuiProfile
|
@GuiProfile
|
||||||
public class SebExamConfigUndo extends RestCall<Configuration> {
|
public class SEBExamConfigUndo extends RestCall<Configuration> {
|
||||||
|
|
||||||
public SebExamConfigUndo() {
|
public SEBExamConfigUndo() {
|
||||||
super(new TypeKey<>(
|
super(new TypeKey<>(
|
||||||
CallType.SAVE,
|
CallType.SAVE,
|
||||||
EntityType.CONFIGURATION,
|
EntityType.CONFIGURATION,
|
|
@ -54,19 +54,19 @@ public class InstructionProcessor {
|
||||||
this.jsonMapper = pageService.getJSONMapper();
|
this.jsonMapper = pageService.getJSONMapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void propagateSebQuitInstruction(
|
public void propagateSEBQuitInstruction(
|
||||||
final Long examId,
|
final Long examId,
|
||||||
final String connectionToken,
|
final String connectionToken,
|
||||||
final PageContext pageContext) {
|
final PageContext pageContext) {
|
||||||
|
|
||||||
propagateSebQuitInstruction(
|
propagateSEBQuitInstruction(
|
||||||
examId,
|
examId,
|
||||||
p -> Stream.of(connectionToken).collect(Collectors.toSet()),
|
p -> Stream.of(connectionToken).collect(Collectors.toSet()),
|
||||||
pageContext);
|
pageContext);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void propagateSebQuitInstruction(
|
public void propagateSEBQuitInstruction(
|
||||||
final Long examId,
|
final Long examId,
|
||||||
final Function<Predicate<ClientConnection>, Set<String>> selectionFunction,
|
final Function<Predicate<ClientConnection>, Set<String>> selectionFunction,
|
||||||
final PageContext pageContext) {
|
final PageContext pageContext) {
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class WebserviceInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSebServerVersion() {
|
public String getSEBServerVersion() {
|
||||||
return this.sebServerVersion;
|
return this.sebServerVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,6 @@ public interface ExamDAO extends ActivatableEntityDAO<Exam, Exam>, BulkActionSup
|
||||||
* @param examId the exam identifier
|
* @param examId the exam identifier
|
||||||
* @param sebRestriction the seb-restriction flag value
|
* @param sebRestriction the seb-restriction flag value
|
||||||
* @return Result refer to the updated Exam or to an error if happened */
|
* @return Result refer to the updated Exam or to an error if happened */
|
||||||
Result<Exam> setSebRestriction(Long examId, boolean sebRestriction);
|
Result<Exam> setSEBRestriction(Long examId, boolean sebRestriction);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationAttribute;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationNode;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationNode;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationValue;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationValue;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.Orientation;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.Orientation;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.session.ClientConnection;
|
import ch.ethz.seb.sebserver.gbl.model.session.ClientConnection;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.session.ClientEvent;
|
import ch.ethz.seb.sebserver.gbl.model.session.ClientEvent;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.session.ClientEvent.EventType;
|
import ch.ethz.seb.sebserver.gbl.model.session.ClientEvent.EventType;
|
||||||
|
@ -101,8 +101,8 @@ public class FilterMap extends POSTMapper {
|
||||||
return Utils.toDateTime(getString(QuizData.FILTER_ATTR_START_TIME));
|
return Utils.toDateTime(getString(QuizData.FILTER_ATTR_START_TIME));
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTime getSebClientConfigFromTime() {
|
public DateTime getSEBClientConfigFromTime() {
|
||||||
return Utils.toDateTime(getString(SebClientConfig.FILTER_ATTR_CREATION_DATE));
|
return Utils.toDateTime(getString(SEBClientConfig.FILTER_ATTR_CREATION_DATE));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getLmsSetupId() {
|
public Long getLmsSetupId() {
|
||||||
|
|
|
@ -14,29 +14,29 @@ import java.util.Set;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
|
|
||||||
import ch.ethz.seb.sebserver.gbl.model.EntityKey;
|
import ch.ethz.seb.sebserver.gbl.model.EntityKey;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Result;
|
import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.bulkaction.BulkActionSupportDAO;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.bulkaction.BulkActionSupportDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentials;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentials;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ClientConfigService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ClientConfigService;
|
||||||
|
|
||||||
/** Concrete EntityDAO interface of SebClientConfig entities */
|
/** Concrete EntityDAO interface of SEBClientConfig entities */
|
||||||
public interface SebClientConfigDAO extends
|
public interface SEBClientConfigDAO extends
|
||||||
ActivatableEntityDAO<SebClientConfig, SebClientConfig>,
|
ActivatableEntityDAO<SEBClientConfig, SEBClientConfig>,
|
||||||
BulkActionSupportDAO<SebClientConfig> {
|
BulkActionSupportDAO<SEBClientConfig> {
|
||||||
|
|
||||||
/** Get a SebClientConfig by specified client identifier
|
/** Get a SEBClientConfig by specified client identifier
|
||||||
*
|
*
|
||||||
* @param clientName the client name
|
* @param clientName the client name
|
||||||
* @return Result refer to the SebClientConfig for client or refer to an error if happened */
|
* @return Result refer to the SEBClientConfig for client or refer to an error if happened */
|
||||||
Result<SebClientConfig> byClientName(String clientName);
|
Result<SEBClientConfig> byClientName(String clientName);
|
||||||
|
|
||||||
/** Get the configured ClientCredentials for a given SebClientConfig.
|
/** Get the configured ClientCredentials for a given SEBClientConfig.
|
||||||
* The ClientCredentials are still encoded as they are on DB storage
|
* The ClientCredentials are still encoded as they are on DB storage
|
||||||
*
|
*
|
||||||
* @param modelId the model identifier of the SebClientConfig to get the ClientCredentials for
|
* @param modelId the model identifier of the SEBClientConfig to get the ClientCredentials for
|
||||||
* @return the configured ClientCredentials for a given SebClientConfig */
|
* @return the configured ClientCredentials for a given SEBClientConfig */
|
||||||
Result<ClientCredentials> getSebClientCredentials(String modelId);
|
Result<ClientCredentials> getSEBClientCredentials(String modelId);
|
||||||
|
|
||||||
/** Get the stored encrypted configuration password from a specified SEB client configuration.
|
/** Get the stored encrypted configuration password from a specified SEB client configuration.
|
||||||
* The SEB client configuration password is used to encrypt a SEB Client Configuration
|
* The SEB client configuration password is used to encrypt a SEB Client Configuration
|
|
@ -244,7 +244,7 @@ public class ExamDAOImpl implements ExamDAO {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public Result<Exam> setSebRestriction(final Long examId, final boolean sebRestriction) {
|
public Result<Exam> setSEBRestriction(final Long examId, final boolean sebRestriction) {
|
||||||
return Result.tryCatch(() -> {
|
return Result.tryCatch(() -> {
|
||||||
|
|
||||||
final ExamRecord examRecord = new ExamRecord(
|
final ExamRecord examRecord = new ExamRecord(
|
||||||
|
|
|
@ -34,8 +34,8 @@ import ch.ethz.seb.sebserver.gbl.api.APIMessage.ErrorMessage;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.Domain;
|
import ch.ethz.seb.sebserver.gbl.model.Domain;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.EntityKey;
|
import ch.ethz.seb.sebserver.gbl.model.EntityKey;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig.ConfigPurpose;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig.ConfigPurpose;
|
||||||
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Result;
|
import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||||
|
@ -49,19 +49,19 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentials;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.DAOLoggingSupport;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.DAOLoggingSupport;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.FilterMap;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.FilterMap;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ResourceNotFoundException;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ResourceNotFoundException;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.SebClientConfigDAO;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.SEBClientConfigDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.TransactionHandler;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.TransactionHandler;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@WebServiceProfile
|
@WebServiceProfile
|
||||||
public class SebClientConfigDAOImpl implements SebClientConfigDAO {
|
public class SEBClientConfigDAOImpl implements SEBClientConfigDAO {
|
||||||
|
|
||||||
private final SebClientConfigRecordMapper sebClientConfigRecordMapper;
|
private final SebClientConfigRecordMapper sebClientConfigRecordMapper;
|
||||||
private final ClientCredentialService clientCredentialService;
|
private final ClientCredentialService clientCredentialService;
|
||||||
private final AdditionalAttributesDAOImpl additionalAttributesDAO;
|
private final AdditionalAttributesDAOImpl additionalAttributesDAO;
|
||||||
|
|
||||||
protected SebClientConfigDAOImpl(
|
protected SEBClientConfigDAOImpl(
|
||||||
final SebClientConfigRecordMapper sebClientConfigRecordMapper,
|
final SebClientConfigRecordMapper sebClientConfigRecordMapper,
|
||||||
final ClientCredentialService clientCredentialService,
|
final ClientCredentialService clientCredentialService,
|
||||||
final AdditionalAttributesDAOImpl additionalAttributesDAO) {
|
final AdditionalAttributesDAOImpl additionalAttributesDAO) {
|
||||||
|
@ -78,14 +78,14 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public Result<SebClientConfig> byPK(final Long id) {
|
public Result<SEBClientConfig> byPK(final Long id) {
|
||||||
return recordById(id)
|
return recordById(id)
|
||||||
.flatMap(this::toDomainModel);
|
.flatMap(this::toDomainModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public Result<Collection<SebClientConfig>> all(final Long institutionId, final Boolean active) {
|
public Result<Collection<SEBClientConfig>> all(final Long institutionId, final Boolean active) {
|
||||||
return Result.tryCatch(() -> {
|
return Result.tryCatch(() -> {
|
||||||
|
|
||||||
final List<SebClientConfigRecord> records = (active != null)
|
final List<SebClientConfigRecord> records = (active != null)
|
||||||
|
@ -109,9 +109,9 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public Result<Collection<SebClientConfig>> allMatching(
|
public Result<Collection<SEBClientConfig>> allMatching(
|
||||||
final FilterMap filterMap,
|
final FilterMap filterMap,
|
||||||
final Predicate<SebClientConfig> predicate) {
|
final Predicate<SEBClientConfig> predicate) {
|
||||||
|
|
||||||
return Result.tryCatch(() -> this.sebClientConfigRecordMapper
|
return Result.tryCatch(() -> this.sebClientConfigRecordMapper
|
||||||
.selectByExample()
|
.selectByExample()
|
||||||
|
@ -123,7 +123,7 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO {
|
||||||
isLikeWhenPresent(filterMap.getName()))
|
isLikeWhenPresent(filterMap.getName()))
|
||||||
.and(
|
.and(
|
||||||
SebClientConfigRecordDynamicSqlSupport.date,
|
SebClientConfigRecordDynamicSqlSupport.date,
|
||||||
isGreaterThanOrEqualToWhenPresent(filterMap.getSebClientConfigFromTime()))
|
isGreaterThanOrEqualToWhenPresent(filterMap.getSEBClientConfigFromTime()))
|
||||||
.and(
|
.and(
|
||||||
SebClientConfigRecordDynamicSqlSupport.active,
|
SebClientConfigRecordDynamicSqlSupport.active,
|
||||||
isEqualToWhenPresent(filterMap.getActiveAsInt()))
|
isEqualToWhenPresent(filterMap.getActiveAsInt()))
|
||||||
|
@ -137,7 +137,7 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<SebClientConfig> byClientName(final String clientName) {
|
public Result<SEBClientConfig> byClientName(final String clientName) {
|
||||||
return Result.tryCatch(() -> this.sebClientConfigRecordMapper
|
return Result.tryCatch(() -> this.sebClientConfigRecordMapper
|
||||||
.selectByExample()
|
.selectByExample()
|
||||||
.where(
|
.where(
|
||||||
|
@ -210,7 +210,7 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public Result<SebClientConfig> createNew(final SebClientConfig sebClientConfig) {
|
public Result<SEBClientConfig> createNew(final SEBClientConfig sebClientConfig) {
|
||||||
return this.clientCredentialService
|
return this.clientCredentialService
|
||||||
.generatedClientCredentials()
|
.generatedClientCredentials()
|
||||||
.map(cc -> {
|
.map(cc -> {
|
||||||
|
@ -240,7 +240,7 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public Result<SebClientConfig> save(final SebClientConfig sebClientConfig) {
|
public Result<SEBClientConfig> save(final SEBClientConfig sebClientConfig) {
|
||||||
return Result.tryCatch(() -> {
|
return Result.tryCatch(() -> {
|
||||||
|
|
||||||
checkUniqueName(sebClientConfig);
|
checkUniqueName(sebClientConfig);
|
||||||
|
@ -287,7 +287,7 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public Result<Collection<SebClientConfig>> allOf(final Set<Long> pks) {
|
public Result<Collection<SEBClientConfig>> allOf(final Set<Long> pks) {
|
||||||
return Result.tryCatch(() -> this.sebClientConfigRecordMapper.selectByExample()
|
return Result.tryCatch(() -> this.sebClientConfigRecordMapper.selectByExample()
|
||||||
.where(SebClientConfigRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
|
.where(SebClientConfigRecordDynamicSqlSupport.id, isIn(new ArrayList<>(pks)))
|
||||||
.build()
|
.build()
|
||||||
|
@ -311,7 +311,7 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public Result<ClientCredentials> getSebClientCredentials(final String modelId) {
|
public Result<ClientCredentials> getSEBClientCredentials(final String modelId) {
|
||||||
return recordByModelId(modelId)
|
return recordByModelId(modelId)
|
||||||
.map(rec -> new ClientCredentials(
|
.map(rec -> new ClientCredentials(
|
||||||
rec.getClientName(),
|
rec.getClientName(),
|
||||||
|
@ -355,7 +355,7 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private Result<SebClientConfig> toDomainModel(final SebClientConfigRecord record) {
|
private Result<SEBClientConfig> toDomainModel(final SebClientConfigRecord record) {
|
||||||
|
|
||||||
final Map<String, AdditionalAttributeRecord> additionalAttributes = this.additionalAttributesDAO
|
final Map<String, AdditionalAttributeRecord> additionalAttributes = this.additionalAttributesDAO
|
||||||
.getAdditionalAttributes(
|
.getAdditionalAttributes(
|
||||||
|
@ -367,37 +367,37 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO {
|
||||||
AdditionalAttributeRecord::getName,
|
AdditionalAttributeRecord::getName,
|
||||||
Function.identity()));
|
Function.identity()));
|
||||||
|
|
||||||
additionalAttributes.get(SebClientConfig.ATTR_CONFIG_PURPOSE);
|
additionalAttributes.get(SEBClientConfig.ATTR_CONFIG_PURPOSE);
|
||||||
|
|
||||||
return Result.tryCatch(() -> new SebClientConfig(
|
return Result.tryCatch(() -> new SEBClientConfig(
|
||||||
record.getId(),
|
record.getId(),
|
||||||
record.getInstitutionId(),
|
record.getInstitutionId(),
|
||||||
record.getName(),
|
record.getName(),
|
||||||
additionalAttributes.containsKey(SebClientConfig.ATTR_CONFIG_PURPOSE)
|
additionalAttributes.containsKey(SEBClientConfig.ATTR_CONFIG_PURPOSE)
|
||||||
? ConfigPurpose
|
? ConfigPurpose
|
||||||
.valueOf(additionalAttributes.get(SebClientConfig.ATTR_CONFIG_PURPOSE).getValue())
|
.valueOf(additionalAttributes.get(SEBClientConfig.ATTR_CONFIG_PURPOSE).getValue())
|
||||||
: ConfigPurpose.START_EXAM,
|
: ConfigPurpose.START_EXAM,
|
||||||
additionalAttributes.containsKey(SebClientConfig.ATTR_FALLBACK) &&
|
additionalAttributes.containsKey(SEBClientConfig.ATTR_FALLBACK) &&
|
||||||
BooleanUtils.toBoolean(additionalAttributes.get(SebClientConfig.ATTR_FALLBACK).getValue()),
|
BooleanUtils.toBoolean(additionalAttributes.get(SEBClientConfig.ATTR_FALLBACK).getValue()),
|
||||||
additionalAttributes.containsKey(SebClientConfig.ATTR_FALLBACK_START_URL)
|
additionalAttributes.containsKey(SEBClientConfig.ATTR_FALLBACK_START_URL)
|
||||||
? additionalAttributes.get(SebClientConfig.ATTR_FALLBACK_START_URL).getValue()
|
? additionalAttributes.get(SEBClientConfig.ATTR_FALLBACK_START_URL).getValue()
|
||||||
: null,
|
: null,
|
||||||
additionalAttributes.containsKey(SebClientConfig.ATTR_FALLBACK_TIMEOUT)
|
additionalAttributes.containsKey(SEBClientConfig.ATTR_FALLBACK_TIMEOUT)
|
||||||
? Long.parseLong(additionalAttributes.get(SebClientConfig.ATTR_FALLBACK_TIMEOUT).getValue())
|
? Long.parseLong(additionalAttributes.get(SEBClientConfig.ATTR_FALLBACK_TIMEOUT).getValue())
|
||||||
: null,
|
: null,
|
||||||
additionalAttributes.containsKey(SebClientConfig.ATTR_FALLBACK_ATTEMPTS)
|
additionalAttributes.containsKey(SEBClientConfig.ATTR_FALLBACK_ATTEMPTS)
|
||||||
? Short.parseShort(additionalAttributes.get(SebClientConfig.ATTR_FALLBACK_ATTEMPTS).getValue())
|
? Short.parseShort(additionalAttributes.get(SEBClientConfig.ATTR_FALLBACK_ATTEMPTS).getValue())
|
||||||
: null,
|
: null,
|
||||||
additionalAttributes.containsKey(SebClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL)
|
additionalAttributes.containsKey(SEBClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL)
|
||||||
? Short.parseShort(
|
? Short.parseShort(
|
||||||
additionalAttributes.get(SebClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL).getValue())
|
additionalAttributes.get(SEBClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL).getValue())
|
||||||
: null,
|
: null,
|
||||||
additionalAttributes.containsKey(SebClientConfig.ATTR_FALLBACK_PASSWORD)
|
additionalAttributes.containsKey(SEBClientConfig.ATTR_FALLBACK_PASSWORD)
|
||||||
? additionalAttributes.get(SebClientConfig.ATTR_FALLBACK_PASSWORD).getValue()
|
? additionalAttributes.get(SEBClientConfig.ATTR_FALLBACK_PASSWORD).getValue()
|
||||||
: null,
|
: null,
|
||||||
null,
|
null,
|
||||||
additionalAttributes.containsKey(SebClientConfig.ATTR_QUIT_PASSWORD)
|
additionalAttributes.containsKey(SEBClientConfig.ATTR_QUIT_PASSWORD)
|
||||||
? additionalAttributes.get(SebClientConfig.ATTR_QUIT_PASSWORD).getValue()
|
? additionalAttributes.get(SEBClientConfig.ATTR_QUIT_PASSWORD).getValue()
|
||||||
: null,
|
: null,
|
||||||
null,
|
null,
|
||||||
record.getDate(),
|
record.getDate(),
|
||||||
|
@ -406,7 +406,7 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO {
|
||||||
BooleanUtils.toBooleanObject(record.getActive())));
|
BooleanUtils.toBooleanObject(record.getActive())));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getEncryptionPassword(final SebClientConfig sebClientConfig) {
|
private String getEncryptionPassword(final SEBClientConfig sebClientConfig) {
|
||||||
if (sebClientConfig.hasEncryptionSecret() &&
|
if (sebClientConfig.hasEncryptionSecret() &&
|
||||||
!sebClientConfig.encryptSecret.equals(sebClientConfig.encryptSecretConfirm)) {
|
!sebClientConfig.encryptSecret.equals(sebClientConfig.encryptSecretConfirm)) {
|
||||||
throw new APIMessageException(ErrorMessage.PASSWORD_MISMATCH);
|
throw new APIMessageException(ErrorMessage.PASSWORD_MISMATCH);
|
||||||
|
@ -420,7 +420,7 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO {
|
||||||
|
|
||||||
// check if same name already exists for the same institution
|
// check if same name already exists for the same institution
|
||||||
// if true an APIMessageException with a field validation error is thrown
|
// if true an APIMessageException with a field validation error is thrown
|
||||||
private void checkUniqueName(final SebClientConfig sebClientConfig) {
|
private void checkUniqueName(final SEBClientConfig sebClientConfig) {
|
||||||
|
|
||||||
final Long otherWithSameName = this.sebClientConfigRecordMapper
|
final Long otherWithSameName = this.sebClientConfigRecordMapper
|
||||||
.countByExample()
|
.countByExample()
|
||||||
|
@ -437,11 +437,11 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveAdditionalAttributes(final SebClientConfig sebClientConfig, final Long configId) {
|
private void saveAdditionalAttributes(final SEBClientConfig sebClientConfig, final Long configId) {
|
||||||
this.additionalAttributesDAO.saveAdditionalAttribute(
|
this.additionalAttributesDAO.saveAdditionalAttribute(
|
||||||
EntityType.SEB_CLIENT_CONFIGURATION,
|
EntityType.SEB_CLIENT_CONFIGURATION,
|
||||||
configId,
|
configId,
|
||||||
SebClientConfig.ATTR_CONFIG_PURPOSE,
|
SEBClientConfig.ATTR_CONFIG_PURPOSE,
|
||||||
(sebClientConfig.configPurpose != null)
|
(sebClientConfig.configPurpose != null)
|
||||||
? sebClientConfig.configPurpose.name()
|
? sebClientConfig.configPurpose.name()
|
||||||
: ConfigPurpose.CONFIGURE_CLIENT.name());
|
: ConfigPurpose.CONFIGURE_CLIENT.name());
|
||||||
|
@ -449,79 +449,79 @@ public class SebClientConfigDAOImpl implements SebClientConfigDAO {
|
||||||
this.additionalAttributesDAO.saveAdditionalAttribute(
|
this.additionalAttributesDAO.saveAdditionalAttribute(
|
||||||
EntityType.SEB_CLIENT_CONFIGURATION,
|
EntityType.SEB_CLIENT_CONFIGURATION,
|
||||||
configId,
|
configId,
|
||||||
SebClientConfig.ATTR_FALLBACK,
|
SEBClientConfig.ATTR_FALLBACK,
|
||||||
String.valueOf(BooleanUtils.isTrue(sebClientConfig.fallback)));
|
String.valueOf(BooleanUtils.isTrue(sebClientConfig.fallback)));
|
||||||
|
|
||||||
if (BooleanUtils.isTrue(sebClientConfig.fallback)) {
|
if (BooleanUtils.isTrue(sebClientConfig.fallback)) {
|
||||||
this.additionalAttributesDAO.saveAdditionalAttribute(
|
this.additionalAttributesDAO.saveAdditionalAttribute(
|
||||||
EntityType.SEB_CLIENT_CONFIGURATION,
|
EntityType.SEB_CLIENT_CONFIGURATION,
|
||||||
configId,
|
configId,
|
||||||
SebClientConfig.ATTR_FALLBACK_START_URL,
|
SEBClientConfig.ATTR_FALLBACK_START_URL,
|
||||||
sebClientConfig.fallbackStartURL);
|
sebClientConfig.fallbackStartURL);
|
||||||
} else {
|
} else {
|
||||||
this.additionalAttributesDAO.delete(
|
this.additionalAttributesDAO.delete(
|
||||||
configId,
|
configId,
|
||||||
SebClientConfig.ATTR_FALLBACK_START_URL);
|
SEBClientConfig.ATTR_FALLBACK_START_URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BooleanUtils.isTrue(sebClientConfig.fallback)) {
|
if (BooleanUtils.isTrue(sebClientConfig.fallback)) {
|
||||||
this.additionalAttributesDAO.saveAdditionalAttribute(
|
this.additionalAttributesDAO.saveAdditionalAttribute(
|
||||||
EntityType.SEB_CLIENT_CONFIGURATION,
|
EntityType.SEB_CLIENT_CONFIGURATION,
|
||||||
configId,
|
configId,
|
||||||
SebClientConfig.ATTR_FALLBACK_TIMEOUT,
|
SEBClientConfig.ATTR_FALLBACK_TIMEOUT,
|
||||||
sebClientConfig.fallbackTimeout.toString());
|
sebClientConfig.fallbackTimeout.toString());
|
||||||
} else {
|
} else {
|
||||||
this.additionalAttributesDAO.delete(
|
this.additionalAttributesDAO.delete(
|
||||||
configId,
|
configId,
|
||||||
SebClientConfig.ATTR_FALLBACK_TIMEOUT);
|
SEBClientConfig.ATTR_FALLBACK_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BooleanUtils.isTrue(sebClientConfig.fallback)) {
|
if (BooleanUtils.isTrue(sebClientConfig.fallback)) {
|
||||||
this.additionalAttributesDAO.saveAdditionalAttribute(
|
this.additionalAttributesDAO.saveAdditionalAttribute(
|
||||||
EntityType.SEB_CLIENT_CONFIGURATION,
|
EntityType.SEB_CLIENT_CONFIGURATION,
|
||||||
configId,
|
configId,
|
||||||
SebClientConfig.ATTR_FALLBACK_ATTEMPTS,
|
SEBClientConfig.ATTR_FALLBACK_ATTEMPTS,
|
||||||
sebClientConfig.fallbackAttempts.toString());
|
sebClientConfig.fallbackAttempts.toString());
|
||||||
} else {
|
} else {
|
||||||
this.additionalAttributesDAO.delete(
|
this.additionalAttributesDAO.delete(
|
||||||
configId,
|
configId,
|
||||||
SebClientConfig.ATTR_FALLBACK_ATTEMPTS);
|
SEBClientConfig.ATTR_FALLBACK_ATTEMPTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BooleanUtils.isTrue(sebClientConfig.fallback)) {
|
if (BooleanUtils.isTrue(sebClientConfig.fallback)) {
|
||||||
this.additionalAttributesDAO.saveAdditionalAttribute(
|
this.additionalAttributesDAO.saveAdditionalAttribute(
|
||||||
EntityType.SEB_CLIENT_CONFIGURATION,
|
EntityType.SEB_CLIENT_CONFIGURATION,
|
||||||
configId,
|
configId,
|
||||||
SebClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL,
|
SEBClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL,
|
||||||
sebClientConfig.fallbackAttemptInterval.toString());
|
sebClientConfig.fallbackAttemptInterval.toString());
|
||||||
} else {
|
} else {
|
||||||
this.additionalAttributesDAO.delete(
|
this.additionalAttributesDAO.delete(
|
||||||
configId,
|
configId,
|
||||||
SebClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL);
|
SEBClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BooleanUtils.isTrue(sebClientConfig.fallback) && StringUtils.isNotBlank(sebClientConfig.fallbackPassword)) {
|
if (BooleanUtils.isTrue(sebClientConfig.fallback) && StringUtils.isNotBlank(sebClientConfig.fallbackPassword)) {
|
||||||
this.additionalAttributesDAO.saveAdditionalAttribute(
|
this.additionalAttributesDAO.saveAdditionalAttribute(
|
||||||
EntityType.SEB_CLIENT_CONFIGURATION,
|
EntityType.SEB_CLIENT_CONFIGURATION,
|
||||||
configId,
|
configId,
|
||||||
SebClientConfig.ATTR_FALLBACK_PASSWORD,
|
SEBClientConfig.ATTR_FALLBACK_PASSWORD,
|
||||||
this.clientCredentialService.encrypt(sebClientConfig.fallbackPassword).toString());
|
this.clientCredentialService.encrypt(sebClientConfig.fallbackPassword).toString());
|
||||||
} else {
|
} else {
|
||||||
this.additionalAttributesDAO.delete(
|
this.additionalAttributesDAO.delete(
|
||||||
configId,
|
configId,
|
||||||
SebClientConfig.ATTR_FALLBACK_PASSWORD);
|
SEBClientConfig.ATTR_FALLBACK_PASSWORD);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BooleanUtils.isTrue(sebClientConfig.fallback) && StringUtils.isNotBlank(sebClientConfig.quitPassword)) {
|
if (BooleanUtils.isTrue(sebClientConfig.fallback) && StringUtils.isNotBlank(sebClientConfig.quitPassword)) {
|
||||||
this.additionalAttributesDAO.saveAdditionalAttribute(
|
this.additionalAttributesDAO.saveAdditionalAttribute(
|
||||||
EntityType.SEB_CLIENT_CONFIGURATION,
|
EntityType.SEB_CLIENT_CONFIGURATION,
|
||||||
configId,
|
configId,
|
||||||
SebClientConfig.ATTR_QUIT_PASSWORD,
|
SEBClientConfig.ATTR_QUIT_PASSWORD,
|
||||||
this.clientCredentialService.encrypt(sebClientConfig.quitPassword).toString());
|
this.clientCredentialService.encrypt(sebClientConfig.quitPassword).toString());
|
||||||
} else {
|
} else {
|
||||||
this.additionalAttributesDAO.delete(
|
this.additionalAttributesDAO.delete(
|
||||||
configId,
|
configId,
|
||||||
SebClientConfig.ATTR_QUIT_PASSWORD);
|
SEBClientConfig.ATTR_QUIT_PASSWORD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import ch.ethz.seb.sebserver.gbl.api.JSONMapper;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator.IndicatorType;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator.IndicatorType;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSebRestriction;
|
import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSEBRestriction;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType;
|
||||||
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
||||||
|
@ -34,7 +34,7 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.dao.AdditionalAttributesDAO
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ExamDAO;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ExamDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.IndicatorDAO;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.IndicatorDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPIService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPIService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.SebRestrictionService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.SEBRestrictionService;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
|
@ -109,14 +109,14 @@ public class ExamAdminServiceImpl implements ExamAdminService {
|
||||||
|
|
||||||
if (lmsSetup.lmsType == LmsType.OPEN_EDX) {
|
if (lmsSetup.lmsType == LmsType.OPEN_EDX) {
|
||||||
final List<String> permissions = Arrays.asList(
|
final List<String> permissions = Arrays.asList(
|
||||||
OpenEdxSebRestriction.PermissionComponent.ALWAYS_ALLOW_STAFF.key,
|
OpenEdxSEBRestriction.PermissionComponent.ALWAYS_ALLOW_STAFF.key,
|
||||||
OpenEdxSebRestriction.PermissionComponent.CHECK_CONFIG_KEY.key);
|
OpenEdxSEBRestriction.PermissionComponent.CHECK_CONFIG_KEY.key);
|
||||||
|
|
||||||
this.additionalAttributesDAO.saveAdditionalAttribute(
|
this.additionalAttributesDAO.saveAdditionalAttribute(
|
||||||
EntityType.EXAM,
|
EntityType.EXAM,
|
||||||
exam.id,
|
exam.id,
|
||||||
SebRestrictionService.SEB_RESTRICTION_ADDITIONAL_PROPERTY_NAME_PREFIX +
|
SEBRestrictionService.SEB_RESTRICTION_ADDITIONAL_PROPERTY_NAME_PREFIX +
|
||||||
OpenEdxSebRestriction.ATTR_PERMISSION_COMPONENTS,
|
OpenEdxSEBRestriction.ATTR_PERMISSION_COMPONENTS,
|
||||||
StringUtils.join(permissions, Constants.LIST_SEPARATOR_CHAR))
|
StringUtils.join(permissions, Constants.LIST_SEPARATOR_CHAR))
|
||||||
.getOrThrow();
|
.getOrThrow();
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ public class ExamAdminServiceImpl implements ExamAdminService {
|
||||||
|
|
||||||
return this.lmsAPIService
|
return this.lmsAPIService
|
||||||
.getLmsAPITemplate(exam.lmsSetupId)
|
.getLmsAPITemplate(exam.lmsSetupId)
|
||||||
.map(lmsAPI -> !lmsAPI.getSebClientRestriction(exam).hasError());
|
.map(lmsAPI -> !lmsAPI.getSEBClientRestriction(exam).hasError());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Chapters;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Chapters;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.QuizData;
|
import ch.ethz.seb.sebserver.gbl.model.exam.QuizData;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.SebRestriction;
|
import ch.ethz.seb.sebserver.gbl.model.exam.SEBRestriction;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Result;
|
import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||||
|
@ -111,37 +111,37 @@ public interface LmsAPITemplate {
|
||||||
|
|
||||||
/** Used to get a list of chapters (display name and chapter-identifier) that can be used to
|
/** Used to get a list of chapters (display name and chapter-identifier) that can be used to
|
||||||
* apply chapter-based SEB restriction for a specified course.
|
* apply chapter-based SEB restriction for a specified course.
|
||||||
*
|
*
|
||||||
* The availability of this depends on the type of LMS and on installed plugins that supports this feature.
|
* The availability of this depends on the type of LMS and on installed plugins that supports this feature.
|
||||||
* If this is not supported by the underling LMS a UnsupportedOperationException will be presented
|
* If this is not supported by the underling LMS a UnsupportedOperationException will be presented
|
||||||
* within the Result.
|
* within the Result.
|
||||||
*
|
*
|
||||||
* @param courseId The course identifier
|
* @param courseId The course identifier
|
||||||
* @return Result referencing to the Chapters model for the given course or to an error when happened. */
|
* @return Result referencing to the Chapters model for the given course or to an error when happened. */
|
||||||
Result<Chapters> getCourseChapters(String courseId);
|
Result<Chapters> getCourseChapters(String courseId);
|
||||||
|
|
||||||
/** Get SEB restriction data form LMS within a SebRestrictionData instance if available
|
/** Get SEB restriction data form LMS within a SEBRestrictionData instance if available
|
||||||
* or a ResourceNotFoundException if not yet available or restricted
|
* or a ResourceNotFoundException if not yet available or restricted
|
||||||
*
|
*
|
||||||
* @param exam the exam to get the SEB restriction data for
|
* @param exam the exam to get the SEB restriction data for
|
||||||
* @return Result refer to the SebRestrictionData instance or to an ResourceNotFoundException if restriction is
|
* @return Result refer to the SEBRestrictionData instance or to an ResourceNotFoundException if restriction is
|
||||||
* missing or to another exception on unexpected error case */
|
* missing or to another exception on unexpected error case */
|
||||||
Result<SebRestriction> getSebClientRestriction(Exam exam);
|
Result<SEBRestriction> getSEBClientRestriction(Exam exam);
|
||||||
|
|
||||||
/** Applies a SEB Client restriction within the LMS with the given attributes.
|
/** Applies a SEB Client restriction within the LMS with the given attributes.
|
||||||
*
|
*
|
||||||
* @param externalExamId The exam identifier from LMS side (Exam.externalId)
|
* @param externalExamId The exam identifier from LMS side (Exam.externalId)
|
||||||
* @param sebRestrictionData containing all data for SEB Client restriction
|
* @param sebRestrictionData containing all data for SEB Client restriction
|
||||||
* @return Result refer to the given SebRestrictionData if restriction was successful or to an error if not */
|
* @return Result refer to the given SEBRestrictionData if restriction was successful or to an error if not */
|
||||||
Result<SebRestriction> applySebClientRestriction(
|
Result<SEBRestriction> applySEBClientRestriction(
|
||||||
String externalExamId,
|
String externalExamId,
|
||||||
SebRestriction sebRestrictionData);
|
SEBRestriction sebRestrictionData);
|
||||||
|
|
||||||
/** Releases an already applied SEB Client restriction within the LMS for a given Exam.
|
/** Releases an already applied SEB Client restriction within the LMS for a given Exam.
|
||||||
* This completely removes the SEB Client restriction on LMS side.
|
* This completely removes the SEB Client restriction on LMS side.
|
||||||
*
|
*
|
||||||
* @param exam the Exam to release the restriction for
|
* @param exam the Exam to release the restriction for
|
||||||
* @return Result refer to the given Exam if successful or to an error if not */
|
* @return Result refer to the given Exam if successful or to an error if not */
|
||||||
Result<Exam> releaseSebClientRestriction(Exam exam);
|
Result<Exam> releaseSEBClientRestriction(Exam exam);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,32 +9,32 @@
|
||||||
package ch.ethz.seb.sebserver.webservice.servicelayer.lms;
|
package ch.ethz.seb.sebserver.webservice.servicelayer.lms;
|
||||||
|
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.SebRestriction;
|
import ch.ethz.seb.sebserver.gbl.model.exam.SEBRestriction;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Result;
|
import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||||
|
|
||||||
public interface SebRestrictionService {
|
public interface SEBRestrictionService {
|
||||||
|
|
||||||
/** Used as name prefix to store additional SEB restriction properties within AdditionalAttribute domain. */
|
/** Used as name prefix to store additional SEB restriction properties within AdditionalAttribute domain. */
|
||||||
String SEB_RESTRICTION_ADDITIONAL_PROPERTY_NAME_PREFIX = "sebRestrictionProp_";
|
String SEB_RESTRICTION_ADDITIONAL_PROPERTY_NAME_PREFIX = "sebRestrictionProp_";
|
||||||
|
|
||||||
String SEB_RESTRICTION_ADDITIONAL_PROPERTY_CONFIG_KEY = "config_key";
|
String SEB_RESTRICTION_ADDITIONAL_PROPERTY_CONFIG_KEY = "config_key";
|
||||||
|
|
||||||
/** Get the SebRestriction properties for specified Exam.
|
/** Get the SEBRestriction properties for specified Exam.
|
||||||
*
|
*
|
||||||
* @param exam the Exam
|
* @param exam the Exam
|
||||||
* @return the SebRestriction properties for specified Exam */
|
* @return the SEBRestriction properties for specified Exam */
|
||||||
Result<SebRestriction> getSebRestrictionFromExam(Exam exam);
|
Result<SEBRestriction> getSEBRestrictionFromExam(Exam exam);
|
||||||
|
|
||||||
/** Saves the given SebRestriction for the given Exam.
|
/** Saves the given SEBRestriction for the given Exam.
|
||||||
*
|
*
|
||||||
* The webservice saves the given browser Exam keys within the Exam record
|
* The webservice saves the given browser Exam keys within the Exam record
|
||||||
* and given additional restriction properties within the Additional attributes linked
|
* and given additional restriction properties within the Additional attributes linked
|
||||||
* to the given Exam.
|
* to the given Exam.
|
||||||
*
|
*
|
||||||
* @param exam the Exam instance to save the SEB restrictions for
|
* @param exam the Exam instance to save the SEB restrictions for
|
||||||
* @param sebRestriction SebRestriction data containing generic and LMS specific restriction attributes
|
* @param sebRestriction SEBRestriction data containing generic and LMS specific restriction attributes
|
||||||
* @return Result refer to the given Exam instance or to an error if happened */
|
* @return Result refer to the given Exam instance or to an error if happened */
|
||||||
Result<Exam> saveSebRestrictionToExam(Exam exam, SebRestriction sebRestriction);
|
Result<Exam> saveSEBRestrictionToExam(Exam exam, SEBRestriction sebRestriction);
|
||||||
|
|
||||||
/** Used to apply SEB Client restriction within the LMS API for a specified Exam.
|
/** Used to apply SEB Client restriction within the LMS API for a specified Exam.
|
||||||
* If the underling LMS Setup API didn't support the SEB restriction feature
|
* If the underling LMS Setup API didn't support the SEB restriction feature
|
||||||
|
@ -42,12 +42,12 @@ public interface SebRestrictionService {
|
||||||
*
|
*
|
||||||
* @param exam the Exam instance
|
* @param exam the Exam instance
|
||||||
* @return Result refer to the Exam instance or to an error if happened */
|
* @return Result refer to the Exam instance or to an error if happened */
|
||||||
Result<Exam> applySebClientRestriction(Exam exam);
|
Result<Exam> applySEBClientRestriction(Exam exam);
|
||||||
|
|
||||||
/** Release SEB Client restriction within the LMS API for a specified Exam.
|
/** Release SEB Client restriction within the LMS API for a specified Exam.
|
||||||
*
|
*
|
||||||
* @param exam the Exam instance
|
* @param exam the Exam instance
|
||||||
* @return Result refer to the Exam instance or to an error if happened */
|
* @return Result refer to the Exam instance or to an error if happened */
|
||||||
Result<Exam> releaseSebClientRestriction(Exam exam);
|
Result<Exam> releaseSEBClientRestriction(Exam exam);
|
||||||
|
|
||||||
}
|
}
|
|
@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gbl.model.Domain.LMS_SETUP;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Chapters;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Chapters;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.QuizData;
|
import ch.ethz.seb.sebserver.gbl.model.exam.QuizData;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.SebRestriction;
|
import ch.ethz.seb.sebserver.gbl.model.exam.SEBRestriction;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult;
|
||||||
|
@ -184,22 +184,22 @@ final class MockupLmsAPITemplate implements LmsAPITemplate {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<SebRestriction> getSebClientRestriction(final Exam exam) {
|
public Result<SEBRestriction> getSEBClientRestriction(final Exam exam) {
|
||||||
log.info("Apply SEB Client restriction for Exam: {}", exam);
|
log.info("Apply SEB Client restriction for Exam: {}", exam);
|
||||||
return Result.ofError(new NoSebRestrictionException());
|
return Result.ofError(new NoSEBRestrictionException());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<SebRestriction> applySebClientRestriction(
|
public Result<SEBRestriction> applySEBClientRestriction(
|
||||||
final String externalExamId,
|
final String externalExamId,
|
||||||
final SebRestriction sebRestrictionData) {
|
final SEBRestriction sebRestrictionData) {
|
||||||
|
|
||||||
log.info("Apply SEB Client restriction: {}", sebRestrictionData);
|
log.info("Apply SEB Client restriction: {}", sebRestrictionData);
|
||||||
return Result.of(sebRestrictionData);
|
return Result.of(sebRestrictionData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<Exam> releaseSebClientRestriction(final Exam exam) {
|
public Result<Exam> releaseSEBClientRestriction(final Exam exam) {
|
||||||
log.info("Release SEB Client restriction for Exam: {}", exam);
|
log.info("Release SEB Client restriction for Exam: {}", exam);
|
||||||
return Result.of(exam);
|
return Result.of(exam);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,14 +8,14 @@
|
||||||
|
|
||||||
package ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl;
|
package ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl;
|
||||||
|
|
||||||
public class NoSebRestrictionException extends RuntimeException {
|
public class NoSEBRestrictionException extends RuntimeException {
|
||||||
|
|
||||||
private static final long serialVersionUID = -6444577025412136884L;
|
private static final long serialVersionUID = -6444577025412136884L;
|
||||||
|
|
||||||
public NoSebRestrictionException() {
|
public NoSEBRestrictionException() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public NoSebRestrictionException(final Throwable cause) {
|
public NoSEBRestrictionException(final Throwable cause) {
|
||||||
super(cause);
|
super(cause);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,29 +28,29 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import ch.ethz.seb.sebserver.gbl.Constants;
|
import ch.ethz.seb.sebserver.gbl.Constants;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.SebRestriction;
|
import ch.ethz.seb.sebserver.gbl.model.exam.SEBRestriction;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.Features;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.Features;
|
||||||
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Result;
|
import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.AdditionalAttributesDAO;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.AdditionalAttributesDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ExamDAO;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ExamDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPIService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPIService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.SebRestrictionService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.SEBRestrictionService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ExamConfigService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ExamConfigService;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@WebServiceProfile
|
@WebServiceProfile
|
||||||
public class SebRestrictionServiceImpl implements SebRestrictionService {
|
public class SEBRestrictionServiceImpl implements SEBRestrictionService {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(SebRestrictionServiceImpl.class);
|
private static final Logger log = LoggerFactory.getLogger(SEBRestrictionServiceImpl.class);
|
||||||
|
|
||||||
private final ExamDAO examDAO;
|
private final ExamDAO examDAO;
|
||||||
private final LmsAPIService lmsAPIService;
|
private final LmsAPIService lmsAPIService;
|
||||||
private final AdditionalAttributesDAO additionalAttributesDAO;
|
private final AdditionalAttributesDAO additionalAttributesDAO;
|
||||||
private final ExamConfigService examConfigService;
|
private final ExamConfigService examConfigService;
|
||||||
|
|
||||||
protected SebRestrictionServiceImpl(
|
protected SEBRestrictionServiceImpl(
|
||||||
final ExamDAO examDAO,
|
final ExamDAO examDAO,
|
||||||
final LmsAPIService lmsAPIService,
|
final LmsAPIService lmsAPIService,
|
||||||
final AdditionalAttributesDAO additionalAttributesDAO,
|
final AdditionalAttributesDAO additionalAttributesDAO,
|
||||||
|
@ -64,7 +64,7 @@ public class SebRestrictionServiceImpl implements SebRestrictionService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public Result<SebRestriction> getSebRestrictionFromExam(final Exam exam) {
|
public Result<SEBRestriction> getSEBRestrictionFromExam(final Exam exam) {
|
||||||
return Result.tryCatch(() -> {
|
return Result.tryCatch(() -> {
|
||||||
// load the config keys from restriction and merge with new generated config keys
|
// load the config keys from restriction and merge with new generated config keys
|
||||||
final Set<String> configKeys = new HashSet<>();
|
final Set<String> configKeys = new HashSet<>();
|
||||||
|
@ -76,7 +76,7 @@ public class SebRestrictionServiceImpl implements SebRestrictionService {
|
||||||
if (generatedKeys != null && !generatedKeys.isEmpty()) {
|
if (generatedKeys != null && !generatedKeys.isEmpty()) {
|
||||||
configKeys.addAll(this.lmsAPIService
|
configKeys.addAll(this.lmsAPIService
|
||||||
.getLmsAPITemplate(exam.lmsSetupId)
|
.getLmsAPITemplate(exam.lmsSetupId)
|
||||||
.flatMap(lmsTemplate -> lmsTemplate.getSebClientRestriction(exam))
|
.flatMap(lmsTemplate -> lmsTemplate.getSEBClientRestriction(exam))
|
||||||
.map(r -> r.configKeys)
|
.map(r -> r.configKeys)
|
||||||
.getOr(Collections.emptyList()));
|
.getOr(Collections.emptyList()));
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ public class SebRestrictionServiceImpl implements SebRestrictionService {
|
||||||
e);
|
e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new SebRestriction(
|
return new SEBRestriction(
|
||||||
exam.id,
|
exam.id,
|
||||||
configKeys,
|
configKeys,
|
||||||
browserExamKeys,
|
browserExamKeys,
|
||||||
|
@ -120,10 +120,10 @@ public class SebRestrictionServiceImpl implements SebRestrictionService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public Result<Exam> saveSebRestrictionToExam(final Exam exam, final SebRestriction sebRestriction) {
|
public Result<Exam> saveSEBRestrictionToExam(final Exam exam, final SEBRestriction sebRestriction) {
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Save SebRestriction: {} for Exam: {}", sebRestriction, exam);
|
log.debug("Save SEBRestriction: {} for Exam: {}", sebRestriction, exam);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.tryCatch(() -> {
|
return Result.tryCatch(() -> {
|
||||||
|
@ -166,7 +166,7 @@ public class SebRestrictionServiceImpl implements SebRestrictionService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<Exam> applySebClientRestriction(final Exam exam) {
|
public Result<Exam> applySEBClientRestriction(final Exam exam) {
|
||||||
if (!this.lmsAPIService
|
if (!this.lmsAPIService
|
||||||
.getLmsSetup(exam.lmsSetupId)
|
.getLmsSetup(exam.lmsSetupId)
|
||||||
.getOrThrow().lmsType.features.contains(Features.SEB_RESTRICTION)) {
|
.getOrThrow().lmsType.features.contains(Features.SEB_RESTRICTION)) {
|
||||||
|
@ -174,16 +174,16 @@ public class SebRestrictionServiceImpl implements SebRestrictionService {
|
||||||
return Result.of(exam);
|
return Result.of(exam);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.getSebRestrictionFromExam(exam)
|
return this.getSEBRestrictionFromExam(exam)
|
||||||
.map(sebRestrictionData -> {
|
.map(sebRestrictionData -> {
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Appling SEB Client restriction on LMS with: {}", sebRestrictionData);
|
log.debug("Applying SEB Client restriction on LMS with: {}", sebRestrictionData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.lmsAPIService
|
return this.lmsAPIService
|
||||||
.getLmsAPITemplate(exam.lmsSetupId)
|
.getLmsAPITemplate(exam.lmsSetupId)
|
||||||
.flatMap(lmsTemplate -> lmsTemplate.applySebClientRestriction(
|
.flatMap(lmsTemplate -> lmsTemplate.applySEBClientRestriction(
|
||||||
exam.externalId,
|
exam.externalId,
|
||||||
sebRestrictionData))
|
sebRestrictionData))
|
||||||
.map(data -> exam)
|
.map(data -> exam)
|
||||||
|
@ -192,7 +192,7 @@ public class SebRestrictionServiceImpl implements SebRestrictionService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<Exam> releaseSebClientRestriction(final Exam exam) {
|
public Result<Exam> releaseSEBClientRestriction(final Exam exam) {
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Release SEB Client restrictions for exam: {}", exam);
|
log.debug("Release SEB Client restrictions for exam: {}", exam);
|
||||||
|
@ -200,7 +200,7 @@ public class SebRestrictionServiceImpl implements SebRestrictionService {
|
||||||
|
|
||||||
return this.lmsAPIService
|
return this.lmsAPIService
|
||||||
.getLmsAPITemplate(exam.lmsSetupId)
|
.getLmsAPITemplate(exam.lmsSetupId)
|
||||||
.flatMap(template -> template.releaseSebClientRestriction(exam));
|
.flatMap(template -> template.releaseSEBClientRestriction(exam));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -26,11 +26,11 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.APIMessage;
|
import ch.ethz.seb.sebserver.gbl.api.APIMessage;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.APIMessage.APIMessageException;
|
import ch.ethz.seb.sebserver.gbl.api.APIMessage.APIMessageException;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.JSONMapper;
|
import ch.ethz.seb.sebserver.gbl.api.JSONMapper;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSebRestriction;
|
import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSEBRestriction;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Result;
|
import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.NoSebRestrictionException;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.NoSEBRestrictionException;
|
||||||
|
|
||||||
public class OpenEdxCourseRestriction {
|
public class OpenEdxCourseRestriction {
|
||||||
|
|
||||||
|
@ -104,24 +104,24 @@ public class OpenEdxCourseRestriction {
|
||||||
return LmsSetupTestResult.ofOkay();
|
return LmsSetupTestResult.ofOkay();
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<OpenEdxSebRestriction> getSebRestriction(final String courseId) {
|
Result<OpenEdxSEBRestriction> getSEBRestriction(final String courseId) {
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("GET SEB Client restriction on course: {}", courseId);
|
log.debug("GET SEB Client restriction on course: {}", courseId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.tryCatch(() -> {
|
return Result.tryCatch(() -> {
|
||||||
final String url = this.lmsSetup.lmsApiUrl + getSebRestrictionUrl(courseId);
|
final String url = this.lmsSetup.lmsApiUrl + getSEBRestrictionUrl(courseId);
|
||||||
final HttpHeaders httpHeaders = new HttpHeaders();
|
final HttpHeaders httpHeaders = new HttpHeaders();
|
||||||
httpHeaders.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
httpHeaders.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
||||||
httpHeaders.add(HttpHeaders.CACHE_CONTROL, "no-cache, no-store, must-revalidate");
|
httpHeaders.add(HttpHeaders.CACHE_CONTROL, "no-cache, no-store, must-revalidate");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final OpenEdxSebRestriction data = this.restTemplate.exchange(
|
final OpenEdxSEBRestriction data = this.restTemplate.exchange(
|
||||||
url,
|
url,
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
new HttpEntity<>(httpHeaders),
|
new HttpEntity<>(httpHeaders),
|
||||||
OpenEdxSebRestriction.class)
|
OpenEdxSEBRestriction.class)
|
||||||
.getBody();
|
.getBody();
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
|
@ -130,36 +130,36 @@ public class OpenEdxCourseRestriction {
|
||||||
return data;
|
return data;
|
||||||
} catch (final HttpClientErrorException ce) {
|
} catch (final HttpClientErrorException ce) {
|
||||||
if (ce.getStatusCode() == HttpStatus.NOT_FOUND || ce.getStatusCode() == HttpStatus.UNAUTHORIZED) {
|
if (ce.getStatusCode() == HttpStatus.NOT_FOUND || ce.getStatusCode() == HttpStatus.UNAUTHORIZED) {
|
||||||
throw new NoSebRestrictionException(ce);
|
throw new NoSEBRestrictionException(ce);
|
||||||
}
|
}
|
||||||
throw ce;
|
throw ce;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<Boolean> putSebRestriction(
|
Result<Boolean> putSEBRestriction(
|
||||||
final String courseId,
|
final String courseId,
|
||||||
final OpenEdxSebRestriction restriction) {
|
final OpenEdxSEBRestriction restriction) {
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("PUT SEB Client restriction on course: {} : {}", courseId, restriction);
|
log.debug("PUT SEB Client restriction on course: {} : {}", courseId, restriction);
|
||||||
}
|
}
|
||||||
|
|
||||||
return handleSebRestriction(processSebRestrictionUpdate(pushSebRestrictionFunction(
|
return handleSEBRestriction(processSEBRestrictionUpdate(pushSEBRestrictionFunction(
|
||||||
restriction,
|
restriction,
|
||||||
courseId)));
|
courseId)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<Boolean> deleteSebRestriction(final String courseId) {
|
Result<Boolean> deleteSEBRestriction(final String courseId) {
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("DELETE SEB Client restriction on course: {}", courseId);
|
log.debug("DELETE SEB Client restriction on course: {}", courseId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return handleSebRestriction(processSebRestrictionUpdate(deleteSebRestrictionFunction(courseId)));
|
return handleSEBRestriction(processSEBRestrictionUpdate(deleteSEBRestrictionFunction(courseId)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private BooleanSupplier processSebRestrictionUpdate(final BooleanSupplier restrictionUpdate) {
|
private BooleanSupplier processSEBRestrictionUpdate(final BooleanSupplier restrictionUpdate) {
|
||||||
return () -> {
|
return () -> {
|
||||||
if (this.restrictionAPIPushCount > 0) {
|
if (this.restrictionAPIPushCount > 0) {
|
||||||
// NOTE: This is a temporary work-around for SEB Restriction API within Open edX SEB integration plugin to
|
// NOTE: This is a temporary work-around for SEB Restriction API within Open edX SEB integration plugin to
|
||||||
|
@ -193,20 +193,20 @@ public class OpenEdxCourseRestriction {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private BooleanSupplier pushSebRestrictionFunction(
|
private BooleanSupplier pushSEBRestrictionFunction(
|
||||||
final OpenEdxSebRestriction restriction,
|
final OpenEdxSEBRestriction restriction,
|
||||||
final String courseId) {
|
final String courseId) {
|
||||||
|
|
||||||
final String url = this.lmsSetup.lmsApiUrl + getSebRestrictionUrl(courseId);
|
final String url = this.lmsSetup.lmsApiUrl + getSEBRestrictionUrl(courseId);
|
||||||
final HttpHeaders httpHeaders = new HttpHeaders();
|
final HttpHeaders httpHeaders = new HttpHeaders();
|
||||||
httpHeaders.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
httpHeaders.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
||||||
httpHeaders.add(HttpHeaders.CACHE_CONTROL, "no-cache, no-store, must-revalidate");
|
httpHeaders.add(HttpHeaders.CACHE_CONTROL, "no-cache, no-store, must-revalidate");
|
||||||
return () -> {
|
return () -> {
|
||||||
final OpenEdxSebRestriction body = this.restTemplate.exchange(
|
final OpenEdxSEBRestriction body = this.restTemplate.exchange(
|
||||||
url,
|
url,
|
||||||
HttpMethod.PUT,
|
HttpMethod.PUT,
|
||||||
new HttpEntity<>(toJson(restriction), httpHeaders),
|
new HttpEntity<>(toJson(restriction), httpHeaders),
|
||||||
OpenEdxSebRestriction.class)
|
OpenEdxSEBRestriction.class)
|
||||||
.getBody();
|
.getBody();
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
|
@ -217,9 +217,9 @@ public class OpenEdxCourseRestriction {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private BooleanSupplier deleteSebRestrictionFunction(final String courseId) {
|
private BooleanSupplier deleteSEBRestrictionFunction(final String courseId) {
|
||||||
|
|
||||||
final String url = this.lmsSetup.lmsApiUrl + getSebRestrictionUrl(courseId);
|
final String url = this.lmsSetup.lmsApiUrl + getSEBRestrictionUrl(courseId);
|
||||||
return () -> {
|
return () -> {
|
||||||
final HttpHeaders httpHeaders = new HttpHeaders();
|
final HttpHeaders httpHeaders = new HttpHeaders();
|
||||||
httpHeaders.add(HttpHeaders.CACHE_CONTROL, "no-cache, no-store, must-revalidate");
|
httpHeaders.add(HttpHeaders.CACHE_CONTROL, "no-cache, no-store, must-revalidate");
|
||||||
|
@ -242,7 +242,7 @@ public class OpenEdxCourseRestriction {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private Result<Boolean> handleSebRestriction(final BooleanSupplier task) {
|
private Result<Boolean> handleSEBRestriction(final BooleanSupplier task) {
|
||||||
return getRestTemplate()
|
return getRestTemplate()
|
||||||
.map(restTemplate -> {
|
.map(restTemplate -> {
|
||||||
try {
|
try {
|
||||||
|
@ -259,7 +259,7 @@ public class OpenEdxCourseRestriction {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getSebRestrictionUrl(final String courseId) {
|
private String getSEBRestrictionUrl(final String courseId) {
|
||||||
return String.format(OPEN_EDX_DEFAULT_COURSE_RESTRICTION_API_PATH, courseId);
|
return String.format(OPEN_EDX_DEFAULT_COURSE_RESTRICTION_API_PATH, courseId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ public class OpenEdxCourseRestriction {
|
||||||
return Result.of(this.restTemplate);
|
return Result.of(this.restTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String toJson(final OpenEdxSebRestriction restriction) {
|
private String toJson(final OpenEdxSEBRestriction restriction) {
|
||||||
try {
|
try {
|
||||||
return this.jsonMapper.writeValueAsString(restriction);
|
return this.jsonMapper.writeValueAsString(restriction);
|
||||||
} catch (final JsonProcessingException e) {
|
} catch (final JsonProcessingException e) {
|
||||||
|
|
|
@ -19,9 +19,9 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Chapters;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Chapters;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSebRestriction;
|
import ch.ethz.seb.sebserver.gbl.model.exam.OpenEdxSEBRestriction;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.QuizData;
|
import ch.ethz.seb.sebserver.gbl.model.exam.QuizData;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.SebRestriction;
|
import ch.ethz.seb.sebserver.gbl.model.exam.SEBRestriction;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Result;
|
import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||||
|
@ -87,40 +87,40 @@ final class OpenEdxLmsAPITemplate implements LmsAPITemplate {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<SebRestriction> getSebClientRestriction(final Exam exam) {
|
public Result<SEBRestriction> getSEBClientRestriction(final Exam exam) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Get SEB Client restriction for Exam: {}", exam);
|
log.debug("Get SEB Client restriction for Exam: {}", exam);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.openEdxCourseRestriction
|
return this.openEdxCourseRestriction
|
||||||
.getSebRestriction(exam.externalId)
|
.getSEBRestriction(exam.externalId)
|
||||||
.map(restriction -> SebRestriction.from(exam.id, restriction));
|
.map(restriction -> SEBRestriction.from(exam.id, restriction));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<SebRestriction> applySebClientRestriction(
|
public Result<SEBRestriction> applySEBClientRestriction(
|
||||||
final String externalExamId,
|
final String externalExamId,
|
||||||
final SebRestriction sebRestrictionData) {
|
final SEBRestriction sebRestrictionData) {
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Apply SEB Client restriction: {}", sebRestrictionData);
|
log.debug("Apply SEB Client restriction: {}", sebRestrictionData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.openEdxCourseRestriction
|
return this.openEdxCourseRestriction
|
||||||
.putSebRestriction(
|
.putSEBRestriction(
|
||||||
externalExamId,
|
externalExamId,
|
||||||
OpenEdxSebRestriction.from(sebRestrictionData))
|
OpenEdxSEBRestriction.from(sebRestrictionData))
|
||||||
.map(result -> sebRestrictionData);
|
.map(result -> sebRestrictionData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<Exam> releaseSebClientRestriction(final Exam exam) {
|
public Result<Exam> releaseSEBClientRestriction(final Exam exam) {
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Release SEB Client restriction for Exam: {}", exam);
|
log.debug("Release SEB Client restriction for Exam: {}", exam);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.openEdxCourseRestriction.deleteSebRestriction(exam.externalId)
|
return this.openEdxCourseRestriction.deleteSEBRestriction(exam.externalId)
|
||||||
.map(result -> exam);
|
.map(result -> exam);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import java.util.Set;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Chapters;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Chapters;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.QuizData;
|
import ch.ethz.seb.sebserver.gbl.model.exam.QuizData;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.SebRestriction;
|
import ch.ethz.seb.sebserver.gbl.model.exam.SEBRestriction;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Result;
|
import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||||
|
@ -75,20 +75,20 @@ public class MoodleLmsAPITemplate implements LmsAPITemplate {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<SebRestriction> getSebClientRestriction(final Exam exam) {
|
public Result<SEBRestriction> getSEBClientRestriction(final Exam exam) {
|
||||||
return Result.ofError(new UnsupportedOperationException("SEB Restriction API not available yet"));
|
return Result.ofError(new UnsupportedOperationException("SEB Restriction API not available yet"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<SebRestriction> applySebClientRestriction(
|
public Result<SEBRestriction> applySEBClientRestriction(
|
||||||
final String externalExamId,
|
final String externalExamId,
|
||||||
final SebRestriction sebRestrictionData) {
|
final SEBRestriction sebRestrictionData) {
|
||||||
|
|
||||||
return Result.ofError(new UnsupportedOperationException("SEB Restriction API not available yet"));
|
return Result.ofError(new UnsupportedOperationException("SEB Restriction API not available yet"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<Exam> releaseSebClientRestriction(final Exam exam) {
|
public Result<Exam> releaseSEBClientRestriction(final Exam exam) {
|
||||||
return Result.ofError(new UnsupportedOperationException("SEB Restriction API not available yet"));
|
return Result.ofError(new UnsupportedOperationException("SEB Restriction API not available yet"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.security.oauth2.provider.ClientDetails;
|
import org.springframework.security.oauth2.provider.ClientDetails;
|
||||||
|
|
||||||
import ch.ethz.seb.sebserver.gbl.async.AsyncServiceSpringConfig;
|
import ch.ethz.seb.sebserver.gbl.async.AsyncServiceSpringConfig;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Result;
|
import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||||
|
|
||||||
public interface ClientConfigService {
|
public interface ClientConfigService {
|
||||||
|
@ -27,32 +27,32 @@ public interface ClientConfigService {
|
||||||
/** The cache name of ClientDetails */
|
/** The cache name of ClientDetails */
|
||||||
String EXAM_CLIENT_DETAILS_CACHE = "EXAM_CLIENT_DETAILS_CACHE";
|
String EXAM_CLIENT_DETAILS_CACHE = "EXAM_CLIENT_DETAILS_CACHE";
|
||||||
|
|
||||||
/** Indicates if there is any SebClientConfiguration for a specified institution.
|
/** Indicates if there is any SEBClientConfiguration for a specified institution.
|
||||||
*
|
*
|
||||||
* @param institutionId the institution identifier
|
* @param institutionId the institution identifier
|
||||||
* @return true if there is any SebClientConfiguration for a specified institution. False otherwise */
|
* @return true if there is any SEBClientConfiguration for a specified institution. False otherwise */
|
||||||
boolean hasSebClientConfigurationForInstitution(Long institutionId);
|
boolean hasSEBClientConfigurationForInstitution(Long institutionId);
|
||||||
|
|
||||||
/** Use this to auto-generate a SebClientConfiguration for a specified institution.
|
/** Use this to auto-generate a SEBClientConfiguration for a specified institution.
|
||||||
* clientName and clientSecret are randomly generated.
|
* clientName and clientSecret are randomly generated.
|
||||||
*
|
*
|
||||||
* @param institutionId the institution identifier
|
* @param institutionId the institution identifier
|
||||||
* @return the created SebClientConfig */
|
* @return the created SEBClientConfiguration */
|
||||||
Result<SebClientConfig> autoCreateSebClientConfigurationForInstitution(Long institutionId);
|
Result<SEBClientConfig> autoCreateSEBClientConfigurationForInstitution(Long institutionId);
|
||||||
|
|
||||||
/** Use this to export a specified SebClientConfiguration within a given OutputStream.
|
/** Use this to export a specified SEBClientConfiguration within a given OutputStream.
|
||||||
* The SEB Client Configuration is exported in the defined SEB Configuration format
|
* The SEB Client Configuration is exported in the defined SEB Configuration format
|
||||||
* as described here: https://www.safeexambrowser.org/developer/seb-file-format.html
|
* as described here: https://www.safeexambrowser.org/developer/seb-file-format.html
|
||||||
*
|
*
|
||||||
* @param out OutputStream to write the export to
|
* @param out OutputStream to write the export to
|
||||||
* @param modelId the model identifier of the SebClientConfiguration to export */
|
* @param modelId the model identifier of the SEBClientConfiguration to export */
|
||||||
void exportSebClientConfiguration(
|
void exportSEBClientConfiguration(
|
||||||
OutputStream out,
|
OutputStream out,
|
||||||
final String modelId);
|
final String modelId);
|
||||||
|
|
||||||
/** Get the ClientDetails for given client name that identifies a SebClientConfig entry.
|
/** Get the ClientDetails for given client name that identifies a SEBClientConfiguration entry.
|
||||||
*
|
*
|
||||||
* @param clientName the client name of a SebClientConfig entry
|
* @param clientName the client name of a SEBClientConfiguration entry
|
||||||
* @return Result refer to the ClientDetails for the specified clientName or to an error if happened */
|
* @return Result refer to the ClientDetails for the specified clientName or to an error if happened */
|
||||||
@Cacheable(
|
@Cacheable(
|
||||||
cacheNames = EXAM_CLIENT_DETAILS_CACHE,
|
cacheNames = EXAM_CLIENT_DETAILS_CACHE,
|
||||||
|
@ -60,12 +60,12 @@ public interface ClientConfigService {
|
||||||
unless = "#result.hasError()")
|
unless = "#result.hasError()")
|
||||||
Result<ClientDetails> getClientConfigDetails(String clientName);
|
Result<ClientDetails> getClientConfigDetails(String clientName);
|
||||||
|
|
||||||
/** Internally used to check OAuth2 access for a active SebClientConfig.
|
/** Internally used to check OAuth2 access for a active SEBClientConfig.
|
||||||
*
|
*
|
||||||
* @param config the SebClientConfig to check access
|
* @param config the SEBClientConfig to check access
|
||||||
* @return true if the system was able to gain an access token for the client. False otherwise */
|
* @return true if the system was able to gain an access token for the client. False otherwise */
|
||||||
boolean checkAccess(SebClientConfig config);
|
boolean checkAccess(SEBClientConfig config);
|
||||||
|
|
||||||
@Async(AsyncServiceSpringConfig.EXECUTOR_BEAN_NAME)
|
@Async(AsyncServiceSpringConfig.EXECUTOR_BEAN_NAME)
|
||||||
void initalCheckAccess(SebClientConfig config);
|
void initalCheckAccess(SEBClientConfig config);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,13 @@ import java.util.Set;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
|
||||||
import ch.ethz.seb.sebserver.gbl.async.AsyncServiceSpringConfig;
|
import ch.ethz.seb.sebserver.gbl.async.AsyncServiceSpringConfig;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionService.Strategy;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionService.Strategy;
|
||||||
|
|
||||||
/** Interface for a SEB Configuration encryption and decryption strategy.
|
/** Interface for a SEB Configuration encryption and decryption strategy.
|
||||||
*
|
*
|
||||||
* To support a new SEB Configuration encryption and decryption strategy use this interface
|
* To support a new SEB Configuration encryption and decryption strategy use this interface
|
||||||
* to implement a concrete strategy for encryption and decryption of SEB configurations */
|
* to implement a concrete strategy for encryption and decryption of SEB configurations */
|
||||||
public interface SebConfigCryptor {
|
public interface SEBConfigCryptor {
|
||||||
|
|
||||||
/** The type of strategies a concrete implementation is supporting
|
/** The type of strategies a concrete implementation is supporting
|
||||||
*
|
*
|
||||||
|
@ -33,23 +33,23 @@ public interface SebConfigCryptor {
|
||||||
*
|
*
|
||||||
* @param output the output stream to write encrypted data to
|
* @param output the output stream to write encrypted data to
|
||||||
* @param input the input stream to read plain data from
|
* @param input the input stream to read plain data from
|
||||||
* @param context the SebConfigEncryptionContext to access strategy specific data needed for encryption */
|
* @param context the SEBConfigEncryptionContext to access strategy specific data needed for encryption */
|
||||||
@Async(AsyncServiceSpringConfig.EXECUTOR_BEAN_NAME)
|
@Async(AsyncServiceSpringConfig.EXECUTOR_BEAN_NAME)
|
||||||
void encrypt(
|
void encrypt(
|
||||||
final OutputStream output,
|
final OutputStream output,
|
||||||
final InputStream input,
|
final InputStream input,
|
||||||
final SebConfigEncryptionContext context);
|
final SEBConfigEncryptionContext context);
|
||||||
|
|
||||||
/** Decrypt an incoming cipher data stream to an outgoing plain text data stream
|
/** Decrypt an incoming cipher data stream to an outgoing plain text data stream
|
||||||
* This uses Springs @Async annotation to run in a separated thread
|
* This uses Springs @Async annotation to run in a separated thread
|
||||||
*
|
*
|
||||||
* @param output the output stream to write the plain text data to
|
* @param output the output stream to write the plain text data to
|
||||||
* @param input the input stream to read the cipher text from
|
* @param input the input stream to read the cipher text from
|
||||||
* @param context the SebConfigEncryptionContext to access strategy specific data needed for encryption */
|
* @param context the SEBConfigEncryptionContext to access strategy specific data needed for encryption */
|
||||||
@Async(AsyncServiceSpringConfig.EXECUTOR_BEAN_NAME)
|
@Async(AsyncServiceSpringConfig.EXECUTOR_BEAN_NAME)
|
||||||
void decrypt(
|
void decrypt(
|
||||||
final OutputStream output,
|
final OutputStream output,
|
||||||
final InputStream input,
|
final InputStream input,
|
||||||
final SebConfigEncryptionContext context);
|
final SEBConfigEncryptionContext context);
|
||||||
|
|
||||||
}
|
}
|
|
@ -10,11 +10,11 @@ package ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig;
|
||||||
|
|
||||||
import java.security.cert.Certificate;
|
import java.security.cert.Certificate;
|
||||||
|
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionService.Strategy;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionService.Strategy;
|
||||||
|
|
||||||
/** Encryption context used to supply additional data for encryption or decryption
|
/** Encryption context used to supply additional data for encryption or decryption
|
||||||
* within a concrete strategy. */
|
* within a concrete strategy. */
|
||||||
public interface SebConfigEncryptionContext {
|
public interface SEBConfigEncryptionContext {
|
||||||
|
|
||||||
/** Get the current encryption/decryption strategy
|
/** Get the current encryption/decryption strategy
|
||||||
*
|
*
|
|
@ -19,7 +19,7 @@ import ch.ethz.seb.sebserver.gbl.async.AsyncServiceSpringConfig;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||||
|
|
||||||
/** Used for SEB Configuration encryption and decryption */
|
/** Used for SEB Configuration encryption and decryption */
|
||||||
public interface SebConfigEncryptionService {
|
public interface SEBConfigEncryptionService {
|
||||||
|
|
||||||
/** Types of encryption strategies */
|
/** Types of encryption strategies */
|
||||||
enum Type {
|
enum Type {
|
||||||
|
@ -67,22 +67,22 @@ public interface SebConfigEncryptionService {
|
||||||
*
|
*
|
||||||
* @param output the output data stream to write the cipher text to
|
* @param output the output data stream to write the cipher text to
|
||||||
* @param input the input stream to read the plain text from
|
* @param input the input stream to read the plain text from
|
||||||
* @param context the SebConfigEncryptionContext to access strategy specific data needed for encryption */
|
* @param context the SEBConfigEncryptionContext to access strategy specific data needed for encryption */
|
||||||
@Async(AsyncServiceSpringConfig.EXECUTOR_BEAN_NAME)
|
@Async(AsyncServiceSpringConfig.EXECUTOR_BEAN_NAME)
|
||||||
void streamEncrypted(
|
void streamEncrypted(
|
||||||
final OutputStream output,
|
final OutputStream output,
|
||||||
final InputStream input,
|
final InputStream input,
|
||||||
SebConfigEncryptionContext context);
|
SEBConfigEncryptionContext context);
|
||||||
|
|
||||||
/** This can be used to stream incoming cipher data to decrypted plain text data output stream.
|
/** This can be used to stream incoming cipher data to decrypted plain text data output stream.
|
||||||
*
|
*
|
||||||
* @param output the output data stream to write encrypted plain text to
|
* @param output the output data stream to write encrypted plain text to
|
||||||
* @param input the input stream to read the cipher text from
|
* @param input the input stream to read the cipher text from
|
||||||
* @param context the SebConfigEncryptionContext to access strategy specific data needed for encryption */
|
* @param context the SEBConfigEncryptionContext to access strategy specific data needed for encryption */
|
||||||
@Async(AsyncServiceSpringConfig.EXECUTOR_BEAN_NAME)
|
@Async(AsyncServiceSpringConfig.EXECUTOR_BEAN_NAME)
|
||||||
Future<Exception> streamDecrypted(
|
Future<Exception> streamDecrypted(
|
||||||
final OutputStream output,
|
final OutputStream output,
|
||||||
final InputStream input,
|
final InputStream input,
|
||||||
final SebConfigEncryptionContext context);
|
final SEBConfigEncryptionContext context);
|
||||||
|
|
||||||
}
|
}
|
|
@ -43,7 +43,7 @@ import ch.ethz.seb.sebserver.WebSecurityConfig;
|
||||||
import ch.ethz.seb.sebserver.gbl.Constants;
|
import ch.ethz.seb.sebserver.gbl.Constants;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.API;
|
import ch.ethz.seb.sebserver.gbl.api.API;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.Institution;
|
import ch.ethz.seb.sebserver.gbl.model.institution.Institution;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig;
|
||||||
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Result;
|
import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||||
|
@ -51,12 +51,12 @@ import ch.ethz.seb.sebserver.webservice.WebserviceInfo;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentialService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentialService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentials;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.client.ClientCredentials;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.InstitutionDAO;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.InstitutionDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.SebClientConfigDAO;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.SEBClientConfigDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ClientConfigService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ClientConfigService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionService.Strategy;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionService.Strategy;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ZipService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ZipService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.impl.SebConfigEncryptionServiceImpl.EncryptionContext;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.impl.SEBConfigEncryptionServiceImpl.EncryptionContext;
|
||||||
import ch.ethz.seb.sebserver.webservice.weblayer.oauth.WebserviceResourceConfiguration;
|
import ch.ethz.seb.sebserver.webservice.weblayer.oauth.WebserviceResourceConfiguration;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
|
@ -99,18 +99,18 @@ public class ClientConfigServiceImpl implements ClientConfigService {
|
||||||
" <string>%s</string>%n";
|
" <string>%s</string>%n";
|
||||||
|
|
||||||
private final InstitutionDAO institutionDAO;
|
private final InstitutionDAO institutionDAO;
|
||||||
private final SebClientConfigDAO sebClientConfigDAO;
|
private final SEBClientConfigDAO sebClientConfigDAO;
|
||||||
private final ClientCredentialService clientCredentialService;
|
private final ClientCredentialService clientCredentialService;
|
||||||
private final SebConfigEncryptionService sebConfigEncryptionService;
|
private final SEBConfigEncryptionService sebConfigEncryptionService;
|
||||||
private final PasswordEncoder clientPasswordEncoder;
|
private final PasswordEncoder clientPasswordEncoder;
|
||||||
private final ZipService zipService;
|
private final ZipService zipService;
|
||||||
private final WebserviceInfo webserviceInfo;
|
private final WebserviceInfo webserviceInfo;
|
||||||
|
|
||||||
protected ClientConfigServiceImpl(
|
protected ClientConfigServiceImpl(
|
||||||
final InstitutionDAO institutionDAO,
|
final InstitutionDAO institutionDAO,
|
||||||
final SebClientConfigDAO sebClientConfigDAO,
|
final SEBClientConfigDAO sebClientConfigDAO,
|
||||||
final ClientCredentialService clientCredentialService,
|
final ClientCredentialService clientCredentialService,
|
||||||
final SebConfigEncryptionService sebConfigEncryptionService,
|
final SEBConfigEncryptionService sebConfigEncryptionService,
|
||||||
final ZipService zipService,
|
final ZipService zipService,
|
||||||
@Qualifier(WebSecurityConfig.CLIENT_PASSWORD_ENCODER_BEAN_NAME) final PasswordEncoder clientPasswordEncoder,
|
@Qualifier(WebSecurityConfig.CLIENT_PASSWORD_ENCODER_BEAN_NAME) final PasswordEncoder clientPasswordEncoder,
|
||||||
final WebserviceInfo webserviceInfo) {
|
final WebserviceInfo webserviceInfo) {
|
||||||
|
@ -125,19 +125,19 @@ public class ClientConfigServiceImpl implements ClientConfigService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasSebClientConfigurationForInstitution(final Long institutionId) {
|
public boolean hasSEBClientConfigurationForInstitution(final Long institutionId) {
|
||||||
final Result<Collection<SebClientConfig>> all = this.sebClientConfigDAO.all(institutionId, true);
|
final Result<Collection<SEBClientConfig>> all = this.sebClientConfigDAO.all(institutionId, true);
|
||||||
return all != null && !all.hasError() && !all.getOrThrow().isEmpty();
|
return all != null && !all.hasError() && !all.getOrThrow().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<SebClientConfig> autoCreateSebClientConfigurationForInstitution(final Long institutionId) {
|
public Result<SEBClientConfig> autoCreateSEBClientConfigurationForInstitution(final Long institutionId) {
|
||||||
return Result.tryCatch(() -> {
|
return Result.tryCatch(() -> {
|
||||||
final Institution institution = this.institutionDAO
|
final Institution institution = this.institutionDAO
|
||||||
.byPK(institutionId)
|
.byPK(institutionId)
|
||||||
.getOrThrow();
|
.getOrThrow();
|
||||||
|
|
||||||
return new SebClientConfig(
|
return new SEBClientConfig(
|
||||||
null,
|
null,
|
||||||
institutionId,
|
institutionId,
|
||||||
institution.name + "_" + UUID.randomUUID(),
|
institution.name + "_" + UUID.randomUUID(),
|
||||||
|
@ -184,11 +184,11 @@ public class ClientConfigServiceImpl implements ClientConfigService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exportSebClientConfiguration(
|
public void exportSEBClientConfiguration(
|
||||||
final OutputStream output,
|
final OutputStream output,
|
||||||
final String modelId) {
|
final String modelId) {
|
||||||
|
|
||||||
final SebClientConfig config = this.sebClientConfigDAO
|
final SEBClientConfig config = this.sebClientConfigDAO
|
||||||
.byModelId(modelId).getOrThrow();
|
.byModelId(modelId).getOrThrow();
|
||||||
|
|
||||||
final CharSequence encryptionPassword = this.sebClientConfigDAO
|
final CharSequence encryptionPassword = this.sebClientConfigDAO
|
||||||
|
@ -236,7 +236,7 @@ public class ClientConfigServiceImpl implements ClientConfigService {
|
||||||
this.zipService.write(output, zipIn);
|
this.zipService.write(output, zipIn);
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("*** Finished Seb client configuration download streaming composition");
|
log.debug("*** Finished SEB client configuration download streaming composition");
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
|
@ -248,35 +248,35 @@ public class ClientConfigServiceImpl implements ClientConfigService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String extractXMLContent(final SebClientConfig config) {
|
private String extractXMLContent(final SEBClientConfig config) {
|
||||||
|
|
||||||
String fallbackAddition = "";
|
String fallbackAddition = "";
|
||||||
if (BooleanUtils.isTrue(config.fallback)) {
|
if (BooleanUtils.isTrue(config.fallback)) {
|
||||||
fallbackAddition += String.format(
|
fallbackAddition += String.format(
|
||||||
SEB_CLIENT_CONFIG_STRING_TEMPLATE,
|
SEB_CLIENT_CONFIG_STRING_TEMPLATE,
|
||||||
SebClientConfig.ATTR_FALLBACK_START_URL,
|
SEBClientConfig.ATTR_FALLBACK_START_URL,
|
||||||
config.fallbackStartURL);
|
config.fallbackStartURL);
|
||||||
|
|
||||||
fallbackAddition += String.format(
|
fallbackAddition += String.format(
|
||||||
SEB_CLIENT_CONFIG_INTEGER_TEMPLATE,
|
SEB_CLIENT_CONFIG_INTEGER_TEMPLATE,
|
||||||
SebClientConfig.ATTR_FALLBACK_TIMEOUT,
|
SEBClientConfig.ATTR_FALLBACK_TIMEOUT,
|
||||||
config.fallbackTimeout);
|
config.fallbackTimeout);
|
||||||
|
|
||||||
fallbackAddition += String.format(
|
fallbackAddition += String.format(
|
||||||
SEB_CLIENT_CONFIG_INTEGER_TEMPLATE,
|
SEB_CLIENT_CONFIG_INTEGER_TEMPLATE,
|
||||||
SebClientConfig.ATTR_FALLBACK_ATTEMPTS,
|
SEBClientConfig.ATTR_FALLBACK_ATTEMPTS,
|
||||||
config.fallbackAttempts);
|
config.fallbackAttempts);
|
||||||
|
|
||||||
fallbackAddition += String.format(
|
fallbackAddition += String.format(
|
||||||
SEB_CLIENT_CONFIG_INTEGER_TEMPLATE,
|
SEB_CLIENT_CONFIG_INTEGER_TEMPLATE,
|
||||||
SebClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL,
|
SEBClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL,
|
||||||
config.fallbackAttemptInterval);
|
config.fallbackAttemptInterval);
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(config.fallbackPassword)) {
|
if (StringUtils.isNotBlank(config.fallbackPassword)) {
|
||||||
final CharSequence decrypt = this.clientCredentialService.decrypt(config.fallbackPassword);
|
final CharSequence decrypt = this.clientCredentialService.decrypt(config.fallbackPassword);
|
||||||
fallbackAddition += String.format(
|
fallbackAddition += String.format(
|
||||||
SEB_CLIENT_CONFIG_STRING_TEMPLATE,
|
SEB_CLIENT_CONFIG_STRING_TEMPLATE,
|
||||||
SebClientConfig.ATTR_FALLBACK_PASSWORD,
|
SEBClientConfig.ATTR_FALLBACK_PASSWORD,
|
||||||
Utils.hash_SHA_256_Base_16(decrypt));
|
Utils.hash_SHA_256_Base_16(decrypt));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,13 +284,13 @@ public class ClientConfigServiceImpl implements ClientConfigService {
|
||||||
final CharSequence decrypt = this.clientCredentialService.decrypt(config.quitPassword);
|
final CharSequence decrypt = this.clientCredentialService.decrypt(config.quitPassword);
|
||||||
fallbackAddition += String.format(
|
fallbackAddition += String.format(
|
||||||
SEB_CLIENT_CONFIG_STRING_TEMPLATE,
|
SEB_CLIENT_CONFIG_STRING_TEMPLATE,
|
||||||
SebClientConfig.ATTR_QUIT_PASSWORD,
|
SEBClientConfig.ATTR_QUIT_PASSWORD,
|
||||||
Utils.hash_SHA_256_Base_16(decrypt));
|
Utils.hash_SHA_256_Base_16(decrypt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final ClientCredentials sebClientCredentials = this.sebClientConfigDAO
|
final ClientCredentials sebClientCredentials = this.sebClientConfigDAO
|
||||||
.getSebClientCredentials(config.getModelId())
|
.getSEBClientCredentials(config.getModelId())
|
||||||
.getOrThrow();
|
.getOrThrow();
|
||||||
final CharSequence plainClientId = sebClientCredentials.clientId;
|
final CharSequence plainClientId = sebClientCredentials.clientId;
|
||||||
final CharSequence plainClientSecret = this.clientCredentialService
|
final CharSequence plainClientSecret = this.clientCredentialService
|
||||||
|
@ -317,7 +317,7 @@ public class ClientConfigServiceImpl implements ClientConfigService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkAccess(final SebClientConfig config) {
|
public boolean checkAccess(final SEBClientConfig config) {
|
||||||
if (!config.isActive()) {
|
if (!config.isActive()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -335,7 +335,7 @@ public class ClientConfigServiceImpl implements ClientConfigService {
|
||||||
final MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
|
final MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
|
||||||
headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);
|
headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);
|
||||||
final ClientCredentials credentials = this.sebClientConfigDAO
|
final ClientCredentials credentials = this.sebClientConfigDAO
|
||||||
.getSebClientCredentials(config.getModelId())
|
.getSEBClientCredentials(config.getModelId())
|
||||||
.getOrThrow();
|
.getOrThrow();
|
||||||
final CharSequence plainClientSecret = this.clientCredentialService.getPlainClientSecret(credentials);
|
final CharSequence plainClientSecret = this.clientCredentialService.getPlainClientSecret(credentials);
|
||||||
final String basicAuth = credentials.clientId +
|
final String basicAuth = credentials.clientId +
|
||||||
|
@ -358,17 +358,17 @@ public class ClientConfigServiceImpl implements ClientConfigService {
|
||||||
if (exchange.getStatusCode().value() == HttpStatus.OK.value()) {
|
if (exchange.getStatusCode().value() == HttpStatus.OK.value()) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
log.warn("Failed to check access SebClientConfig {} response: {}", config, exchange.getStatusCode());
|
log.warn("Failed to check access SEBClientConfig {} response: {}", config, exchange.getStatusCode());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
log.warn("Failed to check access for SebClientConfig: {} cause: {}", config, e.getMessage());
|
log.warn("Failed to check access for SEBClientConfig: {} cause: {}", config, e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initalCheckAccess(final SebClientConfig config) {
|
public void initalCheckAccess(final SEBClientConfig config) {
|
||||||
checkAccess(config);
|
checkAccess(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,7 +378,7 @@ public class ClientConfigServiceImpl implements ClientConfigService {
|
||||||
final InputStream input) {
|
final InputStream input) {
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("*** Seb client configuration with password based encryption");
|
log.debug("*** SEB client configuration with password based encryption");
|
||||||
}
|
}
|
||||||
|
|
||||||
final CharSequence encryptionPasswordPlaintext = (encryptionPassword == StringUtils.EMPTY)
|
final CharSequence encryptionPasswordPlaintext = (encryptionPassword == StringUtils.EMPTY)
|
||||||
|
@ -393,10 +393,10 @@ public class ClientConfigServiceImpl implements ClientConfigService {
|
||||||
encryptionPasswordPlaintext));
|
encryptionPasswordPlaintext));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get a encoded clientSecret for the SebClientConfiguration with specified clientId/clientName.
|
/** Get a encoded clientSecret for the SEBClientConfiguration with specified clientId/clientName.
|
||||||
*
|
*
|
||||||
* @param clientId the clientId/clientName
|
* @param clientId the clientId/clientName
|
||||||
* @return encoded clientSecret for that SebClientConfiguration with clientId or null of not existing */
|
* @return encoded clientSecret for that SEBClientConfiguration with clientId or null of not existing */
|
||||||
private Result<CharSequence> getEncodedClientConfigSecret(final String clientId) {
|
private Result<CharSequence> getEncodedClientConfigSecret(final String clientId) {
|
||||||
return this.sebClientConfigDAO.getConfigPasswordCipherByClientName(clientId)
|
return this.sebClientConfigDAO.getConfigPasswordCipherByClientName(clientId)
|
||||||
.map(cipher -> this.clientPasswordEncoder.encode(this.clientCredentialService.decrypt(cipher)));
|
.map(cipher -> this.clientPasswordEncoder.encode(this.clientCredentialService.decrypt(cipher)));
|
||||||
|
|
|
@ -42,10 +42,10 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ExamConfigurationMapDAO
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ConfigurationFormat;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ConfigurationFormat;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ConfigurationValueValidator;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ConfigurationValueValidator;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ExamConfigService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ExamConfigService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionService.Strategy;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionService.Strategy;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ZipService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ZipService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.impl.SebConfigEncryptionServiceImpl.EncryptionContext;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.impl.SEBConfigEncryptionServiceImpl.EncryptionContext;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
|
@ -60,7 +60,7 @@ public class ExamConfigServiceImpl implements ExamConfigService {
|
||||||
private final Collection<ConfigurationValueValidator> validators;
|
private final Collection<ConfigurationValueValidator> validators;
|
||||||
private final ClientCredentialService clientCredentialService;
|
private final ClientCredentialService clientCredentialService;
|
||||||
private final ZipService zipService;
|
private final ZipService zipService;
|
||||||
private final SebConfigEncryptionService sebConfigEncryptionService;
|
private final SEBConfigEncryptionService sebConfigEncryptionService;
|
||||||
|
|
||||||
protected ExamConfigServiceImpl(
|
protected ExamConfigServiceImpl(
|
||||||
final ExamConfigIO examConfigIO,
|
final ExamConfigIO examConfigIO,
|
||||||
|
@ -69,7 +69,7 @@ public class ExamConfigServiceImpl implements ExamConfigService {
|
||||||
final Collection<ConfigurationValueValidator> validators,
|
final Collection<ConfigurationValueValidator> validators,
|
||||||
final ClientCredentialService clientCredentialService,
|
final ClientCredentialService clientCredentialService,
|
||||||
final ZipService zipService,
|
final ZipService zipService,
|
||||||
final SebConfigEncryptionService sebConfigEncryptionService) {
|
final SEBConfigEncryptionService sebConfigEncryptionService) {
|
||||||
|
|
||||||
this.examConfigIO = examConfigIO;
|
this.examConfigIO = examConfigIO;
|
||||||
this.configurationAttributeDAO = configurationAttributeDAO;
|
this.configurationAttributeDAO = configurationAttributeDAO;
|
||||||
|
@ -180,7 +180,7 @@ public class ExamConfigServiceImpl implements ExamConfigService {
|
||||||
if (StringUtils.isNotBlank(passwordCipher)) {
|
if (StringUtils.isNotBlank(passwordCipher)) {
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("*** Seb exam configuration with password based encryption");
|
log.debug("*** SEB exam configuration with password based encryption");
|
||||||
}
|
}
|
||||||
|
|
||||||
final CharSequence encryptionPasswordPlaintext = this.clientCredentialService
|
final CharSequence encryptionPasswordPlaintext = this.clientCredentialService
|
||||||
|
|
|
@ -21,14 +21,14 @@ import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigCryptor;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigCryptor;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionContext;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionContext;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionService.Strategy;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionService.Strategy;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@WebServiceProfile
|
@WebServiceProfile
|
||||||
public class NoneEncryptor implements SebConfigCryptor {
|
public class NoneEncryptor implements SEBConfigCryptor {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(NoneEncryptor.class);
|
private static final Logger log = LoggerFactory.getLogger(NoneEncryptor.class);
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ public class NoneEncryptor implements SebConfigCryptor {
|
||||||
public void encrypt(
|
public void encrypt(
|
||||||
final OutputStream output,
|
final OutputStream output,
|
||||||
final InputStream input,
|
final InputStream input,
|
||||||
final SebConfigEncryptionContext context) {
|
final SEBConfigEncryptionContext context) {
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("No encryption, write plain input data");
|
log.debug("No encryption, write plain input data");
|
||||||
|
@ -75,7 +75,7 @@ public class NoneEncryptor implements SebConfigCryptor {
|
||||||
public void decrypt(
|
public void decrypt(
|
||||||
final OutputStream output,
|
final OutputStream output,
|
||||||
final InputStream input,
|
final InputStream input,
|
||||||
final SebConfigEncryptionContext context) {
|
final SEBConfigEncryptionContext context) {
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("No decryption, read plain input data");
|
log.debug("No decryption, read plain input data");
|
||||||
|
|
|
@ -29,14 +29,14 @@ import org.springframework.stereotype.Component;
|
||||||
import ch.ethz.seb.sebserver.gbl.Constants;
|
import ch.ethz.seb.sebserver.gbl.Constants;
|
||||||
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigCryptor;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigCryptor;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionContext;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionContext;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionService.Strategy;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionService.Strategy;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Component
|
@Component
|
||||||
@WebServiceProfile
|
@WebServiceProfile
|
||||||
public class PasswordEncryptor implements SebConfigCryptor {
|
public class PasswordEncryptor implements SEBConfigCryptor {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(PasswordEncryptor.class);
|
private static final Logger log = LoggerFactory.getLogger(PasswordEncryptor.class);
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public class PasswordEncryptor implements SebConfigCryptor {
|
||||||
public void encrypt(
|
public void encrypt(
|
||||||
final OutputStream output,
|
final OutputStream output,
|
||||||
final InputStream input,
|
final InputStream input,
|
||||||
final SebConfigEncryptionContext context) {
|
final SEBConfigEncryptionContext context) {
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("*** Start streaming asynchronous encryption");
|
log.debug("*** Start streaming asynchronous encryption");
|
||||||
|
@ -108,7 +108,7 @@ public class PasswordEncryptor implements SebConfigCryptor {
|
||||||
public void decrypt(
|
public void decrypt(
|
||||||
final OutputStream output,
|
final OutputStream output,
|
||||||
final InputStream input,
|
final InputStream input,
|
||||||
final SebConfigEncryptionContext context) {
|
final SEBConfigEncryptionContext context) {
|
||||||
|
|
||||||
final CharSequence password = context.getPassword();
|
final CharSequence password = context.getPassword();
|
||||||
|
|
||||||
|
|
|
@ -36,21 +36,21 @@ import ch.ethz.seb.sebserver.gbl.Constants;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.APIMessage;
|
import ch.ethz.seb.sebserver.gbl.api.APIMessage;
|
||||||
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Result;
|
import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigCryptor;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigCryptor;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionContext;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionContext;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionService;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@WebServiceProfile
|
@WebServiceProfile
|
||||||
public final class SebConfigEncryptionServiceImpl implements SebConfigEncryptionService {
|
public final class SEBConfigEncryptionServiceImpl implements SEBConfigEncryptionService {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(SebConfigEncryptionServiceImpl.class);
|
private static final Logger log = LoggerFactory.getLogger(SEBConfigEncryptionServiceImpl.class);
|
||||||
|
|
||||||
private final Map<Strategy, SebConfigCryptor> encryptors;
|
private final Map<Strategy, SEBConfigCryptor> encryptors;
|
||||||
|
|
||||||
public SebConfigEncryptionServiceImpl(
|
public SEBConfigEncryptionServiceImpl(
|
||||||
final Collection<SebConfigCryptor> encryptors) {
|
final Collection<SEBConfigCryptor> encryptors) {
|
||||||
|
|
||||||
this.encryptors = encryptors
|
this.encryptors = encryptors
|
||||||
.stream()
|
.stream()
|
||||||
|
@ -64,7 +64,7 @@ public final class SebConfigEncryptionServiceImpl implements SebConfigEncryption
|
||||||
public void streamEncrypted(
|
public void streamEncrypted(
|
||||||
final OutputStream output,
|
final OutputStream output,
|
||||||
final InputStream input,
|
final InputStream input,
|
||||||
final SebConfigEncryptionContext context) {
|
final SEBConfigEncryptionContext context) {
|
||||||
|
|
||||||
final Strategy strategy = context.getStrategy();
|
final Strategy strategy = context.getStrategy();
|
||||||
PipedOutputStream pout = null;
|
PipedOutputStream pout = null;
|
||||||
|
@ -108,7 +108,7 @@ public final class SebConfigEncryptionServiceImpl implements SebConfigEncryption
|
||||||
public Future<Exception> streamDecrypted(
|
public Future<Exception> streamDecrypted(
|
||||||
final OutputStream output,
|
final OutputStream output,
|
||||||
final InputStream input,
|
final InputStream input,
|
||||||
final SebConfigEncryptionContext context) {
|
final SEBConfigEncryptionContext context) {
|
||||||
|
|
||||||
PipedOutputStream pout = null;
|
PipedOutputStream pout = null;
|
||||||
PipedInputStream pin = null;
|
PipedInputStream pin = null;
|
||||||
|
@ -180,8 +180,8 @@ public final class SebConfigEncryptionServiceImpl implements SebConfigEncryption
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Result<SebConfigCryptor> getEncryptor(final Strategy strategy) {
|
private Result<SEBConfigCryptor> getEncryptor(final Strategy strategy) {
|
||||||
final SebConfigCryptor encryptor = this.encryptors.get(strategy);
|
final SEBConfigCryptor encryptor = this.encryptors.get(strategy);
|
||||||
if (encryptor == null) {
|
if (encryptor == null) {
|
||||||
return Result.ofError(new IllegalArgumentException("No Encryptor found for strategy : " + strategy));
|
return Result.ofError(new IllegalArgumentException("No Encryptor found for strategy : " + strategy));
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ public final class SebConfigEncryptionServiceImpl implements SebConfigEncryption
|
||||||
return Result.of(encryptor);
|
return Result.of(encryptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
static class EncryptionContext implements SebConfigEncryptionContext {
|
static class EncryptionContext implements SEBConfigEncryptionContext {
|
||||||
|
|
||||||
public final Strategy strategy;
|
public final Strategy strategy;
|
||||||
public final CharSequence password;
|
public final CharSequence password;
|
||||||
|
@ -223,12 +223,12 @@ public final class SebConfigEncryptionServiceImpl implements SebConfigEncryption
|
||||||
return this.certificateStore.apply(key);
|
return this.certificateStore.apply(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SebConfigEncryptionContext contextOf(final Strategy strategy, final CharSequence password) {
|
static SEBConfigEncryptionContext contextOf(final Strategy strategy, final CharSequence password) {
|
||||||
checkPasswordBased(strategy);
|
checkPasswordBased(strategy);
|
||||||
return new EncryptionContext(strategy, password, null);
|
return new EncryptionContext(strategy, password, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SebConfigEncryptionContext contextOf(
|
static SEBConfigEncryptionContext contextOf(
|
||||||
final Strategy strategy,
|
final Strategy strategy,
|
||||||
final Function<CharSequence, Certificate> certificateStore) {
|
final Function<CharSequence, Certificate> certificateStore) {
|
||||||
|
|
||||||
|
@ -248,11 +248,11 @@ public final class SebConfigEncryptionServiceImpl implements SebConfigEncryption
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SebConfigEncryptionContext contextOfPlainText() {
|
public static SEBConfigEncryptionContext contextOfPlainText() {
|
||||||
return new EncryptionContext(Strategy.PLAIN_TEXT, null, null);
|
return new EncryptionContext(Strategy.PLAIN_TEXT, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SebConfigEncryptionContext contextOf(final CharSequence password) {
|
public static SEBConfigEncryptionContext contextOf(final CharSequence password) {
|
||||||
return new EncryptionContext(null, password, null);
|
return new EncryptionContext(null, password, null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ public interface ExamSessionService {
|
||||||
*
|
*
|
||||||
* @param examId The Exam identifier
|
* @param examId The Exam identifier
|
||||||
* @return true if the given Exam has currently no active client connection, false otherwise. */
|
* @return true if the given Exam has currently no active client connection, false otherwise. */
|
||||||
boolean hasActiveSebClientConnections(final Long examId);
|
boolean hasActiveSEBClientConnections(final Long examId);
|
||||||
|
|
||||||
/** Checks if a specified Exam has at least a default SEB Exam configuration attached.
|
/** Checks if a specified Exam has at least a default SEB Exam configuration attached.
|
||||||
*
|
*
|
||||||
|
|
|
@ -15,7 +15,7 @@ import ch.ethz.seb.sebserver.gbl.model.session.ClientEvent;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Result;
|
import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||||
|
|
||||||
/** Service interface defining functionality to handle SEB client connections on running exams. */
|
/** Service interface defining functionality to handle SEB client connections on running exams. */
|
||||||
public interface SebClientConnectionService {
|
public interface SEBClientConnectionService {
|
||||||
|
|
||||||
/** Use this to get the underling ExamSessionService
|
/** Use this to get the underling ExamSessionService
|
||||||
*
|
*
|
|
@ -25,7 +25,7 @@ import ch.ethz.seb.sebserver.webservice.WebserviceInfo;
|
||||||
*
|
*
|
||||||
* SEB instructions are sent as response of a SEB Ping on a active SEB Connection
|
* SEB instructions are sent as response of a SEB Ping on a active SEB Connection
|
||||||
* If there is an instruction in the queue for a specified SEB Client. */
|
* If there is an instruction in the queue for a specified SEB Client. */
|
||||||
public interface SebInstructionService {
|
public interface SEBInstructionService {
|
||||||
|
|
||||||
/** Get the underling WebserviceInfo
|
/** Get the underling WebserviceInfo
|
||||||
*
|
*
|
|
@ -133,8 +133,8 @@ public class ExamConfigUpdateServiceImpl implements ExamConfigUpdateService {
|
||||||
if (exam.getStatus() == ExamStatus.RUNNING || this.examAdminService.isRestricted(exam).getOr(false)) {
|
if (exam.getStatus() == ExamStatus.RUNNING || this.examAdminService.isRestricted(exam).getOr(false)) {
|
||||||
|
|
||||||
this.examUpdateHandler
|
this.examUpdateHandler
|
||||||
.getSebRestrictionService()
|
.getSEBRestrictionService()
|
||||||
.applySebClientRestriction(exam)
|
.applySEBClientRestriction(exam)
|
||||||
.onError(t -> log.error("Failed to update SEB Client restriction for Exam: {}", exam, t));
|
.onError(t -> log.error("Failed to update SEB Client restriction for Exam: {}", exam, t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,8 +203,8 @@ public class ExamConfigUpdateServiceImpl implements ExamConfigUpdateService {
|
||||||
// update seb client restriction if the feature is activated for the exam
|
// update seb client restriction if the feature is activated for the exam
|
||||||
if (this.examAdminService.isRestricted(exam).getOr(false)) {
|
if (this.examAdminService.isRestricted(exam).getOr(false)) {
|
||||||
this.examUpdateHandler
|
this.examUpdateHandler
|
||||||
.getSebRestrictionService()
|
.getSEBRestrictionService()
|
||||||
.applySebClientRestriction(exam)
|
.applySEBClientRestriction(exam)
|
||||||
.onError(t -> log.error(
|
.onError(t -> log.error(
|
||||||
"Failed to update SEB Client restriction for Exam: {}",
|
"Failed to update SEB Client restriction for Exam: {}",
|
||||||
exam,
|
exam,
|
||||||
|
@ -229,7 +229,7 @@ public class ExamConfigUpdateServiceImpl implements ExamConfigUpdateService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkActiveClientConnections(final Exam exam) {
|
private void checkActiveClientConnections(final Exam exam) {
|
||||||
if (this.examSessionService.hasActiveSebClientConnections(exam.id)) {
|
if (this.examSessionService.hasActiveSEBClientConnections(exam.id)) {
|
||||||
throw new APIMessage.APIMessageException(
|
throw new APIMessage.APIMessageException(
|
||||||
ErrorMessage.INTEGRITY_VALIDATION,
|
ErrorMessage.INTEGRITY_VALIDATION,
|
||||||
"Integrity violation: There are currently active SEB Client connection.");
|
"Integrity violation: There are currently active SEB Client connection.");
|
||||||
|
|
|
@ -36,7 +36,7 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ExamConfigService
|
||||||
/** Handles caching for exam session and defines caching for following object:
|
/** Handles caching for exam session and defines caching for following object:
|
||||||
*
|
*
|
||||||
* - Running exams (examId -> Exam)
|
* - Running exams (examId -> Exam)
|
||||||
* - in-memory exam configuration (examId -> InMemorySebConfig)
|
* - in-memory exam configuration (examId -> InMemorySEBConfig)
|
||||||
* - active client connections (connectionToken -> ClientConnectionDataInternal)
|
* - active client connections (connectionToken -> ClientConnectionDataInternal)
|
||||||
* - client event records for last ping store (connectionToken -> ReusableClientEventRecord) */
|
* - client event records for last ping store (connectionToken -> ReusableClientEventRecord) */
|
||||||
@Lazy
|
@Lazy
|
||||||
|
@ -163,7 +163,7 @@ public class ExamSessionCacheService {
|
||||||
cacheNames = CACHE_NAME_SEB_CONFIG_EXAM,
|
cacheNames = CACHE_NAME_SEB_CONFIG_EXAM,
|
||||||
key = "#exam.id",
|
key = "#exam.id",
|
||||||
sync = true)
|
sync = true)
|
||||||
public InMemorySebConfig getDefaultSebConfigForExam(final Exam exam) {
|
public InMemorySEBConfig getDefaultSEBConfigForExam(final Exam exam) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
final ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
|
final ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
|
||||||
|
@ -172,7 +172,7 @@ public class ExamSessionCacheService {
|
||||||
exam.institutionId,
|
exam.institutionId,
|
||||||
exam.id);
|
exam.id);
|
||||||
|
|
||||||
return new InMemorySebConfig(configId, exam.id, byteOut.toByteArray());
|
return new InMemorySEBConfig(configId, exam.id, byteOut.toByteArray());
|
||||||
|
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
log.error("Unexpected error while getting default exam configuration for running exam; {}", exam, e);
|
log.error("Unexpected error while getting default exam configuration for running exam; {}", exam, e);
|
||||||
|
@ -183,7 +183,7 @@ public class ExamSessionCacheService {
|
||||||
@CacheEvict(
|
@CacheEvict(
|
||||||
cacheNames = CACHE_NAME_SEB_CONFIG_EXAM,
|
cacheNames = CACHE_NAME_SEB_CONFIG_EXAM,
|
||||||
key = "#exam.id")
|
key = "#exam.id")
|
||||||
public void evictDefaultSebConfig(final Exam exam) {
|
public void evictDefaultSEBConfig(final Exam exam) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Eviction of default SEB Configuration from cache for exam: {}", exam.id);
|
log.debug("Eviction of default SEB Configuration from cache for exam: {}", exam.id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.SEBServerInitEvent;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
||||||
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ExamDAO;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ExamDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.SebClientConnectionService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.session.SEBClientConnectionService;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@WebServiceProfile
|
@WebServiceProfile
|
||||||
|
@ -35,7 +35,7 @@ class ExamSessionControlTask implements DisposableBean {
|
||||||
private static final Logger log = LoggerFactory.getLogger(ExamSessionControlTask.class);
|
private static final Logger log = LoggerFactory.getLogger(ExamSessionControlTask.class);
|
||||||
|
|
||||||
private final ExamDAO examDAO;
|
private final ExamDAO examDAO;
|
||||||
private final SebClientConnectionService sebClientConnectionService;
|
private final SEBClientConnectionService sebClientConnectionService;
|
||||||
private final ExamUpdateHandler examUpdateHandler;
|
private final ExamUpdateHandler examUpdateHandler;
|
||||||
private final Long examTimePrefix;
|
private final Long examTimePrefix;
|
||||||
private final Long examTimeSuffix;
|
private final Long examTimeSuffix;
|
||||||
|
@ -58,7 +58,7 @@ class ExamSessionControlTask implements DisposableBean {
|
||||||
|
|
||||||
protected ExamSessionControlTask(
|
protected ExamSessionControlTask(
|
||||||
final ExamDAO examDAO,
|
final ExamDAO examDAO,
|
||||||
final SebClientConnectionService sebClientConnectionService,
|
final SEBClientConnectionService sebClientConnectionService,
|
||||||
final ExamUpdateHandler examUpdateHandler,
|
final ExamUpdateHandler examUpdateHandler,
|
||||||
@Value("${sebserver.webservice.api.exam.time-prefix:3600000}") final Long examTimePrefix,
|
@Value("${sebserver.webservice.api.exam.time-prefix:3600000}") final Long examTimePrefix,
|
||||||
@Value("${sebserver.webservice.api.exam.time-suffix:3600000}") final Long examTimeSuffix,
|
@Value("${sebserver.webservice.api.exam.time-suffix:3600000}") final Long examTimeSuffix,
|
||||||
|
|
|
@ -44,7 +44,7 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ExamDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.FilterMap;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.FilterMap;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.IndicatorDAO;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.IndicatorDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPIService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPIService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.NoSebRestrictionException;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.NoSEBRestrictionException;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamSessionService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamSessionService;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
|
@ -131,12 +131,12 @@ public class ExamSessionServiceImpl implements ExamSessionService {
|
||||||
if (t.testCourseRestrictionAPI().isOk()) {
|
if (t.testCourseRestrictionAPI().isOk()) {
|
||||||
return t;
|
return t;
|
||||||
} else {
|
} else {
|
||||||
throw new NoSebRestrictionException();
|
throw new NoSEBRestrictionException();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.flatMap(t -> t.getSebClientRestriction(exam))
|
.flatMap(t -> t.getSEBClientRestriction(exam))
|
||||||
.onError(error -> {
|
.onError(error -> {
|
||||||
if (error instanceof NoSebRestrictionException) {
|
if (error instanceof NoSEBRestrictionException) {
|
||||||
result.add(
|
result.add(
|
||||||
ErrorMessage.EXAM_CONSISTENCY_VALIDATION_SEB_RESTRICTION
|
ErrorMessage.EXAM_CONSISTENCY_VALIDATION_SEB_RESTRICTION
|
||||||
.of(exam.getModelId()));
|
.of(exam.getModelId()));
|
||||||
|
@ -160,7 +160,7 @@ public class ExamSessionServiceImpl implements ExamSessionService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasActiveSebClientConnections(final Long examId) {
|
public boolean hasActiveSEBClientConnections(final Long examId) {
|
||||||
if (examId == null || !this.isExamRunning(examId)) {
|
if (examId == null || !this.isExamRunning(examId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -271,17 +271,17 @@ public class ExamSessionServiceImpl implements ExamSessionService {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Trying to get exam from InMemorySebConfig");
|
log.debug("Trying to get exam from InMemorySEBConfig");
|
||||||
}
|
}
|
||||||
|
|
||||||
final Exam exam = this.getRunningExam(connection.examId)
|
final Exam exam = this.getRunningExam(connection.examId)
|
||||||
.getOrThrow();
|
.getOrThrow();
|
||||||
|
|
||||||
final InMemorySebConfig sebConfigForExam = this.examSessionCacheService
|
final InMemorySEBConfig sebConfigForExam = this.examSessionCacheService
|
||||||
.getDefaultSebConfigForExam(exam);
|
.getDefaultSEBConfigForExam(exam);
|
||||||
|
|
||||||
if (sebConfigForExam == null) {
|
if (sebConfigForExam == null) {
|
||||||
log.error("Failed to get and cache InMemorySebConfig for connection: {}", connection);
|
log.error("Failed to get and cache InMemorySEBConfig for connection: {}", connection);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,7 +342,7 @@ public class ExamSessionServiceImpl implements ExamSessionService {
|
||||||
public Result<Exam> flushCache(final Exam exam) {
|
public Result<Exam> flushCache(final Exam exam) {
|
||||||
return Result.tryCatch(() -> {
|
return Result.tryCatch(() -> {
|
||||||
this.examSessionCacheService.evict(exam);
|
this.examSessionCacheService.evict(exam);
|
||||||
this.examSessionCacheService.evictDefaultSebConfig(exam);
|
this.examSessionCacheService.evictDefaultSEBConfig(exam);
|
||||||
this.clientConnectionDAO
|
this.clientConnectionDAO
|
||||||
.getConnectionTokens(exam.id)
|
.getConnectionTokens(exam.id)
|
||||||
.getOrElse(Collections::emptyList)
|
.getOrElse(Collections::emptyList)
|
||||||
|
|
|
@ -23,7 +23,7 @@ import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||||
import ch.ethz.seb.sebserver.webservice.WebserviceInfo;
|
import ch.ethz.seb.sebserver.webservice.WebserviceInfo;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ExamDAO;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ExamDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.SebRestrictionService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.SEBRestrictionService;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
|
@ -33,13 +33,13 @@ class ExamUpdateHandler {
|
||||||
private static final Logger log = LoggerFactory.getLogger(ExamUpdateHandler.class);
|
private static final Logger log = LoggerFactory.getLogger(ExamUpdateHandler.class);
|
||||||
|
|
||||||
private final ExamDAO examDAO;
|
private final ExamDAO examDAO;
|
||||||
private final SebRestrictionService sebRestrictionService;
|
private final SEBRestrictionService sebRestrictionService;
|
||||||
private final String updatePrefix;
|
private final String updatePrefix;
|
||||||
private final Long examTimeSuffix;
|
private final Long examTimeSuffix;
|
||||||
|
|
||||||
public ExamUpdateHandler(
|
public ExamUpdateHandler(
|
||||||
final ExamDAO examDAO,
|
final ExamDAO examDAO,
|
||||||
final SebRestrictionService sebRestrictionService,
|
final SEBRestrictionService sebRestrictionService,
|
||||||
final WebserviceInfo webserviceInfo,
|
final WebserviceInfo webserviceInfo,
|
||||||
@Value("${sebserver.webservice.api.exam.time-suffix:3600000}") final Long examTimeSuffix) {
|
@Value("${sebserver.webservice.api.exam.time-suffix:3600000}") final Long examTimeSuffix) {
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ class ExamUpdateHandler {
|
||||||
this.examTimeSuffix = examTimeSuffix;
|
this.examTimeSuffix = examTimeSuffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SebRestrictionService getSebRestrictionService() {
|
public SEBRestrictionService getSEBRestrictionService() {
|
||||||
return this.sebRestrictionService;
|
return this.sebRestrictionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ class ExamUpdateHandler {
|
||||||
exam.id,
|
exam.id,
|
||||||
ExamStatus.RUNNING,
|
ExamStatus.RUNNING,
|
||||||
updateId))
|
updateId))
|
||||||
.flatMap(this.sebRestrictionService::applySebClientRestriction)
|
.flatMap(this.sebRestrictionService::applySEBClientRestriction)
|
||||||
.flatMap(e -> this.examDAO.releaseLock(e.id, updateId))
|
.flatMap(e -> this.examDAO.releaseLock(e.id, updateId))
|
||||||
.onError(error -> this.examDAO.forceUnlock(exam.id)
|
.onError(error -> this.examDAO.forceUnlock(exam.id)
|
||||||
.onError(unlockError -> log.error("Failed to force unlock update look for exam: {}", exam.id)))
|
.onError(unlockError -> log.error("Failed to force unlock update look for exam: {}", exam.id)))
|
||||||
|
@ -100,7 +100,7 @@ class ExamUpdateHandler {
|
||||||
exam.id,
|
exam.id,
|
||||||
ExamStatus.FINISHED,
|
ExamStatus.FINISHED,
|
||||||
updateId))
|
updateId))
|
||||||
.flatMap(this.sebRestrictionService::releaseSebClientRestriction)
|
.flatMap(this.sebRestrictionService::releaseSEBClientRestriction)
|
||||||
.flatMap(e -> this.examDAO.releaseLock(e.id, updateId))
|
.flatMap(e -> this.examDAO.releaseLock(e.id, updateId))
|
||||||
.onError(error -> this.examDAO.forceUnlock(exam.id))
|
.onError(error -> this.examDAO.forceUnlock(exam.id))
|
||||||
.getOrThrow();
|
.getOrThrow();
|
||||||
|
|
|
@ -8,13 +8,13 @@
|
||||||
|
|
||||||
package ch.ethz.seb.sebserver.webservice.servicelayer.session.impl;
|
package ch.ethz.seb.sebserver.webservice.servicelayer.session.impl;
|
||||||
|
|
||||||
public final class InMemorySebConfig {
|
public final class InMemorySEBConfig {
|
||||||
|
|
||||||
public final Long configId;
|
public final Long configId;
|
||||||
public final Long examId;
|
public final Long examId;
|
||||||
private final byte[] data;
|
private final byte[] data;
|
||||||
|
|
||||||
protected InMemorySebConfig(final Long configId, final Long examId, final byte[] data) {
|
protected InMemorySEBConfig(final Long configId, final Long examId, final byte[] data) {
|
||||||
super();
|
super();
|
||||||
this.configId = configId;
|
this.configId = configId;
|
||||||
this.examId = examId;
|
this.examId = examId;
|
||||||
|
@ -50,7 +50,7 @@ public final class InMemorySebConfig {
|
||||||
return false;
|
return false;
|
||||||
if (getClass() != obj.getClass())
|
if (getClass() != obj.getClass())
|
||||||
return false;
|
return false;
|
||||||
final InMemorySebConfig other = (InMemorySebConfig) obj;
|
final InMemorySEBConfig other = (InMemorySEBConfig) obj;
|
||||||
if (this.configId == null) {
|
if (this.configId == null) {
|
||||||
if (other.configId != null)
|
if (other.configId != null)
|
||||||
return false;
|
return false;
|
|
@ -33,20 +33,20 @@ import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||||
import ch.ethz.seb.sebserver.webservice.WebserviceInfo;
|
import ch.ethz.seb.sebserver.webservice.WebserviceInfo;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ClientConnectionDAO;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ClientConnectionDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.SebClientConfigDAO;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.SEBClientConfigDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.EventHandlingStrategy;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.session.EventHandlingStrategy;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamSessionService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamSessionService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.PingHandlingStrategy;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.session.PingHandlingStrategy;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.SebClientConnectionService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.session.SEBClientConnectionService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.SebInstructionService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.session.SEBInstructionService;
|
||||||
import ch.ethz.seb.sebserver.webservice.weblayer.api.APIConstraintViolationException;
|
import ch.ethz.seb.sebserver.webservice.weblayer.api.APIConstraintViolationException;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@WebServiceProfile
|
@WebServiceProfile
|
||||||
public class SebClientConnectionServiceImpl implements SebClientConnectionService {
|
public class SEBClientConnectionServiceImpl implements SEBClientConnectionService {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(SebClientConnectionServiceImpl.class);
|
private static final Logger log = LoggerFactory.getLogger(SEBClientConnectionServiceImpl.class);
|
||||||
|
|
||||||
private final ExamSessionService examSessionService;
|
private final ExamSessionService examSessionService;
|
||||||
private final ExamSessionCacheService examSessionCacheService;
|
private final ExamSessionCacheService examSessionCacheService;
|
||||||
|
@ -54,16 +54,16 @@ public class SebClientConnectionServiceImpl implements SebClientConnectionServic
|
||||||
private final EventHandlingStrategy eventHandlingStrategy;
|
private final EventHandlingStrategy eventHandlingStrategy;
|
||||||
private final ClientConnectionDAO clientConnectionDAO;
|
private final ClientConnectionDAO clientConnectionDAO;
|
||||||
private final PingHandlingStrategy pingHandlingStrategy;
|
private final PingHandlingStrategy pingHandlingStrategy;
|
||||||
private final SebClientConfigDAO sebClientConfigDAO;
|
private final SEBClientConfigDAO sebClientConfigDAO;
|
||||||
private final SebInstructionService sebInstructionService;
|
private final SEBInstructionService sebInstructionService;
|
||||||
private final WebserviceInfo webserviceInfo;
|
private final WebserviceInfo webserviceInfo;
|
||||||
|
|
||||||
protected SebClientConnectionServiceImpl(
|
protected SEBClientConnectionServiceImpl(
|
||||||
final ExamSessionService examSessionService,
|
final ExamSessionService examSessionService,
|
||||||
final EventHandlingStrategyFactory eventHandlingStrategyFactory,
|
final EventHandlingStrategyFactory eventHandlingStrategyFactory,
|
||||||
final PingHandlingStrategyFactory pingHandlingStrategyFactory,
|
final PingHandlingStrategyFactory pingHandlingStrategyFactory,
|
||||||
final SebClientConfigDAO sebClientConfigDAO,
|
final SEBClientConfigDAO sebClientConfigDAO,
|
||||||
final SebInstructionService sebInstructionService) {
|
final SEBInstructionService sebInstructionService) {
|
||||||
|
|
||||||
this.examSessionService = examSessionService;
|
this.examSessionService = examSessionService;
|
||||||
this.examSessionCacheService = examSessionService.getExamSessionCacheService();
|
this.examSessionCacheService = examSessionService.getExamSessionCacheService();
|
|
@ -33,14 +33,14 @@ import ch.ethz.seb.sebserver.webservice.WebserviceInfo;
|
||||||
import ch.ethz.seb.sebserver.webservice.datalayer.batis.model.ClientInstructionRecord;
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.model.ClientInstructionRecord;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ClientConnectionDAO;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ClientConnectionDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ClientInstructionDAO;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ClientInstructionDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.SebInstructionService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.session.SEBInstructionService;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@WebServiceProfile
|
@WebServiceProfile
|
||||||
public class SebInstructionServiceImpl implements SebInstructionService {
|
public class SEBInstructionServiceImpl implements SEBInstructionService {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(SebInstructionServiceImpl.class);
|
private static final Logger log = LoggerFactory.getLogger(SEBInstructionServiceImpl.class);
|
||||||
|
|
||||||
private static final String JSON_INST = "instruction";
|
private static final String JSON_INST = "instruction";
|
||||||
private static final String JSON_ATTR = "attributes";
|
private static final String JSON_ATTR = "attributes";
|
||||||
|
@ -52,7 +52,7 @@ public class SebInstructionServiceImpl implements SebInstructionService {
|
||||||
|
|
||||||
private long lastRefresh = 0;
|
private long lastRefresh = 0;
|
||||||
|
|
||||||
public SebInstructionServiceImpl(
|
public SEBInstructionServiceImpl(
|
||||||
final WebserviceInfo webserviceInfo,
|
final WebserviceInfo webserviceInfo,
|
||||||
final ClientConnectionDAO clientConnectionDAO,
|
final ClientConnectionDAO clientConnectionDAO,
|
||||||
final ClientInstructionDAO clientInstructionDAO) {
|
final ClientInstructionDAO clientInstructionDAO) {
|
||||||
|
@ -71,7 +71,7 @@ public class SebInstructionServiceImpl implements SebInstructionService {
|
||||||
@EventListener(SEBServerInitEvent.class)
|
@EventListener(SEBServerInitEvent.class)
|
||||||
public void init() {
|
public void init() {
|
||||||
SEBServerInit.INIT_LOGGER.info("------>");
|
SEBServerInit.INIT_LOGGER.info("------>");
|
||||||
SEBServerInit.INIT_LOGGER.info("------> Run SebInstructionService...");
|
SEBServerInit.INIT_LOGGER.info("------> Run SEBInstructionService...");
|
||||||
|
|
||||||
loadInstruction()
|
loadInstruction()
|
||||||
.onError(
|
.onError(
|
|
@ -48,9 +48,9 @@ import ch.ethz.seb.sebserver.gbl.model.session.RunningExamInfo;
|
||||||
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.LmsSetupDAO;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.LmsSetupDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.SebClientConfigDAO;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.SEBClientConfigDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamSessionService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamSessionService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.SebClientConnectionService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.session.SEBClientConnectionService;
|
||||||
|
|
||||||
@WebServiceProfile
|
@WebServiceProfile
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -61,16 +61,16 @@ public class ExamAPI_V1_Controller {
|
||||||
|
|
||||||
private final LmsSetupDAO lmsSetupDAO;
|
private final LmsSetupDAO lmsSetupDAO;
|
||||||
private final ExamSessionService examSessionService;
|
private final ExamSessionService examSessionService;
|
||||||
private final SebClientConnectionService sebClientConnectionService;
|
private final SEBClientConnectionService sebClientConnectionService;
|
||||||
private final SebClientConfigDAO sebClientConfigDAO;
|
private final SEBClientConfigDAO sebClientConfigDAO;
|
||||||
private final JSONMapper jsonMapper;
|
private final JSONMapper jsonMapper;
|
||||||
private final Executor executor;
|
private final Executor executor;
|
||||||
|
|
||||||
protected ExamAPI_V1_Controller(
|
protected ExamAPI_V1_Controller(
|
||||||
final LmsSetupDAO lmsSetupDAO,
|
final LmsSetupDAO lmsSetupDAO,
|
||||||
final ExamSessionService examSessionService,
|
final ExamSessionService examSessionService,
|
||||||
final SebClientConnectionService sebClientConnectionService,
|
final SEBClientConnectionService sebClientConnectionService,
|
||||||
final SebClientConfigDAO sebClientConfigDAO,
|
final SEBClientConfigDAO sebClientConfigDAO,
|
||||||
final JSONMapper jsonMapper,
|
final JSONMapper jsonMapper,
|
||||||
@Qualifier(AsyncServiceSpringConfig.EXAM_API_EXECUTOR_BEAN_NAME) final Executor executor) {
|
@Qualifier(AsyncServiceSpringConfig.EXAM_API_EXECUTOR_BEAN_NAME) final Executor executor) {
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ import ch.ethz.seb.sebserver.gbl.model.PageSortOrder;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Chapters;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Chapters;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.QuizData;
|
import ch.ethz.seb.sebserver.gbl.model.exam.QuizData;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.SebRestriction;
|
import ch.ethz.seb.sebserver.gbl.model.exam.SEBRestriction;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.Features;
|
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.Features;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.user.UserRole;
|
import ch.ethz.seb.sebserver.gbl.model.user.UserRole;
|
||||||
|
@ -69,7 +69,7 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.dao.UserActivityLogDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.UserDAO;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.UserDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.exam.ExamAdminService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.exam.ExamAdminService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPIService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPIService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.SebRestrictionService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.lms.SEBRestrictionService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ExamConfigService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ExamConfigService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamSessionService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamSessionService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.validation.BeanValidationService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.validation.BeanValidationService;
|
||||||
|
@ -87,7 +87,7 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
|
||||||
private final LmsAPIService lmsAPIService;
|
private final LmsAPIService lmsAPIService;
|
||||||
private final ExamConfigService sebExamConfigService;
|
private final ExamConfigService sebExamConfigService;
|
||||||
private final ExamSessionService examSessionService;
|
private final ExamSessionService examSessionService;
|
||||||
private final SebRestrictionService sebRestrictionService;
|
private final SEBRestrictionService sebRestrictionService;
|
||||||
|
|
||||||
public ExamAdministrationController(
|
public ExamAdministrationController(
|
||||||
final AuthorizationService authorization,
|
final AuthorizationService authorization,
|
||||||
|
@ -101,7 +101,7 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
|
||||||
final ExamAdminService examAdminService,
|
final ExamAdminService examAdminService,
|
||||||
final ExamConfigService sebExamConfigService,
|
final ExamConfigService sebExamConfigService,
|
||||||
final ExamSessionService examSessionService,
|
final ExamSessionService examSessionService,
|
||||||
final SebRestrictionService sebRestrictionService) {
|
final SEBRestrictionService sebRestrictionService) {
|
||||||
|
|
||||||
super(authorization,
|
super(authorization,
|
||||||
bulkActionService,
|
bulkActionService,
|
||||||
|
@ -257,7 +257,7 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
|
||||||
+ API.EXAM_ADMINISTRATION_CHECK_RESTRICTION_PATH_SEGMENT,
|
+ API.EXAM_ADMINISTRATION_CHECK_RESTRICTION_PATH_SEGMENT,
|
||||||
method = RequestMethod.GET,
|
method = RequestMethod.GET,
|
||||||
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||||
public Boolean checkSebRestriction(
|
public Boolean checkSEBRestriction(
|
||||||
@PathVariable final Long modelId,
|
@PathVariable final Long modelId,
|
||||||
@RequestParam(
|
@RequestParam(
|
||||||
name = API.PARAM_INSTITUTION_ID,
|
name = API.PARAM_INSTITUTION_ID,
|
||||||
|
@ -275,7 +275,7 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
|
||||||
+ API.EXAM_ADMINISTRATION_SEB_RESTRICTION_PATH_SEGMENT,
|
+ API.EXAM_ADMINISTRATION_SEB_RESTRICTION_PATH_SEGMENT,
|
||||||
method = RequestMethod.GET,
|
method = RequestMethod.GET,
|
||||||
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||||
public SebRestriction getSebRestriction(
|
public SEBRestriction getSEBRestriction(
|
||||||
@RequestParam(
|
@RequestParam(
|
||||||
name = API.PARAM_INSTITUTION_ID,
|
name = API.PARAM_INSTITUTION_ID,
|
||||||
required = true,
|
required = true,
|
||||||
|
@ -285,7 +285,7 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
|
||||||
checkModifyPrivilege(institutionId);
|
checkModifyPrivilege(institutionId);
|
||||||
return this.entityDAO.byPK(modelId)
|
return this.entityDAO.byPK(modelId)
|
||||||
.flatMap(this.authorization::checkRead)
|
.flatMap(this.authorization::checkRead)
|
||||||
.flatMap(this.sebRestrictionService::getSebRestrictionFromExam)
|
.flatMap(this.sebRestrictionService::getSEBRestrictionFromExam)
|
||||||
.getOrThrow();
|
.getOrThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,20 +294,20 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
|
||||||
+ API.EXAM_ADMINISTRATION_SEB_RESTRICTION_PATH_SEGMENT,
|
+ API.EXAM_ADMINISTRATION_SEB_RESTRICTION_PATH_SEGMENT,
|
||||||
method = RequestMethod.POST,
|
method = RequestMethod.POST,
|
||||||
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||||
public Exam saveSebRestrictionData(
|
public Exam saveSEBRestrictionData(
|
||||||
@RequestParam(
|
@RequestParam(
|
||||||
name = API.PARAM_INSTITUTION_ID,
|
name = API.PARAM_INSTITUTION_ID,
|
||||||
required = true,
|
required = true,
|
||||||
defaultValue = UserService.USERS_INSTITUTION_AS_DEFAULT) final Long institutionId,
|
defaultValue = UserService.USERS_INSTITUTION_AS_DEFAULT) final Long institutionId,
|
||||||
@PathVariable(API.PARAM_MODEL_ID) final Long examId,
|
@PathVariable(API.PARAM_MODEL_ID) final Long examId,
|
||||||
@Valid @RequestBody final SebRestriction sebRestriction) {
|
@Valid @RequestBody final SEBRestriction sebRestriction) {
|
||||||
|
|
||||||
checkModifyPrivilege(institutionId);
|
checkModifyPrivilege(institutionId);
|
||||||
return this.entityDAO.byPK(examId)
|
return this.entityDAO.byPK(examId)
|
||||||
.flatMap(this.authorization::checkModify)
|
.flatMap(this.authorization::checkModify)
|
||||||
.flatMap(exam -> this.sebRestrictionService.saveSebRestrictionToExam(exam, sebRestriction))
|
.flatMap(exam -> this.sebRestrictionService.saveSEBRestrictionToExam(exam, sebRestriction))
|
||||||
.flatMap(exam -> this.examAdminService.isRestricted(exam).getOrThrow()
|
.flatMap(exam -> this.examAdminService.isRestricted(exam).getOrThrow()
|
||||||
? this.applySebRestriction(exam, true)
|
? this.applySEBRestriction(exam, true)
|
||||||
: Result.of(exam))
|
: Result.of(exam))
|
||||||
.getOrThrow();
|
.getOrThrow();
|
||||||
}
|
}
|
||||||
|
@ -317,7 +317,7 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
|
||||||
+ API.EXAM_ADMINISTRATION_SEB_RESTRICTION_PATH_SEGMENT,
|
+ API.EXAM_ADMINISTRATION_SEB_RESTRICTION_PATH_SEGMENT,
|
||||||
method = RequestMethod.PUT,
|
method = RequestMethod.PUT,
|
||||||
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||||
public Exam applySebRestriction(
|
public Exam applySEBRestriction(
|
||||||
@RequestParam(
|
@RequestParam(
|
||||||
name = API.PARAM_INSTITUTION_ID,
|
name = API.PARAM_INSTITUTION_ID,
|
||||||
required = true,
|
required = true,
|
||||||
|
@ -327,7 +327,7 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
|
||||||
checkModifyPrivilege(institutionId);
|
checkModifyPrivilege(institutionId);
|
||||||
return this.entityDAO.byPK(examlId)
|
return this.entityDAO.byPK(examlId)
|
||||||
.flatMap(this.authorization::checkModify)
|
.flatMap(this.authorization::checkModify)
|
||||||
.flatMap(exam -> this.applySebRestriction(exam, true))
|
.flatMap(exam -> this.applySEBRestriction(exam, true))
|
||||||
.flatMap(this.userActivityLogDAO::logModify)
|
.flatMap(this.userActivityLogDAO::logModify)
|
||||||
.getOrThrow();
|
.getOrThrow();
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
|
||||||
+ API.EXAM_ADMINISTRATION_SEB_RESTRICTION_PATH_SEGMENT,
|
+ API.EXAM_ADMINISTRATION_SEB_RESTRICTION_PATH_SEGMENT,
|
||||||
method = RequestMethod.DELETE,
|
method = RequestMethod.DELETE,
|
||||||
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||||
public Exam deleteSebRestriction(
|
public Exam deleteSEBRestriction(
|
||||||
@RequestParam(
|
@RequestParam(
|
||||||
name = API.PARAM_INSTITUTION_ID,
|
name = API.PARAM_INSTITUTION_ID,
|
||||||
required = true,
|
required = true,
|
||||||
|
@ -347,7 +347,7 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
|
||||||
checkModifyPrivilege(institutionId);
|
checkModifyPrivilege(institutionId);
|
||||||
return this.entityDAO.byPK(examlId)
|
return this.entityDAO.byPK(examlId)
|
||||||
.flatMap(this.authorization::checkModify)
|
.flatMap(this.authorization::checkModify)
|
||||||
.flatMap(exam -> this.applySebRestriction(exam, false))
|
.flatMap(exam -> this.applySEBRestriction(exam, false))
|
||||||
.flatMap(this.userActivityLogDAO::logModify)
|
.flatMap(this.userActivityLogDAO::logModify)
|
||||||
.getOrThrow();
|
.getOrThrow();
|
||||||
}
|
}
|
||||||
|
@ -445,8 +445,8 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
|
||||||
return exam;
|
return exam;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Result<Exam> checkNoActiveSebClientConnections(final Exam exam) {
|
private Result<Exam> checkNoActiveSEBClientConnections(final Exam exam) {
|
||||||
if (this.examSessionService.hasActiveSebClientConnections(exam.id)) {
|
if (this.examSessionService.hasActiveSEBClientConnections(exam.id)) {
|
||||||
return Result.ofError(new APIMessageException(
|
return Result.ofError(new APIMessageException(
|
||||||
APIMessage.ErrorMessage.INTEGRITY_VALIDATION
|
APIMessage.ErrorMessage.INTEGRITY_VALIDATION
|
||||||
.of("Exam currently has active SEB Client connections.")));
|
.of("Exam currently has active SEB Client connections.")));
|
||||||
|
@ -455,7 +455,7 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
|
||||||
return Result.of(exam);
|
return Result.of(exam);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Result<Exam> applySebRestriction(final Exam exam, final boolean restrict) {
|
private Result<Exam> applySEBRestriction(final Exam exam, final boolean restrict) {
|
||||||
final LmsSetup lmsSetup = this.lmsAPIService.getLmsSetup(exam.lmsSetupId)
|
final LmsSetup lmsSetup = this.lmsAPIService.getLmsSetup(exam.lmsSetupId)
|
||||||
.getOrThrow();
|
.getOrThrow();
|
||||||
|
|
||||||
|
@ -474,18 +474,18 @@ public class ExamAdministrationController extends EntityController<Exam, Exam> {
|
||||||
.of("The LMS for this Exam has no SEB restriction feature")));
|
.of("The LMS for this Exam has no SEB restriction feature")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.examSessionService.hasActiveSebClientConnections(exam.id)) {
|
if (this.examSessionService.hasActiveSEBClientConnections(exam.id)) {
|
||||||
return Result.ofError(new APIMessageException(
|
return Result.ofError(new APIMessageException(
|
||||||
APIMessage.ErrorMessage.INTEGRITY_VALIDATION
|
APIMessage.ErrorMessage.INTEGRITY_VALIDATION
|
||||||
.of("Exam currently has active SEB Client connections.")));
|
.of("Exam currently has active SEB Client connections.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.checkNoActiveSebClientConnections(exam)
|
return this.checkNoActiveSEBClientConnections(exam)
|
||||||
.flatMap(this.sebRestrictionService::applySebClientRestriction)
|
.flatMap(this.sebRestrictionService::applySEBClientRestriction)
|
||||||
.flatMap(e -> this.examDAO.setSebRestriction(exam.id, restrict));
|
.flatMap(e -> this.examDAO.setSEBRestriction(exam.id, restrict));
|
||||||
} else {
|
} else {
|
||||||
return this.sebRestrictionService.releaseSebClientRestriction(exam)
|
return this.sebRestrictionService.releaseSEBClientRestriction(exam)
|
||||||
.flatMap(e -> this.examDAO.setSebRestriction(exam.id, restrict));
|
.flatMap(e -> this.examDAO.setSEBRestriction(exam.id, restrict));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -237,7 +237,7 @@ public class ExamConfigurationMappingController extends EntityController<ExamCon
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExamConfigurationMap checkNoActiveClientConnections(final ExamConfigurationMap entity) {
|
private ExamConfigurationMap checkNoActiveClientConnections(final ExamConfigurationMap entity) {
|
||||||
if (this.examSessionService.hasActiveSebClientConnections(entity.examId)) {
|
if (this.examSessionService.hasActiveSEBClientConnections(entity.examId)) {
|
||||||
throw new APIMessageException(ErrorMessage.INTEGRITY_VALIDATION.of(
|
throw new APIMessageException(ErrorMessage.INTEGRITY_VALIDATION.of(
|
||||||
"The Exam is currently running and has active SEB Client connections"));
|
"The Exam is currently running and has active SEB Client connections"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,8 +50,8 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.authorization.PermissionDen
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.authorization.UserService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.authorization.UserService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.FilterMap;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.FilterMap;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamSessionService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.session.ExamSessionService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.SebClientConnectionService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.session.SEBClientConnectionService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.session.SebInstructionService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.session.SEBInstructionService;
|
||||||
|
|
||||||
@WebServiceProfile
|
@WebServiceProfile
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -60,15 +60,15 @@ public class ExamMonitoringController {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(ExamMonitoringController.class);
|
private static final Logger log = LoggerFactory.getLogger(ExamMonitoringController.class);
|
||||||
|
|
||||||
private final SebClientConnectionService sebClientConnectionService;
|
private final SEBClientConnectionService sebClientConnectionService;
|
||||||
private final ExamSessionService examSessionService;
|
private final ExamSessionService examSessionService;
|
||||||
private final SebInstructionService sebInstructionService;
|
private final SEBInstructionService sebInstructionService;
|
||||||
private final AuthorizationService authorization;
|
private final AuthorizationService authorization;
|
||||||
private final PaginationService paginationService;
|
private final PaginationService paginationService;
|
||||||
|
|
||||||
public ExamMonitoringController(
|
public ExamMonitoringController(
|
||||||
final SebClientConnectionService sebClientConnectionService,
|
final SEBClientConnectionService sebClientConnectionService,
|
||||||
final SebInstructionService sebInstructionService,
|
final SEBInstructionService sebInstructionService,
|
||||||
final AuthorizationService authorization,
|
final AuthorizationService authorization,
|
||||||
final PaginationService paginationService) {
|
final PaginationService paginationService) {
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ import ch.ethz.seb.sebserver.gbl.api.API;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.APIMessage;
|
import ch.ethz.seb.sebserver.gbl.api.APIMessage;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.POSTMapper;
|
import ch.ethz.seb.sebserver.gbl.api.POSTMapper;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.Domain;
|
import ch.ethz.seb.sebserver.gbl.model.Domain;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.user.PasswordChange;
|
import ch.ethz.seb.sebserver.gbl.model.user.PasswordChange;
|
||||||
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Result;
|
import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||||
|
@ -45,7 +45,7 @@ import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.SebClientConfigRe
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.PaginationService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.PaginationService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.authorization.AuthorizationService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.authorization.AuthorizationService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.bulkaction.BulkActionService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.bulkaction.BulkActionService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.SebClientConfigDAO;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.SEBClientConfigDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.UserActivityLogDAO;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.UserActivityLogDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ClientConfigService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ClientConfigService;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.validation.BeanValidationService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.validation.BeanValidationService;
|
||||||
|
@ -54,12 +54,12 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.validation.BeanValidationSe
|
||||||
@RestController
|
@RestController
|
||||||
@EnableAsync
|
@EnableAsync
|
||||||
@RequestMapping("${sebserver.webservice.api.admin.endpoint}" + API.SEB_CLIENT_CONFIG_ENDPOINT)
|
@RequestMapping("${sebserver.webservice.api.admin.endpoint}" + API.SEB_CLIENT_CONFIG_ENDPOINT)
|
||||||
public class SebClientConfigController extends ActivatableEntityController<SebClientConfig, SebClientConfig> {
|
public class SEBClientConfigController extends ActivatableEntityController<SEBClientConfig, SEBClientConfig> {
|
||||||
|
|
||||||
private final ClientConfigService sebClientConfigService;
|
private final ClientConfigService sebClientConfigService;
|
||||||
|
|
||||||
public SebClientConfigController(
|
public SEBClientConfigController(
|
||||||
final SebClientConfigDAO sebClientConfigDAO,
|
final SEBClientConfigDAO sebClientConfigDAO,
|
||||||
final AuthorizationService authorization,
|
final AuthorizationService authorization,
|
||||||
final UserActivityLogDAO userActivityLogDAO,
|
final UserActivityLogDAO userActivityLogDAO,
|
||||||
final BulkActionService bulkActionService,
|
final BulkActionService bulkActionService,
|
||||||
|
@ -96,7 +96,7 @@ public class SebClientConfigController extends ActivatableEntityController<SebCl
|
||||||
pout = new PipedOutputStream();
|
pout = new PipedOutputStream();
|
||||||
pin = new PipedInputStream(pout);
|
pin = new PipedInputStream(pout);
|
||||||
|
|
||||||
this.sebClientConfigService.exportSebClientConfiguration(
|
this.sebClientConfigService.exportSEBClientConfiguration(
|
||||||
pout,
|
pout,
|
||||||
modelId);
|
modelId);
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ public class SebClientConfigController extends ActivatableEntityController<SebCl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SebClientConfig createNew(final POSTMapper postParams) {
|
protected SEBClientConfig createNew(final POSTMapper postParams) {
|
||||||
|
|
||||||
final Long institutionId = postParams.getLong(
|
final Long institutionId = postParams.getLong(
|
||||||
Domain.SEB_CLIENT_CONFIGURATION.ATTR_INSTITUTION_ID);
|
Domain.SEB_CLIENT_CONFIGURATION.ATTR_INSTITUTION_ID);
|
||||||
|
@ -126,7 +126,7 @@ public class SebClientConfigController extends ActivatableEntityController<SebCl
|
||||||
Domain.SEB_CLIENT_CONFIGURATION.ATTR_DATE,
|
Domain.SEB_CLIENT_CONFIGURATION.ATTR_DATE,
|
||||||
DateTime.now(DateTimeZone.UTC).toString(Constants.DEFAULT_DATE_TIME_FORMAT));
|
DateTime.now(DateTimeZone.UTC).toString(Constants.DEFAULT_DATE_TIME_FORMAT));
|
||||||
|
|
||||||
return new SebClientConfig(institutionId, postParams);
|
return new SEBClientConfig(institutionId, postParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -135,19 +135,19 @@ public class SebClientConfigController extends ActivatableEntityController<SebCl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Result<SebClientConfig> validForCreate(final SebClientConfig entity) {
|
protected Result<SEBClientConfig> validForCreate(final SEBClientConfig entity) {
|
||||||
return super.validForCreate(entity)
|
return super.validForCreate(entity)
|
||||||
.map(this::checkPasswordMatch);
|
.map(this::checkPasswordMatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Result<SebClientConfig> validForSave(final SebClientConfig entity) {
|
protected Result<SEBClientConfig> validForSave(final SEBClientConfig entity) {
|
||||||
return super.validForSave(entity)
|
return super.validForSave(entity)
|
||||||
.map(this::checkPasswordMatch);
|
.map(this::checkPasswordMatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Result<SebClientConfig> notifySaved(final SebClientConfig entity) {
|
protected Result<SEBClientConfig> notifySaved(final SEBClientConfig entity) {
|
||||||
if (entity.isActive()) {
|
if (entity.isActive()) {
|
||||||
// try to get access token for SEB client
|
// try to get access token for SEB client
|
||||||
this.sebClientConfigService.initalCheckAccess(entity);
|
this.sebClientConfigService.initalCheckAccess(entity);
|
||||||
|
@ -155,7 +155,7 @@ public class SebClientConfigController extends ActivatableEntityController<SebCl
|
||||||
return super.notifySaved(entity);
|
return super.notifySaved(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SebClientConfig checkPasswordMatch(final SebClientConfig entity) {
|
private SEBClientConfig checkPasswordMatch(final SEBClientConfig entity) {
|
||||||
final Collection<APIMessage> errors = new ArrayList<>();
|
final Collection<APIMessage> errors = new ArrayList<>();
|
||||||
if (entity.hasEncryptionSecret() && !entity.encryptSecret.equals(entity.encryptSecretConfirm)) {
|
if (entity.hasEncryptionSecret() && !entity.encryptSecret.equals(entity.encryptSecretConfirm)) {
|
||||||
errors.add(APIMessage.fieldValidationError(
|
errors.add(APIMessage.fieldValidationError(
|
||||||
|
@ -169,7 +169,7 @@ public class SebClientConfigController extends ActivatableEntityController<SebCl
|
||||||
errors.add(APIMessage.fieldValidationError(
|
errors.add(APIMessage.fieldValidationError(
|
||||||
new FieldError(
|
new FieldError(
|
||||||
Domain.SEB_CLIENT_CONFIGURATION.TYPE_NAME,
|
Domain.SEB_CLIENT_CONFIGURATION.TYPE_NAME,
|
||||||
SebClientConfig.ATTR_FALLBACK_PASSWORD_CONFIRM,
|
SEBClientConfig.ATTR_FALLBACK_PASSWORD_CONFIRM,
|
||||||
"clientConfig:sebServerFallbackPasswordHashConfirm:password.mismatch")));
|
"clientConfig:sebServerFallbackPasswordHashConfirm:password.mismatch")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ public class SebClientConfigController extends ActivatableEntityController<SebCl
|
||||||
errors.add(APIMessage.fieldValidationError(
|
errors.add(APIMessage.fieldValidationError(
|
||||||
new FieldError(
|
new FieldError(
|
||||||
Domain.SEB_CLIENT_CONFIGURATION.TYPE_NAME,
|
Domain.SEB_CLIENT_CONFIGURATION.TYPE_NAME,
|
||||||
SebClientConfig.ATTR_QUIT_PASSWORD_CONFIRM,
|
SEBClientConfig.ATTR_QUIT_PASSWORD_CONFIRM,
|
||||||
"clientConfig:hashedQuitPasswordConfirm:password.mismatch")));
|
"clientConfig:hashedQuitPasswordConfirm:password.mismatch")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ public class SebClientConfigController extends ActivatableEntityController<SebCl
|
||||||
errors.add(APIMessage.fieldValidationError(
|
errors.add(APIMessage.fieldValidationError(
|
||||||
new FieldError(
|
new FieldError(
|
||||||
Domain.SEB_CLIENT_CONFIGURATION.TYPE_NAME,
|
Domain.SEB_CLIENT_CONFIGURATION.TYPE_NAME,
|
||||||
SebClientConfig.ATTR_FALLBACK_START_URL,
|
SEBClientConfig.ATTR_FALLBACK_START_URL,
|
||||||
"clientConfig:startURL:notNull")));
|
"clientConfig:startURL:notNull")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ public class SebClientConfigController extends ActivatableEntityController<SebCl
|
||||||
errors.add(APIMessage.fieldValidationError(
|
errors.add(APIMessage.fieldValidationError(
|
||||||
new FieldError(
|
new FieldError(
|
||||||
Domain.SEB_CLIENT_CONFIGURATION.TYPE_NAME,
|
Domain.SEB_CLIENT_CONFIGURATION.TYPE_NAME,
|
||||||
SebClientConfig.ATTR_FALLBACK_TIMEOUT,
|
SEBClientConfig.ATTR_FALLBACK_TIMEOUT,
|
||||||
"clientConfig:sebServerFallbackTimeout:notNull")));
|
"clientConfig:sebServerFallbackTimeout:notNull")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ public class SebClientConfigController extends ActivatableEntityController<SebCl
|
||||||
errors.add(APIMessage.fieldValidationError(
|
errors.add(APIMessage.fieldValidationError(
|
||||||
new FieldError(
|
new FieldError(
|
||||||
Domain.SEB_CLIENT_CONFIGURATION.TYPE_NAME,
|
Domain.SEB_CLIENT_CONFIGURATION.TYPE_NAME,
|
||||||
SebClientConfig.ATTR_FALLBACK_ATTEMPTS,
|
SEBClientConfig.ATTR_FALLBACK_ATTEMPTS,
|
||||||
"clientConfig:sebServerFallbackAttempts:notNull")));
|
"clientConfig:sebServerFallbackAttempts:notNull")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ public class SebClientConfigController extends ActivatableEntityController<SebCl
|
||||||
errors.add(APIMessage.fieldValidationError(
|
errors.add(APIMessage.fieldValidationError(
|
||||||
new FieldError(
|
new FieldError(
|
||||||
Domain.SEB_CLIENT_CONFIGURATION.TYPE_NAME,
|
Domain.SEB_CLIENT_CONFIGURATION.TYPE_NAME,
|
||||||
SebClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL,
|
SEBClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL,
|
||||||
"clientConfig:sebServerFallbackAttemptInterval:notNull")));
|
"clientConfig:sebServerFallbackAttemptInterval:notNull")));
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class OpenEdxSebRestrictionTest {
|
||||||
public void testEmpty1() throws JsonProcessingException {
|
public void testEmpty1() throws JsonProcessingException {
|
||||||
final JSONMapper mapper = new JSONMapper();
|
final JSONMapper mapper = new JSONMapper();
|
||||||
|
|
||||||
final OpenEdxSebRestriction data = new OpenEdxSebRestriction(null, null, null, null, null, false);
|
final OpenEdxSEBRestriction data = new OpenEdxSEBRestriction(null, null, null, null, null, false);
|
||||||
final String json = mapper.writeValueAsString(data);
|
final String json = mapper.writeValueAsString(data);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"{\"CONFIG_KEYS\":[],\"BROWSER_KEYS\":[],\"WHITELIST_PATHS\":[],\"BLACKLIST_CHAPTERS\":[],\"PERMISSION_COMPONENTS\":[],\"USER_BANNING_ENABLED\":false}",
|
"{\"CONFIG_KEYS\":[],\"BROWSER_KEYS\":[],\"WHITELIST_PATHS\":[],\"BLACKLIST_CHAPTERS\":[],\"PERMISSION_COMPONENTS\":[],\"USER_BANNING_ENABLED\":false}",
|
||||||
|
@ -33,8 +33,8 @@ public class OpenEdxSebRestrictionTest {
|
||||||
public void testEmpty2() throws JsonProcessingException {
|
public void testEmpty2() throws JsonProcessingException {
|
||||||
final JSONMapper mapper = new JSONMapper();
|
final JSONMapper mapper = new JSONMapper();
|
||||||
|
|
||||||
final OpenEdxSebRestriction data =
|
final OpenEdxSEBRestriction data =
|
||||||
OpenEdxSebRestriction.from(new SebRestriction(null, null, null, null));
|
OpenEdxSEBRestriction.from(new SEBRestriction(null, null, null, null));
|
||||||
final String json = mapper.writeValueAsString(data);
|
final String json = mapper.writeValueAsString(data);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"{\"CONFIG_KEYS\":[],\"BROWSER_KEYS\":[],\"WHITELIST_PATHS\":[],\"BLACKLIST_CHAPTERS\":[],\"PERMISSION_COMPONENTS\":[\"AlwaysAllowStaff\"],\"USER_BANNING_ENABLED\":false}",
|
"{\"CONFIG_KEYS\":[],\"BROWSER_KEYS\":[],\"WHITELIST_PATHS\":[],\"BLACKLIST_CHAPTERS\":[],\"PERMISSION_COMPONENTS\":[\"AlwaysAllowStaff\"],\"USER_BANNING_ENABLED\":false}",
|
||||||
|
|
|
@ -16,7 +16,7 @@ import org.springframework.test.context.jdbc.Sql;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.API;
|
import ch.ethz.seb.sebserver.gbl.api.API;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.Domain;
|
import ch.ethz.seb.sebserver.gbl.model.Domain;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.EntityProcessingReport;
|
import ch.ethz.seb.sebserver.gbl.model.EntityProcessingReport;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig;
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Result;
|
import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestServiceImpl;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestServiceImpl;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.clientconfig.ActivateClientConfig;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.clientconfig.ActivateClientConfig;
|
||||||
|
@ -32,15 +32,15 @@ public class ClientConfigTest extends GuiIntegrationTest {
|
||||||
public void testNewClientConfigWithQueryParam() {
|
public void testNewClientConfigWithQueryParam() {
|
||||||
final RestServiceImpl restService = createRestServiceForUser("admin", "admin", new NewClientConfig());
|
final RestServiceImpl restService = createRestServiceForUser("admin", "admin", new NewClientConfig());
|
||||||
|
|
||||||
final Result<SebClientConfig> call = restService.getBuilder(NewClientConfig.class)
|
final Result<SEBClientConfig> call = restService.getBuilder(NewClientConfig.class)
|
||||||
.withQueryParam(Domain.SEB_CLIENT_CONFIGURATION.ATTR_NAME, "new client config")
|
.withQueryParam(Domain.SEB_CLIENT_CONFIGURATION.ATTR_NAME, "new client config")
|
||||||
.withFormParam("Test", "new client config")
|
.withFormParam("Test", "new client config")
|
||||||
.withFormParam(SebClientConfig.ATTR_CONFIG_PURPOSE, SebClientConfig.ConfigPurpose.START_EXAM.name())
|
.withFormParam(SEBClientConfig.ATTR_CONFIG_PURPOSE, SEBClientConfig.ConfigPurpose.START_EXAM.name())
|
||||||
.call();
|
.call();
|
||||||
|
|
||||||
assertNotNull(call);
|
assertNotNull(call);
|
||||||
assertFalse(call.hasError());
|
assertFalse(call.hasError());
|
||||||
final SebClientConfig createdConfig = call.get();
|
final SEBClientConfig createdConfig = call.get();
|
||||||
assertEquals(Long.valueOf(1), createdConfig.id);
|
assertEquals(Long.valueOf(1), createdConfig.id);
|
||||||
assertEquals("new client config", createdConfig.name);
|
assertEquals("new client config", createdConfig.name);
|
||||||
assertFalse(createdConfig.active);
|
assertFalse(createdConfig.active);
|
||||||
|
@ -50,14 +50,14 @@ public class ClientConfigTest extends GuiIntegrationTest {
|
||||||
public void testNewClientConfigWithURLEncodedForm() {
|
public void testNewClientConfigWithURLEncodedForm() {
|
||||||
final RestServiceImpl restService = createRestServiceForUser("admin", "admin", new NewClientConfig());
|
final RestServiceImpl restService = createRestServiceForUser("admin", "admin", new NewClientConfig());
|
||||||
|
|
||||||
final Result<SebClientConfig> call = restService.getBuilder(NewClientConfig.class)
|
final Result<SEBClientConfig> call = restService.getBuilder(NewClientConfig.class)
|
||||||
.withFormParam(Domain.SEB_CLIENT_CONFIGURATION.ATTR_NAME, "new client config")
|
.withFormParam(Domain.SEB_CLIENT_CONFIGURATION.ATTR_NAME, "new client config")
|
||||||
.withFormParam(SebClientConfig.ATTR_CONFIG_PURPOSE, SebClientConfig.ConfigPurpose.START_EXAM.name())
|
.withFormParam(SEBClientConfig.ATTR_CONFIG_PURPOSE, SEBClientConfig.ConfigPurpose.START_EXAM.name())
|
||||||
.call();
|
.call();
|
||||||
|
|
||||||
assertNotNull(call);
|
assertNotNull(call);
|
||||||
assertFalse(call.hasError());
|
assertFalse(call.hasError());
|
||||||
final SebClientConfig createdConfig = call.get();
|
final SEBClientConfig createdConfig = call.get();
|
||||||
assertEquals(Long.valueOf(1), createdConfig.id);
|
assertEquals(Long.valueOf(1), createdConfig.id);
|
||||||
assertEquals("new client config", createdConfig.name);
|
assertEquals("new client config", createdConfig.name);
|
||||||
assertFalse(createdConfig.active);
|
assertFalse(createdConfig.active);
|
||||||
|
@ -73,20 +73,20 @@ public class ClientConfigTest extends GuiIntegrationTest {
|
||||||
new DeactivateClientConfig());
|
new DeactivateClientConfig());
|
||||||
|
|
||||||
// create one
|
// create one
|
||||||
final SebClientConfig config = restService.getBuilder(NewClientConfig.class)
|
final SEBClientConfig config = restService.getBuilder(NewClientConfig.class)
|
||||||
.withQueryParam(Domain.SEB_CLIENT_CONFIGURATION.ATTR_NAME, "new client config")
|
.withQueryParam(Domain.SEB_CLIENT_CONFIGURATION.ATTR_NAME, "new client config")
|
||||||
.withFormParam(SebClientConfig.ATTR_CONFIG_PURPOSE, SebClientConfig.ConfigPurpose.START_EXAM.name())
|
.withFormParam(SEBClientConfig.ATTR_CONFIG_PURPOSE, SEBClientConfig.ConfigPurpose.START_EXAM.name())
|
||||||
.call()
|
.call()
|
||||||
.getOrThrow();
|
.getOrThrow();
|
||||||
|
|
||||||
// get
|
// get
|
||||||
final Result<SebClientConfig> call = restService.getBuilder(GetClientConfig.class)
|
final Result<SEBClientConfig> call = restService.getBuilder(GetClientConfig.class)
|
||||||
.withURIVariable(API.PARAM_MODEL_ID, config.getModelId())
|
.withURIVariable(API.PARAM_MODEL_ID, config.getModelId())
|
||||||
.call();
|
.call();
|
||||||
|
|
||||||
assertNotNull(call);
|
assertNotNull(call);
|
||||||
assertFalse(call.hasError());
|
assertFalse(call.hasError());
|
||||||
final SebClientConfig createdConfig = call.get();
|
final SEBClientConfig createdConfig = call.get();
|
||||||
assertEquals(config.id, createdConfig.id);
|
assertEquals(config.id, createdConfig.id);
|
||||||
assertEquals("new client config", createdConfig.name);
|
assertEquals("new client config", createdConfig.name);
|
||||||
assertFalse(createdConfig.active);
|
assertFalse(createdConfig.active);
|
||||||
|
@ -104,11 +104,11 @@ public class ClientConfigTest extends GuiIntegrationTest {
|
||||||
|
|
||||||
// save with password (no confirm) expecting validation error
|
// save with password (no confirm) expecting validation error
|
||||||
final Result<?> valError = restService.getBuilder(SaveClientConfig.class)
|
final Result<?> valError = restService.getBuilder(SaveClientConfig.class)
|
||||||
.withBody(new SebClientConfig(
|
.withBody(new SEBClientConfig(
|
||||||
config.id,
|
config.id,
|
||||||
config.institutionId,
|
config.institutionId,
|
||||||
"new client config",
|
"new client config",
|
||||||
SebClientConfig.ConfigPurpose.START_EXAM,
|
SEBClientConfig.ConfigPurpose.START_EXAM,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
|
@ -130,12 +130,12 @@ public class ClientConfigTest extends GuiIntegrationTest {
|
||||||
assertTrue(error.getMessage().contains("password.mismatch"));
|
assertTrue(error.getMessage().contains("password.mismatch"));
|
||||||
|
|
||||||
// save with new password
|
// save with new password
|
||||||
final SebClientConfig newConfig = restService.getBuilder(SaveClientConfig.class)
|
final SEBClientConfig newConfig = restService.getBuilder(SaveClientConfig.class)
|
||||||
.withBody(new SebClientConfig(
|
.withBody(new SEBClientConfig(
|
||||||
config.id,
|
config.id,
|
||||||
config.institutionId,
|
config.institutionId,
|
||||||
"new client config",
|
"new client config",
|
||||||
SebClientConfig.ConfigPurpose.START_EXAM,
|
SEBClientConfig.ConfigPurpose.START_EXAM,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
|
|
|
@ -66,7 +66,7 @@ import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationTableValues;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationTableValues.TableValue;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationTableValues.TableValue;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationValue;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationValue;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.Orientation;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.Orientation;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.TemplateAttribute;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.TemplateAttribute;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.View;
|
import ch.ethz.seb.sebserver.gbl.model.sebconfig.View;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.user.PasswordChange;
|
import ch.ethz.seb.sebserver.gbl.model.user.PasswordChange;
|
||||||
|
@ -136,7 +136,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.Sa
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfigHistory;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfigHistory;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfigTableValues;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfigTableValues;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfigValue;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfigValue;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SebExamConfigUndo;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SEBExamConfigUndo;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.ActivateUserAccount;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.ActivateUserAccount;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.ChangePassword;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.ChangePassword;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.GetUserAccount;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.useraccount.GetUserAccount;
|
||||||
|
@ -930,20 +930,20 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest {
|
||||||
new ExportClientConfig());
|
new ExportClientConfig());
|
||||||
|
|
||||||
// create SEB Client Config without password protection
|
// create SEB Client Config without password protection
|
||||||
final Result<SebClientConfig> newConfigResponse = restService
|
final Result<SEBClientConfig> newConfigResponse = restService
|
||||||
.getBuilder(NewClientConfig.class)
|
.getBuilder(NewClientConfig.class)
|
||||||
.withFormParam(Domain.SEB_CLIENT_CONFIGURATION.ATTR_NAME, "No Password Protection")
|
.withFormParam(Domain.SEB_CLIENT_CONFIGURATION.ATTR_NAME, "No Password Protection")
|
||||||
.withFormParam(SebClientConfig.ATTR_FALLBACK, Constants.TRUE_STRING)
|
.withFormParam(SEBClientConfig.ATTR_FALLBACK, Constants.TRUE_STRING)
|
||||||
.withFormParam(SebClientConfig.ATTR_FALLBACK_START_URL, "http://fallback.com/fallback")
|
.withFormParam(SEBClientConfig.ATTR_FALLBACK_START_URL, "http://fallback.com/fallback")
|
||||||
.withFormParam(SebClientConfig.ATTR_FALLBACK_TIMEOUT, "100")
|
.withFormParam(SEBClientConfig.ATTR_FALLBACK_TIMEOUT, "100")
|
||||||
.withFormParam(SebClientConfig.ATTR_FALLBACK_ATTEMPTS, "5")
|
.withFormParam(SEBClientConfig.ATTR_FALLBACK_ATTEMPTS, "5")
|
||||||
.withFormParam(SebClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL, "5")
|
.withFormParam(SEBClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL, "5")
|
||||||
.withFormParam(SebClientConfig.ATTR_CONFIG_PURPOSE, SebClientConfig.ConfigPurpose.START_EXAM.name())
|
.withFormParam(SEBClientConfig.ATTR_CONFIG_PURPOSE, SEBClientConfig.ConfigPurpose.START_EXAM.name())
|
||||||
.call();
|
.call();
|
||||||
|
|
||||||
assertNotNull(newConfigResponse);
|
assertNotNull(newConfigResponse);
|
||||||
assertFalse(newConfigResponse.hasError());
|
assertFalse(newConfigResponse.hasError());
|
||||||
final SebClientConfig sebClientConfig = newConfigResponse.get();
|
final SEBClientConfig sebClientConfig = newConfigResponse.get();
|
||||||
assertEquals("No Password Protection", sebClientConfig.name);
|
assertEquals("No Password Protection", sebClientConfig.name);
|
||||||
assertFalse(sebClientConfig.isActive());
|
assertFalse(sebClientConfig.isActive());
|
||||||
assertEquals("http://fallback.com/fallback", sebClientConfig.fallbackStartURL);
|
assertEquals("http://fallback.com/fallback", sebClientConfig.fallbackStartURL);
|
||||||
|
@ -957,33 +957,33 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest {
|
||||||
assertNotNull(activationResponse);
|
assertNotNull(activationResponse);
|
||||||
assertFalse(activationResponse.hasError());
|
assertFalse(activationResponse.hasError());
|
||||||
|
|
||||||
final Result<SebClientConfig> getConfigResponse = restService
|
final Result<SEBClientConfig> getConfigResponse = restService
|
||||||
.getBuilder(GetClientConfig.class)
|
.getBuilder(GetClientConfig.class)
|
||||||
.withURIVariable(API.PARAM_MODEL_ID, sebClientConfig.getModelId())
|
.withURIVariable(API.PARAM_MODEL_ID, sebClientConfig.getModelId())
|
||||||
.call();
|
.call();
|
||||||
|
|
||||||
assertNotNull(getConfigResponse);
|
assertNotNull(getConfigResponse);
|
||||||
assertFalse(getConfigResponse.hasError());
|
assertFalse(getConfigResponse.hasError());
|
||||||
final SebClientConfig activeConfig = getConfigResponse.get();
|
final SEBClientConfig activeConfig = getConfigResponse.get();
|
||||||
assertTrue(activeConfig.isActive());
|
assertTrue(activeConfig.isActive());
|
||||||
|
|
||||||
// create a config with password protection
|
// create a config with password protection
|
||||||
final Result<SebClientConfig> configWithPasswordResponse = restService
|
final Result<SEBClientConfig> configWithPasswordResponse = restService
|
||||||
.getBuilder(NewClientConfig.class)
|
.getBuilder(NewClientConfig.class)
|
||||||
.withFormParam(Domain.SEB_CLIENT_CONFIGURATION.ATTR_NAME, "With Password Protection")
|
.withFormParam(Domain.SEB_CLIENT_CONFIGURATION.ATTR_NAME, "With Password Protection")
|
||||||
.withFormParam(SebClientConfig.ATTR_CONFIG_PURPOSE, SebClientConfig.ConfigPurpose.START_EXAM.name())
|
.withFormParam(SEBClientConfig.ATTR_CONFIG_PURPOSE, SEBClientConfig.ConfigPurpose.START_EXAM.name())
|
||||||
.withFormParam(SebClientConfig.ATTR_FALLBACK, Constants.TRUE_STRING)
|
.withFormParam(SEBClientConfig.ATTR_FALLBACK, Constants.TRUE_STRING)
|
||||||
.withFormParam(SebClientConfig.ATTR_FALLBACK_START_URL, "http://fallback.com/fallback")
|
.withFormParam(SEBClientConfig.ATTR_FALLBACK_START_URL, "http://fallback.com/fallback")
|
||||||
.withFormParam(SebClientConfig.ATTR_FALLBACK_TIMEOUT, "100")
|
.withFormParam(SEBClientConfig.ATTR_FALLBACK_TIMEOUT, "100")
|
||||||
.withFormParam(SebClientConfig.ATTR_FALLBACK_ATTEMPTS, "5")
|
.withFormParam(SEBClientConfig.ATTR_FALLBACK_ATTEMPTS, "5")
|
||||||
.withFormParam(SebClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL, "5")
|
.withFormParam(SEBClientConfig.ATTR_FALLBACK_ATTEMPT_INTERVAL, "5")
|
||||||
.withFormParam(SEB_CLIENT_CONFIGURATION.ATTR_ENCRYPT_SECRET, "123")
|
.withFormParam(SEB_CLIENT_CONFIGURATION.ATTR_ENCRYPT_SECRET, "123")
|
||||||
.withFormParam(SebClientConfig.ATTR_ENCRYPT_SECRET_CONFIRM, "123")
|
.withFormParam(SEBClientConfig.ATTR_ENCRYPT_SECRET_CONFIRM, "123")
|
||||||
.call();
|
.call();
|
||||||
|
|
||||||
assertNotNull(configWithPasswordResponse);
|
assertNotNull(configWithPasswordResponse);
|
||||||
assertFalse(configWithPasswordResponse.hasError());
|
assertFalse(configWithPasswordResponse.hasError());
|
||||||
final SebClientConfig configWithPassword = configWithPasswordResponse.get();
|
final SEBClientConfig configWithPassword = configWithPasswordResponse.get();
|
||||||
assertEquals("With Password Protection", configWithPassword.name);
|
assertEquals("With Password Protection", configWithPassword.name);
|
||||||
assertFalse(configWithPassword.isActive());
|
assertFalse(configWithPassword.isActive());
|
||||||
assertEquals("http://fallback.com/fallback", configWithPassword.fallbackStartURL);
|
assertEquals("http://fallback.com/fallback", configWithPassword.fallbackStartURL);
|
||||||
|
@ -1015,13 +1015,13 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest {
|
||||||
assertFalse(readLines.isEmpty());
|
assertFalse(readLines.isEmpty());
|
||||||
|
|
||||||
// get page
|
// get page
|
||||||
final Result<Page<SebClientConfig>> pageResponse = restService
|
final Result<Page<SEBClientConfig>> pageResponse = restService
|
||||||
.getBuilder(GetClientConfigPage.class)
|
.getBuilder(GetClientConfigPage.class)
|
||||||
.call();
|
.call();
|
||||||
|
|
||||||
assertNotNull(pageResponse);
|
assertNotNull(pageResponse);
|
||||||
assertFalse(pageResponse.hasError());
|
assertFalse(pageResponse.hasError());
|
||||||
final Page<SebClientConfig> page = pageResponse.get();
|
final Page<SEBClientConfig> page = pageResponse.get();
|
||||||
assertFalse(page.content.isEmpty());
|
assertFalse(page.content.isEmpty());
|
||||||
assertTrue(page.content.size() == 2);
|
assertTrue(page.content.size() == 2);
|
||||||
}
|
}
|
||||||
|
@ -1097,7 +1097,7 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest {
|
||||||
new GetConfigurations(),
|
new GetConfigurations(),
|
||||||
new SaveExamConfigHistory(),
|
new SaveExamConfigHistory(),
|
||||||
new GetConfigurationTableValues(),
|
new GetConfigurationTableValues(),
|
||||||
new SebExamConfigUndo(),
|
new SEBExamConfigUndo(),
|
||||||
new SaveExamConfigValue(),
|
new SaveExamConfigValue(),
|
||||||
new SaveExamConfigTableValues(),
|
new SaveExamConfigTableValues(),
|
||||||
new GetConfigurationValuePage(),
|
new GetConfigurationValuePage(),
|
||||||
|
@ -1261,7 +1261,7 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest {
|
||||||
|
|
||||||
// undo
|
// undo
|
||||||
final Result<Configuration> undoResponse = restService
|
final Result<Configuration> undoResponse = restService
|
||||||
.getBuilder(SebExamConfigUndo.class)
|
.getBuilder(SEBExamConfigUndo.class)
|
||||||
.withURIVariable(API.PARAM_MODEL_ID, followup.getModelId())
|
.withURIVariable(API.PARAM_MODEL_ID, followup.getModelId())
|
||||||
.call();
|
.call();
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,9 @@ import org.cryptonode.jncryptor.JNCryptor;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionContext;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionContext;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionService.Strategy;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionService.Strategy;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.impl.SebConfigEncryptionServiceImpl.EncryptionContext;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.impl.SEBConfigEncryptionServiceImpl.EncryptionContext;
|
||||||
|
|
||||||
public class PasswordEncryptorTest {
|
public class PasswordEncryptorTest {
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ public class PasswordEncryptorTest {
|
||||||
final String pwd = "password";
|
final String pwd = "password";
|
||||||
final ByteArrayOutputStream out = new ByteArrayOutputStream(512);
|
final ByteArrayOutputStream out = new ByteArrayOutputStream(512);
|
||||||
|
|
||||||
final SebConfigEncryptionContext context = EncryptionContext.contextOf(
|
final SEBConfigEncryptionContext context = EncryptionContext.contextOf(
|
||||||
Strategy.PASSWORD_PWCC,
|
Strategy.PASSWORD_PWCC,
|
||||||
pwd);
|
pwd);
|
||||||
|
|
||||||
|
|
|
@ -23,15 +23,15 @@ import org.cryptonode.jncryptor.JNCryptor;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigCryptor;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigCryptor;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SebConfigEncryptionService.Strategy;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.SEBConfigEncryptionService.Strategy;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.impl.SebConfigEncryptionServiceImpl.EncryptionContext;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.impl.SEBConfigEncryptionServiceImpl.EncryptionContext;
|
||||||
|
|
||||||
public class SebConfigEncryptionServiceImplTest {
|
public class SebConfigEncryptionServiceImplTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPlainText() throws IOException {
|
public void testPlainText() throws IOException {
|
||||||
final SebConfigEncryptionServiceImpl sebConfigEncryptionServiceImpl = sebConfigEncryptionServiceImpl();
|
final SEBConfigEncryptionServiceImpl sebConfigEncryptionServiceImpl = sebConfigEncryptionServiceImpl();
|
||||||
|
|
||||||
final String config = "<TestConfig></TestConfig>";
|
final String config = "<TestConfig></TestConfig>";
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ public class SebConfigEncryptionServiceImplTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPasswordEncryption() throws IOException {
|
public void testPasswordEncryption() throws IOException {
|
||||||
final SebConfigEncryptionServiceImpl sebConfigEncryptionServiceImpl = sebConfigEncryptionServiceImpl();
|
final SEBConfigEncryptionServiceImpl sebConfigEncryptionServiceImpl = sebConfigEncryptionServiceImpl();
|
||||||
|
|
||||||
final String config = "<TestConfig></TestConfig>";
|
final String config = "<TestConfig></TestConfig>";
|
||||||
final String pwd = "password";
|
final String pwd = "password";
|
||||||
|
@ -96,12 +96,12 @@ public class SebConfigEncryptionServiceImplTest {
|
||||||
assertEquals(config, decryptedConfig);
|
assertEquals(config, decryptedConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SebConfigEncryptionServiceImpl sebConfigEncryptionServiceImpl() {
|
private SEBConfigEncryptionServiceImpl sebConfigEncryptionServiceImpl() {
|
||||||
final JNCryptor cryptor = new AES256JNCryptor();
|
final JNCryptor cryptor = new AES256JNCryptor();
|
||||||
final List<SebConfigCryptor> encryptors = Arrays.asList(
|
final List<SEBConfigCryptor> encryptors = Arrays.asList(
|
||||||
new PasswordEncryptor(cryptor),
|
new PasswordEncryptor(cryptor),
|
||||||
new NoneEncryptor());
|
new NoneEncryptor());
|
||||||
return new SebConfigEncryptionServiceImpl(encryptors);
|
return new SEBConfigEncryptionServiceImpl(encryptors);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue