@@ -0,0 +1,2343 @@
+package org.bouncycastle.crypto.tls.test;%0A%0Aimport java.io.IOException;%0Aimport java.net.InetAddress;%0Aimport java.net.ServerSocket;%0Aimport java.net.Socket;%0Aimport java.security.SecureRandom;%0A%0Aimport org.bouncycastle.crypto.tls.TlsServerProtocol;%0A%0A/**%0A * A simple test designed to conduct a TLS handshake with an external TLS client.%0A * %3Cp/%3E%0A * Please refer to GnuTLSSetup.txt or OpenSSLSetup.txt, and x509-*.pem files in this package for%0A * help configuring an external TLS client.%0A */%0Apublic class TlsServerTest%0A%7B%0A    private static final SecureRandom secureRandom = new SecureRandom();%0A%0A    public static void main(String%5B%5D args)%0A        throws Exception%0A    %7B%0A        InetAddress address = InetAddress.getLocalHost();%0A        int port = 5556;%0A%0A        ServerSocket ss = new ServerSocket(port, 16, address);%0A        while (true)%0A        %7B%0A            Socket s = ss.accept();%0A            System.out.println(%22--------------------------------------------------------------------------------%22);%0A            System.out.println(%22Accepted %22 + s);%0A            ServerThread t = new ServerThread(s);%0A            t.start();%0A        %7D%0A    %7D%0A%0A    static class ServerThread%0A        extends Thread%0A    %7B%0A        private final Socket s;%0A%0A        ServerThread(Socket s)%0A        %7B%0A            this.s = s;%0A        %7D%0A%0A        public void run()%0A        %7B%0A            try%0A            %7B%0A                long time1 = System.currentTimeMillis();%0A%0A                MockTlsServer server = new MockTlsServer();%0A                TlsServerProtocol serverProtocol = new TlsServerProtocol(s.getInputStream(), s.getOutputStream(), secureRandom);%0A                serverProtocol.accept(server);%0A                // Streams.pipeAll(serverProtocol.getInputStream(), serverProtocol.getOutputStream());%0A                serverProtocol.close();%0A%0A                long time2 = System.currentTimeMillis();%0A                System.out.println(%22Elapsed 1: %22 + (time2 - time1) + %22ms%22);%0A            %7D%0A            catch (Exception e)%0A            %7B%0A                throw new RuntimeException(e);%0A            %7D%0A            finally%0A            %7B%0A                try%0A                %7B%0A                    s.close();%0A                %7D%0A                catch (IOException e)%0A                %7B%0A                %7D%0A                finally%0A                %7B%0A                %7D%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

Add TlsServerTest, a simple TLS server for testing against external clients