Search in sources :

Example 1 with CDPRestResourceAuditEventConverter

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;
}
Also used : CDPRestResourceAuditEventConverter(com.sequenceiq.cloudbreak.structuredevent.service.audit.auditeventname.rest.CDPRestResourceAuditEventConverter)

Example 2 with CDPRestResourceAuditEventConverter

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();
}
Also used : HashMap(java.util.HashMap) RestRequestDetails(com.sequenceiq.cloudbreak.structuredevent.event.rest.RestRequestDetails) Json(com.sequenceiq.cloudbreak.common.json.Json) CDPRestResourceAuditEventConverter(com.sequenceiq.cloudbreak.structuredevent.service.audit.auditeventname.rest.CDPRestResourceAuditEventConverter)

Example 3 with CDPRestResourceAuditEventConverter

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;
}
Also used : CDPRestResourceAuditEventConverter(com.sequenceiq.cloudbreak.structuredevent.service.audit.auditeventname.rest.CDPRestResourceAuditEventConverter) Crn(com.sequenceiq.cloudbreak.auth.crn.Crn)

Example 4 with CDPRestResourceAuditEventConverter

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;
}
Also used : CDPStructuredRestCallEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredRestCallEvent) CDPRestResourceAuditEventConverter(com.sequenceiq.cloudbreak.structuredevent.service.audit.auditeventname.rest.CDPRestResourceAuditEventConverter)

Aggregations

CDPRestResourceAuditEventConverter (com.sequenceiq.cloudbreak.structuredevent.service.audit.auditeventname.rest.CDPRestResourceAuditEventConverter)4 Crn (com.sequenceiq.cloudbreak.auth.crn.Crn)1 Json (com.sequenceiq.cloudbreak.common.json.Json)1 CDPStructuredRestCallEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredRestCallEvent)1 RestRequestDetails (com.sequenceiq.cloudbreak.structuredevent.event.rest.RestRequestDetails)1 HashMap (java.util.HashMap)1