|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2004 IBM Corporation and others. |
2 |
* Copyright (c) 2004, 2006 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 12-17
Link Here
|
| 12 |
* 20060131 125777 jesper@selskabet.org - Jesper S Moller |
12 |
* 20060131 125777 jesper@selskabet.org - Jesper S Moller |
| 13 |
* 20060222 118019 andyzhai@ca.ibm.com - Andy Zhai |
13 |
* 20060222 118019 andyzhai@ca.ibm.com - Andy Zhai |
| 14 |
* 20060222 128564 jesper@selskabet.org - Jesper S Moller |
14 |
* 20060222 128564 jesper@selskabet.org - Jesper S Moller |
|
|
15 |
* 20060823 99034 makandre@ca.ibm.com - Andrew Mak, WSE support for basic-authenticating firewalls |
| 15 |
*******************************************************************************/ |
16 |
*******************************************************************************/ |
| 16 |
package org.eclipse.wst.ws.internal.explorer.platform.wsdl.transport; |
17 |
package org.eclipse.wst.ws.internal.explorer.platform.wsdl.transport; |
| 17 |
|
18 |
|
|
Lines 44-49
Link Here
|
| 44 |
private final String SYS_PROP_HTTP_NON_PROXY_HOSTS = "http.nonProxyHosts"; |
45 |
private final String SYS_PROP_HTTP_NON_PROXY_HOSTS = "http.nonProxyHosts"; |
| 45 |
|
46 |
|
| 46 |
private final String HTTP_METHOD = "POST"; |
47 |
private final String HTTP_METHOD = "POST"; |
|
|
48 |
private final String HTTP_CONNECT = "CONNECT"; |
| 49 |
private final String HTTP_VERSION_1_0 = "HTTP/1.0"; |
| 47 |
private final String HTTP_VERSION = "HTTP/1.1"; |
50 |
private final String HTTP_VERSION = "HTTP/1.1"; |
| 48 |
private final String HTTP_HEADER_SOAP_ACTION = "SOAPAction"; |
51 |
private final String HTTP_HEADER_SOAP_ACTION = "SOAPAction"; |
| 49 |
public static final String HTTP_HEADER_AUTH = "Authorization"; |
52 |
public static final String HTTP_HEADER_AUTH = "Authorization"; |
|
Lines 62-68
Link Here
|
| 62 |
private final String HTTP_HEADER_CONNECTION = "Connection"; |
65 |
private final String HTTP_HEADER_CONNECTION = "Connection"; |
| 63 |
|
66 |
|
| 64 |
private final int HTTP_CODE_CONTINUE = 100; |
67 |
private final int HTTP_CODE_CONTINUE = 100; |
| 65 |
//private final int HTTP_CODE_OK = 200; |
68 |
private final int HTTP_CODE_OK = 200; |
| 66 |
private final int HTTP_CODE_EXCEPTION = 300; |
69 |
private final int HTTP_CODE_EXCEPTION = 300; |
| 67 |
|
70 |
|
| 68 |
private final String IBM_WEB_SERVICES_EXPLORER = "IBM Web Services Explorer"; |
71 |
private final String IBM_WEB_SERVICES_EXPLORER = "IBM Web Services Explorer"; |
|
Lines 472-477
Link Here
|
| 472 |
return headers; |
475 |
return headers; |
| 473 |
} |
476 |
} |
| 474 |
|
477 |
|
|
|
478 |
/** |
| 479 |
* Builds the first line of a connection request to the proxy server |
| 480 |
* |
| 481 |
* @param url The URL that we want to ultimately connect to. |
| 482 |
* @return A string of the form "CONNECT <hostname>:<port> HTTP/1.0". |
| 483 |
*/ |
| 484 |
private StringBuffer getConnectMethod(URL url) { |
| 485 |
|
| 486 |
StringBuffer sb = new StringBuffer(HTTP_CONNECT); |
| 487 |
sb.append(SPACE); |
| 488 |
sb.append(url.getHost()); |
| 489 |
sb.append(COLON); |
| 490 |
sb.append(url.getPort()); |
| 491 |
sb.append(SPACE); |
| 492 |
sb.append(HTTP_VERSION_1_0); |
| 493 |
sb.append(NEW_LINE); |
| 494 |
return sb; |
| 495 |
} |
| 496 |
|
| 497 |
/** |
| 498 |
* Construct a socket to the proxy server which be used to tunnel through. |
| 499 |
* |
| 500 |
* @param url The URL that we want to ultimately connect to. |
| 501 |
* @param proxyHost The proxy host. |
| 502 |
* @param proxyPort The proxy port. |
| 503 |
* @return A connected socket to the proxy server. |
| 504 |
* @throws IOException |
| 505 |
*/ |
| 506 |
private Socket buildTunnelSocket(URL url, String proxyHost, int proxyPort) throws IOException { |
| 507 |
|
| 508 |
StringBuffer httpHeader = new StringBuffer(); |
| 509 |
httpHeader.append(getConnectMethod(url)); |
| 510 |
httpHeader.append(getProxyAuthentication()); |
| 511 |
httpHeader.append(NEW_LINE); |
| 512 |
|
| 513 |
Socket tunnel = new Socket(proxyHost, proxyPort); |
| 514 |
|
| 515 |
InputStream is = tunnel.getInputStream(); |
| 516 |
OutputStream os = tunnel.getOutputStream(); |
| 517 |
|
| 518 |
os.write(httpHeader.toString().getBytes(DEFAULT_HTTP_HEADER_ENCODING)); |
| 519 |
os.flush(); |
| 520 |
|
| 521 |
HTTPResponse httpResponse = new HTTPResponse(); |
| 522 |
readHTTPResponseHeader(is, httpResponse); |
| 523 |
|
| 524 |
int code = httpResponse.getStatusCode(); |
| 525 |
|
| 526 |
// ensure we are successfully connected to the proxy |
| 527 |
if (code != HTTP_CODE_OK) |
| 528 |
throw new HTTPException(code, httpResponse.getStatusMessage(), httpResponse.getHeaders()); |
| 529 |
|
| 530 |
return tunnel; |
| 531 |
} |
| 532 |
|
| 475 |
private Socket buildSocket(URL url) throws UnknownHostException, IOException |
533 |
private Socket buildSocket(URL url) throws UnknownHostException, IOException |
| 476 |
{ |
534 |
{ |
| 477 |
Socket s = null; |
535 |
Socket s = null; |
|
Lines 492-499
Link Here
|
| 492 |
|
550 |
|
| 493 |
if (proxyHost != null && proxyHost.length() > 0 && !isHostInNonProxyHosts(host, nonProxyHosts, DEFAULT_CASE_SENSITIVE_FOR_HOST_NAME)) |
551 |
if (proxyHost != null && proxyHost.length() > 0 && !isHostInNonProxyHosts(host, nonProxyHosts, DEFAULT_CASE_SENSITIVE_FOR_HOST_NAME)) |
| 494 |
{ |
552 |
{ |
| 495 |
// TODO: |
|
|
| 496 |
// SSL with proxy server |
553 |
// SSL with proxy server |
|
|
554 |
Socket tunnel = buildTunnelSocket(url, proxyHost, proxyPort); |
| 555 |
s = ((SSLSocketFactory) SSLSocketFactory.getDefault()).createSocket(tunnel, host, port, true); |
| 497 |
} |
556 |
} |
| 498 |
else |
557 |
else |
| 499 |
s = SSLSocketFactory.getDefault().createSocket(host, (port > 0 ? port : DEFAULT_HTTPS_PORT)); |
558 |
s = SSLSocketFactory.getDefault().createSocket(host, (port > 0 ? port : DEFAULT_HTTPS_PORT)); |