Search in sources :

Example 6 with AuditConfiguration

use of alien4cloud.audit.model.AuditConfiguration in project alien4cloud by alien4cloud.

the class AuditController method enableAudit.

@ApiOperation(value = "Enable/Disable audit", notes = "Audit configuration update is only accessible to user with role [ ADMIN ]")
@RequestMapping(value = "/configuration/enabled", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasAuthority('ADMIN')")
public RestResponse<Void> enableAudit(@RequestParam boolean enabled) {
    AuditConfiguration auditConfiguration = auditService.getMandatoryAuditConfiguration();
    auditConfiguration.setEnabled(enabled);
    auditService.saveAuditConfiguration(auditConfiguration);
    return RestResponseBuilder.<Void>builder().build();
}
Also used : AuditConfiguration(alien4cloud.audit.model.AuditConfiguration) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with AuditConfiguration

use of alien4cloud.audit.model.AuditConfiguration in project alien4cloud by alien4cloud.

the class AuditController method register.

/**
 * Register a dynamic RequestMappingHandlerMapping in the audit management system.
 *
 * @param requestMappingHandlerMapping The dynamic RequestMappingHandlerMapping to handle for audit.
 */
public void register(RequestMappingHandlerMapping requestMappingHandlerMapping) {
    registeredRequestMappingHandlerMapping.add(requestMappingHandlerMapping);
    // update configuration to inclure methods from plugin or context
    Map<Method, Boolean> allAvailableMethodsForAudit = getAllAvailableMethodsForAudit(requestMappingHandlerMapping);
    AuditConfiguration configuration = auditService.getAuditConfiguration();
    // Put all in new map to not override existing user settings if some methods are already defined.
    allAvailableMethodsForAudit.putAll(configuration.getAuditedMethodsMap());
    configuration.setAuditedMethodsMap(allAvailableMethodsForAudit);
    auditService.saveAuditConfiguration(configuration);
}
Also used : AuditConfiguration(alien4cloud.audit.model.AuditConfiguration) Method(alien4cloud.audit.model.Method) AuditedMethod(alien4cloud.audit.model.AuditedMethod) HandlerMethod(org.springframework.web.method.HandlerMethod) RequestMethod(org.springframework.web.bind.annotation.RequestMethod)

Aggregations

AuditConfiguration (alien4cloud.audit.model.AuditConfiguration)7 AuditedMethod (alien4cloud.audit.model.AuditedMethod)5 HandlerMethod (org.springframework.web.method.HandlerMethod)5 Method (alien4cloud.audit.model.Method)4 ApiOperation (io.swagger.annotations.ApiOperation)4 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 RequestMethod (org.springframework.web.bind.annotation.RequestMethod)4 AuditTrace (alien4cloud.audit.model.AuditTrace)1 User (alien4cloud.security.model.User)1 IOException (java.io.IOException)1 List (java.util.List)1 PostConstruct (javax.annotation.PostConstruct)1 ServletException (javax.servlet.ServletException)1 RequestMappingHandlerMapping (org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping)1