repository = engine.getRepository(repositoryName);
} catch (NoSuchRepositoryException e) {
throw new StartException(e);
}
RepositoryConfiguration repositoryConfig = repository.getConfiguration();
Editor configEditor = repositoryConfig.edit();
EditableDocument security = configEditor.getOrCreateDocument(FieldName.SECURITY);
EditableArray providers = security.getOrCreateArray(FieldName.PROVIDERS);
EditableDocument provider = Schematic.newDocument();
String providerName = authenticatorProperties.getProperty(FieldName.NAME);
provider.set(FieldName.NAME, providerName);
for (Object key : authenticatorProperties.keySet()) {
String keyStr = (String)key;
if (FieldName.NAME.equals(keyStr)) continue;
Object value = authenticatorProperties.get(keyStr);
if (value instanceof List<?>) {
for (Object val : (List<?>)value) {
provider.getOrCreateArray(keyStr).addValue(val);
}
} else {
// Just set the value as a field
provider.set(keyStr, value);
}
}
providers.add(provider);
// Get the changes and validate them ...
Changes changes = configEditor.getChanges();
Problems validationResults = repositoryConfig.validate(changes);
if (validationResults.hasErrors()) {
String msg = JcrI18n.errorsInRepositoryConfiguration.text(this.repositoryName,
validationResults.errorCount(),
validationResults.toString());