package SecureElection;
/**
 * Created by Klas Eskilson on 15-11-16.
 */

public class SecureElectionClient {

    public static void main(String[] args) {

    }
}

@@ -21,139 +21,2581 @@
 on;%0A
-/**%0A * Created by Klas Eskilson on 15-11-16.%0A */%0A%0Apublic class SecureElectionClient %7B%0A%0A    public static void main(String%5B%5D args) %7B
+%0Aimport java.io.BufferedReader;%0Aimport java.io.FileInputStream;%0Aimport java.io.InputStreamReader;%0Aimport java.io.PrintWriter;%0Aimport java.net.InetAddress;%0Aimport java.net.UnknownHostException;%0Aimport java.security.KeyStore;%0Aimport javax.net.ssl.*;%0Aimport SecureElection.Common.Settings;%0A%0A/**%0A * Created by Klas Eskilson on 15-11-16.%0A */%0A%0Apublic class SecureElectionClient %7B%0A    // constants%0A    private static final String CLIENTTRUSTSTORE = Settings.KEYLOCATION + %22ClientTruststore.ks%22;%0A    private static final String CLIENTKEYSTORE   = Settings.KEYLOCATION + %22ClientKeystore.ks%22;%0A    private static final String CLIENTPASSWORD   = %22somephrase%22;%0A%0A    // class variables%0A    BufferedReader socketIn;%0A    PrintWriter socketOut;%0A%0A    /**%0A     * setup ssl client%0A     * @param addr  the address to connect to%0A     */%0A    private void setupSSLClient(InetAddress hostAddr) %7B%0A        try %7B%0A            // load keystores%0A            KeyStore ks = KeyStore.getInstance(%22JCEKS%22);%0A            ks.load(new FileInputStream(CLIENTKEYSTORE),%0A                    CLIENTPASSWORD.toCharArray());%0A            KeyStore ts = KeyStore.getInstance(%22JCEKS%22);%0A            ts.load(new FileInputStream(CLIENTTRUSTSTORE),%0A                    CLIENTPASSWORD.toCharArray());%0A%0A            // setup key managers%0A            KeyManagerFactory kmf = KeyManagerFactory.getInstance(%22SunX509%22);%0A            kmf.init(ks, CLIENTPASSWORD.toCharArray());%0A            TrustManagerFactory tmf = TrustManagerFactory.getInstance(%22SunX509%22);%0A            tmf.init(ts);%0A%0A            // setup ssl%0A            SSLContext sslContext = SSLContext.getInstance(%22TLS%22);%0A            sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);%0A            SSLSocketFactory sslFact = sslContext.getSocketFactory();%0A            SSLSocket client = (SSLSocket) sslFact.createSocket(hostAddr, this.hostPort);%0A            client.setEnabledCipherSuites(client.getSupportedCipherSuites());%0A%0A            // setup transmissions%0A            socketIn = new BufferedReader(new InputStreamReader(client.getInputStream()));%0A            socketOut = new PrintWriter(client.getOutputStream(), true);%0A        %7D catch (Exception e) %7B%0A            System.out.println(e);%0A            e.printStackTrace();%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        try %7B%0A            // setup connection%0A            InetAddress localhost = InetAddress.getLocalHost();%0A            setupSSLClient(localhost);%0A        %7D catch (UnknownHostException uhe) %7B%0A            System.out.println(uhe);%0A            uhe.printStackTrace();%0A        %7D
 %0A%0A  

Add SSL setup to client