kerby-tool/kdc-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/Krb5Conf.java [49:87]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    private File generateConfFile() throws IOException {

        String resourcePath = kdcConfig.allowUdp() ? "/krb5_udp.conf" : "/krb5.conf";
        String templateContent;
        try (InputStream templateResource = getClass().getResourceAsStream(resourcePath)) {
            templateContent = IOUtil.readInput(templateResource);
        }

        String content = templateContent;

        content = content.replaceAll("_REALM_", "" + kdcConfig.getKdcRealm());
        content = content.replaceAll("_KDC_HOST_", "" + kdcConfig.getKdcHost());

        int kdcPort = kdcConfig.allowUdp() ? kdcConfig.getKdcUdpPort()
                : kdcConfig.getKdcTcpPort();
        content = content.replaceAll("_KDC_PORT_",
                String.valueOf(kdcPort));

        if (kdcConfig.allowTcp()) {
            content = content.replaceAll("#_KDC_TCP_PORT_", "kdc_tcp_port = " + kdcConfig.getKdcTcpPort());
        }
        if (kdcConfig.allowUdp()) {
            content = content.replaceAll("#_KDC_UDP_PORT_", "kdc_udp_port = " + kdcConfig.getKdcUdpPort());
        }

        int udpLimit = kdcConfig.allowUdp() ? 4096 : 1;
        content = content.replaceAll("_UDP_LIMIT_", String.valueOf(udpLimit));

        File confFile = new File(confDir, KRB5_CONF_FILE);
        if (confFile.exists()) {
            boolean delete = confFile.delete();
            if (!delete) {
                throw new RuntimeException("File delete error!");
            }
        }
        IOUtil.writeFile(content, confFile);

        return confFile;
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/Krb5Conf.java [49:87]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    private File generateConfFile() throws IOException {

        String resourcePath = kdcConfig.allowUdp() ? "/krb5_udp.conf" : "/krb5.conf";
        String templateContent;
        try (InputStream templateResource = getClass().getResourceAsStream(resourcePath)) {
            templateContent = IOUtil.readInput(templateResource);
        }

        String content = templateContent;

        content = content.replaceAll("_REALM_", "" + kdcConfig.getKdcRealm());
        content = content.replaceAll("_KDC_HOST_", "" + kdcConfig.getKdcHost());

        int kdcPort = kdcConfig.allowUdp() ? kdcConfig.getKdcUdpPort()
                : kdcConfig.getKdcTcpPort();
        content = content.replaceAll("_KDC_PORT_",
                String.valueOf(kdcPort));

        if (kdcConfig.allowTcp()) {
            content = content.replaceAll("#_KDC_TCP_PORT_", "kdc_tcp_port = " + kdcConfig.getKdcTcpPort());
        }
        if (kdcConfig.allowUdp()) {
            content = content.replaceAll("#_KDC_UDP_PORT_", "kdc_udp_port = " + kdcConfig.getKdcUdpPort());
        }

        int udpLimit = kdcConfig.allowUdp() ? 4096 : 1;
        content = content.replaceAll("_UDP_LIMIT_", String.valueOf(udpLimit));

        File confFile = new File(confDir, KRB5_CONF_FILE);
        if (confFile.exists()) {
            boolean delete = confFile.delete();
            if (!delete) {
                throw new RuntimeException("File delete error!");
            }
        }
        IOUtil.writeFile(content, confFile);

        return confFile;
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



