use of pl.edu.icm.unity.webui.common.chips.ChipsWithDropdown 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.ChipsWithDropdown in project unity by unity-idm.
the class PolicyAgreementConfigurationEditor method init.
private void init() {
binder = new Binder<>(PolicyAgreementConfigurationVaadinBean.class);
buttons = new ArrayList<>();
main = new FormLayout();
Label emptyPolicyToAccept = new Label();
emptyPolicyToAccept.setCaption(msg.getMessage("PolicyAgreementConfigEditor.documentsToAccept"));
emptyPolicyToAccept.setVisible(policyDocuments.isEmpty());
emptyPolicyToAccept.setValue(msg.getMessage("PolicyAgreementConfigEditor.noPolicyDocuments"));
policyToAccept = new ChipsWithDropdown<>(p -> p.name, true);
policyToAccept.setCaption(msg.getMessage("PolicyAgreementConfigEditor.documentsToAccept"));
policyToAccept.setItems(policyDocuments.stream().collect(Collectors.toList()));
policyToAccept.setVisible(!policyDocuments.isEmpty());
EnumComboBox<PolicyAgreementPresentationType> presentationType = new EnumComboBox<PolicyAgreementPresentationType>(msg, "PolicyAgreementPresentationType.", PolicyAgreementPresentationType.class, PolicyAgreementPresentationType.INFORMATIVE_ONLY);
presentationType.setCaption(msg.getMessage("PolicyAgreementConfigEditor.presentationType"));
presentationType.setWidth(FieldSizeConstans.MEDIUM_FIELD_WIDTH, FieldSizeConstans.MEDIUM_FIELD_WIDTH_UNIT);
I18nTextField text = new I18nTextField(msg);
text.setWidth(100, Unit.PERCENTAGE);
text.addBlurListener(e -> buttons.forEach(b -> b.setEnabled(false)));
text.addFocusListener(e -> buttons.forEach(b -> b.setEnabled(true)));
HorizontalLayout buttonsLayout = new HorizontalLayout();
HorizontalLayout buttonsWrapper = new HorizontalLayout();
buttonsWrapper.setMargin(false);
Label vars = new Label(msg.getMessage("PolicyAgreementConfigEditor.variables"));
buttonsWrapper.addComponent(vars);
buttonsWrapper.addComponent(buttonsLayout);
buttonsWrapper.setComponentAlignment(vars, Alignment.BOTTOM_LEFT);
buttonsWrapper.setComponentAlignment(buttonsLayout, Alignment.BOTTOM_LEFT);
buttonsWrapper.setVisible(false);
policyToAccept.addValueChangeListener(e -> {
buttonsLayout.removeAllComponents();
e.getValue().forEach(d -> {
Button b = new Button();
b.setCaption(d.name);
b.addStyleName(Styles.varPickerButton.toString());
b.addClickListener(eb -> {
b.setEnabled(false);
text.insertOnLastFocused(prepareToInsert(d.name, d.displayedName));
});
b.addFocusListener(eb -> {
b.setEnabled(true);
});
b.setEnabled(false);
buttonsLayout.addComponent(b);
buttonsLayout.setComponentAlignment(b, Alignment.BOTTOM_LEFT);
buttons.add(b);
});
buttonsWrapper.setVisible(buttonsLayout.getComponentCount() != 0);
});
main.addComponent(emptyPolicyToAccept);
main.addComponent(policyToAccept);
main.addComponent(presentationType);
VerticalLayout buttonsAndTextWrapper = new VerticalLayout();
buttonsAndTextWrapper.setSpacing(true);
buttonsAndTextWrapper.setMargin(false);
buttonsAndTextWrapper.addStyleName(Styles.smallSpacing.toString());
buttonsAndTextWrapper.addComponent(buttonsWrapper);
buttonsAndTextWrapper.addComponent(text);
buttonsAndTextWrapper.setCaption(msg.getMessage("PolicyAgreementConfigEditor.text"));
main.addComponent(buttonsAndTextWrapper);
binder = new Binder<>(PolicyAgreementConfigurationVaadinBean.class);
binder.forField(policyToAccept).withValidator((v, c) -> validatePolicyToAccept(v)).bind("documentsToAccept");
binder.forField(presentationType).bind("presentationType");
binder.forField(text).withValidator((v, c) -> validateText(v)).bind("text");
binder.setBean(new PolicyAgreementConfigurationVaadinBean());
binder.addValueChangeListener(e -> fireEvent(new ValueChangeEvent<>(this, getValue(), true)));
}
use of pl.edu.icm.unity.webui.common.chips.ChipsWithDropdown 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;
}
use of pl.edu.icm.unity.webui.common.chips.ChipsWithDropdown in project unity by unity-idm.
the class AttributePolicyConfigurationEditor method init.
private void init() {
binder = new Binder<>(AttributePolicyBean.class);
main = new VerticalLayout();
FormLayoutWithFixedCaptionWidth header = new FormLayoutWithFixedCaptionWidth();
header.setMargin(false);
main.addComponent(header);
name = new TextField(msg.getMessage("AttributePolicyConfigurationEditor.name"));
header.addComponent(name);
binder.forField(name).bind("name");
ChipsWithDropdown<String> targetIdps = new ChipsWithDropdown<>(p -> getDisplayeName(p), true);
targetIdps.setItems(idPs.keySet());
targetIdps.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
targetIdps.setCaption(msg.getMessage("AttributePolicyConfigurationEditor.targetIdps"));
binder.forField(targetIdps).bind("targetIdps");
header.addComponent(targetIdps);
ChipsWithDropdown<String> targetFederations = new ChipsWithDropdown<>(p -> getGroupDisplayeName(p), true);
targetFederations.setItems(IdPsGroups.keySet());
targetFederations.setWidth(FieldSizeConstans.WIDE_FIELD_WIDTH, FieldSizeConstans.WIDE_FIELD_WIDTH_UNIT);
targetFederations.setCaption(msg.getMessage("AttributePolicyConfigurationEditor.targetFederations"));
binder.forField(targetFederations).bind("targetFederations");
header.addComponent(targetFederations);
AttributesGrid attributes = new AttributesGrid(msg);
binder.forField(attributes).bind("attributes");
main.addComponent(attributes);
binder.addValueChangeListener(e -> fireEvent(new ValueChangeEvent<>(this, getValue(), true)));
}
use of pl.edu.icm.unity.webui.common.chips.ChipsWithDropdown 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;
}
Aggregations