Search in sources :

Example 81 with TextField

use of com.vaadin.ui.TextField in project unity by unity-idm.

the class SAMLAuthenticatorEditor method buildSAMLMetadaPublishingSection.

private CollapsibleLayout buildSAMLMetadaPublishingSection() {
    FormLayoutWithFixedCaptionWidth metadataPublishing = new FormLayoutWithFixedCaptionWidth();
    metadataPublishing.setMargin(false);
    CheckBox publishMetadata = new CheckBox(msg.getMessage("SAMLAuthenticatorEditor.publishMetadata"));
    configBinder.forField(publishMetadata).bind("publishMetadata");
    metadataPublishing.addComponent(publishMetadata);
    TextField metadataPath = new TextField(msg.getMessage("SAMLAuthenticatorEditor.metadataPath"));
    metadataPath.setWidth(FieldSizeConstans.LINK_FIELD_WIDTH, FieldSizeConstans.LINK_FIELD_WIDTH_UNIT);
    configBinder.forField(metadataPath).asRequired((v, c) -> ((v == null || v.isEmpty()) && publishMetadata.getValue()) ? ValidationResult.error(msg.getMessage("fieldRequired")) : ValidationResult.ok()).bind("metadataPath");
    metadataPath.setEnabled(false);
    metadataPublishing.addComponent(metadataPath);
    signMetadata = new CheckBox(msg.getMessage("SAMLAuthenticatorEditor.signMetadata"));
    configBinder.forField(signMetadata).bind("signMetadata");
    signMetadata.setEnabled(false);
    metadataPublishing.addComponent(signMetadata);
    CheckBox autoGenerateMetadata = new CheckBox(msg.getMessage("SAMLAuthenticatorEditor.autoGenerateMetadata"));
    configBinder.forField(autoGenerateMetadata).bind("autoGenerateMetadata");
    autoGenerateMetadata.setEnabled(false);
    metadataPublishing.addComponent(autoGenerateMetadata);
    FileField metadataSource = new FileField(msg, "text/xml", "metadata.xml", serverConfig.getFileSizeLimit());
    metadataSource.setCaption(msg.getMessage("SAMLAuthenticatorEditor.metadataFile"));
    metadataSource.configureBinding(configBinder, "metadataSource", Optional.of((value, context) -> {
        if (value != null && value.getLocal() != null) {
            try {
                EntityDescriptorDocument.Factory.parse(new ByteArrayInputStream(value.getLocal()));
            } catch (Exception e) {
                return ValidationResult.error(msg.getMessage("SAMLAuthenticatorEditor.invalidMetadataFile"));
            }
        }
        boolean isEmpty = value == null || (value.getLocal() == null && (value.getRemote() == null || value.getRemote().isEmpty()));
        if (publishMetadata.getValue() && (!autoGenerateMetadata.getValue() && isEmpty)) {
            return ValidationResult.error(msg.getMessage("SAMLAuthenticatorEditor.spMetaEmpty"));
        }
        return ValidationResult.ok();
    }));
    metadataSource.setEnabled(false);
    metadataPublishing.addComponent(metadataSource);
    publishMetadata.addValueChangeListener(e -> {
        boolean v = e.getValue();
        metadataPath.setEnabled(v);
        signMetadata.setEnabled(v);
        autoGenerateMetadata.setEnabled(v);
        metadataSource.setEnabled(!autoGenerateMetadata.getValue() && v);
    });
    autoGenerateMetadata.addValueChangeListener(e -> {
        metadataSource.setEnabled(!e.getValue() && publishMetadata.getValue());
    });
    return new CollapsibleLayout(msg.getMessage("SAMLAuthenticatorEditor.metadataPublishing"), metadataPublishing);
}
Also used : Arrays(java.util.Arrays) TextField(com.vaadin.ui.TextField) Alignment(com.vaadin.ui.Alignment) PKIManagement(pl.edu.icm.unity.engine.api.PKIManagement) IdentityTypesRegistry(pl.edu.icm.unity.engine.api.identity.IdentityTypesRegistry) ByteArrayInputStream(java.io.ByteArrayInputStream) CheckBox(com.vaadin.ui.CheckBox) ImageAccessService(pl.edu.icm.unity.webui.common.file.ImageAccessService) RegistrationsManagement(pl.edu.icm.unity.engine.api.RegistrationsManagement) GridWithActionColumn(pl.edu.icm.unity.webui.common.GridWithActionColumn) MessageSource(pl.edu.icm.unity.MessageSource) GridWithEditor(pl.edu.icm.unity.webui.common.GridWithEditor) SingleActionHandler(pl.edu.icm.unity.webui.common.SingleActionHandler) Set(java.util.Set) FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) Collectors(java.util.stream.Collectors) Binder(com.vaadin.data.Binder) Images(pl.edu.icm.unity.webui.common.Images) EngineException(pl.edu.icm.unity.exceptions.EngineException) FileField(pl.edu.icm.unity.webui.common.file.FileField) List(java.util.List) SAMLIdentityMapping(pl.edu.icm.unity.saml.console.SAMLIdentityMapping) ChipsWithFreeText(pl.edu.icm.unity.webui.common.chips.ChipsWithFreeText) URIAccessService(pl.edu.icm.unity.engine.api.files.URIAccessService) ConfigurationException(eu.unicore.util.configuration.ConfigurationException) BaseAuthenticatorEditor(pl.edu.icm.unity.webui.authn.authenticators.BaseAuthenticatorEditor) Styles(pl.edu.icm.unity.webui.common.Styles) Optional(java.util.Optional) CustomField(com.vaadin.ui.CustomField) FieldSizeConstans(pl.edu.icm.unity.webui.common.FieldSizeConstans) VerticalLayout(com.vaadin.ui.VerticalLayout) ComboBox(com.vaadin.ui.ComboBox) RealmsManagement(pl.edu.icm.unity.engine.api.RealmsManagement) ValidationResult(com.vaadin.data.ValidationResult) UnityServerConfiguration(pl.edu.icm.unity.engine.api.config.UnityServerConfiguration) SAMLVerificator(pl.edu.icm.unity.saml.sp.SAMLVerificator) AuthenticatorDefinition(pl.edu.icm.unity.types.authn.AuthenticatorDefinition) NotificationPopup(pl.edu.icm.unity.webui.common.NotificationPopup) CollapsibleLayout(pl.edu.icm.unity.webui.common.CollapsibleLayout) InputTranslationProfileFieldFactory(io.imunity.webconsole.utils.tprofile.InputTranslationProfileFieldFactory) StandardButtonsHelper(pl.edu.icm.unity.webui.common.StandardButtonsHelper) Consumer(java.util.function.Consumer) Button(com.vaadin.ui.Button) SubViewSwitcher(pl.edu.icm.unity.webui.common.webElements.SubViewSwitcher) AuthenticatorEditor(pl.edu.icm.unity.webui.authn.authenticators.AuthenticatorEditor) EntityDescriptorDocument(xmlbeans.org.oasis.saml2.metadata.EntityDescriptorDocument) FormValidationException(pl.edu.icm.unity.webui.common.FormValidationException) FileStorageService(pl.edu.icm.unity.engine.api.files.FileStorageService) Component(com.vaadin.ui.Component) CollapsibleLayout(pl.edu.icm.unity.webui.common.CollapsibleLayout) FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) ByteArrayInputStream(java.io.ByteArrayInputStream) CheckBox(com.vaadin.ui.CheckBox) TextField(com.vaadin.ui.TextField) FileField(pl.edu.icm.unity.webui.common.file.FileField) EngineException(pl.edu.icm.unity.exceptions.EngineException) ConfigurationException(eu.unicore.util.configuration.ConfigurationException) FormValidationException(pl.edu.icm.unity.webui.common.FormValidationException)

