use of com.vaadin.ui.TextField in project unity by unity-idm.
the class OTPWithLDAPAuthenticatorEditor method buildUserDNResolvingSection.
private CollapsibleLayout buildUserDNResolvingSection() {
FormLayoutWithFixedCaptionWidth userDNResolvingLayout = new FormLayoutWithFixedCaptionWidth();
userDNResolvingLayout.setMargin(false);
userDNResolvingMode = new RadioButtonGroup<>();
userDNResolvingMode.setItemCaptionGenerator(v -> msg.getMessage("LdapAuthenticatorEditor.userDNResolvingMode." + v.toString()));
userDNResolvingMode.setItems(UserDNResolving.values());
configBinder.forField(userDNResolvingMode).bind("userDNResolving");
userDNResolvingLayout.addComponent(userDNResolvingMode);
TextField userDNtemplate = new TextField(msg.getMessage("LdapAuthenticatorEditor.userDNtemplate"));
userDNtemplate.setPlaceholder("uid={USERNAME},dc=myorg,dc=global");
userDNtemplate.setDescription(msg.getMessage("LdapAuthenticatorEditor.userDNtemplate.desc"));
userDNtemplate.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
configBinder.forField(userDNtemplate).withValidator((v, c) -> {
if (v != null && v.contains("{USERNAME}") || !userDNResolvingMode.getValue().equals(UserDNResolving.template)) {
return ValidationResult.ok();
} else {
return ValidationResult.error(msg.getMessage("LdapAuthenticatorEditor.invalidUserDNtemplate"));
}
}).bind("userDNTemplate");
userDNResolvingLayout.addComponent(userDNtemplate);
TextField ldapSearchBaseName = new TextField(msg.getMessage("LdapAuthenticatorEditor.searchSpecification.baseName"));
ldapSearchBaseName.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
configBinder.forField(ldapSearchBaseName).asRequired(getLdapSearchRequiredValidator()).bind("ldapSearchBaseName");
userDNResolvingLayout.addComponent(ldapSearchBaseName);
TextField ldapSearchFilter = new TextField(msg.getMessage("LdapAuthenticatorEditor.searchSpecification.filter"));
ldapSearchFilter.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
configBinder.forField(ldapSearchFilter).withValidator((v, c) -> {
if (userDNResolvingMode.getValue().equals(UserDNResolving.ldapSearch)) {
return getFilterValidator().apply(v, c);
} else {
return ValidationResult.ok();
}
}).bind("ldapSearchFilter");
userDNResolvingLayout.addComponent(ldapSearchFilter);
ComboBox<SearchScope> ldapSearchScope = new ComboBox<>(msg.getMessage("LdapAuthenticatorEditor.searchSpecification.scope"));
ldapSearchScope.setEmptySelectionAllowed(false);
ldapSearchScope.setItems(SearchScope.values());
configBinder.forField(ldapSearchScope).bind("ldapSearchScope");
userDNResolvingLayout.addComponent(ldapSearchScope);
userDNResolvingMode.addValueChangeListener(e -> {
UserDNResolving v = userDNResolvingMode.getValue();
userDNtemplate.setVisible(v.equals(UserDNResolving.template));
ldapSearchBaseName.setVisible(v.equals(UserDNResolving.ldapSearch));
ldapSearchFilter.setVisible(v.equals(UserDNResolving.ldapSearch));
ldapSearchScope.setVisible(v.equals(UserDNResolving.ldapSearch));
if (v.equals(UserDNResolving.template)) {
ldapSearchBaseName.clear();
ldapSearchFilter.clear();
} else {
userDNtemplate.clear();
}
});
return new CollapsibleLayout(msg.getMessage("OTPWithLDAPAuthenticatorEditor.userDNResolving"), userDNResolvingLayout);
}
use of com.vaadin.ui.TextField in project unity by unity-idm.
the class OTPWithLDAPAuthenticatorEditor method buildServersConnectionConfigurationSection.
private CollapsibleLayout buildServersConnectionConfigurationSection() {
FormLayoutWithFixedCaptionWidth serverConnectionLayout = new FormLayoutWithFixedCaptionWidth();
serverConnectionLayout.setMargin(false);
GridWithEditor<ServerSpecification> serverConfig = new GridWithEditor<>(msg, ServerSpecification.class);
serverConnectionLayout.addComponent(serverConfig);
serverConfig.addTextColumn(s -> s.getServer(), (t, v) -> t.setServer(v), msg.getMessage("LdapAuthenticatorEditor.server"), 40, true);
serverConfig.addIntColumn(s -> s.getPort(), (t, v) -> t.setPort(v), msg.getMessage("LdapAuthenticatorEditor.port"), 10, Optional.of(new IntegerRangeValidator(msg.getMessage("notAPositiveNumber"), 1, 65535)));
serverConfig.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
configBinder.forField(serverConfig).withValidator((v, c) -> {
if (v == null || v.isEmpty()) {
return ValidationResult.error(msg.getMessage("fieldRequired"));
} else {
return ValidationResult.ok();
}
}).bind("servers");
ComboBox<ConnectionMode> connectionMode = new ComboBox<>(msg.getMessage("LdapAuthenticatorEditor.connectionMode"));
connectionMode.setItems(ConnectionMode.values());
connectionMode.setEmptySelectionAllowed(false);
configBinder.forField(connectionMode).bind("connectionMode");
serverConnectionLayout.addComponent(connectionMode);
TextField followReferrals = new TextField(msg.getMessage("LdapAuthenticatorEditor.followReferrals"));
configBinder.forField(followReferrals).asRequired(msg.getMessage("notAPositiveNumber")).withConverter(new StringToIntegerConverter(msg.getMessage("notAPositiveNumber"))).withValidator(new IntegerRangeValidator(msg.getMessage("notAPositiveNumber"), 0, null)).bind("followReferrals");
serverConnectionLayout.addComponent(followReferrals);
TextField searchTimeLimit = new TextField(msg.getMessage("LdapAuthenticatorEditor.searchTimeLimit"));
configBinder.forField(searchTimeLimit).asRequired(msg.getMessage("notAPositiveNumber")).withConverter(new StringToIntegerConverter(msg.getMessage("notAPositiveNumber"))).withValidator(new IntegerRangeValidator(msg.getMessage("notAPositiveNumber"), 0, null)).bind("searchTimeLimit");
serverConnectionLayout.addComponent(searchTimeLimit);
TextField socketTimeout = new TextField(msg.getMessage("LdapAuthenticatorEditor.socketTimeout"));
configBinder.forField(socketTimeout).asRequired(msg.getMessage("notAPositiveNumber")).withConverter(new StringToIntegerConverter(msg.getMessage("notAPositiveNumber"))).withValidator(new IntegerRangeValidator(msg.getMessage("notAPositiveNumber"), 0, null)).bind("socketTimeout");
serverConnectionLayout.addComponent(socketTimeout);
CheckBox trustAllCerts = new CheckBox(msg.getMessage("LdapAuthenticatorEditor.trustAllCerts"));
configBinder.forField(trustAllCerts).bind("trustAllCerts");
serverConnectionLayout.addComponent(trustAllCerts);
ComboBox<String> clientTrustStore = new ComboBox<>(msg.getMessage("LdapAuthenticatorEditor.clientTrustStore"));
clientTrustStore.setItems(validators);
configBinder.forField(clientTrustStore).bind("clientTrustStore");
serverConnectionLayout.addComponent(clientTrustStore);
trustAllCerts.addValueChangeListener(e -> {
clientTrustStore.setEnabled(!e.getValue());
});
TextField resultEntriesLimit = new TextField(msg.getMessage("LdapAuthenticatorEditor.resultEntriesLimit"));
configBinder.forField(resultEntriesLimit).asRequired(msg.getMessage("notAPositiveNumber")).withConverter(new StringToIntegerConverter(msg.getMessage("notAPositiveNumber"))).withValidator(new IntegerRangeValidator(msg.getMessage("notAPositiveNumber"), 0, null)).bind("resultEntriesLimit");
serverConnectionLayout.addComponent(resultEntriesLimit);
return new CollapsibleLayout(msg.getMessage("OTPWithLDAPAuthenticatorEditor.serverConnectionConfiguration"), serverConnectionLayout);
}
use of com.vaadin.ui.TextField in project unity by unity-idm.
the class OTPWithLDAPAuthenticatorEditor method buildLdapHeaderSection.
private CollapsibleLayout buildLdapHeaderSection() {
FormLayoutWithFixedCaptionWidth ldap = new FormLayoutWithFixedCaptionWidth();
TextField systemDN = new TextField(msg.getMessage("LdapAuthenticatorEditor.systemDN"));
systemDN.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
configBinder.forField(systemDN).asRequired().bind("systemDN");
ldap.addComponent(systemDN);
TextField systemPassword = new TextField(msg.getMessage("LdapAuthenticatorEditor.systemPassword"));
systemPassword.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
configBinder.forField(systemPassword).asRequired().bind("systemPassword");
ldap.addComponent(systemPassword);
TextField validUserFilter = new TextField(msg.getMessage("LdapAuthenticatorEditor.validUserFilter"));
validUserFilter.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
configBinder.forField(validUserFilter).withValidator((v, c) -> {
try {
Filter.create(v);
} catch (LDAPException e) {
return ValidationResult.error(msg.getMessage("LdapAuthenticatorEditor.invalidValidUserFilter"));
}
return ValidationResult.ok();
}).bind("validUserFilter");
ldap.addComponent(validUserFilter);
TextField secretAttribute = new TextField(msg.getMessage("OTPWithLDAPAuthenticatorEditor.secretAttribute"));
configBinder.forField(secretAttribute).asRequired().bind("secretAttribute");
ldap.addComponent(secretAttribute);
TextField usernameExtractorRegexp = new TextField(msg.getMessage("LdapAuthenticatorEditor.usernameExtractorRegexp"));
usernameExtractorRegexp.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
configBinder.forField(usernameExtractorRegexp).bind("usernameExtractorRegexp");
ldap.addComponent(usernameExtractorRegexp);
return new CollapsibleLayout(msg.getMessage("OTPWithLDAPAuthenticatorEditor.ldap"), ldap);
}
use of com.vaadin.ui.TextField in project unity by unity-idm.
the class GroupEditDialog method getContents.
@Override
protected Component getContents() {
FormLayout fl = new CompactFormLayout();
fl.setMargin(true);
fl.setSpacing(true);
path = new TextField(msg.getMessage("GroupEditDialog.groupPath"));
path.setValue(originalGroup.getPathEncoded());
path.setReadOnly(true);
path.setWidthFull();
fl.addComponent(path);
displayedName = new I18nTextField(msg, msg.getMessage("displayedNameF"));
displayedName.setValue(originalGroup.getDisplayedName());
description = new I18nTextArea(msg, msg.getMessage("GroupEditDialog.groupDesc"));
description.setValue(originalGroup.getDescription());
isPublic = new CheckBox(msg.getMessage("GroupEditDialog.public"));
isPublic.setValue(originalGroup.isPublic());
propertiesEditor = new GridWithEditor<>(msg, GroupPropertyBean.class, t -> false, false, false);
propertiesEditor.setCaption(msg.getMessage("GroupEditDialog.groupProperties"));
propertiesEditor.getEditor().addOpenListener(e -> edited = e.getBean());
propertiesEditor.addTextColumn(s -> s.key, (t, v) -> t.setKey(v), msg.getMessage("GroupEditDialog.propertyName"), 10, true, Optional.of((value, context) -> {
if (propertiesEditor.getValue().stream().filter(k -> !k.key.equals(edited.key)).map(k -> k.key).anyMatch(k -> k.equals(value))) {
return ValidationResult.error(msg.getMessage("GroupEditDialog.propertyNameExists"));
}
return new StringLengthValidator(msg.getMessage("maxLength", GroupProperty.MAX_KEY_LENGTH), 0, GroupProperty.MAX_KEY_LENGTH).apply(value, context);
}));
propertiesEditor.addTextColumn(s -> s.getValue(), (t, v) -> t.setValue(v), msg.getMessage("GroupEditDialog.propertyValue"), 40, false, Optional.of(new StringLengthValidator(msg.getMessage("maxLength", GroupProperty.MAX_VALUE_LENGHT), 0, GroupProperty.MAX_VALUE_LENGHT)));
propertiesEditor.setValue(originalGroup.getProperties().values().stream().map(p -> new GroupPropertyBean(p)).collect(Collectors.toList()));
fl.addComponents(displayedName, description, isPublic, propertiesEditor);
description.focus();
return fl;
}
use of com.vaadin.ui.TextField in project unity by unity-idm.
the class AddFilterDialog method getContents.
@Override
protected Component getContents() {
Label info = new Label(msg.getMessage("AddFilterDialog.column"));
column = new ComboBox<>();
column.setItems(columns.stream().filter(c -> !c.equals(IdentitiesGridColumnConstans.ACTION_COLUMN_ID)).collect(Collectors.toList()));
column.setEmptySelectionAllowed(false);
column.setSelectedItem(columns.iterator().next());
column.setItemCaptionGenerator(i -> {
if (i.startsWith(IdentitiesGridColumnConstans.ATTR_COL_PREFIX))
return i.substring(IdentitiesGridColumnConstans.ATTR_COL_PREFIX.length());
else if (i.startsWith(IdentitiesGridColumnConstans.CRED_STATUS_COL_PREFIX))
return i.substring(IdentitiesGridColumnConstans.CRED_STATUS_COL_PREFIX.length());
else
return msg.getMessage("Identities." + i);
});
operand = new EnumComboBox<>(msg, "AddFilterDialog.operand.", Operand.class, Operand.contain);
argument = new TextField();
HorizontalLayout filter = new HorizontalLayout();
filter.setMargin(false);
filter.addComponents(info, column, operand, argument);
return filter;
}
Aggregations