ClientConfigurationData createClientConfiguration() {
        ClientConfigurationData initialConf = new ClientConfigurationData();
        ProxyConfiguration proxyConfig = service.getConfiguration();
        initialConf.setServiceUrl(
                proxyConfig.isTlsEnabledWithBroker() ? service.getServiceUrlTls() : service.getServiceUrl());

        // Apply all arbitrary configuration. This must be called before setting any fields annotated as
        // @Secret on the ClientConfigurationData object because of the way they are serialized.
        // See https://github.com/apache/pulsar/issues/8509 for more information.
        Map<String, Object> overrides = PropertiesUtils
                .filterAndMapProperties(proxyConfig.getProperties(), "brokerClient_");
        ClientConfigurationData clientConf = ConfigurationDataUtils
                .loadData(overrides, initialConf, ClientConfigurationData.class);
        /** The proxy service does not need to automatically clean up invalid connections, so set false. **/
        initialConf.setConnectionMaxIdleSeconds(-1);
        clientConf.setAuthentication(this.getClientAuthentication());
        if (proxyConfig.isTlsEnabledWithBroker()) {
            clientConf.setUseTls(true);
            clientConf.setTlsHostnameVerificationEnable(proxyConfig.isTlsHostnameVerificationEnabled());
            if (proxyConfig.isBrokerClientTlsEnabledWithKeyStore()) {
                clientConf.setUseKeyStoreTls(true);
                clientConf.setTlsTrustStoreType(proxyConfig.getBrokerClientTlsTrustStoreType());
                clientConf.setTlsTrustStorePath(proxyConfig.getBrokerClientTlsTrustStore());
                clientConf.setTlsTrustStorePassword(proxyConfig.getBrokerClientTlsTrustStorePassword());
                clientConf.setTlsKeyStoreType(proxyConfig.getBrokerClientTlsKeyStoreType());
                clientConf.setTlsKeyStorePath(proxyConfig.getBrokerClientTlsKeyStore());
                clientConf.setTlsKeyStorePassword(proxyConfig.getBrokerClientTlsKeyStorePassword());
            } else {
                clientConf.setTlsTrustCertsFilePath(proxyConfig.getBrokerClientTrustCertsFilePath());
                clientConf.setTlsKeyFilePath(proxyConfig.getBrokerClientKeyFilePath());
                clientConf.setTlsCertificateFilePath(proxyConfig.getBrokerClientCertificateFilePath());
            }
            clientConf.setTlsAllowInsecureConnection(proxyConfig.isTlsAllowInsecureConnection());
        }
        return clientConf;
    }
@Test
    public void testCreateClientConfiguration() {
        ProxyConfiguration proxyConfiguration = new ProxyConfiguration();
        proxyConfiguration.setTlsEnabledWithBroker(true);
        String proxyUrlTls = "pulsar+ssl://proxy:6651";
        String proxyUrl = "pulsar://proxy:6650";

        ProxyService proxyService = mock(ProxyService.class);
        doReturn(proxyConfiguration).when(proxyService).getConfiguration();
        doReturn(proxyUrlTls).when(proxyService).getServiceUrlTls();
        doReturn(proxyUrl).when(proxyService).getServiceUrl();

        ProxyConnection proxyConnection = new ProxyConnection(proxyService, null);
        ClientConfigurationData clientConfiguration = proxyConnection.createClientConfiguration();
        assertEquals(clientConfiguration.getServiceUrl(), proxyUrlTls);

        proxyConfiguration.setTlsEnabledWithBroker(false);
        clientConfiguration = proxyConnection.createClientConfiguration();
        assertEquals(clientConfiguration.getServiceUrl(), proxyUrl);
    }