use of org.graylog2.system.urlwhitelist.WhitelistEntry in project graylog2-server by Graylog2.
the class V20191129134600_CreateInitialUrlWhitelist method createWhitelist.
private UrlWhitelist createWhitelist() {
final Set<WhitelistEntry> entries = new HashSet<>();
dataAdapterService.findAll().stream().map(this::extractFromDataAdapter).forEach(e -> e.ifPresent(entries::add));
try (final Stream<NotificationDto> notificationsStream = notificationService.streamAll()) {
notificationsStream.map(this::extractFromNotification).forEach(e -> e.ifPresent(entries::add));
}
log.info("Created {} whitelist entries from URLs configured in data adapters and event notifications.", entries.size());
final UrlWhitelist whitelist = UrlWhitelist.createEnabled(new ArrayList<>(entries));
log.debug("Resulting whitelist: {}.", whitelist);
return whitelist;
}
use of org.graylog2.system.urlwhitelist.WhitelistEntry in project graylog2-server by Graylog2.
the class UrlWhitelistFacade method createNativeEntity.
@Override
public NativeEntity<WhitelistEntry> createNativeEntity(Entity entity, Map<String, ValueReference> parameters, Map<EntityDescriptor, Object> nativeEntities, String username) {
if (!(entity instanceof EntityV1)) {
throw new IllegalArgumentException("Unsupported entity version: " + entity.getClass());
}
final WhitelistEntry whitelistEntry = objectMapper.convertValue(((EntityV1) entity).data(), WhitelistEntry.class);
urlWhitelistService.addEntry(whitelistEntry);
return NativeEntity.create(entity.id(), whitelistEntry.id(), TYPE_V1, createTitle(whitelistEntry), whitelistEntry);
}
Aggregations