certificates
This commit is contained in:
parent
f15c851b77
commit
8b025d17af
4 changed files with 93 additions and 2 deletions
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* Copyright (c) 2021 ETH Zürich, Educational Development and Technology (LET)
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package ch.ethz.seb.sebserver.gui.content;
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||
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.impl.PageAction;
|
||||
|
||||
@Lazy
|
||||
@Component
|
||||
@GuiProfile
|
||||
public class CertificateImportPopup {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SEBExamConfigImportPopup.class);
|
||||
|
||||
private final static PageMessageException MISSING_PASSWORD = new PageMessageException(
|
||||
new LocTextKey("sebserver.certificate.action.import.missing-password"));
|
||||
|
||||
private final PageService pageService;
|
||||
|
||||
protected CertificateImportPopup(final PageService pageService) {
|
||||
this.pageService = pageService;
|
||||
}
|
||||
|
||||
public Function<PageAction, PageAction> importFunction() {
|
||||
return importFunction(null);
|
||||
}
|
||||
|
||||
public Function<PageAction, PageAction> importFunction(final Supplier<String> tabSelectionSupplier) {
|
||||
return action -> {
|
||||
|
||||
// final boolean newConfig = tabSelectionSupplier == null || tabSelectionSupplier.get() == null;
|
||||
// final PageContext context = (tabSelectionSupplier != null)
|
||||
// ? action.pageContext()
|
||||
// .withAttribute(SEBSettingsForm.ATTR_VIEW_INDEX, tabSelectionSupplier.get())
|
||||
// : action.pageContext();
|
||||
//
|
||||
// final ModalInputDialog<FormHandle<ConfigurationNode>> dialog =
|
||||
// new ModalInputDialog<FormHandle<ConfigurationNode>>(
|
||||
// action.pageContext().getParent().getShell(),
|
||||
// this.pageService.getWidgetFactory())
|
||||
// .setLargeDialogWidth();
|
||||
//
|
||||
// final ImportFormContext importFormContext = new ImportFormContext(
|
||||
// this.pageService,
|
||||
// context,
|
||||
// newConfig);
|
||||
//
|
||||
// dialog.open(
|
||||
// SEBExamConfigForm.FORM_IMPORT_TEXT_KEY,
|
||||
// (Predicate<FormHandle<ConfigurationNode>>) formHandle -> doImport(
|
||||
// formHandle,
|
||||
// newConfig),
|
||||
// importFormContext::cancelUpload,
|
||||
// importFormContext);
|
||||
|
||||
return action;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
|
@ -13,6 +13,7 @@ import java.io.InputStream;
|
|||
import java.io.PipedInputStream;
|
||||
import java.io.PipedOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.function.Consumer;
|
||||
|
@ -59,6 +60,7 @@ public class FileUploadSelection extends Composite {
|
|||
public FileUploadSelection(
|
||||
final Composite parent,
|
||||
final I18nSupport i18nSupport,
|
||||
final Collection<String> supportedFiles,
|
||||
final boolean readonly) {
|
||||
|
||||
super(parent, SWT.NONE);
|
||||
|
@ -87,6 +89,10 @@ public class FileUploadSelection extends Composite {
|
|||
this.inputReceiver = new InputReceiver();
|
||||
this.uploadHandler = new FileUploadHandler(this.inputReceiver);
|
||||
|
||||
if (supportedFiles != null && !supportedFiles.isEmpty()) {
|
||||
this.fileUpload.setFilterExtensions(supportedFiles.toArray(new String[supportedFiles.size()]));
|
||||
}
|
||||
|
||||
this.fileName = new Label(this, SWT.NONE);
|
||||
this.fileName.setText(i18nSupport.getText(PLEASE_SELECT_TEXT));
|
||||
this.fileName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
||||
|
|
|
@ -866,8 +866,11 @@ public class WidgetFactory {
|
|||
final boolean readonly,
|
||||
final Collection<String> supportedFiles) {
|
||||
|
||||
final FileUploadSelection fileUploadSelection =
|
||||
new FileUploadSelection(parent, this.i18nSupport, readonly);
|
||||
final FileUploadSelection fileUploadSelection = new FileUploadSelection(
|
||||
parent,
|
||||
this.i18nSupport,
|
||||
supportedFiles,
|
||||
readonly);
|
||||
|
||||
if (supportedFiles != null) {
|
||||
supportedFiles.forEach(fileUploadSelection::withSupportFor);
|
||||
|
|
|
@ -1532,6 +1532,9 @@ sebserver.configtemplate.attr.form.value.tooltip=The SEB exam configuration attr
|
|||
sebserver.configtemplate.attr.action.setdefault=Set Default Values
|
||||
sebserver.configtemplate.attr.action.template=View Configuration Template
|
||||
|
||||
################################
|
||||
# Certificates
|
||||
################################
|
||||
|
||||
sebserver.certificate.action.list=Certificates
|
||||
sebserver.certificate.action.import=Import Certificate
|
||||
|
@ -1547,6 +1550,8 @@ sebserver.certificate.list.column.type.DIGITAL_SIGNATURE=TLS/SSL
|
|||
sebserver.certificate.list.column.type.DATA_ENCIPHERMENT=Identity
|
||||
sebserver.certificate.list.column.type.KEY_CERT_SIGN=CA
|
||||
|
||||
sebserver.certificate.action.import.missing-password
|
||||
|
||||
|
||||
################################
|
||||
# Monitoring
|
||||
|
|
Loading…
Add table
Reference in a new issue