/* * Author: Jonathan Tew 12/98 * * jtew@bpsinfo.com * * This is a Java interface to the SSLeay (a popular SSL implementation written by Eric Young and * Tim Hudson). These routines call the proper SSLeay functions to perform the operations * that the java routines need accomplished. They are nothing more than a wrapper around the * natively compiled SSLeay code. * * Copyright remains BPS Info Solutions, Inc., and as such any Copyright notices in * the code are not to be removed. If this code is used in a product (commercial or non-commercial), * BPS Info Solutions, Inc. should be given attribution as the author of the parts used. * This can be in the form of a textual message at program startup or in documentation (online or textual) * provided with the package. If the source code to the product is distributed then the source code * to this package should also be distributed in its unmodified and modified form. * * Any modifications to this code must be submitted to BPS Info Solutions, Inc. for * possible incorporation into this product. As such all modifications made to this * code must be made available to the public domain. * * Thanks to Eric Young and Tim Hudson for programming such an excellent SSL implementation. * Now if we can just get them to port it to Java :) */ /* Sample program */ /* Changes 3/25/1999 - jtew@bpsinfo.com - 1) Removed accident loading of HelloWorld.dll which was a testing dll. 2) Added pause at end of program to make it easier to see results 3) Removed https:// from the host name 4) Placed code in package com.bpsinfo.javassl */ // package com.bpsinfo.javassl; import java.io.*; import java.net.*; import com.bpsinfo.javassl.*; class HelloWorld { public native void displayHelloWorld(); public static void main(String[] args) { try { InetAddress theAddress= InetAddress.getByName("192.168.34.44"); // proxy server IP InetAddress localAddress=InetAddress.getByName("0.0.0.0"); // just something to tell the the code to // use the default IP address // the next line is for going through a proxy server located at 192.168.34.44:8080 SSLSocket s =new SSLSocket(theAddress, 8080, localAddress, 0, "CONNECT store.sun.com:443 HTTP/1.0\r\n\r\n"); // SSLSocket s =new SSLSocket("store.sun.com",443); // this line is for a direct connection (no proxy). s.setSoLinger(true, 30); OutputStream dos = s.getOutputStream(); InputStream is = s.getInputStream(); InputStreamReader dinsr=new InputStreamReader(is); BufferedReader dis=new BufferedReader(dinsr); String themsg=new String("GET / HTTP/1.0\r\n\r\n"); dos.write(themsg.getBytes()); dos.flush(); for (;;) { String st = dis.readLine(); if (st == null) break; System.out.println(st); } s.close(); } catch (Exception e) { System.out.println("\nCrapped out. "+e); e.printStackTrace(); } try { // Pause so we can see if everything was successful System.out.println(""); System.out.println("FINISHED"); Thread.sleep(10000); } catch (Exception e2) { } } }