Search in sources :

Example 91 with Authorizable

use of org.apache.nifi.authorization.resource.Authorizable in project nifi by apache.

the class ControllerServiceResource method getPropertyDescriptor.

/**
 * Returns the descriptor for the specified property.
 *
 * @param id           The id of the controller service.
 * @param propertyName The property
 * @return a propertyDescriptorEntity
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}/descriptors")
@ApiOperation(value = "Gets a controller service property descriptor", response = PropertyDescriptorEntity.class, authorizations = { @Authorization(value = "Read - /controller-services/{uuid}") })
@ApiResponses(value = { @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), @ApiResponse(code = 401, message = "Client could not be authenticated."), @ApiResponse(code = 403, message = "Client is not authorized to make this request."), @ApiResponse(code = 404, message = "The specified resource could not be found."), @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") })
public Response getPropertyDescriptor(@ApiParam(value = "The controller service id.", required = true) @PathParam("id") final String id, @ApiParam(value = "The property name to return the descriptor for.", required = true) @QueryParam("propertyName") final String propertyName) {
    // ensure the property name is specified
    if (propertyName == null) {
        throw new IllegalArgumentException("The property name must be specified.");
    }
    if (isReplicateRequest()) {
        return replicate(HttpMethod.GET);
    }
    // authorize access
    serviceFacade.authorizeAccess(lookup -> {
        final Authorizable controllerService = lookup.getControllerService(id).getAuthorizable();
        controllerService.authorize(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser());
    });
    // get the property descriptor
    final PropertyDescriptorDTO descriptor = serviceFacade.getControllerServicePropertyDescriptor(id, propertyName);
    // generate the response entity
    final PropertyDescriptorEntity entity = new PropertyDescriptorEntity();
    entity.setPropertyDescriptor(descriptor);
    // generate the response
    return generateOkResponse(entity).build();
}
Also used : ComponentAuthorizable(org.apache.nifi.authorization.ComponentAuthorizable) Authorizable(org.apache.nifi.authorization.resource.Authorizable) PropertyDescriptorEntity(org.apache.nifi.web.api.entity.PropertyDescriptorEntity) PropertyDescriptorDTO(org.apache.nifi.web.api.dto.PropertyDescriptorDTO) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 92 with Authorizable

use of org.apache.nifi.authorization.resource.Authorizable in project nifi by apache.

the class ControllerServiceResource method getControllerServiceReferences.

/**
 * Retrieves the references of the specified controller service.
 *
 * @param id The id of the controller service to retrieve
 * @return A controllerServiceEntity.
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}/references")
@ApiOperation(value = "Gets a controller service", response = ControllerServiceReferencingComponentsEntity.class, authorizations = { @Authorization(value = "Read - /controller-services/{uuid}") })
@ApiResponses(value = { @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), @ApiResponse(code = 401, message = "Client could not be authenticated."), @ApiResponse(code = 403, message = "Client is not authorized to make this request."), @ApiResponse(code = 404, message = "The specified resource could not be found."), @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") })
public Response getControllerServiceReferences(@ApiParam(value = "The controller service id.", required = true) @PathParam("id") final String id) {
    if (isReplicateRequest()) {
        return replicate(HttpMethod.GET);
    }
    // authorize access
    serviceFacade.authorizeAccess(lookup -> {
        final Authorizable controllerService = lookup.getControllerService(id).getAuthorizable();
        controllerService.authorize(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser());
    });
    // get the controller service
    final ControllerServiceReferencingComponentsEntity entity = serviceFacade.getControllerServiceReferencingComponents(id);
    return generateOkResponse(entity).build();
}
Also used : ControllerServiceReferencingComponentsEntity(org.apache.nifi.web.api.entity.ControllerServiceReferencingComponentsEntity) ComponentAuthorizable(org.apache.nifi.authorization.ComponentAuthorizable) Authorizable(org.apache.nifi.authorization.resource.Authorizable) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 93 with Authorizable

use of org.apache.nifi.authorization.resource.Authorizable in project nifi by apache.

the class ControllerServiceResource method getState.

/**
 * Gets the state for a controller service.
 *
 * @param id The id of the controller service
 * @return a componentStateEntity
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}/state")
@ApiOperation(value = "Gets the state for a controller service", response = ComponentStateEntity.class, authorizations = { @Authorization(value = "Write - /controller-services/{uuid}") })
@ApiResponses(value = { @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), @ApiResponse(code = 401, message = "Client could not be authenticated."), @ApiResponse(code = 403, message = "Client is not authorized to make this request."), @ApiResponse(code = 404, message = "The specified resource could not be found."), @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") })
public Response getState(@ApiParam(value = "The controller service id.", required = true) @PathParam("id") final String id) {
    if (isReplicateRequest()) {
        return replicate(HttpMethod.GET);
    }
    // authorize access
    serviceFacade.authorizeAccess(lookup -> {
        final Authorizable controllerService = lookup.getControllerService(id).getAuthorizable();
        controllerService.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
    });
    // get the component state
    final ComponentStateDTO state = serviceFacade.getControllerServiceState(id);
    // generate the response entity
    final ComponentStateEntity entity = new ComponentStateEntity();
    entity.setComponentState(state);
    // generate the response
    return generateOkResponse(entity).build();
}
Also used : ComponentAuthorizable(org.apache.nifi.authorization.ComponentAuthorizable) Authorizable(org.apache.nifi.authorization.resource.Authorizable) ComponentStateDTO(org.apache.nifi.web.api.dto.ComponentStateDTO) ComponentStateEntity(org.apache.nifi.web.api.entity.ComponentStateEntity) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 94 with Authorizable

use of org.apache.nifi.authorization.resource.Authorizable in project nifi by apache.

the class FlowFileQueueResource method getListingRequest.

/**
 * Checks the status of an outstanding listing request.
 *
 * @param connectionId     The id of the connection
 * @param listingRequestId The id of the drop request
 * @return A dropRequestEntity
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}/listing-requests/{listing-request-id}")
@ApiOperation(value = "Gets the current status of a listing request for the specified connection.", response = ListingRequestEntity.class, authorizations = { @Authorization(value = "Read Source Data - /data/{component-type}/{uuid}") })
@ApiResponses(value = { @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), @ApiResponse(code = 401, message = "Client could not be authenticated."), @ApiResponse(code = 403, message = "Client is not authorized to make this request."), @ApiResponse(code = 404, message = "The specified resource could not be found."), @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") })
public Response getListingRequest(@ApiParam(value = "The connection id.", required = true) @PathParam("id") final String connectionId, @ApiParam(value = "The listing request id.", required = true) @PathParam("listing-request-id") final String listingRequestId) {
    if (isReplicateRequest()) {
        return replicate(HttpMethod.GET);
    }
    // authorize access
    serviceFacade.authorizeAccess(lookup -> {
        final ConnectionAuthorizable connAuth = lookup.getConnection(connectionId);
        final Authorizable dataAuthorizable = connAuth.getSourceData();
        dataAuthorizable.authorize(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser());
    });
    // get the listing request
    final ListingRequestDTO listingRequest = serviceFacade.getFlowFileListingRequest(connectionId, listingRequestId);
    populateRemainingFlowFileListingContent(connectionId, listingRequest);
    // create the response entity
    final ListingRequestEntity entity = new ListingRequestEntity();
    entity.setListingRequest(listingRequest);
    return generateOkResponse(entity).build();
}
Also used : ListingRequestDTO(org.apache.nifi.web.api.dto.ListingRequestDTO) Authorizable(org.apache.nifi.authorization.resource.Authorizable) ConnectionAuthorizable(org.apache.nifi.authorization.ConnectionAuthorizable) ConnectionAuthorizable(org.apache.nifi.authorization.ConnectionAuthorizable) ListingRequestEntity(org.apache.nifi.web.api.entity.ListingRequestEntity) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 95 with Authorizable

use of org.apache.nifi.authorization.resource.Authorizable in project nifi by apache.

the class FlowFileQueueResource method getDropRequest.

/**
 * Checks the status of an outstanding drop request.
 *
 * @param connectionId  The id of the connection
 * @param dropRequestId The id of the drop request
 * @return A dropRequestEntity
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}/drop-requests/{drop-request-id}")
@ApiOperation(value = "Gets the current status of a drop request for the specified connection.", response = DropRequestEntity.class, authorizations = { @Authorization(value = "Write Source Data - /data/{component-type}/{uuid}") })
@ApiResponses(value = { @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), @ApiResponse(code = 401, message = "Client could not be authenticated."), @ApiResponse(code = 403, message = "Client is not authorized to make this request."), @ApiResponse(code = 404, message = "The specified resource could not be found."), @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") })
public Response getDropRequest(@ApiParam(value = "The connection id.", required = true) @PathParam("id") final String connectionId, @ApiParam(value = "The drop request id.", required = true) @PathParam("drop-request-id") final String dropRequestId) {
    if (isReplicateRequest()) {
        return replicate(HttpMethod.GET);
    }
    // authorize access
    serviceFacade.authorizeAccess(lookup -> {
        final ConnectionAuthorizable connAuth = lookup.getConnection(connectionId);
        final Authorizable dataAuthorizable = connAuth.getSourceData();
        dataAuthorizable.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
    });
    // get the drop request
    final DropRequestDTO dropRequest = serviceFacade.getFlowFileDropRequest(connectionId, dropRequestId);
    dropRequest.setUri(generateResourceUri("flowfile-queues", connectionId, "drop-requests", dropRequestId));
    // create the response entity
    final DropRequestEntity entity = new DropRequestEntity();
    entity.setDropRequest(dropRequest);
    return generateOkResponse(entity).build();
}
Also used : DropRequestDTO(org.apache.nifi.web.api.dto.DropRequestDTO) Authorizable(org.apache.nifi.authorization.resource.Authorizable) ConnectionAuthorizable(org.apache.nifi.authorization.ConnectionAuthorizable) ConnectionAuthorizable(org.apache.nifi.authorization.ConnectionAuthorizable) DropRequestEntity(org.apache.nifi.web.api.entity.DropRequestEntity) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

Authorizable (org.apache.nifi.authorization.resource.Authorizable)140 ApiOperation (io.swagger.annotations.ApiOperation)96 ApiResponses (io.swagger.annotations.ApiResponses)96 Consumes (javax.ws.rs.Consumes)96 Produces (javax.ws.rs.Produces)96 Path (javax.ws.rs.Path)95 ComponentAuthorizable (org.apache.nifi.authorization.ComponentAuthorizable)53 GET (javax.ws.rs.GET)46 Revision (org.apache.nifi.web.Revision)44 ProcessGroupAuthorizable (org.apache.nifi.authorization.ProcessGroupAuthorizable)33 SnippetAuthorizable (org.apache.nifi.authorization.SnippetAuthorizable)28 TemplateContentsAuthorizable (org.apache.nifi.authorization.TemplateContentsAuthorizable)28 POST (javax.ws.rs.POST)24 NiFiUser (org.apache.nifi.authorization.user.NiFiUser)21 ResourceNotFoundException (org.apache.nifi.web.ResourceNotFoundException)21 DELETE (javax.ws.rs.DELETE)20 PUT (javax.ws.rs.PUT)20 RevisionDTO (org.apache.nifi.web.api.dto.RevisionDTO)19 PositionDTO (org.apache.nifi.web.api.dto.PositionDTO)18 PortEntity (org.apache.nifi.web.api.entity.PortEntity)15