use of io.strimzi.api.kafka.model.CertSecretSource in project strimzi-kafka-operator by strimzi.
the class KafkaMirrorMaker2Cluster method getClusterTrustedCerts.
private void getClusterTrustedCerts(final StringBuilder clustersTrustedCerts, KafkaMirrorMaker2ClusterSpec mirrorMaker2Cluster, String clusterAlias) {
ClientTls tls = mirrorMaker2Cluster.getTls();
if (tls != null) {
List<CertSecretSource> trustedCertificates = tls.getTrustedCertificates();
if (trustedCertificates != null && trustedCertificates.size() > 0) {
if (clustersTrustedCerts.length() > 0) {
clustersTrustedCerts.append("\n");
}
clustersTrustedCerts.append(clusterAlias);
clustersTrustedCerts.append("=");
boolean separator = false;
for (CertSecretSource certSecretSource : trustedCertificates) {
if (separator) {
clustersTrustedCerts.append(";");
}
clustersTrustedCerts.append(certSecretSource.getSecretName());
clustersTrustedCerts.append("/");
clustersTrustedCerts.append(certSecretSource.getCertificate());
separator = true;
}
}
}
}
use of io.strimzi.api.kafka.model.CertSecretSource in project strimzi-kafka-operator by strimzi.
the class KafkaMirrorMakerCluster method addConsumerEnvVars.
/**
* Sets the consumer related environment variables in the provided List.
*
* @param varList List with environment variables
*/
private void addConsumerEnvVars(List<EnvVar> varList) {
if (consumer.getTls() != null) {
varList.add(buildEnvVar(ENV_VAR_KAFKA_MIRRORMAKER_TLS_CONSUMER, "true"));
if (consumer.getTls().getTrustedCertificates() != null && consumer.getTls().getTrustedCertificates().size() > 0) {
StringBuilder sb = new StringBuilder();
boolean separator = false;
for (CertSecretSource certSecretSource : consumer.getTls().getTrustedCertificates()) {
if (separator) {
sb.append(";");
}
sb.append(certSecretSource.getSecretName() + "/" + certSecretSource.getCertificate());
separator = true;
}
varList.add(buildEnvVar(ENV_VAR_KAFKA_MIRRORMAKER_TRUSTED_CERTS_CONSUMER, sb.toString()));
}
}
AuthenticationUtils.configureClientAuthenticationEnvVars(consumer.getAuthentication(), varList, name -> ENV_VAR_PREFIX + name + "_CONSUMER");
}
use of io.strimzi.api.kafka.model.CertSecretSource in project strimzi-kafka-operator by strimzi.
the class KafkaMirrorMakerCluster method addProducerEnvVars.
/**
* Sets the producer related environment variables in the provided List.
*
* @param varList List with environment variables
*/
private void addProducerEnvVars(List<EnvVar> varList) {
if (producer.getTls() != null) {
varList.add(buildEnvVar(ENV_VAR_KAFKA_MIRRORMAKER_TLS_PRODUCER, "true"));
if (producer.getTls().getTrustedCertificates() != null && producer.getTls().getTrustedCertificates().size() > 0) {
StringBuilder sb = new StringBuilder();
boolean separator = false;
for (CertSecretSource certSecretSource : producer.getTls().getTrustedCertificates()) {
if (separator) {
sb.append(";");
}
sb.append(certSecretSource.getSecretName() + "/" + certSecretSource.getCertificate());
separator = true;
}
varList.add(buildEnvVar(ENV_VAR_KAFKA_MIRRORMAKER_TRUSTED_CERTS_PRODUCER, sb.toString()));
}
}
AuthenticationUtils.configureClientAuthenticationEnvVars(producer.getAuthentication(), varList, name -> ENV_VAR_PREFIX + name + "_PRODUCER");
}
use of io.strimzi.api.kafka.model.CertSecretSource in project strimzi-kafka-operator by strimzi.
the class AuthenticationUtils method configureOauthCertificateVolumeMounts.
/**
* Generates volume mounts needed for certificates needed to connect to OAuth server.
* This is used in both OAuth servers and clients.
*
* @param volumeNamePrefix Prefix which was used to name the secret volumes
* @param trustedCertificates List of certificates which should be mounted
* @param baseVolumeMount The Base volume into which the certificates should be mounted
*
* @return List of new VolumeMounts
*/
public static List<VolumeMount> configureOauthCertificateVolumeMounts(String volumeNamePrefix, List<CertSecretSource> trustedCertificates, String baseVolumeMount) {
List<VolumeMount> newVolumeMounts = new ArrayList<>();
if (trustedCertificates != null && trustedCertificates.size() > 0) {
int i = 0;
for (CertSecretSource certSecretSource : trustedCertificates) {
String volumeName = String.format("%s-%d", volumeNamePrefix, i);
newVolumeMounts.add(VolumeUtils.createVolumeMount(volumeName, String.format("%s/%s-%d", baseVolumeMount, certSecretSource.getSecretName(), i)));
i++;
}
}
return newVolumeMounts;
}
use of io.strimzi.api.kafka.model.CertSecretSource in project strimzi-kafka-operator by strimzi.
the class AuthenticationUtils method configureOauthCertificateVolumes.
/**
* Generates volumes needed for certificates needed to connect to OAuth server.
* This is used in both OAuth servers and clients.
*
* @param volumeNamePrefix Prefix for naming the secret volumes
* @param trustedCertificates List of certificates which should be mounted
* @param isOpenShift Flag whether we are on OpenShift or not
*
* @return List of new Volumes
*/
public static List<Volume> configureOauthCertificateVolumes(String volumeNamePrefix, List<CertSecretSource> trustedCertificates, boolean isOpenShift) {
List<Volume> newVolumes = new ArrayList<>();
if (trustedCertificates != null && trustedCertificates.size() > 0) {
int i = 0;
for (CertSecretSource certSecretSource : trustedCertificates) {
Map<String, String> items = Collections.singletonMap(certSecretSource.getCertificate(), "tls.crt");
String volumeName = String.format("%s-%d", volumeNamePrefix, i);
Volume vol = VolumeUtils.createSecretVolume(volumeName, certSecretSource.getSecretName(), items, isOpenShift);
newVolumes.add(vol);
i++;
}
}
return newVolumes;
}
Aggregations