Search in sources :

Example 61 with TextField

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

the class EditOAuthProviderSubView method buildHeaderSection.

private FormLayoutWithFixedCaptionWidth buildHeaderSection(Set<String> providersIds) {
    FormLayoutWithFixedCaptionWidth header = new FormLayoutWithFixedCaptionWidth();
    header.setMargin(true);
    loadTemplates();
    templateCombo = new ComboBox<>();
    templateCombo.setCaption(msg.getMessage("EditOAuthProviderSubView.template"));
    templateCombo.setItems(templates.keySet().stream().sorted());
    templateCombo.setEmptySelectionAllowed(false);
    configBinder.forField(templateCombo).asRequired(msg.getMessage("fieldRequired")).bind("type");
    if (!editMode) {
        header.addComponent(templateCombo);
    }
    TextField id = new TextField(msg.getMessage("EditOAuthProviderSubView.id"));
    configBinder.forField(id).asRequired(msg.getMessage("fieldRequired")).withValidator((s, c) -> {
        if (providersIds.contains(s)) {
            return ValidationResult.error(msg.getMessage("EditOAuthProviderSubView.idExists"));
        } else {
            return ValidationResult.ok();
        }
    }).withValidator(new NoSpaceValidator(msg)).bind("id");
    id.setReadOnly(editMode);
    header.addComponent(id);
    I18nTextField name = new I18nTextField(msg, msg.getMessage("EditOAuthProviderSubView.name"));
    configBinder.forField(name).asRequired(msg.getMessage("fieldRequired")).bind("name");
    header.addComponent(name);
    TextField clientId = new TextField(msg.getMessage("EditOAuthProviderSubView.clientId"));
    clientId.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
    configBinder.forField(clientId).asRequired(msg.getMessage("fieldRequired")).bind("clientId");
    header.addComponent(clientId);
    TextField clientSecret = new TextField(msg.getMessage("EditOAuthProviderSubView.clientSecret"));
    clientSecret.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
    configBinder.forField(clientSecret).asRequired(msg.getMessage("fieldRequired")).bind("clientSecret");
    header.addComponent(clientSecret);
    ChipsWithTextfield requestedScopes = new ChipsWithTextfield(msg);
    requestedScopes.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
    requestedScopes.setCaption(msg.getMessage("EditOAuthProviderSubView.requestedScopes"));
    header.addComponent(requestedScopes);
    configBinder.forField(requestedScopes).bind("requestedScopes");
    ImageField logo = new ImageField(msg, uriAccessService, serverConfig.getFileSizeLimit());
    logo.setCaption(msg.getMessage("EditOAuthProviderSubView.logo"));
    logo.configureBinding(configBinder, "logo");
    header.addComponent(logo);
    CheckBox openIdConnect = new CheckBox(msg.getMessage("EditOAuthProviderSubView.openIdConnect"));
    configBinder.forField(openIdConnect).bind("openIdConnect");
    header.addComponent(openIdConnect);
    TextField openIdDiscovery = new TextField(msg.getMessage("EditOAuthProviderSubView.openIdDiscoverEndpoint"));
    openIdDiscovery.setWidth(FieldSizeConstans.LINK_FIELD_WIDTH, FieldSizeConstans.LINK_FIELD_WIDTH_UNIT);
    configBinder.forField(openIdDiscovery).asRequired(getOpenIdFieldValidator(openIdConnect, true)).bind("openIdDiscoverEndpoint");
    openIdDiscovery.setVisible(false);
    openIdDiscovery.setRequiredIndicatorVisible(false);
    header.addComponent(openIdDiscovery);
    openIdConnect.addValueChangeListener(e -> openIdDiscovery.setVisible(e.getValue()));
    TextField authenticationEndpoint = new TextField(msg.getMessage("EditOAuthProviderSubView.authenticationEndpoint"));
    configBinder.forField(authenticationEndpoint).asRequired(getOpenIdFieldValidator(openIdConnect, false)).bind("authenticationEndpoint");
    authenticationEndpoint.setWidth(FieldSizeConstans.LINK_FIELD_WIDTH, FieldSizeConstans.LINK_FIELD_WIDTH_UNIT);
    authenticationEndpoint.setRequiredIndicatorVisible(false);
    header.addComponent(authenticationEndpoint);
    TextField accessTokenEndpoint = new TextField(msg.getMessage("EditOAuthProviderSubView.accessTokenEndpoint"));
    accessTokenEndpoint.setWidth(FieldSizeConstans.LINK_FIELD_WIDTH, FieldSizeConstans.LINK_FIELD_WIDTH_UNIT);
    configBinder.forField(accessTokenEndpoint).asRequired(getOpenIdFieldValidator(openIdConnect, false)).bind("accessTokenEndpoint");
    accessTokenEndpoint.setRequiredIndicatorVisible(false);
    header.addComponent(accessTokenEndpoint);
    TextField profileEndpoint = new TextField(msg.getMessage("EditOAuthProviderSubView.profileEndpoint"));
    profileEndpoint.setWidth(FieldSizeConstans.LINK_FIELD_WIDTH, FieldSizeConstans.LINK_FIELD_WIDTH_UNIT);
    configBinder.forField(profileEndpoint).bind("profileEndpoint");
    header.addComponent(profileEndpoint);
    return header;
}
Also used : 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) I18nTextField(pl.edu.icm.unity.webui.common.i18n.I18nTextField) TextField(com.vaadin.ui.TextField) I18nTextField(pl.edu.icm.unity.webui.common.i18n.I18nTextField) NoSpaceValidator(pl.edu.icm.unity.webui.common.validators.NoSpaceValidator)

