org.apache.nifi.authorization.exception.AuthorizerDestructionException Java Examples

The following examples show how to use org.apache.nifi.authorization.exception.AuthorizerDestructionException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AuthorizerFactoryBean.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
/**
 * @return a default Authorizer to use when running unsecurely with no authorizer configured
 */
private Authorizer createDefaultAuthorizer() {
    return new Authorizer() {
        @Override
        public AuthorizationResult authorize(final AuthorizationRequest request) throws AuthorizationAccessException {
            return AuthorizationResult.approved();
        }

        @Override
        public void initialize(AuthorizerInitializationContext initializationContext) throws AuthorizerCreationException {
        }

        @Override
        public void onConfigured(AuthorizerConfigurationContext configurationContext) throws AuthorizerCreationException {
        }

        @Override
        public void preDestruction() throws AuthorizerDestructionException {
        }
    };
}
 
Example #2
Source File: CompositeUserGroupProvider.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public void preDestruction() throws AuthorizerDestructionException {
    Exception error = null;
    for (final UserGroupProvider userGroupProvider : userGroupProviders) {
        try {
            userGroupProvider.preDestruction();
        } catch (Exception e) {
            error = e;
            logger.error("Error pre-destructing: " + e);
        }
    }

    if (error != null) {
        throw new AuthorizerDestructionException(error);
    }
}
 
Example #3
Source File: AuthorizerFactoryBean.java    From nifi with Apache License 2.0 6 votes vote down vote up
/**
 * @return a default Authorizer to use when running unsecurely with no authorizer configured
 */
private Authorizer createDefaultAuthorizer() {
    return new Authorizer() {
        @Override
        public AuthorizationResult authorize(final AuthorizationRequest request) throws AuthorizationAccessException {
            return AuthorizationResult.approved();
        }

        @Override
        public void initialize(AuthorizerInitializationContext initializationContext) throws AuthorizerCreationException {
        }

        @Override
        public void onConfigured(AuthorizerConfigurationContext configurationContext) throws AuthorizerCreationException {
        }

        @Override
        public void preDestruction() throws AuthorizerDestructionException {
        }
    };
}
 
Example #4
Source File: RangerNiFiAuthorizer.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void preDestruction() throws AuthorizerDestructionException {
    if (nifiPlugin != null) {
        try {
            nifiPlugin.cleanup();
            nifiPlugin = null;
        } catch (Throwable t) {
            throw new AuthorizerDestructionException("Error cleaning up RangerBasePlugin", t);
        }
    }
}
 
Example #5
Source File: CompositeConfigurableUserGroupProvider.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void preDestruction() throws AuthorizerDestructionException {
    try {
        configurableUserGroupProvider.preDestruction();
    } finally {
        super.preDestruction();
    }
}
 
Example #6
Source File: RangerNiFiAuthorizer.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void preDestruction() throws AuthorizerDestructionException {
    if (nifiPlugin != null) {
        try {
            nifiPlugin.cleanup();
            nifiPlugin = null;
        } catch (Throwable t) {
            throw new AuthorizerDestructionException("Error cleaning up RangerBasePlugin", t);
        }
    }
}
 
Example #7
Source File: ManagedRangerAuthorizer.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public AccessPolicyProvider getAccessPolicyProvider() {
    return new AccessPolicyProvider() {
        @Override
        public Set<AccessPolicy> getAccessPolicies() throws AuthorizationAccessException {
            return nifiPlugin.getAccessPolicies();
        }

        @Override
        public AccessPolicy getAccessPolicy(String identifier) throws AuthorizationAccessException {
            return nifiPlugin.getAccessPolicy(identifier);
        }

        @Override
        public AccessPolicy getAccessPolicy(String resourceIdentifier, RequestAction action) throws AuthorizationAccessException {
            return nifiPlugin.getAccessPolicy(resourceIdentifier, action);
        }

        @Override
        public UserGroupProvider getUserGroupProvider() {
            return userGroupProvider;
        }

        @Override
        public void initialize(AccessPolicyProviderInitializationContext initializationContext) throws AuthorizerCreationException {
        }

        @Override
        public void onConfigured(AuthorizerConfigurationContext configurationContext) throws AuthorizerCreationException {
        }

        @Override
        public void preDestruction() throws AuthorizerDestructionException {
        }
    };
}
 
