use of pl.edu.icm.unity.engine.api.files.URIAccessService 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.engine.api.files.URIAccessService 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;
}
use of pl.edu.icm.unity.engine.api.files.URIAccessService in project unity by unity-idm.
the class MetadataSourceHandlerTest method init.
@Before
public void init() throws EngineException, IOException, URISyntaxException {
executorsService = mock(ExecutorsService.class);
ScheduledExecutorService pool = Executors.newScheduledThreadPool(1);
when(executorsService.getService()).thenReturn(pool);
src = new RemoteMetadataSrc("http://url", null);
fileStorageService = mock(FileStorageService.class);
uriAccessService = mock(URIAccessService.class);
when(fileStorageService.readFileFromWorkspace(any())).thenThrow(EngineException.class);
when(uriAccessService.readURI(eq(new URI("http://url")))).thenAnswer((a) -> new FileData("xx", Files.readAllBytes(Paths.get("src/test/resources/unity-as-sp-meta.xml")), new Date()));
when(uriAccessService.readURI(eq(new URI("http://url")), any())).thenAnswer((a) -> new FileData("xx", Files.readAllBytes(Paths.get("src/test/resources/unity-as-sp-meta.xml")), new Date()));
when(fileStorageService.storeFileInWorkspace(any(), any())).thenAnswer((a) -> new FileData("xx", Files.readAllBytes(Paths.get("src/test/resources/unity-as-sp-meta.xml")), new Date()));
}
Aggregations