Search in sources :

Example 1 with RestResourceAuditEventConverter

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

Example 2 with RestResourceAuditEventConverter

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;
}
Also used : StructuredRestCallEvent(com.sequenceiq.cloudbreak.structuredevent.event.StructuredRestCallEvent) RestResourceAuditEventConverter(com.sequenceiq.cloudbreak.structuredevent.auditeventname.rest.RestResourceAuditEventConverter)

Example 3 with RestResourceAuditEventConverter

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

Example 4 with RestResourceAuditEventConverter

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

Aggregations

RestResourceAuditEventConverter (com.sequenceiq.cloudbreak.structuredevent.auditeventname.rest.RestResourceAuditEventConverter)4 Crn (com.sequenceiq.cloudbreak.auth.crn.Crn)1 Json (com.sequenceiq.cloudbreak.common.json.Json)1 StructuredRestCallEvent (com.sequenceiq.cloudbreak.structuredevent.event.StructuredRestCallEvent)1 RestRequestDetails (com.sequenceiq.cloudbreak.structuredevent.event.rest.RestRequestDetails)1 HashMap (java.util.HashMap)1