Example 62 with TextField

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

the class OAuthAuthenticatorEditor method getEditor.

@Override
public Component getEditor(AuthenticatorDefinition toEdit, SubViewSwitcher subViewSwitcher, boolean forceNameEditable) {
    this.subViewSwitcher = subViewSwitcher;
    boolean editMode = init(msg.getMessage("OAuthAuthenticatorEditor.defaultName"), toEdit, forceNameEditable);
    configBinder = new Binder<>(OAuthConfiguration.class);
    FormLayoutWithFixedCaptionWidth header = new FormLayoutWithFixedCaptionWidth();
    header.setMargin(true);
    header.addComponent(name);
    CheckBox accountAssociation = new CheckBox(msg.getMessage("OAuthAuthenticatorEditor.accountAssociation"));
    header.addComponent(accountAssociation);
    TextField returnURLInfo = new TextField();
    returnURLInfo.setValue(buildReturnURL());
    returnURLInfo.setReadOnly(true);
    returnURLInfo.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
    CopyToClipboardButton copy = new CopyToClipboardButton(msg, returnURLInfo);
    HorizontalLayout hr = new HorizontalLayout(returnURLInfo, copy);
    hr.setComponentAlignment(copy, Alignment.MIDDLE_LEFT);
    hr.setCaption(msg.getMessage("OAuthAuthenticatorEditor.returnURLInfo"));
    header.addComponent(hr);
    configBinder.forField(accountAssociation).bind("defAccountAssociation");
    providersComponent = new ProvidersComponent();
    providersComponent.setCaption(msg.getMessage("OAuthAuthenticatorEditor.providers"));
    configBinder.forField(providersComponent).bind("providers");
    header.addComponent(providersComponent);
    VerticalLayout mainView = new VerticalLayout();
    mainView.setMargin(false);
    mainView.addComponent(header);
    OAuthConfiguration config = new OAuthConfiguration();
    if (editMode) {
        config.fromProperties(toEdit.configuration, msg, pkiMan, imageAccessService);
    }
    configBinder.setBean(config);
    return mainView;
}
Also used : FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) CheckBox(com.vaadin.ui.CheckBox) TextField(com.vaadin.ui.TextField) CopyToClipboardButton(io.imunity.webelements.clipboard.CopyToClipboardButton) VerticalLayout(com.vaadin.ui.VerticalLayout) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 63 with TextField

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

