use of com.sequenceiq.cloudbreak.structuredevent.auditeventname.rest.RestResourceAuditEventConverter in project cloudbreak by hortonworks.
the class RestLegacyEventDataExtractor method eventData.
@Override
public EventData eventData(StructuredRestCallEvent structuredEvent) {
RestRequestDetails restRequest = structuredEvent.getRestCall().getRestRequest();
boolean mutating = Set.of("POST", "PUT", "DELETE").contains(restRequest.getMethod());
String userAgent = restRequest.getHeaders().get("user-agent");
Map<String, Object> requestParameters = new HashMap<>();
requestParameters.put("uri", restRequest.getRequestUri());
String resourceType = structuredEvent.getOperation().getResourceType();
RestResourceAuditEventConverter restResourceAuditEventConverter = getConverter(resourceType);
if (restResourceAuditEventConverter != null) {
LOGGER.info("Determine request params with {}", restResourceAuditEventConverter);
Map<String, Object> params = restResourceAuditEventConverter.requestParameters(structuredEvent);
requestParameters.putAll(params);
}
return ApiRequestData.builder().withApiVersion(cbVersion).withMutating(mutating).withRequestParameters(new Json(requestParameters).getValue()).withUserAgent(userAgent).build();
}
use of com.sequenceiq.cloudbreak.structuredevent.auditeventname.rest.RestResourceAuditEventConverter in project cloudbreak by hortonworks.
the class RestLegacyEventDataExtractor method shouldAudit.
@Override
public boolean shouldAudit(StructuredEvent structuredEvent) {
StructuredRestCallEvent event = (StructuredRestCallEvent) structuredEvent;
String resourceType = event.getOperation().getResourceType();
if (resourceType != null) {
RestResourceAuditEventConverter restResourceAuditEventConverter = getConverter(resourceType);
return restResourceAuditEventConverter != null && restResourceAuditEventConverter.shouldAudit(event);
}
return false;
}
use of com.sequenceiq.cloudbreak.structuredevent.auditeventname.rest.RestResourceAuditEventConverter in project cloudbreak by hortonworks.
the class RestLegacyEventDataExtractor method eventSource.
@Override
public Crn.Service eventSource(StructuredRestCallEvent structuredEvent) {
String resourceType = structuredEvent.getOperation().getResourceType();
if (resourceType != null) {
RestResourceAuditEventConverter restResourceAuditEventConverter = getConverter(resourceType);
if (restResourceAuditEventConverter != null) {
Crn.Service service = restResourceAuditEventConverter.eventSource(structuredEvent);
LOGGER.info("Determined event source service: {}", service.getName());
return service;
}
}
return null;
}
use of com.sequenceiq.cloudbreak.structuredevent.auditeventname.rest.RestResourceAuditEventConverter in project cloudbreak by hortonworks.
the class RestLegacyEventDataExtractor method determineEventName.
private AuditEventName determineEventName(StructuredRestCallEvent structuredEvent) {
String resourceType = structuredEvent.getOperation().getResourceType();
RestResourceAuditEventConverter restResourceAuditEventConverter = getConverter(resourceType);
if (restResourceAuditEventConverter != null) {
LOGGER.info("Determine eventName with {}", restResourceAuditEventConverter);
return restResourceAuditEventConverter.auditEventName(structuredEvent);
}
return null;
}
Aggregations