Properties props = new Properties();
props.load(new StringReader(data));
- Collection<String> plugins = Arrays.asList(StringUtils.split(props.getProperty(PLUGINS_KEY), ','));
+ String[] plugins = StringUtils.split(props.getProperty(PLUGINS_KEY), ',');
String editionKey = props.getProperty(EDITION_KEY);
- if (editionKey != null && !plugins.isEmpty()) {
- return Optional.of(new License(editionKey, plugins, base64));
+ if (StringUtils.isNotBlank(editionKey) && plugins.length > 0) {
+ return Optional.of(new License(editionKey, Arrays.asList(plugins), base64));
} else {
LOG.debug("Failed to parse license: no edition key and/or no plugin found");
}
assertThat(license).isEmpty();
}
+ @Test
+ public void parse_is_empty_if_license_has_empty_edition_key() throws IOException {
+ Properties props = new Properties();
+ props.setProperty("Plugins", "p1");
+ props.setProperty("Edition", "");
+ StringWriter writer = new StringWriter();
+ props.store(writer, "");
+
+ byte[] encoded = Base64.getEncoder().encode(writer.toString().getBytes());
+
+ Optional<License> license = License.parse(new String(encoded));
+ assertThat(license).isEmpty();
+ }
+
@Test
public void parse_is_empty_if_license_has_no_edition_key() throws IOException {
Properties props = new Properties();