the class OAuthRPAuthenticatorEditor method buildHeaderSection.

private FormLayout buildHeaderSection() {
    FormLayoutWithFixedCaptionWidth header = new FormLayoutWithFixedCaptionWidth();
    header.setMargin(true);
    header.addComponent(name);
    TextField clientId = new TextField(msg.getMessage("OAuthRPAuthenticatorEditor.clientId"));
    clientId.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
    configBinder.forField(clientId).asRequired(msg.getMessage("fieldRequired")).bind("clientId");
    header.addComponent(clientId);
    TextField clientSecret = new TextField(msg.getMessage("OAuthRPAuthenticatorEditor.clientSecret"));
    clientSecret.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
    configBinder.forField(clientSecret).asRequired(msg.getMessage("fieldRequired")).bind("clientSecret");
    header.addComponent(clientSecret);
    ChipsWithTextfield requiredScopes = new ChipsWithTextfield(msg);
    requiredScopes.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
    requiredScopes.setCaption(msg.getMessage("OAuthRPAuthenticatorEditor.requiredScopes"));
    header.addComponent(requiredScopes);
    configBinder.forField(requiredScopes).bind("requiredScopes");
    ComboBox<VerificationProtocol> verificationProtocol = new ComboBox<>(msg.getMessage("OAuthRPAuthenticatorEditor.verificationProtocol"));
    verificationProtocol.setItems(VerificationProtocol.values());
    verificationProtocol.setEmptySelectionAllowed(false);
    configBinder.forField(verificationProtocol).bind("verificationProtocol");
    header.addComponent(verificationProtocol);
    TextField verificationEndpoint = new TextField(msg.getMessage("OAuthRPAuthenticatorEditor.verificationEndpoint"));
    verificationEndpoint.setWidth(LINK_FIELD_WIDTH, Unit.EM);
    verificationEndpoint.setRequiredIndicatorVisible(false);
    configBinder.forField(verificationEndpoint).asRequired((v, c) -> {
        if (verificationProtocol.getValue() != VerificationProtocol.internal && v.isEmpty()) {
            return ValidationResult.error(msg.getMessage("fieldRequired"));
        } else {
            return ValidationResult.ok();
        }
    }).bind("verificationEndpoint");
    header.addComponent(verificationEndpoint);
    TextField profileEndpoint = new TextField(msg.getMessage("OAuthRPAuthenticatorEditor.profileEndpoint"));
    profileEndpoint.setWidth(LINK_FIELD_WIDTH, Unit.EM);
    configBinder.forField(profileEndpoint).bind("profileEndpoint");
    header.addComponent(profileEndpoint);
    return header;
}
Also used : FieldSizeConstans(pl.edu.icm.unity.webui.common.FieldSizeConstans) TextField(com.vaadin.ui.TextField) VerticalLayout(com.vaadin.ui.VerticalLayout) ComboBox(com.vaadin.ui.ComboBox) ValidationResult(com.vaadin.data.ValidationResult) PKIManagement(pl.edu.icm.unity.engine.api.PKIManagement) CheckBox(com.vaadin.ui.CheckBox) ClientAuthnMode(pl.edu.icm.unity.oauth.client.config.CustomProviderProperties.ClientAuthnMode) ClientHttpMethod(pl.edu.icm.unity.oauth.client.config.CustomProviderProperties.ClientHttpMethod) AuthenticatorDefinition(pl.edu.icm.unity.types.authn.AuthenticatorDefinition) OAuthTokenRepository(pl.edu.icm.unity.oauth.as.OAuthTokenRepository) MessageSource(pl.edu.icm.unity.MessageSource) ChipsWithTextfield(pl.edu.icm.unity.webui.common.chips.ChipsWithTextfield) CollapsibleLayout(pl.edu.icm.unity.webui.common.CollapsibleLayout) ServerHostnameCheckingMode(eu.unicore.util.httpclient.ServerHostnameCheckingMode) Set(java.util.Set) InputTranslationProfileFieldFactory(io.imunity.webconsole.utils.tprofile.InputTranslationProfileFieldFactory) BearerTokenVerificator(pl.edu.icm.unity.oauth.rp.verificator.BearerTokenVerificator) VerificationProtocol(pl.edu.icm.unity.oauth.rp.OAuthRPProperties.VerificationProtocol) FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) Binder(com.vaadin.data.Binder) EngineException(pl.edu.icm.unity.exceptions.EngineException) SubViewSwitcher(pl.edu.icm.unity.webui.common.webElements.SubViewSwitcher) AuthenticatorEditor(pl.edu.icm.unity.webui.authn.authenticators.AuthenticatorEditor) FormLayout(com.vaadin.ui.FormLayout) ConfigurationException(eu.unicore.util.configuration.ConfigurationException) BaseAuthenticatorEditor(pl.edu.icm.unity.webui.authn.authenticators.BaseAuthenticatorEditor) FormValidationException(pl.edu.icm.unity.webui.common.FormValidationException) StringToIntegerConverter(com.vaadin.data.converter.StringToIntegerConverter) Unit(com.vaadin.server.Sizeable.Unit) Component(com.vaadin.ui.Component) VerificationProtocol(pl.edu.icm.unity.oauth.rp.OAuthRPProperties.VerificationProtocol) FormLayoutWithFixedCaptionWidth(pl.edu.icm.unity.webui.common.FormLayoutWithFixedCaptionWidth) ComboBox(com.vaadin.ui.ComboBox) ChipsWithTextfield(pl.edu.icm.unity.webui.common.chips.ChipsWithTextfield) TextField(com.vaadin.ui.TextField)

