Search in sources :

Example 1 with ConnectRestExtensionContext

use of org.apache.kafka.connect.rest.ConnectRestExtensionContext in project kafka by apache.

the class BasicAuthSecurityRestExtensionTest method testJaasConfigurationNotOverwritten.

@SuppressWarnings("unchecked")
@Test
public void testJaasConfigurationNotOverwritten() {
    ArgumentCaptor<JaasBasicAuthFilter> jaasFilter = ArgumentCaptor.forClass(JaasBasicAuthFilter.class);
    Configurable<? extends Configurable<?>> configurable = mock(Configurable.class);
    when(configurable.register(jaasFilter.capture())).thenReturn(null);
    ConnectRestExtensionContext context = mock(ConnectRestExtensionContext.class);
    when(context.configurable()).thenReturn((Configurable) configurable);
    BasicAuthSecurityRestExtension extension = new BasicAuthSecurityRestExtension();
    Configuration overwrittenConfiguration = mock(Configuration.class);
    Configuration.setConfiguration(overwrittenConfiguration);
    extension.register(context);
    assertNotEquals(overwrittenConfiguration, jaasFilter.getValue().configuration, "Overwritten JAAS configuration should not be used by basic auth REST extension");
}
Also used : Configuration(javax.security.auth.login.Configuration) ConnectRestExtensionContext(org.apache.kafka.connect.rest.ConnectRestExtensionContext) Test(org.junit.jupiter.api.Test)

Example 2 with ConnectRestExtensionContext

use of org.apache.kafka.connect.rest.ConnectRestExtensionContext in project kafka by apache.

the class RestServer method registerRestExtensions.

void registerRestExtensions(Herder herder, ResourceConfig resourceConfig) {
    connectRestExtensions = herder.plugins().newPlugins(config.getList(WorkerConfig.REST_EXTENSION_CLASSES_CONFIG), config, ConnectRestExtension.class);
    long herderRequestTimeoutMs = ConnectorsResource.REQUEST_TIMEOUT_MS;
    Integer rebalanceTimeoutMs = config.getRebalanceTimeout();
    if (rebalanceTimeoutMs != null) {
        herderRequestTimeoutMs = Math.min(herderRequestTimeoutMs, rebalanceTimeoutMs.longValue());
    }
    ConnectClusterDetails connectClusterDetails = new ConnectClusterDetailsImpl(herder.kafkaClusterId());
    ConnectRestExtensionContext connectRestExtensionContext = new ConnectRestExtensionContextImpl(new ConnectRestConfigurable(resourceConfig), new ConnectClusterStateImpl(herderRequestTimeoutMs, connectClusterDetails, herder));
    for (ConnectRestExtension connectRestExtension : connectRestExtensions) {
        connectRestExtension.register(connectRestExtensionContext);
    }
}
Also used : ConnectClusterDetails(org.apache.kafka.connect.health.ConnectClusterDetails) ConnectClusterStateImpl(org.apache.kafka.connect.runtime.health.ConnectClusterStateImpl) ConnectClusterDetailsImpl(org.apache.kafka.connect.runtime.health.ConnectClusterDetailsImpl) ConnectRestExtension(org.apache.kafka.connect.rest.ConnectRestExtension) ConnectRestExtensionContext(org.apache.kafka.connect.rest.ConnectRestExtensionContext)

Aggregations

ConnectRestExtensionContext (org.apache.kafka.connect.rest.ConnectRestExtensionContext)2 Configuration (javax.security.auth.login.Configuration)1 ConnectClusterDetails (org.apache.kafka.connect.health.ConnectClusterDetails)1 ConnectRestExtension (org.apache.kafka.connect.rest.ConnectRestExtension)1 ConnectClusterDetailsImpl (org.apache.kafka.connect.runtime.health.ConnectClusterDetailsImpl)1 ConnectClusterStateImpl (org.apache.kafka.connect.runtime.health.ConnectClusterStateImpl)1 Test (org.junit.jupiter.api.Test)1