use of org.apache.kafka.common.security.auth.SecurityProtocol in project apache-kafka-on-k8s by banzaicloud.
the class ClientUtils method createChannelBuilder.
/**
* @param config client configs
* @return configured ChannelBuilder based on the configs.
*/
public static ChannelBuilder createChannelBuilder(AbstractConfig config) {
SecurityProtocol securityProtocol = SecurityProtocol.forName(config.getString(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG));
String clientSaslMechanism = config.getString(SaslConfigs.SASL_MECHANISM);
return ChannelBuilders.clientChannelBuilder(securityProtocol, JaasContext.Type.CLIENT, config, null, clientSaslMechanism, true);
}
use of org.apache.kafka.common.security.auth.SecurityProtocol in project cruise-control by linkedin.
the class CCEmbeddedBroker method parseConfigs.
private void parseConfigs(Map<Object, Object> config) {
_id = Integer.parseInt((String) config.get(KafkaConfig.BrokerIdProp()));
_logDir = new File((String) config.get(KafkaConfig.LogDirProp()));
// Bind addresses
String listenersString = (String) config.get(KafkaConfig.ListenersProp());
for (String protocolAddr : listenersString.split("\\s*,\\s*")) {
try {
URI uri = new URI(protocolAddr.trim());
SecurityProtocol protocol = SecurityProtocol.forName(uri.getScheme());
_hosts.put(protocol, uri.getHost());
// We get the value after boot
_ports.put(protocol, null);
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
}
use of org.apache.kafka.common.security.auth.SecurityProtocol in project cruise-control by linkedin.
the class CCKafkaClientsIntegrationTestHarness method setSecurityConfigs.
protected void setSecurityConfigs(Properties clientProps, String certAlias) {
SecurityProtocol protocol = securityProtocol();
if (protocol == SecurityProtocol.SSL) {
File trustStoreFile = trustStoreFile();
if (trustStoreFile == null) {
throw new AssertionError("ssl set but no trust store provided");
}
clientProps.setProperty(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, protocol.name);
clientProps.setProperty(KafkaConfig.SslEndpointIdentificationAlgorithmProp(), "");
try {
clientProps.putAll(TestSslUtils.createSslConfig(true, true, Mode.CLIENT, trustStoreFile, certAlias));
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
}
use of org.apache.kafka.common.security.auth.SecurityProtocol in project kcache by rayokota.
the class SASLClusterTestHarness method getKafkaConfig.
@Override
protected KafkaConfig getKafkaConfig(int brokerId) {
final Option<File> trustStoreFileOption = Option.apply(null);
final Option<SecurityProtocol> saslInterBrokerSecurityProtocol = Option.apply(SecurityProtocol.SASL_PLAINTEXT);
Properties props = TestUtils.createBrokerConfig(brokerId, zkConnect, false, false, TestUtils.RandomPort(), saslInterBrokerSecurityProtocol, trustStoreFileOption, EMPTY_SASL_PROPERTIES, false, true, TestUtils.RandomPort(), false, TestUtils.RandomPort(), false, TestUtils.RandomPort(), Option.<String>empty(), 1, false, 1, (short) 1);
injectProperties(props);
props.setProperty("zookeeper.connection.timeout.ms", "30000");
props.setProperty("sasl.mechanism.inter.broker.protocol", "GSSAPI");
props.setProperty(BrokerSecurityConfigs.SASL_ENABLED_MECHANISMS_CONFIG, "GSSAPI");
return KafkaConfig.fromProps(props);
}
use of org.apache.kafka.common.security.auth.SecurityProtocol in project kcache by rayokota.
the class SSLClusterTestHarness method getKafkaConfig.
@Override
protected KafkaConfig getKafkaConfig(int brokerId) {
File trustStoreFile;
try {
trustStoreFile = File.createTempFile("SSLClusterTestHarness-truststore", ".jks");
} catch (IOException ioe) {
throw new RuntimeException("Unable to create temporary file for the truststore.");
}
final Option<File> trustStoreFileOption = Option.apply(trustStoreFile);
final Option<SecurityProtocol> sslInterBrokerSecurityProtocol = Option.apply(SecurityProtocol.SSL);
Properties props = TestUtils.createBrokerConfig(brokerId, zkConnect, false, false, TestUtils.RandomPort(), sslInterBrokerSecurityProtocol, trustStoreFileOption, EMPTY_SASL_PROPERTIES, false, false, TestUtils.RandomPort(), true, TestUtils.RandomPort(), false, TestUtils.RandomPort(), Option.<String>empty(), 1, false, 1, (short) 1);
// setup client SSL. Needs to happen before the broker is initialized, because the client's cert
// needs to be added to the broker's trust store.
Map<String, Object> sslConfigs;
try {
this.clientSslConfigs = TestSslUtils.createSslConfig(true, true, Mode.CLIENT, trustStoreFile, "client", "localhost");
} catch (Exception e) {
throw new RuntimeException(e);
}
injectProperties(props);
if (requireSSLClientAuth()) {
props.setProperty("ssl.client.auth", "required");
}
return KafkaConfig.fromProps(props);
}
Aggregations