Search in sources :

Example 6 with PortAuthorizationResult

use of org.apache.nifi.remote.PortAuthorizationResult in project nifi by apache.

the class StandardAuthorizableLookup method getRootGroupOutputPort.

@Override
public RootGroupPortAuthorizable getRootGroupOutputPort(String id) {
    final Port outputPort = outputPortDAO.getPort(id);
    if (!(outputPort instanceof RootGroupPort)) {
        throw new IllegalArgumentException(String.format("The specified id '%s' does not represent an output port in the root group.", id));
    }
    final DataTransferAuthorizable baseAuthorizable = new DataTransferAuthorizable(outputPort);
    return new RootGroupPortAuthorizable() {

        @Override
        public Authorizable getAuthorizable() {
            return baseAuthorizable;
        }

        @Override
        public AuthorizationResult checkAuthorization(NiFiUser user) {
            // perform the authorization of the user by using the underlying component, ensures consistent authorization with raw s2s
            final PortAuthorizationResult authorizationResult = ((RootGroupPort) outputPort).checkUserAuthorization(user);
            if (authorizationResult.isAuthorized()) {
                return AuthorizationResult.approved();
            } else {
                return AuthorizationResult.denied(authorizationResult.getExplanation());
            }
        }
    };
}
Also used : NiFiUser(org.apache.nifi.authorization.user.NiFiUser) RootGroupPort(org.apache.nifi.remote.RootGroupPort) Port(org.apache.nifi.connectable.Port) RootGroupPort(org.apache.nifi.remote.RootGroupPort) DataTransferAuthorizable(org.apache.nifi.authorization.resource.DataTransferAuthorizable) PortAuthorizationResult(org.apache.nifi.remote.PortAuthorizationResult)

Aggregations

PortAuthorizationResult (org.apache.nifi.remote.PortAuthorizationResult)6 RootGroupPort (org.apache.nifi.remote.RootGroupPort)6 HandshakeException (org.apache.nifi.remote.exception.HandshakeException)4 Port (org.apache.nifi.connectable.Port)3 ProcessGroup (org.apache.nifi.groups.ProcessGroup)3 Peer (org.apache.nifi.remote.Peer)3 HttpServerCommunicationsSession (org.apache.nifi.remote.io.http.HttpServerCommunicationsSession)3 Test (org.junit.Test)3 DataTransferAuthorizable (org.apache.nifi.authorization.resource.DataTransferAuthorizable)2 NiFiUser (org.apache.nifi.authorization.user.NiFiUser)2 Connection (org.apache.nifi.connectable.Connection)2 HashSet (java.util.HashSet)1 FlowFileQueue (org.apache.nifi.controller.queue.FlowFileQueue)1