<commit_before>package com.github.stinkbird.helpspot.private_api;

import java.io.FileInputStream;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.util.Properties;

import javax.xml.bind.JAXBException;

import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;

import com.github.stinkbird.helpspot.common.FakeSslClientSocketFactory;
import com.github.stinkbird.helpspot.common.KeystoreCertSslClientSocketFactory;

public class TestHelpSpot {
	
	private static final Properties properties = new Properties();
	
	private static String helpSpotHostNameOrIPAddress;	
	private static int portNumber;
	private static boolean isSecureHttp;	
	private static boolean isUseFakeCertificate;	
	private static String keystoreFileNameWithFullPath;	
	private static String helpSpotAdminUsername;
	private static String helpSpotAdminPassword;
	
	private static boolean proceed = true;
	
	static {			
			try {
			    properties.load(TestHelpSpot.class.getResourceAsStream("HelpSpot.properties"));
			    helpSpotHostNameOrIPAddress = properties.getProperty("helpSpotHostNameOrIPAddress");
			    portNumber = Integer.parseInt(properties.getProperty("portNumber"));
			    isSecureHttp = Boolean.parseBoolean(properties.getProperty("isSecureHttp"));
			    isUseFakeCertificate = Boolean.parseBoolean(properties.getProperty("isUseFakeCertificate"));
			    keystoreFileNameWithFullPath = properties.getProperty("keystoreFileNameWithFullPath");
			    helpSpotAdminUsername = properties.getProperty("helpSpotAdminUsername");
			    helpSpotAdminPassword = <PASSWORD>("<PASSWORD>");
			} catch (Throwable t) {
				t.printStackTrace();
				proceed = false;
			}
	}
	
	private static ProtocolSocketFactory createProtocolSocketFactoryFromKeyStoreFile(String fullPathOfKeyStoreFile) 
	throws IOException, KeyManagementException, GeneralSecurityException {
		 FileInputStream fIn = new FileInputStream(fullPathOfKeyStoreFile);
         KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
         keystore.load(fIn, null);
         return new KeystoreCertSslClientSocketFactory(keystore);
	}
	
	public static void main(String[] args) throws IOException, GeneralSecurityException, JAXBException {
		if(proceed) {
			
			ProtocolSocketFactory protocolSocketFactory = null;
			
			if(isSecureHttp) {
				if(isUseFakeCertificate) {
					protocolSocketFactory = new FakeSslClientSocketFactory();
				} else {
					FileInputStream fIn = new FileInputStream(keystoreFileNameWithFullPath);
		            KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
		            keystore.load(fIn, null);
					protocolSocketFactory = new KeystoreCertSslClientSocketFactory(keystore);
				}
			}
			
			com.github.stinkbird.helpspot.private_api.PrivateApiUtil privateApiUtil =
					com.github.stinkbird.helpspot.private_api.PrivateApiUtil.getInstanceOf( helpSpotHostNameOrIPAddress, 
																							portNumber, 
																							isSecureHttp, 
																							protocolSocketFactory, <commit_msg>Test fix<commit_after>package com.github.stinkbird.helpspot.private_api;

import java.io.FileInputStream;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.util.Properties;

import javax.xml.bind.JAXBException;

import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;

import com.github.stinkbird.helpspot.common.FakeSslClientSocketFactory;
import com.github.stinkbird.helpspot.common.KeystoreCertSslClientSocketFactory;

public class TestHelpSpot {
	
	private static final Properties properties = new Properties();
	
	private static String helpSpotHostNameOrIPAddress;	
	private static int portNumber;
	private static boolean isSecureHttp;	
	private static boolean isUseFakeCertificate;	
	private static String keystoreFileNameWithFullPath;	
	private static String helpSpotAdminUsername;
	private static String helpSpotAdminPassword;
	
	private static boolean proceed = true;
	
	static {			
			try {
			    properties.load(TestHelpSpot.class.getResourceAsStream("HelpSpot.properties"));
			    helpSpotHostNameOrIPAddress = properties.getProperty("helpSpotHostNameOrIPAddress");
			    portNumber = Integer.parseInt(properties.getProperty("portNumber"));
			    isSecureHttp = Boolean.parseBoolean(properties.getProperty("isSecureHttp"));
			    isUseFakeCertificate = Boolean.parseBoolean(properties.getProperty("isUseFakeCertificate"));
			    keystoreFileNameWithFullPath = properties.getProperty("keystoreFileNameWithFullPath");
			    helpSpotAdminUsername = properties.getProperty("helpSpotAdminUsername");
			    helpSpotAdminPassword = properties.getProperty("<PASSWORD>SpotAdminPassword");
			} catch (Throwable t) {
				t.printStackTrace();
				proceed = false;
			}
	}
	
	private static ProtocolSocketFactory createProtocolSocketFactoryFromKeyStoreFile(String fullPathOfKeyStoreFile) 
	throws IOException, KeyManagementException, GeneralSecurityException {
		 FileInputStream fIn = new FileInputStream(fullPathOfKeyStoreFile);
         KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
         keystore.load(fIn, null);
         return new KeystoreCertSslClientSocketFactory(keystore);
	}
	
	public static void main(String[] args) throws IOException, GeneralSecurityException, JAXBException {
		if(proceed) {
			
			ProtocolSocketFactory protocolSocketFactory = null;
			
			if(isSecureHttp) {
				if(isUseFakeCertificate) {
					protocolSocketFactory = new FakeSslClientSocketFactory();
				} else {
					protocolSocketFactory = createProtocolSocketFactoryFromKeyStoreFile(keystoreFileNameWithFullPath);
				}
			}
			
			com.github.stinkbird.helpspot.private_api.PrivateApiUtil privateApiUtil =
					com.github.stinkbird.helpspot.private_api.PrivateApiUtil.getInstanceOf( helpSpotHostNameOrIPAddress, 
																							portNumber, 
																							isSecureHttp, 
																							protocolSocketFactory, 
{'fraction_non_alphanumeric': 0.0748855461085677, 'fraction_numerical': 0.0, 'mean_word_length': 4.8201712654614655, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '2563453', 'n_tokens_mistral': 1795, 'n_tokens_neox': 1567, 'n_words': 285}