Example #8
Source File: StandardPolicyBasedAuthorizerDAO.java    From nifi with Apache License 2.0 4 votes vote down vote up
public StandardPolicyBasedAuthorizerDAO(final Authorizer authorizer) {
    if (AuthorizerCapabilityDetection.isManagedAuthorizer(authorizer)) {
        accessPolicyProvider = ((ManagedAuthorizer) authorizer).getAccessPolicyProvider();
    } else {
        accessPolicyProvider = new AccessPolicyProvider() {
            @Override
            public Set<AccessPolicy> getAccessPolicies() throws AuthorizationAccessException {
                throw new IllegalStateException(MSG_NON_MANAGED_AUTHORIZER);
            }

            @Override
            public AccessPolicy getAccessPolicy(String identifier) throws AuthorizationAccessException {
                throw new IllegalStateException(MSG_NON_MANAGED_AUTHORIZER);
            }

            @Override
            public AccessPolicy getAccessPolicy(String resourceIdentifier, RequestAction action) throws AuthorizationAccessException {
                throw new IllegalStateException(MSG_NON_MANAGED_AUTHORIZER);
            }

            @Override
            public UserGroupProvider getUserGroupProvider() {
                return new UserGroupProvider() {
                    @Override
                    public Set<User> getUsers() throws AuthorizationAccessException {
                        throw new IllegalStateException(MSG_NON_MANAGED_AUTHORIZER);
                    }

                    @Override
                    public User getUser(String identifier) throws AuthorizationAccessException {
                        throw new IllegalStateException(MSG_NON_MANAGED_AUTHORIZER);
                    }

                    @Override
                    public User getUserByIdentity(String identity) throws AuthorizationAccessException {
                        throw new IllegalStateException(MSG_NON_MANAGED_AUTHORIZER);
                    }

                    @Override
                    public Set<Group> getGroups() throws AuthorizationAccessException {
                        throw new IllegalStateException(MSG_NON_MANAGED_AUTHORIZER);
                    }

                    @Override
                    public Group getGroup(String identifier) throws AuthorizationAccessException {
                        throw new IllegalStateException(MSG_NON_MANAGED_AUTHORIZER);
                    }

                    @Override
                    public UserAndGroups getUserAndGroups(String identity) throws AuthorizationAccessException {
                        throw new IllegalStateException(MSG_NON_MANAGED_AUTHORIZER);
                    }

                    @Override
                    public void initialize(UserGroupProviderInitializationContext initializationContext) throws AuthorizerCreationException {

                    }

                    @Override
                    public void onConfigured(AuthorizerConfigurationContext configurationContext) throws AuthorizerCreationException {

                    }

                    @Override
                    public void preDestruction() throws AuthorizerDestructionException {

                    }
                };
            }

            @Override
            public void initialize(AccessPolicyProviderInitializationContext initializationContext) throws AuthorizerCreationException {

            }

            @Override
            public void onConfigured(AuthorizerConfigurationContext configurationContext) throws AuthorizerCreationException {

            }

            @Override
            public void preDestruction() throws AuthorizerDestructionException {

            }
        };
    }

    userGroupProvider = accessPolicyProvider.getUserGroupProvider();
}
 
Example #9
Source File: SimpleUserGroupProvider.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public void preDestruction() throws AuthorizerDestructionException {
}
 
Example #10
Source File: FileAccessPolicyProvider.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public void preDestruction() throws AuthorizerDestructionException {
}
 
Example #11
Source File: FileUserGroupProvider.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public void preDestruction() throws AuthorizerDestructionException {
}
 
Example #12
Source File: AlwaysAuthorizedAuthorizer.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public void preDestruction() throws AuthorizerDestructionException {
}
 
Example #13
Source File: VolatileUserGroupProvider.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public void preDestruction() throws AuthorizerDestructionException {
}
 
Example #14
Source File: VolatileAccessPolicyProvider.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public void preDestruction() throws AuthorizerDestructionException {
}
 
