Search in sources :

Example 1 with URIAccessService

use of pl.edu.icm.unity.engine.api.files.URIAccessService in project unity by unity-idm.

the class EditIndividualTrustedSPSubView method buildHeaderSection.

private FormLayout buildHeaderSection() {
    FormLayoutWithFixedCaptionWidth header = new FormLayoutWithFixedCaptionWidth();
    header.setMargin(true);
    TextField name = new TextField(msg.getMessage("EditIndividualTrustedSPSubView.name"));
    name.focus();
    configBinder.forField(name).asRequired(msg.getMessage("fieldRequired")).withValidator(new NoSpaceValidator(msg)).withValidator((s, c) -> {
        if (usedNames.contains(s)) {
            return ValidationResult.error(msg.getMessage("EditIndividualTrustedSPSubView.nameExists"));
        } else {
            return ValidationResult.ok();
        }
    }).bind("name");
    header.addComponent(name);
    I18nTextField displayedName = new I18nTextField(msg, msg.getMessage("EditIndividualTrustedSPSubView.displayedName"));
    configBinder.forField(displayedName).bind("displayedName");
    header.addComponent(displayedName);
    ImageField logo = new ImageField(msg, uriAccessService, serverConfig.getFileSizeLimit());
    logo.setCaption(msg.getMessage("EditIndividualTrustedSPSubView.logo"));
    logo.configureBinding(configBinder, "logo");
    header.addComponent(logo);
    CheckBox x500Name = new CheckBox(msg.getMessage("EditIndividualTrustedSPSubView.X500NameUse"));
    configBinder.forField(x500Name).bind("x500Name");
    header.addComponent(x500Name);
    TextField id = new TextField(msg.getMessage("EditIndividualTrustedSPSubView.id"));
    id.setWidth(FieldSizeConstans.LINK_FIELD_WIDTH, FieldSizeConstans.LINK_FIELD_WIDTH_UNIT);
    configBinder.forField(id).asRequired(msg.getMessage("fieldRequired")).withValidator((s, c) -> {
        if (x500Name.getValue()) {
            try {
                new X500Name(s);
                return ValidationResult.ok();
            } catch (Exception e) {
                return ValidationResult.error(msg.getMessage("EditIndividualTrustedSPSubView.invalidX500Name"));
            }
        } else {
            return ValidationResult.ok();
        }
    }).bind("id");
    header.addComponent(id);
    ChipsWithDropdown<String> certificatesCombo = new ChipsWithDropdown<>();
    certificatesCombo.setCaption(msg.getMessage("EditIndividualTrustedSPSubView.certificates"));
    certificatesCombo.setItems(certificates.stream().collect(Collectors.toList()));
    configBinder.forField(certificatesCombo).bind("certificates");
    header.addComponent(certificatesCombo);
    CheckBox encryptAssertions = new CheckBox(msg.getMessage("EditIndividualTrustedSPSubView.encryptAssertions"));
    configBinder.forField(encryptAssertions).bind("encryptAssertions");
    header.addComponent(encryptAssertions);
    ChipsWithTextfield authorizedURIs = new ChipsWithTextfield(msg);
    authorizedURIs.setWidth(FieldSizeConstans.LINK_FIELD_WIDTH, FieldSizeConstans.LINK_FIELD_WIDTH_UNIT);
    authorizedURIs.setCaption(msg.getMessage("EditIndividualTrustedSPSubView.authorizedURIs"));
    configBinder.forField(authorizedURIs).withValidator((v, c) -> {
        if (v == null || v.isEmpty()) {
            return ValidationResult.error(msg.getMessage("fieldRequired"));
        }
        return ValidationResult.ok();
    }).bind("authorizedRedirectsUri");
    header.addComponent(authorizedURIs);
    return header;
}
Also used : FieldSizeConstans(pl.edu.icm.unity.webui.common.FieldSizeConstans) Arrays(java.util.Arrays) CustomComponent(com.vaadin.ui.CustomComponent) TextField(com.vaadin.ui.TextField) VerticalLayout(com.vaadin.ui.VerticalLayout) ValidationResult(com.vaadin.data.ValidationResult) ImageField(pl.edu.icm.unity.webui.common.file.ImageField) NoSpaceValidator(pl.edu.icm.unity.webui.common.validators.NoSpaceValidator) UnityServerConfiguration(pl.edu.icm.unity.engine.api.config.UnityServerConfiguration) X500Name(org.bouncycastle.asn1.x500.X500Name) UnitySubView(pl.edu.icm.unity.webui.common.webElements.UnitySubView) CheckBox(com.vaadin.ui.CheckBox) MessageSource(pl.edu.icm.unity.MessageSource) NotificationPopup(pl.edu.icm.unity.webui.common.NotificationPopup) ChipsWithTextfield(pl.edu.icm.unity.webui.common.chips.ChipsWithTextfield) CollapsibleLayout(pl.edu.icm.unity.webui.common.CollapsibleLayout) Set(java.util.Set) FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) StandardButtonsHelper(pl.edu.icm.unity.webui.common.StandardButtonsHelper) Collectors(java.util.stream.Collectors) Binder(com.vaadin.data.Binder) Consumer(java.util.function.Consumer) List(java.util.List) SubViewSwitcher(pl.edu.icm.unity.webui.common.webElements.SubViewSwitcher) I18nTextField(pl.edu.icm.unity.webui.common.i18n.I18nTextField) URIAccessService(pl.edu.icm.unity.engine.api.files.URIAccessService) FormLayout(com.vaadin.ui.FormLayout) FormValidationException(pl.edu.icm.unity.webui.common.FormValidationException) ChipsWithDropdown(pl.edu.icm.unity.webui.common.chips.ChipsWithDropdown) I18nTextField(pl.edu.icm.unity.webui.common.i18n.I18nTextField) ChipsWithDropdown(pl.edu.icm.unity.webui.common.chips.ChipsWithDropdown) X500Name(org.bouncycastle.asn1.x500.X500Name) FormValidationException(pl.edu.icm.unity.webui.common.FormValidationException) ImageField(pl.edu.icm.unity.webui.common.file.ImageField) FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) CheckBox(com.vaadin.ui.CheckBox) ChipsWithTextfield(pl.edu.icm.unity.webui.common.chips.ChipsWithTextfield) TextField(com.vaadin.ui.TextField) I18nTextField(pl.edu.icm.unity.webui.common.i18n.I18nTextField) NoSpaceValidator(pl.edu.icm.unity.webui.common.validators.NoSpaceValidator)

