Search in sources :

Example 1 with AuditEventName

use of com.sequenceiq.cloudbreak.audit.model.AuditEventName in project cloudbreak by hortonworks.

the class FlowCDPEventDataExtractor method eventName.

@Override
public AuditEventName eventName(CDPStructuredFlowEvent structuredEvent) {
    FlowDetails flow = structuredEvent.getFlow();
    String flowEvent = flow.getFlowEvent();
    AuditEventName eventName = null;
    String resourceType = structuredEvent.getOperation().getResourceType();
    CDPFlowResourceAuditEventConverter flowResourceAuditEventConverter = getConverter(resourceType);
    if (flowResourceAuditEventConverter != null) {
        eventName = flowResourceAuditEventConverter.auditEventName(structuredEvent);
    }
    if (eventName != null) {
        LOGGER.info("Flow event name: {}", eventName);
        return eventName;
    }
    String flowState = flow.getFlowState();
    String flowType = flow.getFlowType();
    throw new UnsupportedOperationException(String.format("The %s, %s and %s does not support for auditing for %s", flowType, flowEvent, flowState, resourceType));
}
Also used : AuditEventName(com.sequenceiq.cloudbreak.audit.model.AuditEventName) CDPFlowResourceAuditEventConverter(com.sequenceiq.cloudbreak.structuredevent.service.audit.auditeventname.flow.CDPFlowResourceAuditEventConverter) FlowDetails(com.sequenceiq.cloudbreak.structuredevent.event.FlowDetails)

Example 2 with AuditEventName

use of com.sequenceiq.cloudbreak.audit.model.AuditEventName in project cloudbreak by hortonworks.

the class RestCDPEventDataExtractor method eventName.

@Override
public AuditEventName eventName(CDPStructuredRestCallEvent structuredEvent) {
    AuditEventName auditEventName = determineEventName(structuredEvent);
    if (auditEventName != null) {
        LOGGER.info("Determined event name: {}", auditEventName);
        return auditEventName;
    }
    String resourceType = structuredEvent.getOperation().getResourceType();
    String method = structuredEvent.getRestCall().getRestRequest().getMethod();
    throw new UnsupportedOperationException(String.format("The `%s` with `%s` does not support for auditing", resourceType, method));
}
Also used : AuditEventName(com.sequenceiq.cloudbreak.audit.model.AuditEventName)

Example 3 with AuditEventName

use of com.sequenceiq.cloudbreak.audit.model.AuditEventName in project cloudbreak by hortonworks.

the class KerberosRestResourceAuditEventConverter method auditEventName.

@Override
public AuditEventName auditEventName(CDPStructuredRestCallEvent structuredEvent) {
    String method = structuredEvent.getRestCall().getRestRequest().getMethod();
    AuditEventName eventName = null;
    String resourceEvent = structuredEvent.getOperation().getResourceEvent();
    if ("POST".equals(method) || "PUT".equals(method)) {
        if (resourceEvent == null) {
            eventName = AuditEventName.CREATE_KERBEROS_CONFIG;
        }
    } else if ("DELETE".equals(method)) {
        eventName = deletionRest(resourceEvent, structuredEvent.getOperation());
    }
    return eventName;
}
Also used : AuditEventName(com.sequenceiq.cloudbreak.audit.model.AuditEventName)

Example 4 with AuditEventName

use of com.sequenceiq.cloudbreak.audit.model.AuditEventName in project cloudbreak by hortonworks.

the class DatahubRestResourceAuditEventConverter method requestParameters.

@Override
public Map<String, Object> requestParameters(StructuredRestCallEvent structuredEvent) {
    Map<String, Object> params = legacyRestCommonService.addClusterCrnAndNameIfPresent(structuredEvent);
    OperationDetails operation = structuredEvent.getOperation();
    Optional<Stack> stack = stackService.findStackByNameAndWorkspaceId(operation.getResourceName(), operation.getWorkspaceId());
    AuditEventName auditEventName = auditEventName(structuredEvent);
    if (stack.isPresent() && auditEventName == AuditEventName.RESIZE_DATAHUB_CLUSTER) {
        Json json = new Json(structuredEvent.getRestCall().getRestRequest().getBody());
        String group = json.getValue("group");
        HostGroup hostGroup = hostGroupService.getByClusterIdAndNameWithRecipes(stack.get().getCluster().getId(), group);
        Integer desiredCount = json.getValue("desiredCount");
        Integer originalNodeCount = hostGroup.getInstanceGroup().getNodeCount();
        params.put("desiredCount", desiredCount);
        params.put("originalCount", originalNodeCount);
        params.put("hostGroup", group);
    }
    return params;
}
Also used : OperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.legacy.OperationDetails) AuditEventName(com.sequenceiq.cloudbreak.audit.model.AuditEventName) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) Json(com.sequenceiq.cloudbreak.common.json.Json) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 5 with AuditEventName

use of com.sequenceiq.cloudbreak.audit.model.AuditEventName in project cloudbreak by hortonworks.

the class BlueprintsRestResourceAuditEventConverter method auditEventName.

@Override
public AuditEventName auditEventName(StructuredRestCallEvent structuredEvent) {
    String method = structuredEvent.getRestCall().getRestRequest().getMethod();
    AuditEventName eventName = null;
    String resourceEvent = structuredEvent.getOperation().getResourceEvent();
    if ("POST".equals(method) && resourceEvent == null) {
        eventName = AuditEventName.CREATE_BLUEPRINT;
    } else if ("DELETE".equals(method)) {
        eventName = AuditEventName.DELETE_BLUEPRINT;
    }
    return eventName;
}
Also used : AuditEventName(com.sequenceiq.cloudbreak.audit.model.AuditEventName)

Aggregations

AuditEventName (com.sequenceiq.cloudbreak.audit.model.AuditEventName)15 FlowDetails (com.sequenceiq.cloudbreak.structuredevent.event.FlowDetails)2 Json (com.sequenceiq.cloudbreak.common.json.Json)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)1 FlowResourceAuditEventConverter (com.sequenceiq.cloudbreak.structuredevent.auditeventname.flow.FlowResourceAuditEventConverter)1 OperationDetails (com.sequenceiq.cloudbreak.structuredevent.event.legacy.OperationDetails)1 CDPFlowResourceAuditEventConverter (com.sequenceiq.cloudbreak.structuredevent.service.audit.auditeventname.flow.CDPFlowResourceAuditEventConverter)1