You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@ws.apache.org by du...@locus.apache.org on 2000/12/11 19:51:13 UTC
cvs commit: xml-soap/java/src/org/apache/soap/util/net HTTPUtils.java SSLUtils.java
duftler 00/12/11 10:51:13
Modified: java/src/org/apache/soap/util/net HTTPUtils.java
SSLUtils.java
Log:
Removed extra linefeeds.
Revision Changes Path
1.11 +296 -296 xml-soap/java/src/org/apache/soap/util/net/HTTPUtils.java
Index: HTTPUtils.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/util/net/HTTPUtils.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- HTTPUtils.java 2000/12/11 16:29:44 1.10
+++ HTTPUtils.java 2000/12/11 18:51:12 1.11
@@ -1,296 +1,296 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 2000 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "SOAP" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 2000, International
- * Business Machines, Inc., http://www.apache.org. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-package org.apache.soap.util.net;
-
-import java.net.*;
-import java.io.*;
-import java.util.*;
-
-import org.apache.soap.*;
-import org.apache.soap.rpc.*;
-import org.apache.soap.transport.*;
-import org.apache.soap.util.mime.*;
-import javax.mail.*;
-import javax.mail.internet.*;
-import javax.activation.*;
-import java.lang.reflect.*;
-
-/**
- * A bunch of utility stuff for doing HTTP things.
- * <p>
- * 2000/07/30 W. Cloetens added Multipart Mime support
- *
- * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
- * @author Matthew J. Duftler (duftler@us.ibm.com)
- * @author Wouter Cloetens (wcloeten@raleigh.ibm.com)
- */
-public class HTTPUtils {
- private static final String HTTP_VERSION = "1.0";
- private static final int HTTP_DEFAULT_PORT = 80;
- private static final int HTTPS_DEFAULT_PORT = 443;
-
- /** This method either creates a socket or calls SSLUtils to
- create an SSLSocket. It uses reflection to avoid a compile time
- dependency on SSL.
- @author Chris Nelson
- */
-
- private static Socket buildSocket(URL url,
- String httpProxyHost, int httpProxyPort)
- throws IOException, UnknownHostException
- {
- Socket s = null;
- String host = null;
-
- int port = 0;
-
- if (httpProxyHost == null) {
- host = url.getHost ();
- port = url.getPort();
- } else {
- host = httpProxyHost;
- port = httpProxyPort;
- }
-
- if (url.getProtocol().equalsIgnoreCase("HTTPS"))
- {
- if (port < 0)
- {
- port = HTTPS_DEFAULT_PORT;
- }
- try
- {
- // Using reflection to avoid compile time dependencies
- Class SSLUtilsClass =
- Class.forName("org.apache.soap.util.net.SSLUtils");
- Class[] paramTypes = new Class[] {String.class, int.class};
- Method buildSSLSocket = SSLUtilsClass.getMethod(
- "buildSSLSocket", paramTypes);
- Object[] params = new Object[] {host, new Integer(port)};
- s = (Socket)buildSSLSocket.invoke(null, params);
- }
- catch (Exception e) {e.printStackTrace();}
- }
- else
- {
- if (port < 0) // No port given..use HTTP default which is pry 80 :-)
- port = HTTP_DEFAULT_PORT;
- s = new Socket (host, port);
- }
-
- return s;
- }
-
- /**
- * POST something to the given URL. The headers are put in as
- * HTTP headers, the content length is calculated and the content
- * byte array is sent as the POST content.
- *
- * @param url the url to post to
- * @param request the message
- * @param timeout the timeout, in ms, to wait for connection establishment
- * @param httpProxyHost the HTTP proxy host or null if no proxy.
- * @param httpProxyPort the HTTP proxy port, if the proxy host is not null
- */
- public static TransportMessage post(URL url, TransportMessage request,
- int timeout,
- String httpProxyHost, int httpProxyPort)
- throws IllegalArgumentException, IOException, SOAPException {
- /* Open the connection */
- PrintWriter out = null;
- OutputStream outStream = null;
- InputStream inStream = null;
- BufferedReader in = null;
- int port;
- try {
- port = url.getPort ();
-
- Socket s = buildSocket(url, httpProxyHost, httpProxyPort);
-
- if (port < 0) // No port given..use HTTP default which is pry 80 :-)
- port = HTTP_DEFAULT_PORT;
-
-
- if (timeout > 0) // Should be redundant but not every JVM likes this
- s.setSoTimeout(timeout);
-
- outStream = s.getOutputStream ();
- out = new PrintWriter (outStream);
- inStream = s.getInputStream ();
- }
- catch (Exception e) {
- throw new IllegalArgumentException("Error opening socket: " +
- e.getMessage ());
- }
-
- /* Send the request. */
- out.print(Constants.HEADER_POST + " " +
- (httpProxyHost == null ? url.getFile() : url.toString()) +
- " HTTP/" + HTTP_VERSION + "\r\n");
- out.print(Constants.HEADER_HOST + ": " + url.getHost() + ':' +
- port + "\r\n");
- out.print(Constants.HEADER_CONTENT_TYPE + ": " +
- request.getContentType() + "\r\n");
- out.print(Constants.HEADER_CONTENT_LENGTH + ": " +
- request.getContentLength() + "\r\n");
- for (Enumeration e = request.getHeaderNames(); e.hasMoreElements(); ) {
- Object key = e.nextElement();
- out.print(key + ": " + request.getHeader((String)key) + "\r\n");
- }
- out.print("\r\n");
- out.flush();
- request.writeTo(outStream);
- out.print("\r\n\r\n");
- out.flush();
-
- /* Read the response status line. */
- int statusCode = 0;
- String statusString = null;
- StringBuffer linebuf = new StringBuffer();
- int b = 0;
- while (b != '\n' && b != -1) {
- b = inStream.read();
- if (b != '\n' && b != '\r' && b != -1)
- linebuf.append((char)b);
- }
- String line = linebuf.toString();
- try {
- StringTokenizer st = new StringTokenizer(line);
- st.nextToken(); // ignore version part
- statusCode = Integer.parseInt (st.nextToken());
- StringBuffer sb = new StringBuffer();
- while (st.hasMoreTokens()) {
- sb.append (st.nextToken());
- if (st.hasMoreTokens()) {
- sb.append(" ");
- }
- }
- statusString = sb.toString();
- }
- catch (Exception e) {
- throw new IllegalArgumentException("Error parsing HTTP status line: " +
- e.getMessage());
- }
-
- /* Read the entire response (following the status line)
- * into a byte array. */
- ByteArrayDataSource ds = new ByteArrayDataSource(inStream,
- Constants.HEADERVAL_DEFAULT_CHARSET);
-
- /* Extract the headers, content type and content length. */
- byte[] bytes = ds.toByteArray();
- Hashtable respHeaders = new Hashtable();
- int respContentLength = -1;
- String respContentType = null;
- StringBuffer namebuf = new StringBuffer();
- StringBuffer valuebuf = new StringBuffer();
- boolean parsingName = true;
- int offset;
- for (offset = 0; offset < bytes.length; offset++) {
- if (bytes[offset] == '\n') {
- if (namebuf.length() == 0)
- break;
- String name = namebuf.toString();
- String value = valuebuf.toString();
- if (name.equalsIgnoreCase(Constants.HEADER_CONTENT_LENGTH))
- respContentLength = Integer.parseInt(value);
- else if (name.equalsIgnoreCase(Constants.HEADER_CONTENT_TYPE))
- respContentType = value;
- else
- respHeaders.put(name, value);
- namebuf = new StringBuffer();
- valuebuf = new StringBuffer();
- parsingName = true;
- }
- else if (bytes[offset] != '\r') {
- if (parsingName) {
- if (bytes[offset] == ':') {
- parsingName = false;
- offset++;
- }
- else
- namebuf.append((char)bytes[offset]);
- }
- else
- valuebuf.append((char)bytes[offset]);
- }
- }
- InputStream is = ds.getInputStream();
- is.skip(offset + 1);
-
- /* Construct the response object. */
- SOAPContext ctx;
- TransportMessage response;
- try {
- // Create response SOAPContext.
- ctx = new SOAPContext();
- // Read content.
- response = new TransportMessage(is, respContentLength,
- respContentType, ctx);
- // Extract envelope and SOAPContext
- response.read();
- // Associate SOAPContext with current thread.
- ctx.setSOAPContext();
- } catch (MessagingException me) {
- throw new IllegalArgumentException("Error parsing response: " + me);
- }
-
- /* All done here! */
- return response;
- }
-}
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "SOAP" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 2000, International
+ * Business Machines, Inc., http://www.apache.org. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+package org.apache.soap.util.net;
+
+import java.net.*;
+import java.io.*;
+import java.util.*;
+
+import org.apache.soap.*;
+import org.apache.soap.rpc.*;
+import org.apache.soap.transport.*;
+import org.apache.soap.util.mime.*;
+import javax.mail.*;
+import javax.mail.internet.*;
+import javax.activation.*;
+import java.lang.reflect.*;
+
+/**
+ * A bunch of utility stuff for doing HTTP things.
+ * <p>
+ * 2000/07/30 W. Cloetens added Multipart Mime support
+ *
+ * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
+ * @author Matthew J. Duftler (duftler@us.ibm.com)
+ * @author Wouter Cloetens (wcloeten@raleigh.ibm.com)
+ */
+public class HTTPUtils {
+ private static final String HTTP_VERSION = "1.0";
+ private static final int HTTP_DEFAULT_PORT = 80;
+ private static final int HTTPS_DEFAULT_PORT = 443;
+
+ /** This method either creates a socket or calls SSLUtils to
+ create an SSLSocket. It uses reflection to avoid a compile time
+ dependency on SSL.
+ @author Chris Nelson
+ */
+
+ private static Socket buildSocket(URL url,
+ String httpProxyHost, int httpProxyPort)
+ throws IOException, UnknownHostException
+ {
+ Socket s = null;
+ String host = null;
+
+ int port = 0;
+
+ if (httpProxyHost == null) {
+ host = url.getHost ();
+ port = url.getPort();
+ } else {
+ host = httpProxyHost;
+ port = httpProxyPort;
+ }
+
+ if (url.getProtocol().equalsIgnoreCase("HTTPS"))
+ {
+ if (port < 0)
+ {
+ port = HTTPS_DEFAULT_PORT;
+ }
+ try
+ {
+ // Using reflection to avoid compile time dependencies
+ Class SSLUtilsClass =
+ Class.forName("org.apache.soap.util.net.SSLUtils");
+ Class[] paramTypes = new Class[] {String.class, int.class};
+ Method buildSSLSocket = SSLUtilsClass.getMethod(
+ "buildSSLSocket", paramTypes);
+ Object[] params = new Object[] {host, new Integer(port)};
+ s = (Socket)buildSSLSocket.invoke(null, params);
+ }
+ catch (Exception e) {e.printStackTrace();}
+ }
+ else
+ {
+ if (port < 0) // No port given..use HTTP default which is pry 80 :-)
+ port = HTTP_DEFAULT_PORT;
+ s = new Socket (host, port);
+ }
+
+ return s;
+ }
+
+ /**
+ * POST something to the given URL. The headers are put in as
+ * HTTP headers, the content length is calculated and the content
+ * byte array is sent as the POST content.
+ *
+ * @param url the url to post to
+ * @param request the message
+ * @param timeout the timeout, in ms, to wait for connection establishment
+ * @param httpProxyHost the HTTP proxy host or null if no proxy.
+ * @param httpProxyPort the HTTP proxy port, if the proxy host is not null
+ */
+ public static TransportMessage post(URL url, TransportMessage request,
+ int timeout,
+ String httpProxyHost, int httpProxyPort)
+ throws IllegalArgumentException, IOException, SOAPException {
+ /* Open the connection */
+ PrintWriter out = null;
+ OutputStream outStream = null;
+ InputStream inStream = null;
+ BufferedReader in = null;
+ int port;
+ try {
+ port = url.getPort ();
+
+ Socket s = buildSocket(url, httpProxyHost, httpProxyPort);
+
+ if (port < 0) // No port given..use HTTP default which is pry 80 :-)
+ port = HTTP_DEFAULT_PORT;
+
+
+ if (timeout > 0) // Should be redundant but not every JVM likes this
+ s.setSoTimeout(timeout);
+
+ outStream = s.getOutputStream ();
+ out = new PrintWriter (outStream);
+ inStream = s.getInputStream ();
+ }
+ catch (Exception e) {
+ throw new IllegalArgumentException("Error opening socket: " +
+ e.getMessage ());
+ }
+
+ /* Send the request. */
+ out.print(Constants.HEADER_POST + " " +
+ (httpProxyHost == null ? url.getFile() : url.toString()) +
+ " HTTP/" + HTTP_VERSION + "\r\n");
+ out.print(Constants.HEADER_HOST + ": " + url.getHost() + ':' +
+ port + "\r\n");
+ out.print(Constants.HEADER_CONTENT_TYPE + ": " +
+ request.getContentType() + "\r\n");
+ out.print(Constants.HEADER_CONTENT_LENGTH + ": " +
+ request.getContentLength() + "\r\n");
+ for (Enumeration e = request.getHeaderNames(); e.hasMoreElements(); ) {
+ Object key = e.nextElement();
+ out.print(key + ": " + request.getHeader((String)key) + "\r\n");
+ }
+ out.print("\r\n");
+ out.flush();
+ request.writeTo(outStream);
+ out.print("\r\n\r\n");
+ out.flush();
+
+ /* Read the response status line. */
+ int statusCode = 0;
+ String statusString = null;
+ StringBuffer linebuf = new StringBuffer();
+ int b = 0;
+ while (b != '\n' && b != -1) {
+ b = inStream.read();
+ if (b != '\n' && b != '\r' && b != -1)
+ linebuf.append((char)b);
+ }
+ String line = linebuf.toString();
+ try {
+ StringTokenizer st = new StringTokenizer(line);
+ st.nextToken(); // ignore version part
+ statusCode = Integer.parseInt (st.nextToken());
+ StringBuffer sb = new StringBuffer();
+ while (st.hasMoreTokens()) {
+ sb.append (st.nextToken());
+ if (st.hasMoreTokens()) {
+ sb.append(" ");
+ }
+ }
+ statusString = sb.toString();
+ }
+ catch (Exception e) {
+ throw new IllegalArgumentException("Error parsing HTTP status line: " +
+ e.getMessage());
+ }
+
+ /* Read the entire response (following the status line)
+ * into a byte array. */
+ ByteArrayDataSource ds = new ByteArrayDataSource(inStream,
+ Constants.HEADERVAL_DEFAULT_CHARSET);
+
+ /* Extract the headers, content type and content length. */
+ byte[] bytes = ds.toByteArray();
+ Hashtable respHeaders = new Hashtable();
+ int respContentLength = -1;
+ String respContentType = null;
+ StringBuffer namebuf = new StringBuffer();
+ StringBuffer valuebuf = new StringBuffer();
+ boolean parsingName = true;
+ int offset;
+ for (offset = 0; offset < bytes.length; offset++) {
+ if (bytes[offset] == '\n') {
+ if (namebuf.length() == 0)
+ break;
+ String name = namebuf.toString();
+ String value = valuebuf.toString();
+ if (name.equalsIgnoreCase(Constants.HEADER_CONTENT_LENGTH))
+ respContentLength = Integer.parseInt(value);
+ else if (name.equalsIgnoreCase(Constants.HEADER_CONTENT_TYPE))
+ respContentType = value;
+ else
+ respHeaders.put(name, value);
+ namebuf = new StringBuffer();
+ valuebuf = new StringBuffer();
+ parsingName = true;
+ }
+ else if (bytes[offset] != '\r') {
+ if (parsingName) {
+ if (bytes[offset] == ':') {
+ parsingName = false;
+ offset++;
+ }
+ else
+ namebuf.append((char)bytes[offset]);
+ }
+ else
+ valuebuf.append((char)bytes[offset]);
+ }
+ }
+ InputStream is = ds.getInputStream();
+ is.skip(offset + 1);
+
+ /* Construct the response object. */
+ SOAPContext ctx;
+ TransportMessage response;
+ try {
+ // Create response SOAPContext.
+ ctx = new SOAPContext();
+ // Read content.
+ response = new TransportMessage(is, respContentLength,
+ respContentType, ctx);
+ // Extract envelope and SOAPContext
+ response.read();
+ // Associate SOAPContext with current thread.
+ ctx.setSOAPContext();
+ } catch (MessagingException me) {
+ throw new IllegalArgumentException("Error parsing response: " + me);
+ }
+
+ /* All done here! */
+ return response;
+ }
+}
1.2 +103 -103 xml-soap/java/src/org/apache/soap/util/net/SSLUtils.java
Index: SSLUtils.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/util/net/SSLUtils.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SSLUtils.java 2000/12/11 16:31:17 1.1
+++ SSLUtils.java 2000/12/11 18:51:13 1.2
@@ -1,103 +1,103 @@
-/*
- * The Apache Software License, Version 1.1
- *
- *
- * Copyright (c) 2000 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "SOAP" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation and was
- * originally based on software copyright (c) 2000, International
- * Business Machines, Inc., http://www.apache.org. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-package org.apache.soap.util.net;
-
-import java.net.*;
-import java.io.*;
-import java.util.*;
-import javax.net.ssl.*;
-import java.security.*;
-
-/**
- * A bunch of utility stuff for doing SSL things.
- *
- * @author Chris Nelson (cnelson@synchrony.net)
- */
-public class SSLUtils {
-
- /** This method builds an SSL socket, after auto-starting SSL */
- public static Socket buildSSLSocket(String host, int port)
- throws IOException, UnknownHostException
- {
-
- Security.addProvider(
- new com.sun.net.ssl.internal.ssl.Provider());
-
-
- SSLSocketFactory factory =
- (SSLSocketFactory)SSLSocketFactory.getDefault();
- SSLSocket sslSocket =
- (SSLSocket)factory.createSocket(host, port);
-
- /*
- * Handshaking is started manually in this example because
- * PrintWriter catches all IOExceptions (including
- * SSLExceptions), sets an internal error flag, and then
- * returns without rethrowing the exception.
- *
- * Unfortunately, this means any error messages are lost,
- * which caused lots of confusion for others using this
- * code. The only way to tell there was an error is to call
- * PrintWriter.checkError().
- */
- sslSocket.startHandshake();
-
- return sslSocket;
-
- }
-}
\ No newline at end of file
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "SOAP" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 2000, International
+ * Business Machines, Inc., http://www.apache.org. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+package org.apache.soap.util.net;
+
+import java.net.*;
+import java.io.*;
+import java.util.*;
+import javax.net.ssl.*;
+import java.security.*;
+
+/**
+ * A bunch of utility stuff for doing SSL things.
+ *
+ * @author Chris Nelson (cnelson@synchrony.net)
+ */
+public class SSLUtils {
+
+ /** This method builds an SSL socket, after auto-starting SSL */
+ public static Socket buildSSLSocket(String host, int port)
+ throws IOException, UnknownHostException
+ {
+
+ Security.addProvider(
+ new com.sun.net.ssl.internal.ssl.Provider());
+
+
+ SSLSocketFactory factory =
+ (SSLSocketFactory)SSLSocketFactory.getDefault();
+ SSLSocket sslSocket =
+ (SSLSocket)factory.createSocket(host, port);
+
+ /*
+ * Handshaking is started manually in this example because
+ * PrintWriter catches all IOExceptions (including
+ * SSLExceptions), sets an internal error flag, and then
+ * returns without rethrowing the exception.
+ *
+ * Unfortunately, this means any error messages are lost,
+ * which caused lots of confusion for others using this
+ * code. The only way to tell there was an error is to call
+ * PrintWriter.checkError().
+ */
+ sslSocket.startHandshake();
+
+ return sslSocket;
+
+ }
+}