<commit_before>package enmasse.controller.auth;

import io.fabric8.kubernetes.api.model.Secret;
import io.fabric8.openshift.client.OpenShiftClient;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.util.Base64;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * Controller that creates self-signed certificates for instances.
 */
public class SelfSignedCertManager implements CertManager {
    private static final Logger log = LoggerFactory.getLogger(SelfSignedCertManager.class.getName());
    private final OpenShiftClient client;

    public SelfSignedCertManager(OpenShiftClient controllerClient) {
        this.client = controllerClient;
    }

    @Override
    public void issueCert(String secretName, String namespace, String ... hostnames) throws Exception {
        Secret secret = client.secrets().inNamespace(namespace).withName(secretName).get();
        if (secret != null) { // && addressspace.messagingHost().isPresent() && addressspace.mqttHost().isPresent() && addressspace.consoleHost().isPresent()) {
            // TODO: Have this sign certificates with OpenShift CA

            String keyKey = "server-key.pem";
            String certKey = "server-cert.pem";
            if (secret.getData() != null && secret.getData().containsKey(keyKey) && secret.getData().containsKey(certKey)) {
                return;
            }

            log.info("Creating self-signed certificates for " + hostnames);
            File keyFile = new File("/tmp/server-key.pem");<commit_msg>Remove old comment<commit_after>package enmasse.controller.auth;

import io.fabric8.kubernetes.api.model.Secret;
import io.fabric8.openshift.client.OpenShiftClient;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.util.Base64;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * Controller that creates self-signed certificates for instances.
 */
public class SelfSignedCertManager implements CertManager {
    private static final Logger log = LoggerFactory.getLogger(SelfSignedCertManager.class.getName());
    private final OpenShiftClient client;

    public SelfSignedCertManager(OpenShiftClient controllerClient) {
        this.client = controllerClient;
    }

    @Override
    public void issueCert(String secretName, String namespace, String ... hostnames) throws Exception {
        Secret secret = client.secrets().inNamespace(namespace).withName(secretName).get();
        if (secret != null) {
            // TODO: Have this sign certificates with OpenShift CA

            String keyKey = "server-key.pem";
            String certKey = "server-cert.pem";
            if (secret.getData() != null && secret.getData().containsKey(keyKey) && secret.getData().containsKey(certKey)) {
                return;
            }

            log.info("Creating self-signed certificates for " + hostnames);
            File keyFile = new File("/tmp/server-key.pem");
{'fraction_non_alphanumeric': 0.10947503201024328, 'fraction_numerical': 0.0038412291933418692, 'mean_word_length': 3.5093795093795093, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1798392', 'n_tokens_mistral': 858, 'n_tokens_neox': 834, 'n_words': 194}