public void run() {
   OutputStream outputstream = null;
   try {
     outputstream = c.getOutputStream();
   } catch (IOException ioexception) {
     b = ioexception;
   }
   a = outputstream;
   synchronized (event) {
     event.notifyAll();
   }
 }
  /*
   * Define the client side of the test.
   *
   * If the server prematurely exits, serverReady will be set to true
   * to avoid infinite hangs.
   */
  void doClientSide() throws Exception {
    /*
     * Wait for server to get started.
     */
    while (!serverReady) {
      Thread.sleep(50);
    }

    System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
    HttpsURLConnection.setDefaultHostnameVerifier(new NameVerifier());

    URL url = new URL("https://" + "localhost:" + serverPort + "/etc/hosts");
    URLConnection urlc = url.openConnection();

    if (!(urlc instanceof com.sun.net.ssl.HttpsURLConnection)) {
      throw new Exception("URLConnection ! instanceof " + "com.sun.net.ssl.HttpsURLConnection");
    }

    BufferedReader in = null;
    try {
      in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));
      String inputLine;
      System.out.print("Client reading... ");
      while ((inputLine = in.readLine()) != null) System.out.println(inputLine);

      System.out.println("Cipher Suite: " + ((HttpsURLConnection) urlc).getCipherSuite());
      X509Certificate[] certs = ((HttpsURLConnection) urlc).getServerCertificateChain();
      for (int i = 0; i < certs.length; i++) {
        System.out.println(certs[0]);
      }

      in.close();
    } catch (SSLException e) {
      if (in != null) in.close();
      throw e;
    }
    System.out.println("Client reports:  SUCCESS");
  }
Esempio n. 3
0
  /** Creates an XMLRPC call from the given method name and parameters and sends it */
  protected void writeCall(String methodName, Object[] args) throws Exception {
    huc = u.openConnection();
    huc.setDoOutput(true);
    huc.setDoInput(true);
    huc.setUseCaches(false);
    huc.setRequestProperty("Content-Type", "binary/message-pack");
    huc.setReadTimeout(0);
    OutputStream os = huc.getOutputStream();
    Packer pk = new Packer(os);

    pk.packArray(args.length + 1);
    pk.pack(methodName);
    for (Object o : args) pk.pack(o);
    os.close();
  }
Esempio n. 4
0
 /** Receives an RPC response and converts to an object */
 protected Object readResp() throws Exception {
   InputStream is = huc.getInputStream();
   MessagePackObject mpo = MessagePack.unpack(is);
   return unMsg(mpo);
 }