Example 82 with TextField

use of com.vaadin.ui.TextField in project unity by unity-idm.

the class SAMLAuthenticatorEditor method buildSingleLogoutSection.

private CollapsibleLayout buildSingleLogoutSection() {
    FormLayoutWithFixedCaptionWidth singleLogout = new FormLayoutWithFixedCaptionWidth();
    singleLogout.setMargin(false);
    TextField sloPath = new TextField(msg.getMessage("SAMLAuthenticatorEditor.sloPath"));
    configBinder.forField(sloPath).bind("sloPath");
    singleLogout.addComponent(sloPath);
    ComboBox<String> sloRealm = new ComboBox<>(msg.getMessage("SAMLAuthenticatorEditor.sloRealm"));
    sloRealm.setItems(realms);
    singleLogout.addComponent(sloRealm);
    configBinder.forField(sloRealm).bind("sloRealm");
    GridWithEditor<SAMLIdentityMapping> sloMappings = new GridWithEditor<>(msg, SAMLIdentityMapping.class);
    sloMappings.setCaption(msg.getMessage("SAMLAuthenticatorEditor.sloMappings"));
    singleLogout.addComponent(sloMappings);
    sloMappings.addComboColumn(s -> s.getUnityId(), (t, v) -> t.setUnityId(v), msg.getMessage("SAMLAuthenticatorEditor.sloMappings.unityId"), idTypes, 30, false);
    sloMappings.addTextColumn(s -> s.getSamlId(), (t, v) -> t.setSamlId(v), msg.getMessage("SAMLAuthenticatorEditor.sloMappings.samlId"), 70, false);
    sloMappings.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
    configBinder.forField(sloMappings).bind("sloMappings");
    return new CollapsibleLayout(msg.getMessage("SAMLAuthenticatorEditor.singleLogout"), singleLogout);
}
Also used : CollapsibleLayout(pl.edu.icm.unity.webui.common.CollapsibleLayout) FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) ComboBox(com.vaadin.ui.ComboBox) TextField(com.vaadin.ui.TextField) SAMLIdentityMapping(pl.edu.icm.unity.saml.console.SAMLIdentityMapping) GridWithEditor(pl.edu.icm.unity.webui.common.GridWithEditor)