Example 64 with TextField

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

the class MobileNumberConfirmationDialog method getConfirmCodeComponent.

private Component getConfirmCodeComponent() {
    field = new TextField();
    field.setCaption(msg.getMessage("MobileNumberConfirmationDialog.code"));
    field.setRequiredIndicatorVisible(true);
    Label infoLabel = new Label(msg.getMessage("MobileNumberConfirmationDialog.confirmInfo", mobileToConfirm));
    infoLabel.setSizeFull();
    errorLabel = new Label();
    errorLabel.setSizeFull();
    errorLabel.setVisible(false);
    errorLabel.setStyleName(Styles.error.toString());
    CompactFormLayout mainForm = new CompactFormLayout();
    mainForm.addComponents(field, errorLabel);
    VerticalLayout wrapper = new VerticalLayout();
    wrapper.setMargin(false);
    wrapper.addComponents(infoLabel, mainForm);
    return wrapper;
}
Also used : CompactFormLayout(pl.edu.icm.unity.webui.common.CompactFormLayout) Label(com.vaadin.ui.Label) TextField(com.vaadin.ui.TextField) VerticalLayout(com.vaadin.ui.VerticalLayout)

Example 65 with TextField

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

the class IdentifierIdentityEditor method getEditor.

@Override
public ComponentsContainer getEditor(IdentityEditorContext context) {
    binder = new SingleStringFieldBinder(msg);
    this.context = context;
    field = new TextField();
    setLabel(new IdentifierIdentity().getHumanFriendlyName(msg));
    if (context.isCustomWidth())
        field.setWidth(context.getCustomWidth(), context.getCustomWidthUnit());
    binder.forField(field, context.isRequired()).bind("value");
    binder.setBean(new StringBindingValue(""));
    return new ComponentsContainer(field);
}
Also used : IdentifierIdentity(pl.edu.icm.unity.stdext.identity.IdentifierIdentity) TextField(com.vaadin.ui.TextField) StringBindingValue(pl.edu.icm.unity.webui.common.binding.StringBindingValue) ComponentsContainer(pl.edu.icm.unity.webui.common.ComponentsContainer) SingleStringFieldBinder(pl.edu.icm.unity.webui.common.binding.SingleStringFieldBinder)

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