Search in sources :

Example 41 with AuthorizerConfigurationContext

use of org.apache.nifi.authorization.AuthorizerConfigurationContext in project nifi by apache.

the class LdapUserGroupProviderTest method testNoSearchBasesSpecified.

@Test(expected = AuthorizerCreationException.class)
public void testNoSearchBasesSpecified() throws Exception {
    final AuthorizerConfigurationContext configurationContext = getBaseConfiguration(null, null);
    ldapUserGroupProvider.onConfigured(configurationContext);
}
Also used : AuthorizerConfigurationContext(org.apache.nifi.authorization.AuthorizerConfigurationContext) Test(org.junit.Test)

Example 42 with AuthorizerConfigurationContext

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

the class MiNiFiServer method start.

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, // revision manager
        null, 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));
    }
}
Also used : VolatileBulletinRepository(org.apache.nifi.events.VolatileBulletinRepository) VolatileBulletinRepository(org.apache.nifi.events.VolatileBulletinRepository) BulletinRepository(org.apache.nifi.reporting.BulletinRepository) AuthorizationRequest(org.apache.nifi.authorization.AuthorizationRequest) FileBasedVariableRegistry(org.apache.nifi.util.FileBasedVariableRegistry) VariableRegistry(org.apache.nifi.registry.VariableRegistry) StatusRequestException(org.apache.nifi.minifi.status.StatusRequestException) AuthorizerCreationException(org.apache.nifi.authorization.exception.AuthorizerCreationException) AuthorizerDestructionException(org.apache.nifi.authorization.exception.AuthorizerDestructionException) AuthorizationAccessException(org.apache.nifi.authorization.exception.AuthorizationAccessException) RingBufferEventRepository(org.apache.nifi.controller.repository.metrics.RingBufferEventRepository) FlowFileEventRepository(org.apache.nifi.controller.repository.FlowFileEventRepository) Authorizer(org.apache.nifi.authorization.Authorizer) StringEncryptor(org.apache.nifi.encrypt.StringEncryptor) FlowController(org.apache.nifi.controller.FlowController) AuthorizerInitializationContext(org.apache.nifi.authorization.AuthorizerInitializationContext) StandardFlowRegistryClient(org.apache.nifi.registry.flow.StandardFlowRegistryClient) StandardAuditService(org.apache.nifi.admin.service.impl.StandardAuditService) AuditService(org.apache.nifi.admin.service.AuditService) StandardAuditService(org.apache.nifi.admin.service.impl.StandardAuditService) AuthorizerConfigurationContext(org.apache.nifi.authorization.AuthorizerConfigurationContext) FileBasedVariableRegistry(org.apache.nifi.util.FileBasedVariableRegistry)

Aggregations

AuthorizerConfigurationContext (org.apache.nifi.authorization.AuthorizerConfigurationContext)42 Test (org.junit.Test)38 StandardPropertyValue (org.apache.nifi.attribute.expression.language.StandardPropertyValue)33 Group (org.apache.nifi.authorization.Group)14 UserAndGroups (org.apache.nifi.authorization.UserAndGroups)11 Properties (java.util.Properties)9 UserGroupProviderInitializationContext (org.apache.nifi.authorization.UserGroupProviderInitializationContext)9 AuthorizerCreationException (org.apache.nifi.authorization.exception.AuthorizerCreationException)9 Set (java.util.Set)8 CreateLdapServer (org.apache.directory.server.annotations.CreateLdapServer)8 CreateTransport (org.apache.directory.server.annotations.CreateTransport)8 ApplyLdifFiles (org.apache.directory.server.core.annotations.ApplyLdifFiles)8 CreateDS (org.apache.directory.server.core.annotations.CreateDS)8 CreatePartition (org.apache.directory.server.core.annotations.CreatePartition)8 AbstractLdapTestUnit (org.apache.directory.server.core.integ.AbstractLdapTestUnit)8 FrameworkRunner (org.apache.directory.server.core.integ.FrameworkRunner)8 LdapAuthenticationStrategy (org.apache.nifi.ldap.LdapAuthenticationStrategy)8 ReferralStrategy (org.apache.nifi.ldap.ReferralStrategy)8 PROP_AUTHENTICATION_STRATEGY (org.apache.nifi.ldap.tenants.LdapUserGroupProvider.PROP_AUTHENTICATION_STRATEGY)8 PROP_CONNECT_TIMEOUT (org.apache.nifi.ldap.tenants.LdapUserGroupProvider.PROP_CONNECT_TIMEOUT)8