Search in sources :

Example 76 with NiFiUser

use of org.apache.nifi.authorization.user.NiFiUser in project nifi by apache.

the class ComponentStateAuditor method clearProcessorStateAdvice.

/**
 * Audits clearing of state from a Processor.
 *
 * @param proceedingJoinPoint join point
 * @param processor the processor
 * @throws java.lang.Throwable ex
 */
@Around("within(org.apache.nifi.web.dao.ComponentStateDAO+) && " + "execution(void clearState(org.apache.nifi.controller.ProcessorNode)) && " + "args(processor)")
public StateMap clearProcessorStateAdvice(ProceedingJoinPoint proceedingJoinPoint, ProcessorNode processor) throws Throwable {
    // update the processors state
    final StateMap stateMap = (StateMap) proceedingJoinPoint.proceed();
    // if no exception were thrown, add the clear action...
    // get the current user
    NiFiUser user = NiFiUserUtils.getNiFiUser();
    // ensure the user was found
    if (user != null) {
        Collection<Action> actions = new ArrayList<>();
        // create the processor details
        FlowChangeExtensionDetails processorDetails = new FlowChangeExtensionDetails();
        processorDetails.setType(processor.getComponentType());
        // create the clear action
        FlowChangeAction configAction = new FlowChangeAction();
        configAction.setUserIdentity(user.getIdentity());
        configAction.setOperation(Operation.ClearState);
        configAction.setTimestamp(new Date());
        configAction.setSourceId(processor.getIdentifier());
        configAction.setSourceName(processor.getName());
        configAction.setSourceType(Component.Processor);
        configAction.setComponentDetails(processorDetails);
        actions.add(configAction);
        // record the action
        saveActions(actions, logger);
    }
    return stateMap;
}
Also used : FlowChangeAction(org.apache.nifi.action.FlowChangeAction) Action(org.apache.nifi.action.Action) NiFiUser(org.apache.nifi.authorization.user.NiFiUser) StateMap(org.apache.nifi.components.state.StateMap) FlowChangeExtensionDetails(org.apache.nifi.action.component.details.FlowChangeExtensionDetails) ArrayList(java.util.ArrayList) Date(java.util.Date) FlowChangeAction(org.apache.nifi.action.FlowChangeAction) Around(org.aspectj.lang.annotation.Around)

Example 77 with NiFiUser

use of org.apache.nifi.authorization.user.NiFiUser in project nifi by apache.

the class ComponentStateAuditor method clearControllerServiceStateAdvice.

/**
 * Audits clearing of state from a Controller Service.
 *
 * @param proceedingJoinPoint join point
 * @param controllerService the controller service
 * @throws java.lang.Throwable ex
 */
@Around("within(org.apache.nifi.web.dao.ComponentStateDAO+) && " + "execution(void clearState(org.apache.nifi.controller.service.ControllerServiceNode)) && " + "args(controllerService)")
public StateMap clearControllerServiceStateAdvice(ProceedingJoinPoint proceedingJoinPoint, ControllerServiceNode controllerService) throws Throwable {
    // update the controller service state
    final StateMap stateMap = (StateMap) proceedingJoinPoint.proceed();
    // if no exception were thrown, add the clear action...
    // get the current user
    NiFiUser user = NiFiUserUtils.getNiFiUser();
    // ensure the user was found
    if (user != null) {
        Collection<Action> actions = new ArrayList<>();
        // create the controller service details
        FlowChangeExtensionDetails controllerServiceDetails = new FlowChangeExtensionDetails();
        controllerServiceDetails.setType(controllerService.getComponentType());
        // create the clear action
        FlowChangeAction configAction = new FlowChangeAction();
        configAction.setUserIdentity(user.getIdentity());
        configAction.setOperation(Operation.ClearState);
        configAction.setTimestamp(new Date());
        configAction.setSourceId(controllerService.getIdentifier());
        configAction.setSourceName(controllerService.getName());
        configAction.setSourceType(Component.ControllerService);
        configAction.setComponentDetails(controllerServiceDetails);
        actions.add(configAction);
        // record the action
        saveActions(actions, logger);
    }
    return stateMap;
}
Also used : FlowChangeAction(org.apache.nifi.action.FlowChangeAction) Action(org.apache.nifi.action.Action) NiFiUser(org.apache.nifi.authorization.user.NiFiUser) StateMap(org.apache.nifi.components.state.StateMap) FlowChangeExtensionDetails(org.apache.nifi.action.component.details.FlowChangeExtensionDetails) ArrayList(java.util.ArrayList) Date(java.util.Date) FlowChangeAction(org.apache.nifi.action.FlowChangeAction) Around(org.aspectj.lang.annotation.Around)