Example 2 with URIAccessService

use of pl.edu.icm.unity.engine.api.files.URIAccessService in project unity by unity-idm.

the class EditIndividualTrustedIdpSubView method buildHeaderSection.

private FormLayout buildHeaderSection() {
    FormLayoutWithFixedCaptionWidth header = new FormLayoutWithFixedCaptionWidth();
    header.setMargin(true);
    TextField name = new TextField(msg.getMessage("EditIndividualTrustedIdpSubView.name"));
    name.focus();
    configBinder.forField(name).asRequired(msg.getMessage("fieldRequired")).withValidator(new NoSpaceValidator(msg)).withValidator((s, c) -> {
        if (usedNames.contains(s)) {
            return ValidationResult.error(msg.getMessage("EditIndividualTrustedIdpSubView.nameExists"));
        } else {
            return ValidationResult.ok();
        }
    }).bind("name");
    header.addComponent(name);
    I18nTextField displayedName = new I18nTextField(msg, msg.getMessage("EditIndividualTrustedIdpSubView.displayedName"));
    configBinder.forField(displayedName).asRequired(msg.getMessage("fieldRequired")).bind("displayedName");
    header.addComponent(displayedName);
    ImageField logo = new ImageField(msg, uriAccessService, serverConfig.getFileSizeLimit());
    logo.setCaption(msg.getMessage("EditIndividualTrustedIdpSubView.logo"));
    logo.configureBinding(configBinder, "logo");
    header.addComponent(logo);
    TextField id = new TextField(msg.getMessage("EditIndividualTrustedIdpSubView.id"));
    id.setWidth(FieldSizeConstans.LINK_FIELD_WIDTH, FieldSizeConstans.LINK_FIELD_WIDTH_UNIT);
    configBinder.forField(id).asRequired(msg.getMessage("fieldRequired")).bind("id");
    header.addComponent(id);
    TextField address = new TextField(msg.getMessage("EditIndividualTrustedIdpSubView.address"));
    address.setWidth(FieldSizeConstans.LINK_FIELD_WIDTH, FieldSizeConstans.LINK_FIELD_WIDTH_UNIT);
    configBinder.forField(address).bind("address");
    header.addComponent(address);
    ChipsWithFreeText requestedNameFormats = new ChipsWithFreeText(msg);
    requestedNameFormats.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
    requestedNameFormats.setCaption(msg.getMessage("EditIndividualTrustedIdpSubView.requestedNameFormats"));
    requestedNameFormats.setItems(SAMLAuthenticatorEditor.STANDART_NAME_FORMATS);
    header.addComponent(requestedNameFormats);
    configBinder.forField(requestedNameFormats).bind("requestedNameFormats");
    CheckBox signRequest = new CheckBox(msg.getMessage("EditIndividualTrustedIdpSubView.signRequest"));
    ComboBox<Binding> binding = new ComboBox<>(msg.getMessage("EditIndividualTrustedIdpSubView.binding"));
    binding.setItems(Binding.values());
    binding.setEmptySelectionAllowed(false);
    binding.addValueChangeListener(e -> {
        boolean v = e.getValue().equals(Binding.HTTP_POST);
        signRequest.setEnabled(v);
        if (!v) {
            signRequest.setValue(false);
        }
    });
    configBinder.forField(binding).bind("binding");
    configBinder.forField(signRequest).withValidator((v, c) -> {
        if (v != null && v && (binding.getValue().equals(Binding.HTTP_REDIRECT) || binding.getValue().equals(Binding.SOAP))) {
            return ValidationResult.error(msg.getMessage("EditIndividualTrustedIdpSubView.signRequestValidationError"));
        }
        return ValidationResult.ok();
    }).bind("signRequest");
    header.addComponent(binding);
    header.addComponent(signRequest);
    ChipsWithDropdown<String> certificatesCombo = new ChipsWithDropdown<>();
    certificatesCombo.setCaption(msg.getMessage("EditIndividualTrustedIdpSubView.certificates"));
    certificatesCombo.setItems(certificates.stream().collect(Collectors.toList()));
    configBinder.forField(certificatesCombo).bind("certificates");
    header.addComponent(certificatesCombo);
    TextField groupAttribute = new TextField(msg.getMessage("EditIndividualTrustedIdpSubView.groupMembershipAttribute"));
    configBinder.forField(groupAttribute).bind("groupMembershipAttribute");
    header.addComponent(groupAttribute);
    ComboBox<String> registrationForm = new ComboBox<>(msg.getMessage("EditIndividualTrustedIdpSubView.registrationForm"));
    registrationForm.setItems(registrationForms);
    header.addComponent(registrationForm);
    configBinder.forField(registrationForm).bind("registrationForm");
    EnableDisableCombo accountAssociation = new EnableDisableCombo(msg.getMessage("EditIndividualTrustedIdpSubView.accountAssociation"), msg);
    configBinder.forField(accountAssociation).bind("accountAssociation");
    header.addComponent(accountAssociation);
    return header;
}
Also used : FieldSizeConstans(pl.edu.icm.unity.webui.common.FieldSizeConstans) Arrays(java.util.Arrays) CustomComponent(com.vaadin.ui.CustomComponent) TextField(com.vaadin.ui.TextField) VerticalLayout(com.vaadin.ui.VerticalLayout) ComboBox(com.vaadin.ui.ComboBox) ValidationResult(com.vaadin.data.ValidationResult) ImageField(pl.edu.icm.unity.webui.common.file.ImageField) NoSpaceValidator(pl.edu.icm.unity.webui.common.validators.NoSpaceValidator) UnityServerConfiguration(pl.edu.icm.unity.engine.api.config.UnityServerConfiguration) UnitySubView(pl.edu.icm.unity.webui.common.webElements.UnitySubView) CheckBox(com.vaadin.ui.CheckBox) MessageSource(pl.edu.icm.unity.MessageSource) NotificationPopup(pl.edu.icm.unity.webui.common.NotificationPopup) CollapsibleLayout(pl.edu.icm.unity.webui.common.CollapsibleLayout) Binding(pl.edu.icm.unity.saml.SamlProperties.Binding) EnableDisableCombo(pl.edu.icm.unity.webui.common.EnableDisableCombo) Set(java.util.Set) InputTranslationProfileFieldFactory(io.imunity.webconsole.utils.tprofile.InputTranslationProfileFieldFactory) FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) StandardButtonsHelper(pl.edu.icm.unity.webui.common.StandardButtonsHelper) Collectors(java.util.stream.Collectors) Binder(com.vaadin.data.Binder) Consumer(java.util.function.Consumer) List(java.util.List) SubViewSwitcher(pl.edu.icm.unity.webui.common.webElements.SubViewSwitcher) ChipsWithFreeText(pl.edu.icm.unity.webui.common.chips.ChipsWithFreeText) I18nTextField(pl.edu.icm.unity.webui.common.i18n.I18nTextField) URIAccessService(pl.edu.icm.unity.engine.api.files.URIAccessService) FormLayout(com.vaadin.ui.FormLayout) FormValidationException(pl.edu.icm.unity.webui.common.FormValidationException) ChipsWithDropdown(pl.edu.icm.unity.webui.common.chips.ChipsWithDropdown) Binding(pl.edu.icm.unity.saml.SamlProperties.Binding) ChipsWithFreeText(pl.edu.icm.unity.webui.common.chips.ChipsWithFreeText) ComboBox(com.vaadin.ui.ComboBox) I18nTextField(pl.edu.icm.unity.webui.common.i18n.I18nTextField) ChipsWithDropdown(pl.edu.icm.unity.webui.common.chips.ChipsWithDropdown) ImageField(pl.edu.icm.unity.webui.common.file.ImageField) 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) EnableDisableCombo(pl.edu.icm.unity.webui.common.EnableDisableCombo) NoSpaceValidator(pl.edu.icm.unity.webui.common.validators.NoSpaceValidator)

