use of org.graylog2.plugin.configuration.Configuration in project graylog2-server by Graylog2.
the class OutputResource method update.
@PUT
@Path("/{outputId}")
@Timed
@ApiOperation(value = "Update output")
@RequiresPermissions(RestPermissions.OUTPUTS_EDIT)
@Produces(MediaType.APPLICATION_JSON)
@ApiResponses(value = { @ApiResponse(code = 404, message = "No such output on this node.") })
@AuditEvent(type = AuditEventTypes.MESSAGE_OUTPUT_UPDATE)
public Output update(@ApiParam(name = "outputId", value = "The id of the output that should be deleted", required = true) @PathParam("outputId") String outputId, @ApiParam(name = "JSON body", required = true) Map<String, Object> deltas) throws ValidationException, NotFoundException {
checkPermission(RestPermissions.OUTPUTS_EDIT, outputId);
final Output oldOutput = outputService.load(outputId);
final AvailableOutputSummary outputSummary = messageOutputFactory.getAvailableOutputs().get(oldOutput.getType());
if (outputSummary == null) {
throw new ValidationException("type", "Invalid output type");
}
deltas.remove("streams");
if (deltas.containsKey("configuration")) {
@SuppressWarnings("unchecked") final Map<String, Object> configuration = (Map<String, Object>) deltas.get("configuration");
deltas.put("configuration", ConfigurationMapConverter.convertValues(configuration, outputSummary.requestedConfiguration()));
}
final Output output = this.outputService.update(outputId, deltas);
this.outputRegistry.removeOutput(oldOutput);
return output;
}
use of org.graylog2.plugin.configuration.Configuration in project graylog2-server by Graylog2.
the class LdapUserAuthenticatorTest method setUp.
@Before
public void setUp() throws Exception {
server = getLdapServer();
final LdapConnectionConfig ldapConfig = new LdapConnectionConfig();
ldapConfig.setLdapHost("localHost");
ldapConfig.setLdapPort(server.getPort());
ldapConfig.setName(ADMIN_DN);
ldapConfig.setCredentials(ADMIN_PASSWORD);
configuration = mock(Configuration.class);
when(configuration.getPasswordSecret()).thenReturn(PASSWORD_SECRET);
ldapConnector = new LdapConnector(10000);
ldapSettingsService = mock(LdapSettingsService.class);
userService = mock(UserService.class);
ldapSettings = new LdapSettingsImpl(configuration, mock(RoleService.class));
ldapSettings.setEnabled(true);
ldapSettings.setUri(URI.create("ldap://localhost:" + server.getPort()));
ldapSettings.setUseStartTls(false);
ldapSettings.setSystemUsername(ADMIN_DN);
ldapSettings.setSystemPassword(ADMIN_PASSWORD);
ldapSettings.setSearchBase("ou=users,dc=example,dc=com");
ldapSettings.setSearchPattern("(&(objectClass=posixAccount)(uid={0}))");
ldapSettings.setDisplayNameAttribute("cn");
ldapSettings.setActiveDirectory(false);
ldapSettings.setGroupSearchBase("ou=groups,dc=example,dc=com");
ldapSettings.setGroupIdAttribute("cn");
ldapSettings.setGroupSearchPattern("(|(objectClass=groupOfNames)(objectClass=posixGroup))");
}
use of org.graylog2.plugin.configuration.Configuration in project graylog2-server by Graylog2.
the class KafkaJournalTest method setUp.
@Before
public void setUp() throws IOException {
scheduler = new ScheduledThreadPoolExecutor(1);
scheduler.prestartCoreThread();
journalDirectory = temporaryFolder.newFolder();
final File nodeId = temporaryFolder.newFile("node-id");
Files.write(UUID.randomUUID().toString(), nodeId, StandardCharsets.UTF_8);
final Configuration configuration = new Configuration() {
@Override
public String getNodeIdFile() {
return nodeId.getAbsolutePath();
}
};
serverStatus = new ServerStatus(configuration, EnumSet.of(ServerStatus.Capability.MASTER), new EventBus("KafkaJournalTest"), NullAuditEventSender::new);
}
use of org.graylog2.plugin.configuration.Configuration in project opennms by OpenNMS.
the class SyslogEventForwarder method forward.
/**
* Forwards an event.
*
* @param event the event to be forwarded
* @param node the node associated with the event if apply
*/
public void forward(Event event, OnmsNode node) {
if (initialized) {
LOG.info("Forwarding event {} to destination:{}", event.getUei(), destination.getName());
SyslogIF instance;
try {
instance = Syslog.getInstance(destination.getName());
} catch (SyslogRuntimeException e) {
LOG.error("Could not find Syslog instance for destination: '{}': {}", destination.getName(), e);
return;
}
try {
LOG.debug("Making substitutions for tokens in message format for event: {}.", event.getDbid());
String msgFormat = null;
for (SyslogFilter filter : destination.getFilters()) {
if (passFilter(filter, event)) {
msgFormat = filter.getMessageFormat();
}
}
if (msgFormat != null) {
String syslogMessage = getTranslatedMessage(event, node, msgFormat);
LOG.debug("Determining LOG_LEVEL for event: {}", event.getDbid());
int level = SyslogUtils.determineLogLevel(OnmsSeverity.get(event.getSeverity()));
LOG.debug("Forwarding event: {} via syslog to destination: {}", event.getDbid(), destination.getName());
instance.log(level, syslogMessage);
} else {
LOG.warn("Can't find message format for the incoming. Check your destination's configuration.");
}
} catch (Exception ex) {
LOG.error("Caught exception sending to destination: '{}': {}", destination.getName(), ex);
}
} else {
LOG.error("Can't forward event {} because the facility has not been initialized.", event.getUei());
}
}
Aggregations