use of pl.edu.icm.unity.webui.common.chips.ChipsWithTextfield in project unity by unity-idm.
the class EditOAuthClientSubView method buildHeaderSection.
private FormLayoutWithFixedCaptionWidth buildHeaderSection() {
FormLayoutWithFixedCaptionWidth header = new FormLayoutWithFixedCaptionWidth();
header.setMargin(true);
TextField name = new TextField();
name.setCaption(msg.getMessage("EditOAuthClientSubView.name"));
binder.forField(name).withValidator((v, c) -> {
if (v != null && !v.isEmpty() && v.length() < 2) {
return ValidationResult.error(msg.getMessage("toShortValue"));
}
return ValidationResult.ok();
}).bind("name");
header.addComponent(name);
ComboBox<String> type = new ComboBox<>();
type.setCaption(msg.getMessage("EditOAuthClientSubView.type"));
type.setItems(Stream.of(ClientType.values()).map(f -> f.toString()).collect(Collectors.toList()));
type.setEmptySelectionAllowed(false);
binder.forField(type).bind("type");
header.addComponent(type);
TextFieldWithGenerator id = new TextFieldWithGenerator();
id.setCaption(msg.getMessage("EditOAuthClientSubView.id"));
id.setReadOnly(editMode);
id.setWidth(30, Unit.EM);
binder.forField(id).asRequired(msg.getMessage("fieldRequired")).withValidator((v, c) -> {
if (v != null && allClientsIds.contains(v)) {
return ValidationResult.error(msg.getMessage("EditOAuthClientSubView.invalidClientId"));
}
return ValidationResult.ok();
}).bind("id");
header.addComponent(id);
CustomField<String> secret;
if (!editMode) {
secret = new TextFieldWithGenerator();
secret.setCaption(msg.getMessage("EditOAuthClientSubView.secret"));
secret.setWidth(30, Unit.EM);
binder.forField(secret).withValidator((v, c) -> {
if ((v == null || v.isEmpty()) && ClientType.CONFIDENTIAL.toString().equals(type.getValue())) {
return ValidationResult.error(msg.getMessage("fieldRequired"));
}
return ValidationResult.ok();
}).bind("secret");
header.addComponent(secret);
} else {
TextFieldWithChangeConfirmation<TextFieldWithGenerator> secretWithChangeConfirmation = new TextFieldWithChangeConfirmation<>(msg, new TextFieldWithGenerator());
secretWithChangeConfirmation.setCaption(msg.getMessage("EditOAuthClientSubView.secret"));
secretWithChangeConfirmation.setWidth(30, Unit.EM);
binder.forField(secretWithChangeConfirmation).withValidator((v, c) -> {
if (secretWithChangeConfirmation.isEditMode()) {
return ValidationResult.error(msg.getMessage("fieldRequired"));
}
return ValidationResult.ok();
}).bind("secret");
header.addComponent(secretWithChangeConfirmation);
secret = secretWithChangeConfirmation;
}
type.addValueChangeListener(e -> {
secret.setEnabled(ClientType.CONFIDENTIAL.toString().equals(e.getValue()));
if (!secret.isEnabled())
secret.setValue("");
});
ChipsWithDropdown<String> allowedFlows = new ChipsWithDropdown<>();
allowedFlows.setCaption(msg.getMessage("EditOAuthClientSubView.allowedFlows"));
allowedFlows.setItems(Stream.of(GrantFlow.values()).map(f -> f.toString()).collect(Collectors.toList()));
binder.forField(allowedFlows).withValidator((v, c) -> {
if (v == null || v.isEmpty()) {
return ValidationResult.error(msg.getMessage("fieldRequired"));
}
return ValidationResult.ok();
}).bind("flows");
header.addComponent(allowedFlows);
ChipsWithTextfield redirectURIs = new ChipsWithTextfield(msg);
redirectURIs.setWidth(FieldSizeConstans.LINK_FIELD_WIDTH, FieldSizeConstans.LINK_FIELD_WIDTH_UNIT);
redirectURIs.setCaption(msg.getMessage("EditOAuthClientSubView.authorizedRedirectURIs"));
binder.forField(redirectURIs).withValidator((v, c) -> {
if (v == null || v.size() == 0) {
return ValidationResult.error(msg.getMessage("fieldRequired"));
}
return ValidationResult.ok();
}).bind("redirectURIs");
header.addComponent(redirectURIs);
Set<String> definedScopes = scopesSupplier.get();
ChipsWithDropdown<String> allowedScopes = new ChipsWithDropdown<>();
allowedScopes.setCaption(msg.getMessage("EditOAuthClientSubView.allowedScopes"));
allowedScopes.setItems(definedScopes);
allowedScopes.setSkipRemoveInvalidSelections(true);
binder.forField(allowedScopes).withValidator((v, c) -> {
if (v != null && !v.isEmpty() && !definedScopes.containsAll(v)) {
return ValidationResult.error(msg.getMessage("EditOAuthClientSubView.invalidAllowedScopes"));
}
return ValidationResult.ok();
}).bind("scopes");
CheckBox allowAllScopes = new CheckBox(msg.getMessage("EditOAuthClientSubView.allowAllScopes"));
binder.forField(allowAllScopes).bind("allowAnyScopes");
allowAllScopes.addValueChangeListener(v -> allowedScopes.setEnabled(!v.getValue()));
header.addComponent(allowAllScopes);
header.addComponent(allowedScopes);
return header;
}
use of pl.edu.icm.unity.webui.common.chips.ChipsWithTextfield in project unity by unity-idm.
the class RestAdminServiceEditorGeneralTab method buildCorsSection.
private Component buildCorsSection() {
FormLayoutWithFixedCaptionWidth main = new FormLayoutWithFixedCaptionWidth();
main.setMargin(false);
ChipsWithTextfield allowedCORSheaders = new ChipsWithTextfield(msg);
allowedCORSheaders.setCaption(msg.getMessage("RestAdminServiceEditorComponent.allowedCORSheaders"));
restBinder.forField(allowedCORSheaders).bind("allowedCORSheaders");
main.addComponent(allowedCORSheaders);
ChipsWithTextfield allowedCORSorigins = new ChipsWithTextfield(msg);
allowedCORSorigins.setCaption(msg.getMessage("RestAdminServiceEditorComponent.allowedCORSorigins"));
main.addComponent(allowedCORSorigins);
restBinder.forField(allowedCORSorigins).bind("allowedCORSorigins");
CollapsibleLayout corsSection = new CollapsibleLayout(msg.getMessage("RestAdminServiceEditorComponent.cors"), main);
return corsSection;
}
use of pl.edu.icm.unity.webui.common.chips.ChipsWithTextfield 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;
}
use of pl.edu.icm.unity.webui.common.chips.ChipsWithTextfield 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;
}
use of pl.edu.icm.unity.webui.common.chips.ChipsWithTextfield 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;
}
Aggregations