Search in sources :

Example 66 with Authorizable

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

the class WriteAheadProvenanceRepository method authorize.

private void authorize(final ProvenanceEventRecord event, final NiFiUser user) {
    if (authorizer == null || user == null) {
        return;
    }
    final Authorizable eventAuthorizable;
    if (event.isRemotePortType()) {
        eventAuthorizable = resourceFactory.createRemoteDataAuthorizable(event.getComponentId());
    } else {
        eventAuthorizable = resourceFactory.createLocalDataAuthorizable(event.getComponentId());
    }
    eventAuthorizable.authorize(authorizer, RequestAction.READ, user, event.getAttributes());
}
Also used : Authorizable(org.apache.nifi.authorization.resource.Authorizable)

Example 67 with Authorizable

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

the class VolatileProvenanceRepository method authorize.

protected void authorize(final ProvenanceEventRecord event, final NiFiUser user) {
    if (authorizer == null || user == null) {
        return;
    }
    final Authorizable eventAuthorizable;
    if (event.isRemotePortType()) {
        eventAuthorizable = resourceFactory.createRemoteDataAuthorizable(event.getComponentId());
    } else {
        eventAuthorizable = resourceFactory.createLocalDataAuthorizable(event.getComponentId());
    }
    eventAuthorizable.authorize(authorizer, RequestAction.READ, user, event.getAttributes());
}
Also used : Authorizable(org.apache.nifi.authorization.resource.Authorizable)

Example 68 with Authorizable

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

the class VolatileProvenanceRepository method isAuthorized.

public boolean isAuthorized(final ProvenanceEventRecord event, final NiFiUser user) {
    if (authorizer == null || user == null) {
        return true;
    }
    final Authorizable eventAuthorizable;
    try {
        if (event.isRemotePortType()) {
            eventAuthorizable = resourceFactory.createRemoteDataAuthorizable(event.getComponentId());
        } else {
            eventAuthorizable = resourceFactory.createLocalDataAuthorizable(event.getComponentId());
        }
    } catch (final ResourceNotFoundException rnfe) {
        return false;
    }
    final AuthorizationResult result = eventAuthorizable.checkAuthorization(authorizer, RequestAction.READ, user, event.getAttributes());
    return Result.Approved.equals(result.getResult());
}
Also used : Authorizable(org.apache.nifi.authorization.resource.Authorizable) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException) AuthorizationResult(org.apache.nifi.authorization.AuthorizationResult)

Example 69 with Authorizable

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

the class StandardConnection method getDestinationAuthorizable.

@Override
public Authorizable getDestinationAuthorizable() {
    final Connectable destinationConnectable = getDestination();
    final Authorizable destinationAuthorizable;
    // if the destination is a remote group port, authorize according to the RPG
    if (destinationConnectable instanceof RemoteGroupPort) {
        destinationAuthorizable = ((RemoteGroupPort) destinationConnectable).getRemoteProcessGroup();
    } else {
        destinationAuthorizable = destinationConnectable;
    }
    return destinationAuthorizable;
}
Also used : RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) Authorizable(org.apache.nifi.authorization.resource.Authorizable)

Example 70 with Authorizable

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

the class MiNiFiPersistentProvenanceRepository method authorize.

public void authorize(final ProvenanceEventRecord event, final NiFiUser user) {
    if (authorizer == null) {
        return;
    }
    final Authorizable eventAuthorizable;
    if (event.isRemotePortType()) {
        eventAuthorizable = resourceFactory.createRemoteDataAuthorizable(event.getComponentId());
    } else {
        eventAuthorizable = resourceFactory.createLocalDataAuthorizable(event.getComponentId());
    }
    eventAuthorizable.authorize(authorizer, RequestAction.READ, user, event.getAttributes());
}
Also used : Authorizable(org.apache.nifi.authorization.resource.Authorizable)

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