Example 83 with TextField

use of com.vaadin.ui.TextField in project unity by unity-idm.

the class GeneralTab method initUI.

public void initUI(Binder<DefaultServiceDefinition> binder, boolean editMode) {
    setCaption(msg.getMessage("ServiceEditorBase.general"));
    setIcon(Images.cogs.getResource());
    mainLayout = new VerticalLayout();
    mainLayout.setMargin(false);
    FormLayoutWithFixedCaptionWidth mainGeneralLayout = new FormLayoutWithFixedCaptionWidth();
    TextField name = new TextField();
    name.setCaption(msg.getMessage("ServiceEditorBase.name"));
    name.setReadOnly(editMode);
    binder.forField(name).asRequired().bind("name");
    mainGeneralLayout.addComponent(name);
    Label binding = new Label();
    binding.setCaption(msg.getMessage("ServiceEditorBase.binding"));
    binding.setValue(ServiceTypeInfoHelper.getBinding(msg, type.getSupportedBinding()));
    mainGeneralLayout.addComponent(binding);
    if (type.getPaths() != null && !type.getPaths().isEmpty() && !type.getPaths().keySet().iterator().next().isEmpty()) {
        ChipsWithTextfield paths = new ChipsWithTextfield(msg);
        paths.setCaption(msg.getMessage("ServiceEditorBase.paths"));
        List<String> pathsList = type.getPaths().keySet().stream().collect(Collectors.toList());
        pathsList.set(0, pathsList.get(0).isEmpty() ? "" : pathsList.get(0) + " (" + msg.getMessage("default") + ")");
        paths.setValue(pathsList);
        paths.setReadOnly(true);
        mainGeneralLayout.addComponent(paths);
    }
    TextField contextPath = new TextField();
    contextPath.setCaption(msg.getMessage("ServiceEditorBase.contextPath"));
    contextPath.setReadOnly(editMode);
    binder.forField(contextPath).asRequired().withValidator((v, c) -> {
        return editMode ? validatePathForEdit(v) : validatePathForAdd(v);
    }).bind("address");
    mainGeneralLayout.addComponent(contextPath);
    I18nTextField displayedName = new I18nTextField(msg);
    displayedName.setCaption(msg.getMessage("ServiceEditorBase.displayedName"));
    binder.forField(displayedName).bind("displayedName");
    mainGeneralLayout.addComponent(displayedName);
    TextField description = new DescriptionTextField(msg);
    binder.forField(description).bind("description");
    mainGeneralLayout.addComponent(description);
    mainLayout.addComponent(mainGeneralLayout);
    setCompositionRoot(mainLayout);
}
Also used : ChipsWithTextfield(pl.edu.icm.unity.webui.common.chips.ChipsWithTextfield) CustomComponent(com.vaadin.ui.CustomComponent) ServiceEditorTab(pl.edu.icm.unity.webui.console.services.ServiceEditorComponent.ServiceEditorTab) TextField(com.vaadin.ui.TextField) ServiceTypeInfoHelper(pl.edu.icm.unity.webui.console.services.ServiceTypeInfoHelper) VerticalLayout(com.vaadin.ui.VerticalLayout) WrongArgumentException(pl.edu.icm.unity.exceptions.WrongArgumentException) Set(java.util.Set) ValidationResult(com.vaadin.data.ValidationResult) FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) Collectors(java.util.stream.Collectors) Binder(com.vaadin.data.Binder) DescriptionTextField(pl.edu.icm.unity.webui.common.widgets.DescriptionTextField) EndpointPathValidator(pl.edu.icm.unity.engine.api.endpoint.EndpointPathValidator) Images(pl.edu.icm.unity.webui.common.Images) List(java.util.List) EndpointTypeDescription(pl.edu.icm.unity.types.endpoint.EndpointTypeDescription) I18nTextField(pl.edu.icm.unity.webui.common.i18n.I18nTextField) EditorTab(pl.edu.icm.unity.webui.console.services.ServiceEditorBase.EditorTab) Label(com.vaadin.ui.Label) DefaultServiceDefinition(pl.edu.icm.unity.webui.console.services.DefaultServiceDefinition) MessageSource(pl.edu.icm.unity.MessageSource) DescriptionTextField(pl.edu.icm.unity.webui.common.widgets.DescriptionTextField) FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) ChipsWithTextfield(pl.edu.icm.unity.webui.common.chips.ChipsWithTextfield) Label(com.vaadin.ui.Label) I18nTextField(pl.edu.icm.unity.webui.common.i18n.I18nTextField) VerticalLayout(com.vaadin.ui.VerticalLayout) TextField(com.vaadin.ui.TextField) DescriptionTextField(pl.edu.icm.unity.webui.common.widgets.DescriptionTextField) I18nTextField(pl.edu.icm.unity.webui.common.i18n.I18nTextField)

