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