Example 78 with NiFiUser

use of org.apache.nifi.authorization.user.NiFiUser in project nifi by apache.

the class ControllerAuditor method updateControllerEventDrivenThreadsAdvice.

/**
 * Audits updating the max number of event driven threads for the controller.
 *
 * @param proceedingJoinPoint join point
 * @param maxEventDrivenThreadCount thread count
 * @param controllerFacade facade
 * @throws java.lang.Throwable ex
 */
@Around("within(org.apache.nifi.web.controller.ControllerFacade) && " + "execution(void setMaxEventDrivenThreadCount(int)) && " + "args(maxEventDrivenThreadCount) && " + "target(controllerFacade)")
public void updateControllerEventDrivenThreadsAdvice(ProceedingJoinPoint proceedingJoinPoint, int maxEventDrivenThreadCount, ControllerFacade controllerFacade) throws Throwable {
    // get the current max thread count
    int previousMaxEventDrivenThreadCount = controllerFacade.getMaxEventDrivenThreadCount();
    // update the processors state
    proceedingJoinPoint.proceed();
    // ensure the value changed
    if (previousMaxEventDrivenThreadCount != maxEventDrivenThreadCount) {
        // get the current user
        NiFiUser user = NiFiUserUtils.getNiFiUser();
        // ensure the user was found
        if (user != null) {
            Collection<Action> actions = new ArrayList<>();
            // create the configure details
            FlowChangeConfigureDetails configDetails = new FlowChangeConfigureDetails();
            configDetails.setName("Controller Max Event Driven Thread Count");
            configDetails.setValue(String.valueOf(maxEventDrivenThreadCount));
            configDetails.setPreviousValue(String.valueOf(previousMaxEventDrivenThreadCount));
            // create the config action
            FlowChangeAction configAction = new FlowChangeAction();
            configAction.setUserIdentity(user.getIdentity());
            configAction.setOperation(Operation.Configure);
            configAction.setTimestamp(new Date());
            configAction.setSourceId("Flow Controller");
            configAction.setSourceName("Flow Controller");
            configAction.setSourceType(Component.Controller);
            configAction.setActionDetails(configDetails);
            actions.add(configAction);
            // record the action
            saveActions(actions, logger);
        }
    }
}
Also used : FlowChangeAction(org.apache.nifi.action.FlowChangeAction) Action(org.apache.nifi.action.Action) NiFiUser(org.apache.nifi.authorization.user.NiFiUser) FlowChangeConfigureDetails(org.apache.nifi.action.details.FlowChangeConfigureDetails) ArrayList(java.util.ArrayList) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint) Date(java.util.Date) FlowChangeAction(org.apache.nifi.action.FlowChangeAction) Around(org.aspectj.lang.annotation.Around)

Example 79 with NiFiUser

use of org.apache.nifi.authorization.user.NiFiUser in project nifi by apache.

the class ControllerAuditor method updateControllerTimerDrivenThreadsAdvice.

/**
 * Audits updating the max number of timer driven threads for the controller.
 *
 * @param proceedingJoinPoint joint point
 * @param maxTimerDrivenThreadCount thread count
 * @param controllerFacade facade
 * @throws java.lang.Throwable ex
 */
