use of com.sequenceiq.cloudbreak.structuredevent.service.audit.auditeventname.rest.CDPRestResourceAuditEventConverter in project cloudbreak by hortonworks.
the class RestCDPEventDataExtractor method determineEventName.
private AuditEventName determineEventName(CDPStructuredRestCallEvent structuredEvent) {
String resourceType = structuredEvent.getOperation().getResourceType();
CDPRestResourceAuditEventConverter restResourceAuditEventConverter = getConverter(resourceType);
if (restResourceAuditEventConverter != null) {
LOGGER.info("Determine eventName with {}", restResourceAuditEventConverter);
return restResourceAuditEventConverter.auditEventName(structuredEvent);
}
return null;
}
use of com.sequenceiq.cloudbreak.structuredevent.service.audit.auditeventname.rest.CDPRestResourceAuditEventConverter in project cloudbreak by hortonworks.
the class RestCDPEventDataExtractor method eventData.
@Override
public EventData eventData(CDPStructuredRestCallEvent 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();
CDPRestResourceAuditEventConverter restResourceAuditEventConverter = getConverter(resourceType);
if (restResourceAuditEventConverter != null) {
LOGGER.info("Determine request params with {}", restResourceAuditEventConverter);
Map<String, String> 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.service.audit.auditeventname.rest.CDPRestResourceAuditEventConverter in project cloudbreak by hortonworks.
the class RestCDPEventDataExtractor method eventSource.
@Override
public Crn.Service eventSource(CDPStructuredRestCallEvent structuredEvent) {
String resourceType = structuredEvent.getOperation().getResourceType();
if (resourceType != null) {
CDPRestResourceAuditEventConverter 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.service.audit.auditeventname.rest.CDPRestResourceAuditEventConverter in project cloudbreak by hortonworks.
the class RestCDPEventDataExtractor method shouldAudit.
@Override
public boolean shouldAudit(CDPStructuredEvent structuredEvent) {
CDPStructuredRestCallEvent event = (CDPStructuredRestCallEvent) structuredEvent;
String resourceType = event.getOperation().getResourceType();
if (resourceType != null) {
CDPRestResourceAuditEventConverter restResourceAuditEventConverter = getConverter(resourceType);
return restResourceAuditEventConverter != null && restResourceAuditEventConverter.shouldAudit(event);
}
return false;
}
Aggregations