ejbca-ce
ejbca-ce copied to clipboard
Only the first line in a multiline textbox is saved
When creating a custom publisher with a CustomPublisherProperty.UI_TEXTOUTPUT only the first line of the text entered into the multiline textbox is saved.
How can it be fixed best?
The current code in CustomPublisherMBData.java encodes multiple lines as:
Key=Value 1
Value2
I replaced the code with the built in Properties.store method:
public void setCustomPublisherData(final CustomPublisherContainer publisher) throws PublisherException, IOException {
publisher.setClassPath(customPublisherCurrentClass);
if (!publisher.isCustomUiRenderingSupported()) {
publisher.setPropertyData(customPublisherPropertyData);
return;
}
final Properties properties = new Properties();
properties.putAll(publisher.getCustomUiPropertyList(EjbcaJSFHelper.getBean().getAdmin()).stream()
.map(p -> getEntry(p))
.collect(Collectors.toMap(Entry::getKey, Entry::getValue)));
final StringWriter writer = new StringWriter();
properties.store(new PrintWriter(writer), "");
final String customPublisherDataString = writer.getBuffer().toString();
log.info("Setting custom publisher data:" + System.lineSeparator() + customPublisherDataString);
publisher.setPropertyData(customPublisherDataString);
}
private SimpleEntry<?, ?> getEntry(final CustomPublisherProperty p) {
if (p.getType() == CustomPublisherProperty.UI_TEXTINPUT_PASSWORD &&
customPublisherPropertyValues.get(p.getName()).equals(PASSWORD_PLACEHOLDER)) {
return new AbstractMap.SimpleEntry<>(p.getName(), p.getValue());
} else {
return new SimpleEntry<>(p.getName(), customPublisherPropertyValues.get(p.getName()));
}
}
The same data is now saved as:
Key=Value1\r\nValue2
However, it is still not loaded correctly.