From 4b2074a507882dbb89beeb7626cbe93ab9551866 Mon Sep 17 00:00:00 2001 From: merrimanr Date: Thu, 26 Sep 2019 15:58:27 -0500 Subject: [PATCH] initial commit --- .../rest/controller/SensorEnrichmentConfigController.java | 8 ++++++++ .../rest/controller/SensorIndexingConfigController.java | 8 ++++++++ .../rest/controller/SensorParserConfigController.java | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java index 826be98b95..971c68334f 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java @@ -24,7 +24,10 @@ import org.apache.metron.common.aggregator.Aggregators; import org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig; import org.apache.metron.rest.RestException; +import org.apache.metron.rest.security.SecurityUtils; import org.apache.metron.rest.service.SensorEnrichmentConfigService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -34,6 +37,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import java.lang.invoke.MethodHandles; import java.util.List; import java.util.Map; @@ -41,6 +45,8 @@ @RequestMapping("/api/v1/sensor/enrichment/config") public class SensorEnrichmentConfigController { + private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + @Autowired private SensorEnrichmentConfigService sensorEnrichmentConfigService; @@ -50,6 +56,7 @@ public class SensorEnrichmentConfigController { @RequestMapping(value = "/{name}", method = RequestMethod.POST) ResponseEntity save(@ApiParam(name="name", value="SensorEnrichmentConfig name", required=true)@PathVariable String name, @ApiParam(name="sensorEnrichmentConfig", value="SensorEnrichmentConfig", required=true)@RequestBody SensorEnrichmentConfig sensorEnrichmentConfig) throws RestException { + LOG.info(String.format("User '%s' changed the '%s' enrichment config to %s", SecurityUtils.getCurrentUser(), name, sensorEnrichmentConfig.toString())); if (sensorEnrichmentConfigService.findOne(name) == null) { return new ResponseEntity<>(sensorEnrichmentConfigService.save(name, sensorEnrichmentConfig), HttpStatus.CREATED); } else { @@ -83,6 +90,7 @@ ResponseEntity> getAll() throws Exception { @RequestMapping(value = "/{name}", method = RequestMethod.DELETE) ResponseEntity delete(@ApiParam(name="name", value="SensorEnrichmentConfig name", required=true)@PathVariable String name) throws RestException { if (sensorEnrichmentConfigService.delete(name)) { + LOG.info(String.format("User '%s' deleted the '%s' enrichment config", SecurityUtils.getCurrentUser(), name)); return new ResponseEntity<>(HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.NOT_FOUND); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorIndexingConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorIndexingConfigController.java index ff1d6bd90a..4e02cb818e 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorIndexingConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorIndexingConfigController.java @@ -22,7 +22,10 @@ import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import org.apache.metron.rest.RestException; +import org.apache.metron.rest.security.SecurityUtils; import org.apache.metron.rest.service.SensorIndexingConfigService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -32,6 +35,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import java.lang.invoke.MethodHandles; import java.util.List; import java.util.Map; @@ -39,6 +43,8 @@ @RequestMapping("/api/v1/sensor/indexing/config") public class SensorIndexingConfigController { + private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + @Autowired private SensorIndexingConfigService sensorIndexingConfigService; @@ -48,6 +54,7 @@ public class SensorIndexingConfigController { @RequestMapping(value = "/{name}", method = RequestMethod.POST) ResponseEntity> save(@ApiParam(name="name", value="SensorIndexingConfig name", required=true)@PathVariable String name, @ApiParam(name="sensorIndexingConfig", value="SensorIndexingConfig", required=true)@RequestBody Map sensorIndexingConfig) throws RestException { + LOG.info(String.format("User '%s' changed the '%s' indexing config to %s", SecurityUtils.getCurrentUser(), name, sensorIndexingConfig.toString())); if (sensorIndexingConfigService.findOne(name) == null) { return new ResponseEntity<>(sensorIndexingConfigService.save(name, sensorIndexingConfig), HttpStatus.CREATED); } else { @@ -88,6 +95,7 @@ ResponseEntity> getAllIndices(@ApiParam(name="writerName", valu @RequestMapping(value = "/{name}", method = RequestMethod.DELETE) ResponseEntity delete(@ApiParam(name="name", value="SensorIndexingConfig name", required=true)@PathVariable String name) throws RestException { if (sensorIndexingConfigService.delete(name)) { + LOG.info(String.format("User '%s' deleted the '%s' indexing config", SecurityUtils.getCurrentUser(), name)); return new ResponseEntity<>(HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.NOT_FOUND); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java index ecbd034ae2..fdb7a605f8 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java @@ -24,8 +24,11 @@ import org.apache.metron.common.configuration.SensorParserConfig; import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.ParseMessageRequest; +import org.apache.metron.rest.security.SecurityUtils; import org.apache.metron.rest.service.SensorParserConfigService; import org.json.simple.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -35,12 +38,15 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import java.lang.invoke.MethodHandles; import java.util.Map; @RestController @RequestMapping("/api/v1/sensor/parser/config") public class SensorParserConfigController { + private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + @Autowired private SensorParserConfigService sensorParserConfigService; @@ -50,6 +56,7 @@ public class SensorParserConfigController { @RequestMapping(value = "/{name}", method = RequestMethod.POST) ResponseEntity save(@ApiParam(name="name", value="SensorParserConfig name", required=true)@PathVariable String name, @ApiParam(name="sensorParserConfig", value="SensorParserConfig", required=true)@RequestBody SensorParserConfig sensorParserConfig) throws RestException { + LOG.info(String.format("User '%s' changed the '%s' parser config to %s", SecurityUtils.getCurrentUser(), name, sensorParserConfig.toString())); if (sensorParserConfigService.findOne(name) == null) { return new ResponseEntity<>(sensorParserConfigService.save(name, sensorParserConfig), HttpStatus.CREATED); } else { @@ -83,6 +90,7 @@ ResponseEntity> findAll() throws RestException { @RequestMapping(value = "/{name}", method = RequestMethod.DELETE) ResponseEntity delete(@ApiParam(name="name", value="SensorParserConfig name", required=true)@PathVariable String name) throws RestException { if (sensorParserConfigService.delete(name)) { + LOG.info(String.format("User '%s' deleted the '%s' parser config", SecurityUtils.getCurrentUser(), name)); return new ResponseEntity<>(HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.NOT_FOUND);