Example 84 with TextField

use of com.vaadin.ui.TextField in project unity by unity-idm.

the class WebServiceAuthenticationTab method buildRegistrationSection.

private Component buildRegistrationSection() {
    FormLayoutWithFixedCaptionWidth main = new FormLayoutWithFixedCaptionWidth();
    main.setMargin(false);
    CheckBox enableRegistration = new CheckBox();
    enableRegistration.setCaption(msg.getMessage("WebServiceEditorBase.enableRegistration"));
    webConfigBinder.forField(enableRegistration).bind("enableRegistration");
    main.addComponent(enableRegistration);
    CheckBox showRegistrationFormsInHeader = new CheckBox();
    showRegistrationFormsInHeader.setCaption(msg.getMessage("WebServiceEditorBase.showRegistrationFormsInHeader"));
    showRegistrationFormsInHeader.setEnabled(false);
    webConfigBinder.forField(showRegistrationFormsInHeader).bind("showRegistrationFormsInHeader");
    main.addComponent(showRegistrationFormsInHeader);
    TextField externalRegistrationURL = new TextField();
    externalRegistrationURL.setEnabled(false);
    externalRegistrationURL.setWidth(FieldSizeConstans.LINK_FIELD_WIDTH, FieldSizeConstans.LINK_FIELD_WIDTH_UNIT);
    externalRegistrationURL.setCaption(msg.getMessage("WebServiceEditorBase.externalRegistrationURL"));
    webConfigBinder.forField(externalRegistrationURL).bind("externalRegistrationURL");
    main.addComponent(externalRegistrationURL);
    ChipsWithDropdown<String> regFormsCombo = new ChipsWithDropdown<>();
    regFormsCombo.setEnabled(false);
    regFormsCombo.setCaption(msg.getMessage("WebServiceEditorBase.registrationForms"));
    regFormsCombo.setItems(registrationForms);
    webConfigBinder.forField(regFormsCombo).bind("registrationForms");
    main.addComponent(regFormsCombo);
    enableRegistration.addValueChangeListener(e -> {
        boolean v = e.getValue();
        showRegistrationFormsInHeader.setEnabled(v);
        externalRegistrationURL.setEnabled(v);
        regFormsCombo.setEnabled(v);
    });
    CollapsibleLayout regSection = new CollapsibleLayout(msg.getMessage("WebServiceEditorBase.usersRegistration"), main);
    regSection.expand();
    return regSection;
}
Also used : CollapsibleLayout(pl.edu.icm.unity.webui.common.CollapsibleLayout) FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) CheckBox(com.vaadin.ui.CheckBox) TextField(com.vaadin.ui.TextField) I18nTextField(pl.edu.icm.unity.webui.common.i18n.I18nTextField) GroupedValuesChipsWithDropdown(pl.edu.icm.unity.webui.common.chips.GroupedValuesChipsWithDropdown) ChipsWithDropdown(pl.edu.icm.unity.webui.common.chips.ChipsWithDropdown)