Example 3 with URIAccessService

use of pl.edu.icm.unity.engine.api.files.URIAccessService in project unity by unity-idm.

the class MetadataSourceHandlerTest method init.

@Before
public void init() throws EngineException, IOException, URISyntaxException {
    executorsService = mock(ExecutorsService.class);
    ScheduledExecutorService pool = Executors.newScheduledThreadPool(1);
    when(executorsService.getService()).thenReturn(pool);
    src = new RemoteMetadataSrc("http://url", null);
    fileStorageService = mock(FileStorageService.class);
    uriAccessService = mock(URIAccessService.class);
    when(fileStorageService.readFileFromWorkspace(any())).thenThrow(EngineException.class);
    when(uriAccessService.readURI(eq(new URI("http://url")))).thenAnswer((a) -> new FileData("xx", Files.readAllBytes(Paths.get("src/test/resources/unity-as-sp-meta.xml")), new Date()));
    when(uriAccessService.readURI(eq(new URI("http://url")), any())).thenAnswer((a) -> new FileData("xx", Files.readAllBytes(Paths.get("src/test/resources/unity-as-sp-meta.xml")), new Date()));
    when(fileStorageService.storeFileInWorkspace(any(), any())).thenAnswer((a) -> new FileData("xx", Files.readAllBytes(Paths.get("src/test/resources/unity-as-sp-meta.xml")), new Date()));
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ExecutorsService(pl.edu.icm.unity.engine.api.utils.ExecutorsService) FileStorageService(pl.edu.icm.unity.engine.api.files.FileStorageService) URIAccessService(pl.edu.icm.unity.engine.api.files.URIAccessService) URI(java.net.URI) FileData(pl.edu.icm.unity.base.file.FileData) Date(java.util.Date) Before(org.junit.Before)

Aggregations

URIAccessService (pl.edu.icm.unity.engine.api.files.URIAccessService)3 Binder (com.vaadin.data.Binder)2 ValidationResult (com.vaadin.data.ValidationResult)2 CheckBox (com.vaadin.ui.CheckBox)2 CustomComponent (com.vaadin.ui.CustomComponent)2 FormLayout (com.vaadin.ui.FormLayout)2 TextField (com.vaadin.ui.TextField)2 VerticalLayout (com.vaadin.ui.VerticalLayout)2 Arrays (java.util.Arrays)2 List (java.util.List)2 Set (java.util.Set)2 Consumer (java.util.function.Consumer)2 Collectors (java.util.stream.Collectors)2 MessageSource (pl.edu.icm.unity.MessageSource)2 UnityServerConfiguration (pl.edu.icm.unity.engine.api.config.UnityServerConfiguration)2 CollapsibleLayout (pl.edu.icm.unity.webui.common.CollapsibleLayout)2 FieldSizeConstans (pl.edu.icm.unity.webui.common.FieldSizeConstans)2 FormLayoutWithFixedCaptionWidth (pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth)2 FormValidationException (pl.edu.icm.unity.webui.common.FormValidationException)2 NotificationPopup (pl.edu.icm.unity.webui.common.NotificationPopup)2