use of pl.edu.icm.unity.webui.common.CollapsibleLayout in project unity by unity-idm.
the class OAuthEditorGeneralTab method buildScopesSection.
private CollapsibleLayout buildScopesSection() {
VerticalLayout scopesLayout = new VerticalLayout();
scopesLayout.setMargin(false);
scopesGrid = new GridWithEditorInDetails<>(msg, OAuthScope.class, () -> new ScopeEditor(msg, attrTypes), s -> false, s -> s != null && s.getName() != null && (SCOPES_BLOCKED_TO_EDIT.contains(s.getName())), true);
scopesGrid.addGotoEditColumn(s -> s.getName(), msg.getMessage("OAuthEditorGeneralTab.scopeName"), 10);
scopesGrid.addTextColumn(s -> s.getDescription(), msg.getMessage("OAuthEditorGeneralTab.scopeDescription"), 10);
scopesGrid.addTextColumn(s -> s.getAttributes() != null ? String.join(",", s.getAttributes()) : "", msg.getMessage("OAuthEditorGeneralTab.scopeAttributes"), 10);
scopesGrid.setMinHeightByRow(7);
configBinder.forField(scopesGrid).bind("scopes");
scopesLayout.addComponent(scopesGrid);
return new CollapsibleLayout(msg.getMessage("OAuthEditorGeneralTab.scopes"), scopesLayout);
}
use of pl.edu.icm.unity.webui.common.CollapsibleLayout in project unity by unity-idm.
the class OTPWithLDAPAuthenticatorEditor method buildOtpHeaderSection.
private CollapsibleLayout buildOtpHeaderSection() {
FormLayoutWithFixedCaptionWidth otp = new FormLayoutWithFixedCaptionWidth();
ComboBox<Integer> codeLength = new ComboBox<>(msg.getMessage("OTPCredentialDefinitionEditor.codeLength"));
tooltip(codeLength, msg.getMessage("OTPWithLDAPAuthenticatorEditor.codeLength.tip"));
codeLength.setItems(6, 8);
codeLength.setEmptySelectionAllowed(false);
configBinder.forField(codeLength).asRequired().bind("codeLength");
otp.addComponent(codeLength);
IntStepper allowedTimeDrift = new IntStepper(msg.getMessage("OTPWithLDAPAuthenticatorEditor.allowedTimeDrift"));
tooltip(allowedTimeDrift, msg.getMessage("OTPWithLDAPAuthenticatorEditor.allowedTimeDrift.tip"));
allowedTimeDrift.setWidth(3, Unit.EM);
allowedTimeDrift.setMinValue(0);
allowedTimeDrift.setMaxValue(2880);
configBinder.forField(allowedTimeDrift).asRequired().bind("allowedTimeDriftSteps");
otp.addComponent(allowedTimeDrift);
IntStepper timeStep = new IntStepper(msg.getMessage("OTPWithLDAPAuthenticatorEditor.timeStep"));
tooltip(timeStep, msg.getMessage("OTPWithLDAPAuthenticatorEditor.timeStep.tip"));
timeStep.setWidth(3, Unit.EM);
timeStep.setMinValue(5);
timeStep.setMaxValue(180);
configBinder.forField(timeStep).asRequired().bind("timeStepSeconds");
otp.addComponent(timeStep);
EnumComboBox<HashFunction> hashAlgorithm = new EnumComboBox<>(msg.getMessage("OTPWithLDAPAuthenticatorEditor.hashAlgorithm"), msg, "OTPWithLDAPAuthenticatorEditor.hashAlgorithm.", HashFunction.class, HashFunction.SHA1);
tooltip(hashAlgorithm, msg.getMessage("OTPWithLDAPAuthenticatorEditor.hashAlgorithm.tip"));
configBinder.forField(hashAlgorithm).asRequired().bind("hashFunction");
otp.addComponent(hashAlgorithm);
return new CollapsibleLayout(msg.getMessage("OTPWithLDAPAuthenticatorEditor.otp"), otp);
}
use of pl.edu.icm.unity.webui.common.CollapsibleLayout 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 pl.edu.icm.unity.webui.common.CollapsibleLayout 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 pl.edu.icm.unity.webui.common.CollapsibleLayout 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);
}
Aggregations