Example 85 with TextField

use of com.vaadin.ui.TextField in project unity by unity-idm.

the class GetRegistrationCodeDialog method getContents.

@Override
protected Component getContents() throws Exception {
    VerticalLayout main = new VerticalLayout();
    main.setMargin(false);
    main.addComponent(new Label(information));
    FormLayout sub = new FormLayout();
    codeTextField = new TextField(codeCaption);
    codeTextField.setWidth("70%");
    binder = new Binder<>(CodeBean.class);
    binder.forField(codeTextField).asRequired(msg.getMessage("fieldRequired")).bind("code");
    binder.setBean(new CodeBean());
    sub.addComponent(codeTextField);
    main.addComponent(sub);
    return main;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) TextField(com.vaadin.ui.TextField)

Aggregations

TextField (com.vaadin.ui.TextField)185 VerticalLayout (com.vaadin.ui.VerticalLayout)51 CheckBox (com.vaadin.ui.CheckBox)45 Label (com.vaadin.ui.Label)41 Button (com.vaadin.ui.Button)40 ComboBox (com.vaadin.ui.ComboBox)39 HorizontalLayout (com.vaadin.ui.HorizontalLayout)39 FormLayoutWithFixedCaptionWidth (pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth)38 FormLayout (com.vaadin.ui.FormLayout)28 CollapsibleLayout (pl.edu.icm.unity.webui.common.CollapsibleLayout)28 I18nTextField (pl.edu.icm.unity.webui.common.i18n.I18nTextField)27 Binder (com.vaadin.data.Binder)23 StringToIntegerConverter (com.vaadin.data.converter.StringToIntegerConverter)23 Test (org.junit.Test)22 MessageSource (pl.edu.icm.unity.MessageSource)22 Component (com.vaadin.ui.Component)21 ValidationResult (com.vaadin.data.ValidationResult)19 List (java.util.List)18 IntegerRangeValidator (com.vaadin.data.validator.IntegerRangeValidator)17 Set (java.util.Set)17