@Around("within(org.apache.nifi.web.controller.ControllerFacade) && " + "execution(void setMaxTimerDrivenThreadCount(int)) && " + "args(maxTimerDrivenThreadCount) && " + "target(controllerFacade)")
public void updateControllerTimerDrivenThreadsAdvice(ProceedingJoinPoint proceedingJoinPoint, int maxTimerDrivenThreadCount, ControllerFacade controllerFacade) throws Throwable {
    // get the current max thread count
    int previousMaxTimerDrivenThreadCount = controllerFacade.getMaxTimerDrivenThreadCount();
    // update the processors state
    proceedingJoinPoint.proceed();
    // ensure the value changed
    if (previousMaxTimerDrivenThreadCount != maxTimerDrivenThreadCount) {
        // get the current user
        NiFiUser user = NiFiUserUtils.getNiFiUser();
        // ensure the user was found
        if (user != null) {
            Collection<Action> actions = new ArrayList<>();
            // create the configure details
            FlowChangeConfigureDetails configDetails = new FlowChangeConfigureDetails();
            configDetails.setName("Controller Max Timer Driven Thread Count");
            configDetails.setValue(String.valueOf(maxTimerDrivenThreadCount));
            configDetails.setPreviousValue(String.valueOf(previousMaxTimerDrivenThreadCount));
            // create the config action
            FlowChangeAction configAction = new FlowChangeAction();
            configAction.setUserIdentity(user.getIdentity());
            configAction.setOperation(Operation.Configure);
            configAction.setTimestamp(new Date());
            configAction.setSourceId("Flow Controller");
            configAction.setSourceName("Flow Controller");
            configAction.setSourceType(Component.Controller);
            configAction.setActionDetails(configDetails);
            actions.add(configAction);
            // record the action
            saveActions(actions, logger);
        }
    }
}
Also used : FlowChangeAction(org.apache.nifi.action.FlowChangeAction) Action(org.apache.nifi.action.Action) NiFiUser(org.apache.nifi.authorization.user.NiFiUser) FlowChangeConfigureDetails(org.apache.nifi.action.details.FlowChangeConfigureDetails) ArrayList(java.util.ArrayList) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint) Date(java.util.Date) FlowChangeAction(org.apache.nifi.action.FlowChangeAction) Around(org.aspectj.lang.annotation.Around)

Example 80 with NiFiUser

use of org.apache.nifi.authorization.user.NiFiUser in project nifi by apache.

the class FunnelAuditor method generateAuditRecord.

/**
 * Generates an audit record for the creation of the specified funnel.
 *
 * @param funnel funnel
 * @param operation operation
 * @param actionDetails details
 * @return action
 */
public Action generateAuditRecord(Funnel funnel, Operation operation, ActionDetails actionDetails) {
    FlowChangeAction action = null;
    // get the current user
    NiFiUser user = NiFiUserUtils.getNiFiUser();
    // ensure the user was found
    if (user != null) {
        // create the action for adding this funnel
        action = new FlowChangeAction();
        action.setUserIdentity(user.getIdentity());
        action.setOperation(operation);
        action.setTimestamp(new Date());
        action.setSourceId(funnel.getIdentifier());
        action.setSourceName(funnel.getName());
        action.setSourceType(Component.Funnel);
        if (actionDetails != null) {
            action.setActionDetails(actionDetails);
        }
    }
    return action;
}
Also used : NiFiUser(org.apache.nifi.authorization.user.NiFiUser) Date(java.util.Date) FlowChangeAction(org.apache.nifi.action.FlowChangeAction)

Aggregations

NiFiUser (org.apache.nifi.authorization.user.NiFiUser)127 Date (java.util.Date)47 FlowChangeAction (org.apache.nifi.action.FlowChangeAction)42 ArrayList (java.util.ArrayList)33 Authorizable (org.apache.nifi.authorization.resource.Authorizable)32 Action (org.apache.nifi.action.Action)29 HashMap (java.util.HashMap)27 Map (java.util.Map)26 AccessDeniedException (org.apache.nifi.authorization.AccessDeniedException)26 RevisionDTO (org.apache.nifi.web.api.dto.RevisionDTO)26 IOException (java.io.IOException)25 Set (java.util.Set)25 ScheduledState (org.apache.nifi.controller.ScheduledState)25 Collectors (java.util.stream.Collectors)24 UUID (java.util.UUID)23 ControllerServiceState (org.apache.nifi.controller.service.ControllerServiceState)22 AffectedComponentDTO (org.apache.nifi.web.api.dto.AffectedComponentDTO)22 DtoFactory (org.apache.nifi.web.api.dto.DtoFactory)22 AffectedComponentEntity (org.apache.nifi.web.api.entity.AffectedComponentEntity)22 ProcessorEntity (org.apache.nifi.web.api.entity.ProcessorEntity)22