From: megacz Date: Fri, 30 Jan 2004 07:42:47 +0000 (+0000) Subject: 2003/12/13 00:44:41 X-Git-Tag: RC3~272 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=c191f0122fbd24c2df21c41affb0c039d59f16d8;p=org.ibex.core.git 2003/12/13 00:44:41 darcs-hash:20040130074247-2ba56-3b30ae7d4fd084b4e56527c84c7ad7b51385955b.gz --- diff --git a/src/org/xwt/HTTP.java b/src/org/xwt/HTTP.java index e82e23c..5f89ce3 100644 --- a/src/org/xwt/HTTP.java +++ b/src/org/xwt/HTTP.java @@ -189,7 +189,7 @@ public class HTTP { // Methods to attempt socket creation ///////////////////////////////////////////////////////////////// private Socket getSocket(String host, int port, boolean ssl, boolean negotiate) throws IOException { - Socket ret = ssl ? new TinySSL(host, port, negotiate) : new Socket(java.net.InetAddress.getByName(host), port); + Socket ret = ssl ? new SSL(host, port, negotiate) : new Socket(java.net.InetAddress.getByName(host), port); ret.setTcpNoDelay(true); return ret; } @@ -222,7 +222,7 @@ public class HTTP { String s = br.readLine(); if (s.charAt(9) != '2') throw new HTTPException("proxy refused CONNECT method: \"" + s + "\""); while (br.readLine().length() > 0) { }; - ((TinySSL)sock).negotiate(); + ((SSL)sock).negotiate(); } return sock; @@ -270,7 +270,7 @@ public class HTTP { dis.skip(6); // ip/port if ((int)(success & 0xff) == 90) { - if (ssl) ((TinySSL)sock).negotiate(); + if (ssl) ((SSL)sock).negotiate(); return sock; } if (Log.on) Log.log(this, "SOCKS server denied access, code " + (success & 0xff)); diff --git a/src/org/xwt/VectorGraphics.java b/src/org/xwt/VectorGraphics.java index 4b29e47..988c18a 100644 --- a/src/org/xwt/VectorGraphics.java +++ b/src/org/xwt/VectorGraphics.java @@ -1,3 +1,4 @@ +// FIXME // Copyright 2002 Adam Megacz, see the COPYING file for licensing [GPL] package org.xwt; import org.xwt.util.*; diff --git a/src/org/xwt/XWT.java b/src/org/xwt/XWT.java index 5d18134..5fa9a8d 100644 --- a/src/org/xwt/XWT.java +++ b/src/org/xwt/XWT.java @@ -1,3 +1,4 @@ +// FIXME // Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL] package org.xwt; diff --git a/src/org/xwt/TinySSL.java b/src/org/xwt/util/SSL.java similarity index 98% rename from src/org/xwt/TinySSL.java rename to src/org/xwt/util/SSL.java index db082fa..08d6fef 100644 --- a/src/org/xwt/TinySSL.java +++ b/src/org/xwt/util/SSL.java @@ -5,7 +5,7 @@ // the portion of clause 6a after the semicolon (aka the "obnoxious // relink clause") -package org.xwt; +package org.xwt.util; import org.bouncycastle.crypto.AsymmetricBlockCipher; import org.bouncycastle.crypto.Digest; @@ -87,16 +87,18 @@ import java.text.*; 1.03 10-Aug-02 Fixed a vulnerability outlined at http://online.securityfocus.com/archive/1/286290 + 1.04 12-Dec-03 Renamed to org.xwt.SSL, fixed race condition + */ -public class TinySSL extends Socket { +public class SSL extends Socket { // Simple Test ////////////////////////////////////////////// public static void main(String[] args) { Log.on = true; try { - Socket s = new TinySSL("www.paypal.com", 443); + Socket s = new SSL("www.paypal.com", 443); PrintWriter pw = new PrintWriter(s.getOutputStream()); BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream())); pw.println("GET / HTTP/1.0"); @@ -106,7 +108,7 @@ public class TinySSL extends Socket { while(true) { String s2 = br.readLine(); if (s2 == null) return; - Log.log(TinySSL.class, s2); + Log.log(SSL.class, s2); } } catch (Exception e) { @@ -161,14 +163,14 @@ public class TinySSL extends Socket { public InputStream getInputStream() throws IOException { return is != null ? is : super.getInputStream(); } public OutputStream getOutputStream() throws IOException { return os != null ? os : super.getOutputStream(); } - public TinySSL(String host, int port) throws IOException { this(host, port, true, false); } - public TinySSL(String host, int port, boolean negotiateImmediately) throws IOException { this(host, port, negotiateImmediately, false); } - public TinySSL(String host, int port, boolean negotiateImmediately, boolean ignoreUntrustedCert) throws IOException { + public SSL(String host, int port) throws IOException { this(host, port, true, false); } + public SSL(String host, int port, boolean negotiateImmediately) throws IOException { this(host, port, negotiateImmediately, false); } + public SSL(String host, int port, boolean negotiateImmediately, boolean ignoreUntrustedCert) throws IOException { super(host, port); if (!initializationFinished) { - synchronized(TinySSL.class) { + synchronized(SSL.class) { while (!initializationFinished) - try { TinySSL.class.wait(); } catch (Exception e) { } + try { SSL.class.wait(); } catch (Exception e) { } } } hostname = host; @@ -1539,7 +1541,7 @@ public class TinySSL extends Socket { for(int i=0; i