Example #15
Source File: MiNiFiServer.java    From nifi-minifi with Apache License 2.0 4 votes vote down vote up
public void start() {
    try {
        logger.info("Loading Flow...");

        FlowFileEventRepository flowFileEventRepository = new RingBufferEventRepository(5);
        AuditService auditService = new StandardAuditService();
        Authorizer authorizer = new Authorizer() {
            @Override
            public AuthorizationResult authorize(AuthorizationRequest request) throws AuthorizationAccessException {
                return AuthorizationResult.approved();
            }

            @Override
            public void initialize(AuthorizerInitializationContext initializationContext) throws AuthorizerCreationException {
                // do nothing
            }

            @Override
            public void onConfigured(AuthorizerConfigurationContext configurationContext) throws AuthorizerCreationException {
                // do nothing
            }

            @Override
            public void preDestruction() throws AuthorizerDestructionException {
                // do nothing
            }
        };

        final String sensitivePropAlgorithmVal = props.getProperty(StringEncryptor.NF_SENSITIVE_PROPS_ALGORITHM);
        final String sensitivePropProviderVal = props.getProperty(StringEncryptor.NF_SENSITIVE_PROPS_PROVIDER);
        final String sensitivePropValueNifiPropVar = props.getProperty(StringEncryptor.NF_SENSITIVE_PROPS_KEY, DEFAULT_SENSITIVE_PROPS_KEY);

        StringEncryptor encryptor = StringEncryptor.createEncryptor(sensitivePropAlgorithmVal, sensitivePropProviderVal, sensitivePropValueNifiPropVar);
        VariableRegistry variableRegistry = new FileBasedVariableRegistry(props.getVariableRegistryPropertiesPaths());
        BulletinRepository bulletinRepository = new VolatileBulletinRepository();

        FlowController flowController = FlowController.createStandaloneInstance(
                flowFileEventRepository,
                props,
                authorizer,
                auditService,
                encryptor,
                bulletinRepository,
                variableRegistry,
                new StandardFlowRegistryClient()
                );

        flowService = StandardFlowService.createStandaloneInstance(
                flowController,
                props,
                encryptor,
                null, // revision manager
                authorizer);

        // start and load the flow
        flowService.start();
        flowService.load(null);
        flowController.onFlowInitialized(true);
        flowController.getGroup(flowController.getRootGroupId()).startProcessing();

        this.flowController = flowController;

        logger.info("Flow loaded successfully.");
    } catch (Exception e) {
        // ensure the flow service is terminated
        if (flowService != null && flowService.isRunning()) {
            flowService.stop(false);
        }
        startUpFailure(new Exception("Unable to load flow due to: " + e, e));
    }
}
 
Example #16
Source File: Authorizer.java    From localization_nifi with Apache License 2.0 2 votes vote down vote up
/**
 * Called immediately before instance destruction for implementers to release resources.
 *
 * @throws AuthorizerDestructionException If pre-destruction fails.
 */
void preDestruction() throws AuthorizerDestructionException;
 
Example #17
Source File: MockPolicyBasedAuthorizer.java    From nifi with Apache License 2.0 2 votes vote down vote up
@Override
public void preDestruction() throws AuthorizerDestructionException {

}
 
Example #18
Source File: Authorizer.java    From nifi with Apache License 2.0 2 votes vote down vote up
/**
 * Called immediately before instance destruction for implementers to release resources.
 *
 * @throws AuthorizerDestructionException If pre-destruction fails.
 */
void preDestruction() throws AuthorizerDestructionException;
 
Example #19
Source File: AccessPolicyProvider.java    From nifi with Apache License 2.0 2 votes vote down vote up
/**
 * Called immediately before instance destruction for implementers to release resources.
 *
 * @throws AuthorizerDestructionException If pre-destruction fails.
 */
void preDestruction() throws AuthorizerDestructionException;
 
Example #20
Source File: UserGroupProvider.java    From nifi with Apache License 2.0 2 votes vote down vote up
/**
 * Called immediately before instance destruction for implementers to release resources.
 *
 * @throws AuthorizerDestructionException If pre-destruction fails.
 */
void preDestruction() throws AuthorizerDestructionException;
 
Example #21
Source File: MockPolicyBasedAuthorizer.java    From nifi with Apache License 2.0 2 votes vote down vote up
@Override
public void preDestruction() throws AuthorizerDestructionException {

}
 
Example #22
Source File: StandardManagedAuthorizer.java    From nifi with Apache License 2.0 2 votes vote down vote up
@Override
public void preDestruction() throws AuthorizerDestructionException {

}
 
Example #23
Source File: MockPolicyBasedAuthorizer.java    From localization_nifi with Apache License 2.0 2 votes vote down vote up
@Override
public void preDestruction() throws AuthorizerDestructionException {

}
 
Example #24
Source File: MockPolicyBasedAuthorizer.java    From localization_nifi with Apache License 2.0 2 votes vote down vote up
@Override
public void preDestruction() throws AuthorizerDestructionException {

}