Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 92286 Details for
Bug 208110
Generic Recorder Wizard enhancement to filter the list of recorders
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch (part 2)
Bugzilla_208110_patch_part_2.txt (text/plain), 246.49 KB, created by
Paul Slauenwhite
on 2008-03-12 06:48:29 EDT
(
hide
)
Description:
Patch (part 2)
Filename:
MIME Type:
Creator:
Paul Slauenwhite
Created:
2008-03-12 06:48:29 EDT
Size:
246.49 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.hyades.test.tools.core >Index: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/ConnectionObj.java >=================================================================== >RCS file: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/ConnectionObj.java >diff -N src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/ConnectionObj.java >--- src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/ConnectionObj.java 2 May 2007 19:36:27 -0000 1.5 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,35 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: ConnectionObj.java,v 1.5 2007/05/02 19:36:27 paules Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >-package org.eclipse.hyades.execution.recorder.http.remote; >- >-/** >- * This simple class is used to hold connection numbers. >- * >- * @author mdunn >- * @deprecated This is not public API. It will be moved to internal in TPTP 5 >- * >- */ >-public final class ConnectionObj >-{ >- private int connectionNumber = 0; >- >- int getConnectionNumber(){ >- >- return connectionNumber; >- } >- // method provided for convenience only if it is ever needed >- void setConnectionNumber(int thisConnectionNumber){ >- connectionNumber = thisConnectionNumber; >- } >- >- >-} >Index: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/PeekServerSocket.java >=================================================================== >RCS file: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/PeekServerSocket.java >diff -N src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/PeekServerSocket.java >--- src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/PeekServerSocket.java 9 Jun 2005 21:15:29 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,130 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: PeekServerSocket.java,v 1.3 2005/06/09 21:15:29 mddunn Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >-package org.eclipse.hyades.execution.recorder.http.remote; >- >-import java.io.IOException; >-import java.net.InetAddress; >-import java.net.ServerSocket; >-import java.net.Socket; >- >- >-/** >- * Function: Custom server socket that can accept >- * Sockets of type PeekSocket. >- * @author ptasnik@us.ibm.com >- * @deprecated This is not public API. It will be moved to internal in TPTP 5 >- * >- */ >-public class PeekServerSocket extends ServerSocket { >- >- /** >- * @throws java.io.IOException >- */ >- public PeekServerSocket() throws IOException { >- super(); >- } >- >- /** >- * @param port >- * @throws java.io.IOException >- */ >- public PeekServerSocket(int port) throws IOException { >- super(port); >- } >- >- /** >- * @param port >- * @param backlog >- * @throws java.io.IOException >- */ >- public PeekServerSocket(int port, int backlog) throws IOException { >- super(port, backlog); >- } >- >- /** >- * @param port >- * @param backlog >- * @param bindAddr >- * @throws java.io.IOException >- */ >- public PeekServerSocket(int port, int backlog, InetAddress bindAddr) >- throws IOException { >- super(port, backlog, bindAddr); >- } >- >- >- /** >- * Override server socket accept to return >- * a empty PeekSocket. implAccept() does >- * all the work to make it connected to >- * the client socket. >- */ >- >- public PeekSocket acceptPeekSocket() throws IOException { >- PeekSocket s = new PeekSocket(); >- implAccept(s); >- return s; >- } >- >- >- public static void main(String[] args) { >- try { >- PeekServerSocket server_sock = new PeekServerSocket (4444); >- PeekSocket client_sock; >- Thread myThread = new Thread (server_sock.new TestPeekServerSocket()); >- myThread.start (); >- >- while (true) { >- System.out.println ("Server - waiting to accept ..."); >- client_sock = server_sock.acceptPeekSocket(); >- System.out.println ("Server - accepted"); >- >- int peek_int = client_sock.peek(); >- System.out.println ("Server - peek_int=" + String.valueOf(peek_int)); >- int peek_read = client_sock.getInputStream().read(); >- System.out.println ("Server - peek_read=" + String.valueOf(peek_read)); >- peek_read = client_sock.getInputStream().read(); >- System.out.println ("Server - peek_read=" + String.valueOf(peek_read)); >- >- client_sock.close(); >- } >- >- } catch (Exception e) { >- e.printStackTrace (); >- } >- } >- >- private class TestPeekServerSocket implements Runnable { >- >- public void run () { >- byte data[] = new byte [20]; >- data[0] = 'h'; >- data[1] = 'e'; >- >- while (true) { >- try { >- System.out.println ("Client - sleeping"); >- Thread.sleep(5000); // wait for server >- >- System.out.println ("Client - going to connect"); >- Socket s = new Socket ("localhost", 4444); >- s.getOutputStream().write(data, 0, 2); >- System.out.println ("Client - wrote bytes"); >- >- } catch (Exception e) { >- e.printStackTrace (); >- } >- } >- } >- } >-} >- >Index: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/RecorderX509TrustManager.java >=================================================================== >RCS file: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/RecorderX509TrustManager.java >diff -N src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/RecorderX509TrustManager.java >--- src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/RecorderX509TrustManager.java 7 Mar 2008 15:06:25 -0000 1.7 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,50 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: RecorderX509TrustManager.java,v 1.7 2008/03/07 15:06:25 paules Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >-package org.eclipse.hyades.execution.recorder.http.remote; >- >-import java.security.cert.X509Certificate; >- >-import javax.net.ssl.X509TrustManager; >- >-/** >- * This object is used to create the SSL trust manager. >- * for the URL Recorder. >- * >- * @author mdunn >- * @deprecated This is not public API. It will be moved to internal in TPTP 5 >- * >- * >- */ >- >-class RecorderX509TrustManager implements X509TrustManager { >- >- >- RecorderX509TrustManager() { >- } >- >- public void checkClientTrusted(X509Certificate[] chain, String authType){ >- >- return; >- } >- >- public void checkServerTrusted(X509Certificate[] chain, String authType){ >- >- return; >- } >- >- public X509Certificate[] getAcceptedIssuers() { >- return null; >- } >- >-} >- >- >Index: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/ClientSideReaderSOCKS.java >=================================================================== >RCS file: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/ClientSideReaderSOCKS.java >diff -N src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/ClientSideReaderSOCKS.java >--- src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/ClientSideReaderSOCKS.java 10 Dec 2007 03:03:15 -0000 1.16 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,1050 +0,0 @@ >-/*``````````````````````````````````````````````````````````````/********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: ClientSideReaderSOCKS.java,v 1.16 2007/12/10 03:03:15 dmorris Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >- >-/* >- * NONE OF THE QUOTED STRINGS IN THIS FILE ARE TO BE LOCALIZED >- * THEY ARE ALL FOR XML TAGS, DEBUGGING SUPPORT, THEY ARE NOT FOR USER INTERFACES >- */ >-package org.eclipse.hyades.execution.recorder.http.remote; >- >-import java.io.IOException; >-import java.io.InputStream; >-import java.net.InetAddress; >-import java.net.InetSocketAddress; >-import java.net.UnknownHostException; >- >-/** >- * This class extends the ClientSideReader object. This handles the traffic from the >- * browser when the browser 'talks' SOCKS protocol. >- * >- * @author dmorris >- * modified by: mddunn 11/17/2003 for Hyades-O 1.2 >- * @deprecated This is not public API. It will be moved to internal in TPTP 5 >- * >- */ >-public class ClientSideReaderSOCKS extends ClientSideReader { >- >- public static final String ERROR_SSL_REQUEST_MADE = "-1"; //this is an error until SSL is supported >- public static final String ERROR_NO_TESTKEYS = "-2"; //this is an error until SSL is supported >- static final String STR_KEEP_ALIVE = "Proxy-Connection: Keep-Alive\r\n"; >- static final String ClientSideReaderException = HttpRecResourceBundle.RECORDER_CLIENTSIDE_READER_EXCEPTION; >- static boolean didSocks5Handshake = false; >- // SOCKS5 header maximum = 1 (version) + 1 (number of methods (1-255) + 255 (possible number of methods) >- int MAX_LEN_SOCKS5_REQUEST = 257; >- int proxyRecorderPort = 0; >- // Socks 5 Method Selected >- int socks5MethodSelected = 0; >- byte[] thisReadBuffer = null; >- final int NO_METHOD = -1; >- public String socks5DestinationInetAddrStr = null; >- public int socks5DestPort = 0; >- public int socks5AddressType = 0; >- byte [] destinationInetAddress = null; >- public static final int ADDRESS_TYPE_V4 = 1; >- public static final int ADDRESS_TYPE_V6 = 4; >- public static final int ADDRESS_TYPE_DOMAINNAME = 3; >- public static final int NO_AUTHENTICATION_REQUIRED = 0; >- public static final int NUM_BYTES_V4_ADDR = 4; >- public static final int NUM_BYTES_V6_ADDR = 16; >- public static final int NUM_BYTES_DESTINATION_PORT = 2; >- >- ClientSideReaderSOCKS(PeekSocket client, PacketWriter packetWriter, String keyFile, int iProxyRecorderPort){ >- super(client,packetWriter, keyFile); >- proxyRecorderPort = iProxyRecorderPort; >- >- } >- >- public void run(){ >- >- int bytes_read = 0; >- boolean socks_OK = false; >- boolean wroteOnePacket = false; >- // Unexpected message >- >- if (isSSLClassAvailable == -1) { >- isSSLClassAvailable = findSSLClass(); >- if (isSSLClassAvailable == 1) { >- foundTestKeys = checkForTestKeys(); >- } >- } >- this.setName("ClientSideReaderSOCKS-"+"Conn:"+ iConnection); >- try{ >- >- byte[] buffer = new byte[client.getReceiveBufferSize()]; >- //packetWriter.writeRecorderMessage(1, "IN RUN() getReceiveBufferSize is: " + bsize ); >- socks_OK = processSocksRequest(); >- if (socks_OK) { >- //packetWriter.writeRecorderMessage(1, "IN RUN() just got Back from ProcessSocksRequest() for connection: " + iConnection); >- // check for SSL Connection first before read >- bSecure = checkSSLByte(); >- if (bSecure) { >- if (isSSLClassAvailable == 1) { >- if (foundTestKeys) { >- SSLCheckClass thisSSLCheck = new SSLCheckClass(this, keyFile); >- thisSSLCheck.makeSecureConnection(); >- if (httpServer != null) { >- //packetWriter.writeRecorderMessage(1, "IN RUN() just got NEW SSL SOCKET for connection: " + iConnection); >- //respondToClient(true); >- } >- else { >- //respondToClient(false); >- // must throw exception >- packetWriter.writeRecorderMessage(1, "Error connecting to SSL Server:" + destServer + " Port: "+serverPort); >- packetWriter.getAgentController().sendControlMessageToDataProcessor(ERROR_SSL_REQUEST_MADE); >- return; >- } >- } >- else { >- // send message to UI >- packetWriter.getAgentController().sendControlMessageToDataProcessor(ERROR_NO_TESTKEYS); >- //respondToClient(false); >- return; >- } >- } >- else { >- // send message to UI >- packetWriter.getAgentController().sendControlMessageToDataProcessor(ERROR_SSL_REQUEST_MADE); >- respondToClient(false); >- return; >- } >- } >- else { >- //packetWriter.writeRecorderMessage(1, "IN RUN() newAddr is: " + newAddr + " destPort is: " + destPort + " for connection: " + iConnection); >- // This next line ensures we get a "plain" socket which does not do Reverse DNS LookUp >- httpServer = createPlainSocket(); >- InetSocketAddress epoint = new InetSocketAddress(newAddr, destPort); >- httpServer.connect(epoint); >- >- if (httpServer != null) { >- makeRegularConnection(); >- //packetWriter.writeRecorderMessage(1, "IN RUN() AFTER MakeRegularConnection, strReturn is: " + strReturn + " for connection: " + iConnection); >- //packetWriter.writeRecorderMessage(1, "IN RUN() just got NEW SOCKET for connection: " + iConnection); >- //respondToClient(true); >- } >- else { >- //respondToClient(false); >- //packetWriter.getAgentController().sendControlMessageToDataProcessor(ERROR_REQUEST_MADE); >- packetWriter.writeRecorderMessage(1, "Error connecting to Server:" + destServer + " Port: "+serverPort); >- return; >- } >- } >- >- while ((bytes_read = from_client.read(buffer)) != -1){ >- yield(); >- bNoPrintToServer = false; >- wroteOnePacket = true; >- // bugzilla 137958 simplified the code by always using a byte array for communication buffer >- // Defect 83619 mdd synch for write to socket and write to file >- >- /* if (!bNoPrintToServer){ >- to_server.write(buffer, 0, bytes_read); >- to_server.flush(); >- }*/ >- packetWriter.writePacket(bSecure, true, connectionNumber, buffer, bytes_read, to_server, bNoPrintToServer); >- >- >- } >- } else { >- //packetWriter.writeRecorderMessage(1, "IN RUN() SOCKS IS NOT OK for connection: " + iConnection); >- } >- >- //packetWriter.writeRecorderMessage(1, "IN RUN()Broke Out of Read Loop for connection: " + iConnection + " Bytes Read is: " + bytes_read); >- if (httpServer != null){ >- //if (! httpServer.isClosed()) >- // httpServer.close(); >- // new mdd >- httpServer.setSoLinger(true,0); >- if (!wroteOnePacket) { >- if (! httpServer.isClosed()) { >- //packetWriter.writeRecorderMessage(1, "IN CLIENTSIDEREADER A1 - CLOSED SERVERSIDE COnnection: " + iConnection); >- httpServer.close(); >- } >- else { >- //packetWriter.writeRecorderMessage(1, "IN CLIENTSIDEREADER A - httpServer IS Closed for COnnection: " + iConnection); >- } >- } >- else if (! httpServer.isOutputShutdown()){ >- if (bSecure) { >- //packetWriter.writeRecorderMessage(1, "IN CLIENTSIDEREADER A WRITING SSL CLOSE ALERT for COnnection: " + iConnection); >- to_server.flush(); >- httpServer.close(); >- >- } else { >- httpServer.shutdownOutput(); >- //packetWriter.writeRecorderMessage(1, "IN CLIENTSIDEREADER A - SHUTDOWN SERVERSIDE OUTPUT for COnnection: " + iConnection); >- } >- } >- else { >- //packetWriter.writeRecorderMessage(1, "IN CLIENTSIDEREADER A - NO PACKET and OUTPUT IS Shutdown for COnnection: " + iConnection); >- } >- // mdd tell Server reader we are closed >- // MAY NEED serverReader.setClosedByClient(); >- } >- else { >- //packetWriter.writeRecorderMessage(1, "IN CLIENTSIDEREADER A - httpServer WAS NULL for Connection: " + iConnection); >- } >- >- yield(); >- //packetWriter.writeCloseConnectionInfo(iConnection); >- >- } >- catch (Exception e) { >- >- //packetWriter.writeRecorderMessage(1, "JUST CAUGHT AN EXCEPTION In ClientSideReader connection " + iConnection + " Exception: " +e.getLocalizedMessage() ); >- >- try { >- if (httpServer != null) { >- //if (!httpServer.isClosed()) >- // httpServer.close(); >- if (!wroteOnePacket) { >- if (! httpServer.isClosed()) { >- //packetWriter.writeRecorderMessage(1, "IN CLIENTSIDEREADER B1 - CLOSED SERVERSIDE COnnection: " + iConnection); >- httpServer.close(); >- } >- else { >- //packetWriter.writeRecorderMessage(1, "IN CLIENTSIDEREADER B2 - !wroteOnePacket; httpServer IS CLOSED for COnnection: " + iConnection); >- } >- } else if (!httpServer.isOutputShutdown()&& !httpServer.isClosed()){ >- if (bSecure) { >- //packetWriter.writeRecorderMessage(1, "IN CLIENTSIDEREADER B WRITING SSL CLOSE ALERT for COnnection: " + iConnection); >- to_server.flush(); >- httpServer.close(); >- >- } else { >- httpServer.shutdownOutput(); >- //packetWriter.writeRecorderMessage(1, "IN CLIENTSIDEREADER B - SHUTDOWN SERVERSIDE OUTPUT for COnnection: " + iConnection); >- } >- } >- // mdd tell Server reader we are closed >- // add check for null 032204 >- //if (serverReader != null) >- // MAT NEED serverReader.setClosedByClient(); >- } >- else { >- //packetWriter.writeRecorderMessage(1, "IN CLIENTSIDEREADER B - httpServer IS NULL for COnnection: " + iConnection); >- } >- >- yield(); >- // force interrupt by nulling the buffer SSR is reading mdd >- //serverReader.interrupt(); >- //packetWriter.writeRecorderMessage(1, "IN CLIENTSIDEREADER NULL BUFFER FORCE INTERRUPT for COnnection: " + iConnection); >- //serverReader.ssrBuffer = null; >- >- } >- catch (IOException ioe){ >- String mess = ioe.getMessage(); >- // no record for the following exceptions, they are expected >- >- if (mess.indexOf("Stream closed") < 0 && mess.indexOf("Socket closed") < 0 && >- mess.indexOf("JVM_recv in socket input") <0 && mess.indexOf("onnection closed")<0 >- && mess.indexOf("socket closed")<0 && mess.indexOf("onnection reset") < 0 >- && mess.indexOf("Socket is closed") <0) { >- packetWriter.writeRecorderMessage(2, "IOException in ClientSideReader connection " + iConnection + " : " + e.toString()); >- } >- } >- } >- //packetWriter.writeRecorderMessage(1, "IN CLIENTSIDEREADER LEAVING RUN METHOD for COnnection: " + iConnection); >- } >- >- >-// private static synchronized void debugMsg (String msg) { >-// try { >-// FileOutputStream out = new FileOutputStream("c:\\test.out", true); >-// String outStr = msg + "\r\n"; >-// out.write (outStr.getBytes()); >-// } catch (Exception e) { >-// //temp >-// } >-// } >- >- /** >- * Attempts to read exactSize from the InputStream, no more, no less. If a short >- * read comes in block until exactSize is placed in the out buf. Will not read >- * more than exactSize from the stream. >- * >- * Assumptions, buf is large enough from exactSize, IndexOutOfRange would probably occur. >- * >- * @param in InputStream of bytes. >- * @param buf Output byte[] buffer >- * @param exactSize The exact number of bytes to read, -1 on EOF or exception. >- * @return exactSize if bytes are read, -1 all other times, say on EOF. >- * @throws IOException InputStream.read() exception. >- */ >- private static int readExactOrBust (InputStream in, byte[]buf, int exactSize) throws IOException { >- int offset = 0; >- do { >- int currentReadSize = in.read (buf, offset, (exactSize - offset)); >- //debugMsg (in.toString() + " " + String.valueOf(currentReadSize)); >- if (currentReadSize <= 0) { >- return -1; // read or bust >- } >- offset += currentReadSize; >- } while (offset < exactSize); >- >- if (offset != exactSize) { >- throw new RuntimeException ("Internal logic problem ClientSideReadSOCKS.readExactOrBust()"); //$NON-NLS-1$ >- } >- >- return offset; // should always be exactSize >- } >- >- /** >- * Skip all bytes including delimitor in the stream. This operation will block until delimitor >- * is seen or EOF, in which case -1 is returned. If delimitorByte is read, then the number of bytes >- * read is returned. >- * >- * @param in InputStream >- * @param delimitorByte Byte to read until(over). >- * @return Number of byts read or -1 on EOF, will block as described above. >- * @throws IOException Standard InputStream read() exceptions. >- */ >- private static int flushUntilByteOccurs (InputStream in, byte delimitorByte) throws IOException { >- int currentByteAsInt; >- int totalBytesRead = 0; >- do { >- currentByteAsInt = in.read (); >- if (currentByteAsInt <= 0) { >- return -1; // never saw delimitor >- } >- totalBytesRead += 1; >- } while (delimitorByte != ((byte)currentByteAsInt)); >- >- return totalBytesRead; >- } >- >- private boolean processSocksRequest() { >- boolean returnCode = false; >- int bytes_read = 0; >- >- int socksVersion = 0; >- String inetAddrStr = ""; >- byte newInetAddress[] = new byte[4]; >- boolean gotSocks5OK = false; >- >- // first read the entire socks header >- try { >- //packetWriter.writeRecorderMessage(1, "IN ProcessSocksRequest() for connection: " + iConnection); >- byte[] buffer = new byte[client.getReceiveBufferSize()]; >- socksVersion = client.peek(); >- if (socksVersion == 4) >- { >- bytes_read = ClientSideReaderSOCKS.readExactOrBust (from_client, buffer, 8); >- if (bytes_read < 8){ >- // we have an error, must have at least 8 bytes >- returnCode = false; >- } >- else { >- int i=0; >- // have socks header, now process it >- for (i = 0; i < 8; i++){ >- Byte tmpByte = new Byte(buffer[i]); >- switch(i){ >- case 0: >- socksVersion = tmpByte.intValue(); >- break; >- case 1: >- break; >- case 2: >- int tmp = 0; >- tmp = tmpByte.intValue(); >- if (tmp < 0) >- tmp = tmp+256; >- destPort = (tmp*256) ; >- break; >- case 3: >- int tmp2 = 0; >- tmp2 = tmpByte.intValue(); >- if (tmp2 < 0) >- tmp2 += 256; >- destPort += tmp2; >- break; >- case 4: >- case 5: >- case 6: >- case 7: >- newInetAddress[i-4] = buffer[i]; >- break; >- } >- } >- // Part of SOCKS4 protocol, read until '00', end of request >- if (ClientSideReaderSOCKS.flushUntilByteOccurs (from_client, (byte)0) == -1) { >- returnCode = false; >- } >- >- // now must connect to IP address >- inetAddrStr = IP4ByteToString(newInetAddress); >- packetWriter.writeRecorderMessage(1, "SOCKS 4 Connection"); >- //packetWriter.writeRecorderMessage(1, "IN ProcessSocksRequest() CALL getByName() for connection: " + iConnection); >- // bugzilla 137969 avoid unnecessary NS lookup in getByName()by using getByAddress() >- newAddr = InetAddress.getByAddress(newInetAddress); >- //packetWriter.writeRecorderMessage(1, "IN ProcessSocksRequest() return from getByName() for connection: " + iConnection); >- //destServer = newAddr.getHostName(); >- destServer = inetAddrStr; >- serverPort = destPort; >- returnCode = true; >- } >- respondToClient(returnCode); >- } >- else if (socksVersion == 5) { >- // first, get the connect request usually: 05 01 00 >- //packetWriter.writeRecorderMessage(1, "Read Socks5 Connect for" + " Connection: " + iConnection); >- gotSocks5OK = readSocks5ConnectRequest(buffer); >- if (gotSocks5OK) { >- //packetWriter.writeRecorderMessage(1, "Read Socks5 gotSocks5OK is TRUE" + " Connection: " + iConnection); >- respondToClientSocks5MethodSelection(gotSocks5OK); >- //handShakeWorked = doSocks5Handshake(buffer, bytes_read); >- didSocks5Handshake = true; >- //packetWriter.writeRecorderMessage(1, "Read Socks5 REGULAR REQUEST" + " Connection: " + iConnection); >- returnCode = readSocks5RegularRequest(buffer); >- >- if (returnCode == true){ >- //packetWriter.writeRecorderMessage(1, "Read Socks5 REGULAR REQUEST- TRUE" + " Connection: " + iConnection); >- } >- else { >- packetWriter.writeRecorderMessage(1, "Read Socks5 REGULAR REQUEST- FALSE" + " Connection: " + iConnection); >- } >- >- //returnCode = processRegularSocks5Request(buffer); >- respondToClientSocks5RegularRequest(returnCode); >- //packetWriter.writeRecorderMessage(1, "JUST Responded to Regular Request" + " Connection: " + iConnection); >- // now must connect to IP address >- //inetAddrStr = IP4ByteToString(newInetAddress); >- //newAddr = InetAddress.getByName(socks5DestinationInetAddrStr); >- newAddr = InetAddress.getByAddress(destinationInetAddress); >- destServer = socks5DestinationInetAddrStr; >- serverPort = socks5DestPort; >- destPort = serverPort; >- returnCode = true; >- } // got Socks5 connect request OK >- else { >- packetWriter.writeRecorderMessage(1, "Read Socks5 gotSocks5OK is FALSE" + " Connection: " + iConnection); >- } // got Socks5 connect request OK >- } // version is socks 5 >- else { // unknown socks version (not 4 or 5) >- returnCode = false; >- respondToClientSocks5MethodSelection(returnCode); >- } >- } >- catch (Exception e) { >- packetWriter.writeRecorderMessage(1, "Error Reading from Client" + " Connection: " + iConnection); >- >- try { >- client.close(); >- } >- catch (IOException ioe){ >- packetWriter.writeRecorderMessage(1, "Error closing Client" + ioe + " Connection: " + iConnection); >- } >- //packetWriter.writeCloseConnectionInfo(iConnection); >- } >- //packetWriter.writeRecorderMessage(1, "LEAVING ProcessSocksRequest() for connection: " + iConnection); >- return returnCode; >- } >- >- private boolean readSocks5ConnectRequest(byte[] inBuf){ >- //boolean returnCode = false; >- int bytes_read = -1; >- >- int selected_method = NO_METHOD; // -1 means not selected >- //doTest(buffer); >- // bytes_read = ClientSideReaderSOCKS.readEntireRequest (from_client, buffer, MAX_LEN_SOCKS5_REQUEST); >- >- byte[] version_buf = new byte[1]; >- byte[] nmeths_buf = new byte[1]; >- byte[] supported_auths = {00}; // add additional, perference left to right >- >- byte[] methods_buf; >- try { >- bytes_read = ClientSideReaderSOCKS.readExactOrBust(from_client, version_buf, 1); >- if (bytes_read <= 0) return false; >- >- bytes_read = ClientSideReaderSOCKS.readExactOrBust(from_client, nmeths_buf, 1); >- if (bytes_read <= 0) return false; >- >- int numMethods = (int)nmeths_buf[0]; >- if (numMethods < 0) numMethods += 256; // Java's byte->int assumes byte is signed >- >- methods_buf = new byte[numMethods]; >- bytes_read = ClientSideReaderSOCKS.readExactOrBust(from_client, methods_buf, numMethods); >- if (bytes_read <= 0) >- return false; >- >- // iterate through the authentication types >- >- for (int i = 0; selected_method == NO_METHOD && i < methods_buf.length; i++) { >- for (int j = 0; selected_method == NO_METHOD && j < supported_auths.length; j++) { >- if (methods_buf[i] == supported_auths[j]) { >- selected_method = supported_auths[j]; >- if (selected_method < 0) selected_method += 256; >- } >- } >- } >- if (selected_method == NO_METHOD) { >- return false; // don't support that junk >- } >- } catch (IOException e) { >- // TODO Auto-generated catch block >- e.printStackTrace(); >- } >- >- socks5MethodSelected = selected_method; >- return true; >- } >- private boolean readSocks5RegularRequest(byte[] buffer) { >- //int bufferLength = -1; >- // number of bytes until you get to the Destination Address >- int NUM_BYTES_DESTINATION_PORT = 2; >- int numberBytesAddress = 0; >- >- int bytes_read = -1; >- byte[] tmp_buf = new byte[1]; >- int totalBytesRead = 0; >- byte [] tmpReturnBuff = null; >- byte [] return_buf = null; >- //byte [] destinationInetAddress = null; >- byte [] destinationPortBytes = null; >- >- >- /*The SOCKS request is formed as follows: >- +----+-----+-------+------+----------+----------+ >- |VER | CMD | RSV | ATYP | DST.ADDR | DST.PORT | >- +----+-----+-------+------+----------+----------+ >- | 1 | 1 | X'00' | 1 | Variable | 2 | >- +----+-----+-------+------+----------+----------+ >- Where: >- >- VER protocol version: X'05' >- CMD >- CONNECT X'01' >- BIND X'02' >- UDP ASSOCIATE X'03' >- RSV RESERVED >- ATYP address type of following address >- IP V4 address: X'01' >- DOMAINNAME: X'03' >- IP V6 address: X'04' >- DST.ADDR desired destination address >- DST.PORT desired destination port in network octet >- order >- */ >- >- try { >- tmpReturnBuff = new byte[client.getReceiveBufferSize()]; >- >- // VERSION - BYTE 1 >- bytes_read = ClientSideReaderSOCKS.readExactOrBust(from_client, tmp_buf, 1); >- if (bytes_read <= 0) return false; >- //packetWriter.writeRecorderMessage(1, "IN ReadSocks5REGULARREQUEST - VERSION" + " for Connection: " + iConnection); >- tmpReturnBuff[totalBytesRead] = tmp_buf[0]; >- totalBytesRead += 1; >- // COMMAND - BYTE 2 >- bytes_read = ClientSideReaderSOCKS.readExactOrBust(from_client, tmp_buf, 1); >- if (bytes_read <= 0) return false; >- tmpReturnBuff[totalBytesRead] = tmp_buf[0]; >- totalBytesRead += 1; >- Byte tmpByte = new Byte(tmp_buf[0]); >- int tmp = 0; >- tmp = tmpByte.intValue(); >- // 1 is for CONNECT >- if (tmp != 1) return false; >- tmpByte = null; >- //packetWriter.writeRecorderMessage(1, "IN ReadSocks5REGULARREQUEST - COMMAND is CONNECT" + " for Connection: " + iConnection); >- >- // RESERVED - BYTE 3 >- bytes_read = ClientSideReaderSOCKS.readExactOrBust(from_client, tmp_buf, 1); >- if (bytes_read <= 0) return false; >- //packetWriter.writeRecorderMessage(1, "IN ReadSocks5REGULARREQUEST - RESERVED" + " for Connection: " + iConnection); >- tmpReturnBuff[totalBytesRead] = tmp_buf[0]; >- totalBytesRead += 1; >- // ADDRESSING TYPE - BYTE 4 >- // ATYP address type of following address >- // IP V4 address: X'01' >- // DOMAINNAME: X'03' >- // IP V6 address: X'04' >- int addressType = -1; >- bytes_read = ClientSideReaderSOCKS.readExactOrBust(from_client, tmp_buf, 1); >- if (bytes_read <= 0) return false; >- //packetWriter.writeRecorderMessage(1, "IN ReadSocks5REGULARREQUEST - ATYPE" + " for Connection: " + iConnection); >- tmpReturnBuff[totalBytesRead] = tmp_buf[0]; >- totalBytesRead += 1; >- tmpByte = new Byte(tmp_buf[0]); >- addressType = tmpByte.intValue(); >- socks5AddressType = addressType; >- if (addressType == ADDRESS_TYPE_V4 ){ >- //packetWriter.writeRecorderMessage(1, "IN ReadSocks5REGULARREQUEST - ATYPE is V4" + " for Connection: " + iConnection); >- numberBytesAddress = NUM_BYTES_V4_ADDR; >- destinationInetAddress = new byte[NUM_BYTES_V4_ADDR]; >- } >- else if (addressType == ADDRESS_TYPE_V6){ >- //packetWriter.writeRecorderMessage(1, "IN ReadSocks5REGULARREQUEST - ATYPE is V6" + " for Connection: " + iConnection); >- numberBytesAddress = NUM_BYTES_V6_ADDR; >- destinationInetAddress = new byte[NUM_BYTES_V6_ADDR]; >- } >- else { >- // not supported DOMAINNAME >- packetWriter.writeRecorderMessage(2, "IN ReadSocks5REGULARREQUEST - ATYPE is DOMAIN" + " for Connection: " + iConnection); >- return false; >- } >- bytes_read = ClientSideReaderSOCKS.readExactOrBust(from_client, destinationInetAddress, numberBytesAddress); >- if (bytes_read != numberBytesAddress) return false; >- for (int j = 0; j < bytes_read; j++, totalBytesRead++) { >- tmpReturnBuff[totalBytesRead]= destinationInetAddress[j]; >- } >- if (addressType == ADDRESS_TYPE_V4){ >- socks5DestinationInetAddrStr = IP4ByteToString(destinationInetAddress); >- //packetWriter.writeRecorderMessage(1, "socks 5, V4 address"); >- } >- else if (addressType == ADDRESS_TYPE_V6) { >- socks5DestinationInetAddrStr = IP6ByteToString(destinationInetAddress); >- //packetWriter.writeRecorderMessage(1, "socks 5, V6 address"); >- >- } >- //packetWriter.writeRecorderMessage(1, "IN ReadSocks5REGULARREQUEST - DESTINATION ADDRESS is: " + socks5DestinationInetAddrStr + " for Connection: " + iConnection); >- // DESTINATION PORT 2 bytes long >- destinationPortBytes = new byte[NUM_BYTES_DESTINATION_PORT]; >- bytes_read = ClientSideReaderSOCKS.readExactOrBust(from_client, destinationPortBytes, NUM_BYTES_DESTINATION_PORT); >- if (bytes_read != NUM_BYTES_DESTINATION_PORT) return false; >- for (int j = 0; j < bytes_read; j++, totalBytesRead++) { >- tmpReturnBuff[totalBytesRead]= destinationPortBytes[j]; >- } >- socks5DestPort = getDestinationPort(destinationPortBytes ); >- //packetWriter.writeRecorderMessage(1, "IN ReadSocks5REGULARREQUEST - DESTINATION PORT is: " + socks5DestPort + " for Connection: " + iConnection); >- } catch (IOException e) { >- // TODO Auto-generated catch block >- e.printStackTrace(); >- } >- >- return_buf = new byte[totalBytesRead]; >- for (int k = 0; k < totalBytesRead; k++){ >- return_buf[k] = tmpReturnBuff[k]; >- } >- return true; >- } >- >- private int getDestinationPort(byte[] destinationPortBytes) { >- // TODO Auto-generated method stub >- int myDestinationPort = 0; >- for (int j = 0; j < NUM_BYTES_DESTINATION_PORT ; j++){ >- Byte tmpByte = new Byte(destinationPortBytes[j]); >- switch (j) { >- case 0: >- int tmp = 0; >- tmp = tmpByte.intValue(); >- if (tmp < 0){ >- tmp = tmp+256; >- } >- myDestinationPort = (tmp*256); >- break; >- case 1: >- int tmp2 = 0; >- tmp2 = tmpByte.intValue(); >- if (tmp2 < 0) >- tmp2 += 256; >- myDestinationPort += tmp2; >- } >- } >- return myDestinationPort; >- } >- >- /** >- * This class responds to a SOCKS 5 regular request. >- * >- * The SOCKS request information is sent by the client as soon as it has >- * established a connection to the SOCKS server(the Recorder) , and completed the >- * authentication negotiations. The server evaluates the request, and >- * returns a reply formed as follows: >- * >- * VER REPLY RSV ATYPE BND.ADDR BND.PORT >- * 1 1 X'00 1 Variable 2 >- * >- * Where: >- * VER protocol version: X'05' >- * REP Reply field: >- * X'00' succeeded >- * X'01' general SOCKS server failure >- * X'02' connection not allowed by ruleset >- * X'03' Network unreachable >- * X'04' Host unreachable >- * X'05' Connection refused >- * X'06' TTL expired >- * X'07' Command not supported >- * X'08' Address type not supported >- * X'09' to X'FF' unassigned >- * RSV RESERVED >- * ATYP address type of following address >- * >- * IP V4 address: X'01' >- * DOMAINNAME: X'03' >- * IP V6 address: X'04' >- * BND.ADDR server bound address >- * BND.PORT server bound port in network octet order >- * >- * Fields marked RESERVED (RSV) must be set to X'00'. >- * >- * @param returnCode - The code to send to the client >- * >- * @author mdunn >- * @internal This is not public API. >- */ >- private void respondToClientSocks5RegularRequest(boolean returnCode) { >- >- byte[] reply_buffer = null; >- // reply size depends on addressing type >- int replySize = 0; >- int addressLen = 0; >- byte replyAddressType = 0; >- int i = 0; >- int replyIndx = 0; >- >- InetAddress lh = null; >- try { >- lh = InetAddress.getLocalHost(); >- } catch (UnknownHostException e) { >- // TODO Auto-generated catch block >- e.printStackTrace(); >- >- } >- //packetWriter.writeRecorderMessage(1, "IN ResondToClientSocks5RegularRequest for Connection: " + iConnection); >- byte[] localHostAddress = lh.getAddress(); >- //String tmpLocalhost = lh.toString(); >- //String localHostStr = getAddressFromLocalhost(tmpLocalhost); >- int thisPort = proxyRecorderPort; >- >- >- addressLen = localHostAddress.length; >- if (addressLen == NUM_BYTES_V4_ADDR){ >- replyAddressType = 1; >- } >- if (addressLen == NUM_BYTES_V6_ADDR){ >- replyAddressType = 4; >- } >- >- // reply will include: Version (1 byte) + Reply (1) + Reserved (1) + AddressType (1) >- // + Bind Address (variable from above) + Bnd.Port (2) == 6 + Bind.Address Length >- replySize = addressLen + 6; >- reply_buffer = new byte[replySize]; >- //packetWriter.writeRecorderMessage(1, "IN ResondToClientSocks5RegularRequest- replySize is: " + replySize + " for Connection: " + iConnection); >- >- reply_buffer[0] = 5; // Version >- reply_buffer[1] = 0; // Reply - successful = 0 >- reply_buffer[2] = 0; // Reserved - must be 0 >- reply_buffer[3] = replyAddressType; // address type >- for (i = 0, replyIndx = 4 ; i < localHostAddress.length && replyIndx < replySize; i++, replyIndx++){ >- reply_buffer[replyIndx]=localHostAddress[i]; >- } >- // convert integet thisPort to 2 bytes >- Uint16_Network(thisPort, reply_buffer, replyIndx); >- try { >- to_client.write(reply_buffer,0, replySize); >- to_client.flush(); >- } catch (Exception e){ >- packetWriter.writeRecorderMessage(1, "ERROR writing to Client in ResondToClientSocks5RegularRequest for Connection: " + iConnection); >- e.printStackTrace(); >- } >- >- >- } >-/* >- private void respondToClientSocks5RegularRequest(boolean returnCode) { >- >- byte[] reply_buffer = null; >- // reply size depends on addressing type >- int replySize = 0; >- int addressLen = 0; >- byte replyAddressType = 0; >- int i = 0; >- int replyIndx = 0; >- >- InetAddress lh = null; >- try { >- lh = InetAddress.getLocalHost(); >- } catch (UnknownHostException e) { >- // TODO Auto-generated catch block >- packetWriter.writeRecorderMessage(1, "ERROR in getLocalHost" + iConnection); >- e.printStackTrace(); >- >- } >- //packetWriter.writeRecorderMessage(1, "IN ResondToClientSocks5RegularRequest for Connection: " + iConnection); >- byte[] localHostAddress = lh.getAddress(); >- //String tmpLocalhost = lh.toString(); >- //String localHostStr = getAddressFromLocalhost(tmpLocalhost); >- int thisPort = proxyRecorderPort; >- >- //int thisAddressType = mySocks5Obj.getAddressType(); >- int thisAddressType = socks5AddressType; >- >- if (thisAddressType == ADDRESS_TYPE_V4) { >- addressLen = NUM_BYTES_V4_ADDR; >- replyAddressType = 1; >- } >- else if (thisAddressType == ADDRESS_TYPE_V6){ >- addressLen = NUM_BYTES_V6_ADDR; >- replyAddressType = 4; >- } >- // reply will include: Version (1 byte) + Reply (1) + Reserved (1) + AddressType (1) >- // + Bind Address (variable from above) + Bnd.Port (2) == 6 + Bind.Address Length >- replySize = addressLen + 6; >- reply_buffer = new byte[replySize]; >- //packetWriter.writeRecorderMessage(1, "IN ResondToClientSocks5RegularRequest- replySize is: " + replySize + " for Connection: " + iConnection); >- >- reply_buffer[0] = 5; // Version >- reply_buffer[1] = 0; // Reply - successful = 0 >- reply_buffer[2] = 0; // Reserved - must be 0 >- reply_buffer[3] = replyAddressType; // address type >- for (i = 0, replyIndx = 4 ; i < localHostAddress.length && replyIndx < replySize; i++, replyIndx++){ >- reply_buffer[replyIndx]=localHostAddress[i]; >- } >- // convert integet thisPort to 2 bytes >- Uint16_Network(thisPort, reply_buffer, replyIndx); >- try { >- to_client.write(reply_buffer,0, replySize); >- to_client.flush(); >- } catch (Exception e){ >- packetWriter.writeRecorderMessage(1, "ERROR writing to Client in ResondToClientSocks5RegularRequest for Connection: " + iConnection); >- e.printStackTrace(); >- } >- >- >- } >- */ >- /** >- * The server selects from one of the methods given in METHODS, and sends a METHOD selection message: >- * >- * VERSION METHOD >- * 1 1 >- * >- * If the selected METHOD is X'FF', none of the methods listed by the >- * client are acceptable, and the client MUST close the connection. >- * >- * The values currently defined for METHOD are: >- * >- * X'00' NO AUTHENTICATION REQUIRED >- * X'01' GSSAPI >- * X'02' USERNAME/PASSWORD >- * X'03' to X'7F' IANA ASSIGNED >- * X'80' to X'FE' RESERVED FOR PRIVATE METHODS >- * X'FF' NO ACCEPTABLE METHODS >- * >- * @author mdunn >- * @internal >- * >- * @param returnCode >- */ >- >- private void respondToClientSocks5MethodSelection(boolean returnCode) { >- int REPLY_SIZE = 2; >- byte[] reply_buff = new byte[REPLY_SIZE]; >- >- reply_buff[0] = 5; >- if ((returnCode == true) && (socks5MethodSelected != NO_METHOD)){ >- reply_buff[1] = 0; >- } >- else { >- reply_buff[1] = (byte)255; >- } >- >- try { >- to_client.write(reply_buff,0, REPLY_SIZE); >- to_client.flush(); >- } catch (IOException e) { >- // TODO Auto-generated catch block >- e.printStackTrace(); >- } >- >- } >- /** >- * Convert uint16 into 2 octets in unsigned network byte order. >- * >- * @param uint16 Positive integer 0->2^16. >- * @param destBuf The buffer to store uint16 in network byte order. >- * @param destStartIdx The offset into buffer, will consome buffer[offset] and >- * buffer[offset+1] >- */ >- public static void Uint16_Network(int uint16, byte[] destBuf, int destStartIdx) { >- destBuf[destStartIdx+0] = (byte)(uint16 / 256); >- destBuf[destStartIdx+1] = (byte)(uint16 % 256); >- } >- >- /** >- * >- * @param myvar >- * @return >- */ >- private static String IP4ByteToString (byte myvar[]) { >- String strResult = ""; >- for (int i = 0; i < 4; i++) { >- if ((int)myvar[i] >= 0) { >- strResult += String.valueOf((int)myvar[i]); >- } else { >- strResult += String.valueOf(256 + (int)myvar[i]); >- } >- if (i < 3) { >- strResult += "."; >- } >- } >- return strResult; >- } >- >- private String IP6ByteToString(byte[] destinationInetAddress2) { >- String address = null; >- try{ >- InetAddress add = InetAddress.getByAddress(destinationInetAddress2); >- address = add.getHostAddress(); >- } >- catch (UnknownHostException e){ >- return null; >- } >- >- return address; >- } >- >- >- private void respondToClient(boolean flag) { >- byte[] reply_buff = new byte[8]; >- >- reply_buff[0] = 0; >- if (flag == true){ >- reply_buff[1] = 90; >- } >- else { >- reply_buff[1] = 91; >- } >- try { >- to_client.write(reply_buff,0, 8); >- to_client.flush(); >- } catch (Exception e){ >- e.printStackTrace(); >- } >- } >- >- private String makeRegularConnection( ){ >- >- String strReturn = null; >- //int index; >- //int port = 80; >- //String destStr = null; >- try{ >- // Note : already have open port to server >- //httpServer = new Socket(destStr, port); >- packetWriter.writeOpenConnectionInfo(bSecure, iConnection, destServer, serverPort, client, httpServer, null, null); >- >- to_server = httpServer.getOutputStream(); >- from_server = httpServer.getInputStream(); >- >- serverReader = new ServerSideReader(client, >- httpServer, >- from_server, >- to_client, >- packetWriter, >- connectionNumber, >- bSecure, >- httpServer.getReceiveBufferSize()); >- serverReader.start(); >- >- } >- catch (Exception e){ >- packetWriter.writeRecorderMessage(2, "exception in ClientSideReader : " + e + " Connection: " + iConnection); >- packetWriter.getAgentController().reportException(ClientSideReaderException,e); >- >- try { >- if (!client.isClosed()) { >- client.close(); >- } >- strReturn = null; >- } >- catch (IOException ioe){ >- packetWriter.writeRecorderMessage(2, "IOException in ClientSideReader connection " + iConnection + ": " + ioe); >- >- } >- //packetWriter.writeCloseConnectionInfo(iConnection); >- } >- return strReturn; >- } >- public int findSSLClass() { >- int gotSSL = -1; >- >- try{ >- Class.forName("javax.net.ssl.SSLSocket"); >- gotSSL = 1; >- } >- catch (ClassNotFoundException cnf){ >- gotSSL = 0; >- } >- return gotSSL; >- } >- boolean checkSSLByte() { >- boolean isSSL = false; >- int ssl_byte = 0; >- //TODO must mark beginning of buffer, read 1 byte and check if the >- // byte = 128 or 20 or 21 or 22 or 23 >- // if so, must convert client to spysocket and server to SSLSocketFactory socket >- // and reset() the buffer to beginning >- >- try { >- ssl_byte = client.peek(); >- } >- catch (IOException e) { >- packetWriter.writeRecorderMessage(2, "exception checking for SSL Connection: " + iConnection + e); >- >- } >- // packetWriter.writeRecorderMessage(1, "ssl_byte is: " + ssl_byte ); >- if ((ssl_byte == 128) || (ssl_byte == 20) || (ssl_byte == 21) >- || (ssl_byte == 22) || (ssl_byte == 23)) { >- >- isSSL = true; >- bSecure = true; >- } >- else { >- bSecure = false; >- isSSL = false; >- } >- return isSSL; >- } >- >-// private static synchronized void debugMsg (String msg) { >-// try { >-// FileOutputStream out = new FileOutputStream("c:\\test.out", true); >-// String outStr = msg + "\r\n"; >-// out.write (outStr.getBytes()); >-// } catch (Exception e) { >-// //temp >-// } >-// } >- >- /** >- * Attempts to read exactSize from the InputStream, no more, no less. If a short >- * read comes in block until exactSize is placed in the out buf. Will not read >- * more than exactSize from the stream. >- * >- * Assumptions, buf is large enough from exactSize, IndexOutOfRange would probably occur. >- * >- * @param in InputStream of bytes. >- * @param buf Output byte[] buffer >- * @param exactSize The exact number of bytes to read, -1 on EOF or exception. >- * @return exactSize if bytes are read, -1 all other times, say on EOF. >- * @throws IOException InputStream.read() exception. >- */ >- >- public String getAddressFromLocalhost(String originalString) { >- String retString = ""; >- int foundSlash = -1; >- >- foundSlash = originalString.indexOf("/"); >- if (foundSlash == -1) { >- retString = originalString; >- } else { >- retString = originalString.substring(foundSlash + 1); >- } >- >- return retString; >- } >- >-} >\ No newline at end of file >Index: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/TicketDispatcher.java >=================================================================== >RCS file: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/TicketDispatcher.java >diff -N src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/TicketDispatcher.java >--- src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/TicketDispatcher.java 2 May 2007 19:36:26 -0000 1.5 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,35 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: TicketDispatcher.java,v 1.5 2007/05/02 19:36:26 paules Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >-package org.eclipse.hyades.execution.recorder.http.remote; >- >-/** >- * This class creates a unique ticket number for each packet of information written to the >- * .rec file. >- * >- * @author morris >- * @deprecated This is not public API. It will be moved to internal in TPTP 5 >- * >- */ >-public final class TicketDispatcher { >- static int iTicket = 0; >- >- synchronized static int getTicket(){ >- iTicket++; >- return iTicket; >- } >- // method provided for convenience only if it is ever needed >- synchronized static void resetTicketCounter(){ >- iTicket = 0; >- } >- >- >-} >Index: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/CleanupObj.java >=================================================================== >RCS file: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/CleanupObj.java >diff -N src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/CleanupObj.java >--- src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/CleanupObj.java 7 Mar 2008 14:19:57 -0000 1.7 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,65 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2005, 2008 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: CleanupObj.java,v 1.7 2008/03/07 14:19:57 paules Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.hyades.execution.recorder.http.remote; >-import java.net.Socket; >- >- >-/** >- * This object is used to clean up any sockets that are still hanging around when we close >- * the URL recorder. >- * >- * @author mdunn >- * @deprecated This is not public API. It will be moved to internal in TPTP 5 >- * >- * >- */ >-public class CleanupObj { >- Socket thisSocket = null; >- PacketWriter thisWriter = null; >- String thisConnection = null; >- /** >- * @return Returns the thisSocket. >- */ >- public Socket getThisSocket() { >- return thisSocket; >- } >- /** >- * @param thisSocket The thisSocket to set. >- */ >- public void setThisSocket(Socket thisSocket) { >- this.thisSocket = thisSocket; >- } >- /** >- * @return Returns the thisWriter. >- */ >- public PacketWriter getThisWriter() { >- return thisWriter; >- } >- /** >- * @param thisWriter The thisWriter to set. >- */ >- public void setThisWriter(PacketWriter thisWriter) { >- this.thisWriter = thisWriter; >- } >- /** >- * @return Returns the thisConnection. >- */ >- public String getThisConnection() { >- return thisConnection; >- } >- /** >- * @param thisConnection The thisConnection to set. >- */ >- public void setThisConnection(String thisConnection) { >- this.thisConnection = thisConnection; >- } >-} >Index: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/PacketWriter.java >=================================================================== >RCS file: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/PacketWriter.java >diff -N src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/PacketWriter.java >--- src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/PacketWriter.java 2 May 2007 19:36:26 -0000 1.27 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,806 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: PacketWriter.java,v 1.27 2007/05/02 19:36:26 paules Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >- >-/* >- * NONE OF THE QUOTED STRINGS IN THIS FILE ARE TO BE LOCALIZED >- * THEY ARE ALL FOR XML TAGS, DEBUGGING SUPPORT, THEY ARE NOT FOR USER INTERFACES >- */ >-package org.eclipse.hyades.execution.recorder.http.remote; >- >-import java.io.IOException; >-import java.io.OutputStream; >-import java.net.InetAddress; >-import java.net.Socket; >-import java.util.Date; >-import java.util.Properties; >- >-import javax.net.ssl.SSLSocket; >- >-import org.eclipse.hyades.execution.recorder.remote.RecorderAgent; >- >-import com.ibm.icu.text.SimpleDateFormat; >- >-/** >- * This object is used to write the packets of information (XML fragments) to the .rec file >- * >- * @author morris >- * modified by: mdunn >- * @deprecated This is not public API. It will be moved to internal in TPTP 5 >- */ >-public class PacketWriter >-{ >- static final int ENCODING_TYPE_NONE = 0; >- static final int ENCODING_TYPE_BASE64 = 1; >- static final int ENCODING_TYPE_ASCIIFY = 2; >- >- static final String PACKET_TAG = "<TRCPacket>\r\n"; >- static final String XML_IDENT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n\r\n<TRACE>\r\n\r\n"; >- >- static final String DATA_TAGEND = "]]></data>\r\n"; >- static final String PACKET_TAGEND = "</TRCPacket>\r\n\r\n"; >- >- static int iTicket = 0; >- static long lTimeRef = 0; >- >- Date date; >- static int encodedLength = -1; >- static int encodedNonASCIIs = -1; >- >- static boolean bStopRecording = false; >- >- private RecorderAgent agent; >- >- protected GlobalPacketQueue packetQueue; >- >- public PacketWriter(RecorderAgent theAgentController){ >- super(); >- date = new Date(); >- agent = theAgentController; >- bStopRecording = false; >- >- packetQueue = new GlobalPacketQueue (this); >- packetQueue.setPriority(Thread.MIN_PRIORITY); >- packetQueue.start(); >- } >- >- public synchronized boolean writePacket(boolean bSecure, >- boolean bFromClient, >- ConnectionObj iConnection, >- byte [] buffer, >- int bufLength, >- OutputStream where_to, >- boolean bNoPrintToServer) throws Exception { >- >- boolean bRet = false; >- >- String dirString = null; >- String typeString = null; >- int encodingType = ENCODING_TYPE_NONE; >- String strEncoded = null; >- byte [] byteEncodedArray = null; >- >- >- try { >- if (!bNoPrintToServer){ >- where_to.write(buffer, 0, bufLength); >- where_to.flush(); >- } >- } catch (IOException e1) { >- // TODO Auto-generated catch block >- throw e1; >- } >- >- int thisConn = iConnection.getConnectionNumber(); >- if (thisConn == 0) { >- writeRecorderMessage(1, "REJECTED writePacket - connection number is 0"); >- return false; >- } >- >- >- iTicket = TicketDispatcher.getTicket(); >- >- try{ >- encodedLength = -1; >- encodedNonASCIIs = 0; // Used to determine if really ALL ASCII >- >- // ASCIIFY string -- This sets encodedLength to -100 if more >- // than 5 Non-ASCIIs in the first 50 bytes >- byteEncodedArray = getASCIIFYEncodedByteArray(buffer, bufLength); >- >- // Check length of ASCIIFY encoding >- if (encodedLength < 0) { >- // Lots of Non-ASCII so Base64 it >- strEncoded = getBase64EncodedString(buffer, bufLength); >- encodingType = ENCODING_TYPE_BASE64; >- encodedLength = strEncoded.length(); >- byteEncodedArray = null; // Free Up the ASCIIFY string >- } else { >-/* ASCIIFY all Non-BASE64 packets until TestGen Xerces Parser is fixed to not drop CR's >- } else if (encodedNonASCIIs > 0) { >- // Had some Non-ASCII so we use ASCIIFIED >- encodingType = ENCODING_TYPE_ASCIIFY; >- } else { >- // Had NO Non-ASCII so use the original buffer >- encodingType = ENCODING_TYPE_NONE; >- byteEncodedArray = null; // Free Up the ASCIIFY string >- } >-*/ >- encodingType = ENCODING_TYPE_ASCIIFY; >- } >-/* >- * End of ASCIIFY temporary fix >- */ >- if (bFromClient == true) >- dirString = "CLIENT\" "; >- else >- dirString = "SERVER\" "; >- >- if (bSecure == true) >- typeString = "HTTPS"; >- else >- typeString = "HTTP"; >- >- >- writeString("<TRCPacket ticket=\"" + Integer.toString(iTicket) + >- "\" connectionNumber=\"" + iConnection.getConnectionNumber() + >- "\" timestamp=\"" + Long.toString(TimeStampDispatcher.getTimeStamp())+ >- "\" from=\"" + dirString + >- " type=\"" + typeString + >- "\">\r\n"); >- >- StringBuffer strData; >- >- strData = new StringBuffer("<data length=\"" + Integer.toString(bufLength)+ >- "\" encoding=\""); >- >- switch (encodingType){ >- case ENCODING_TYPE_BASE64: >- strData.append("BASE64\""); >- break; >- case ENCODING_TYPE_ASCIIFY: >- strData.append("ASCIIFY\""); >- break; >- case ENCODING_TYPE_NONE: >- default: >- strData.append("NONE\""); >- break; >- }; >- >- if (encodingType != ENCODING_TYPE_NONE){ >- strData.append(" encodedLength=\"" + Integer.toString(encodedLength) + "\" "); >- } >- strData.append(" type=\"HTTPDATA\" ><![CDATA["); >- String strTemp = new String(strData); >- writeString(strTemp); >- >- if (encodingType == ENCODING_TYPE_ASCIIFY){ >- flushStreamWriter(); >- writeBytes(byteEncodedArray, 0, encodedLength); >- byteEncodedArray = null; >- }else if (encodingType == ENCODING_TYPE_NONE){ >- flushStreamWriter(); >- writeBytes(buffer, 0, bufLength); >- }else{ // ENCODING_TYPE_BASE64 >- writeString(strEncoded); >- } >- writeString(DATA_TAGEND); >- writeString(PACKET_TAGEND); >- //flushOutputStream(); >- } >- catch (Exception e){ >- e.printStackTrace(); >- } >- return bRet; >- } >- >- public synchronized boolean writeOpenConnectionInfo(boolean bSecure, >- int iConnection, >- String strServer, >- int port, >- Socket client, >- Socket server, >- SSLSocket sslClient, >- SSLSocket sslServer){ >- >- try{ >- >- >- // mdd long timeStamp = TimeStampDispatcher.getTimeStamp(); >- iTicket = TicketDispatcher.getTicket(); >- //InetAddress tempaddr = client.getInetAddress(); >- InetAddress lh = InetAddress.getLocalHost(); >- String tmpLocalhost = lh.toString(); >- String localHostStr = getAddressFromLocalhost(tmpLocalhost); >- >- //String tempStr = tempaddr.toString(); >- //String prtString = ""; >- >- //prtString = removeLeadingSlash(tempStr); >- >- writeString("<TRCConnection type=\"OPEN\" ticket=\"" + >- Integer.toString(iTicket) + >- "\" connectionNumber=\"" + >- Integer.toString(iConnection) + >- "\" timestamp=\"" + >- Long.toString(TimeStampDispatcher.getTimeStamp())+ >- "\">\r\n<servername>\r\n" + strServer + >- "</servername>\r\n<port>" + Integer.toString(port) + >- "</port>\r\n" + >- //"<clientInetAddress>" + prtString + "</clientInetAddress>\r\n" + >- "<clientInetAddress>" + localHostStr + "</clientInetAddress>\r\n" + >- "<clientPort>" + Integer.toString(client.getPort()) + "</clientPort>\r\n" + >- "</TRCConnection>\r\n\r\n"); >- //flushOutputStream(); >- String thisconn = Integer.toString(iConnection); >- CleanupObj clean = new CleanupObj(); >- clean.setThisSocket(server); >- clean.setThisWriter(this); >- clean.setThisConnection(thisconn); >- GlobalSocketList.add(thisconn,clean); >- } >- catch (Exception e){ >- } >- >- return true; >- } >- >- public synchronized boolean writeOpenSecureConnectionInfo(boolean bSecure, >- int iConnection, >- String strServer, >- int port, >- Socket client, >- Socket server, >- SSLSocket sslClient, >- SSLSocket sslServer, >- String cipherSuite, >- String sslProtocol){ >- >- try{ >- >- >- // mdd long timeStamp = TimeStampDispatcher.getTimeStamp(); >- iTicket = TicketDispatcher.getTicket(); >- InetAddress tempaddr = client.getInetAddress(); >- String tempStr = tempaddr.toString(); >- >- String prtString = ""; >- >- prtString = removeLeadingSlash(tempStr); >- >- writeString("<TRCConnection type=\"OPEN\" ticket=\"" + >- Integer.toString(iTicket) + >- "\" connectionNumber=\"" + >- Integer.toString(iConnection) + >- "\" timestamp=\"" + >- Long.toString(TimeStampDispatcher.getTimeStamp())+ >- "\">\r\n<servername>\r\n" + strServer + >- "</servername>\r\n<port>" + Integer.toString(port) + >- "</port>\r\n" + >- "<clientInetAddress>" + prtString + "</clientInetAddress>\r\n" + >- "<clientPort>" + Integer.toString(client.getPort()) + "</clientPort>\r\n" + >- "<cipherSuite>" + cipherSuite + "</cipherSuite>\r\n" + >- "<protocol>" + sslProtocol + "</protocol>\r\n" + >- "</TRCConnection>\r\n\r\n"); >- //flushOutputStream(); >- >- } >- catch (Exception e){ >- } >- String tmpConn = ""; >- >- tmpConn = Integer.toString(iConnection); >- CleanupObj tmpCleanup = new CleanupObj(); >- tmpCleanup.setThisSocket(server); >- tmpCleanup.setThisWriter(this); >- tmpCleanup.setThisConnection(tmpConn); >- >- GlobalSocketList.add(tmpConn,tmpCleanup); >- >- >- return true; >- } >- >- >- public synchronized boolean writeCloseConnectionInfo(ConnectionObj iConnection){ >- >- String originalConnectionNumber = Integer.toString(iConnection.getConnectionNumber()); >- try{ >- >- >- // long timeStamp = TimeStampDispatcher.getTimeStamp(); >- iTicket = TicketDispatcher.getTicket(); >- >- >- writeString("<TRCConnection type=\"CLOSE\" ticket=\"" + >- Integer.toString(iTicket) + >- "\" connectionNumber=\"" + >- //Integer.toString(iConnection) + >- iConnection.getConnectionNumber() + >- "\" timestamp=\"" + >- Long.toString(TimeStampDispatcher.getTimeStamp())+ >- "\"/>\r\n"); >- //flushOutputStream(); >- //writeRecorderMessage(1, "WRITECLOSECONNECTION - NOW RESET to 0"); >- iConnection.setConnectionNumber(0); >- } >- catch (Exception e){ >- e.printStackTrace(); >- } >- GlobalSocketList.remove(originalConnectionNumber,this); >- return true; >- } >- public synchronized boolean writeConnectConnectionInfo(int iConnection){ >- >- try{ >- >- // long timeStamp = TimeStampDispatcher.getTimeStamp(); >- iTicket = TicketDispatcher.getTicket(); >- >- writeString("<TRCConnection type=\"CONNECT\" ticket=\"" + >- Integer.toString(iTicket) + >- "\" connectionNumber=\"" + >- //Integer.toString(iConnection) + >- iConnection + >- "\" timestamp=\"" + >- Long.toString(TimeStampDispatcher.getTimeStamp())+ >- "\"/>\r\n"); >- //flushOutputStream(); >- } >- catch (Exception e){ >- e.printStackTrace(); >- } >- return true; >- } >- >- >- public synchronized boolean writeRecorderStartInfo(int iProxyRecorderPort, >- String iProxyAddr, int iProxyPort, String iSSLProxyAddr, int iSSLProxyPort){ >- >- try{ >- //long timeStamp = TimeStampDispatcher.getTimeStamp(); >- iTicket = TicketDispatcher.getTicket(); >- Properties prop = System.getProperties(); >- writeString(XML_IDENT); >- String recorderInfo = ""; >- Date now = new Date(); >- SimpleDateFormat militaryTime = new SimpleDateFormat("MM/dd/yyyy kk:mm:ss"); >- >- >- >- >- recorderInfo = "<TRCRecorderInfo type=\"start\" ticket=\"" + >- Integer.toString(iTicket) + >- "\" timestamp=\"" + >- Long.toString(TimeStampDispatcher.getTimeStamp())+ >- "\">\r\n<recorderport>" + Integer.toString(iProxyRecorderPort) + >- // "</recorderport>\r\n<date>" + date.toLocaleString() + "</date>\r\n" + >- "</recorderport>\r\n<date>" + militaryTime.format(now) + "</date>\r\n" + >- "<recorderversion>4.4.0.2</recorderversion>\r\n" + >- "<javavmversion>" + prop.getProperty("java.vm.version") + "</javavmversion>\r\n" + >- "<javavmvendor>" + prop.getProperty("java.vm.vendor") + "</javavmvendor>\r\n" + >- "<javahome>" + prop.getProperty("java.home") + "</javahome>\r\n" + >- "<osname>" + prop.getProperty("os.name") + "</osname>\r\n" + >- "<osversion>" + prop.getProperty("os.version") + "</osversion>\r\n"; >- if (iProxyAddr != null && iProxyAddr.length() > 0) { >- recorderInfo = recorderInfo + "<proxyaddress>" + iProxyAddr + "</proxyaddress>\r\n"+ >- "<proxyport>" + iProxyPort + "</proxyport>\r\n"; >- } >- if (iSSLProxyAddr != null && iSSLProxyAddr.length() > 0) { >- recorderInfo = recorderInfo + "<sslproxyaddress>" + iSSLProxyAddr + "</sslproxyaddress>\r\n"+ >- "<sslproxyport>" + iSSLProxyPort + "</sslproxyport>\r\n"; >- } >- >- writeString(recorderInfo); >- writeString("</TRCRecorderInfo>\r\n\r\n"); >- >- //flushOutputStream(); >- } >- catch (Exception e){ >- } >- >- return true; >- } >- >- public synchronized boolean writeRecorderStopInfo(){ >- >- try{ >- >- >- // long timeStamp = TimeStampDispatcher.getTimeStamp(); >- iTicket = TicketDispatcher.getTicket(); >- >- writeString("<TRCRecorderInfo type=\"STOP\" ticket=\"" + >- Integer.toString(iTicket) + >- "\" timestamp=\"" + >- Long.toString(TimeStampDispatcher.getTimeStamp())+ >- "\">\r\n"); >- writeString("</TRCRecorderInfo>\r\n\r\n</TRACE>\r\n"); >- //flushOutputStream(); >- bStopRecording = true; >- } >- catch (Exception e){ >- } >- >- return true; >- } >- public synchronized boolean writeRecorderBrowserConfigInfo(int iProxyRecorderPort, >- String iProxyAddr, int iProxyPort, String iSSLProxyAddr, int iSSLProxyPort, >- String iProxyOverride, String iProxyAutoConfigURL){ >- >- try{ >- //long timeStamp = TimeStampDispatcher.getTimeStamp(); >- iTicket = TicketDispatcher.getTicket(); >- //Properties prop = System.getProperties(); >- >- String recorderInfo = ""; >- Date now = new Date(); >- SimpleDateFormat militaryTime = new SimpleDateFormat("MM/dd/yyyy kk:mm:ss"); >- >-// <TRCRecorderInfo type="WEBBROWSERCONFIG" ticket="2" timestamp="5047"> >-// <ProxyEnabled>FALSE</ProxyEnabled> >-// <ProxyName>NONE</ProxyName> >-// <ProxyPort>NONE</ProxyPort> >-// <ProxyOverride>NONE</ProxyOverride> >-// <AutoConfigURL>NONE</AutoConfigURL> >-// </TRCRecorderInfo> >- >- >- >- recorderInfo = "<TRCRecorderInfo type=\"WEBBROWSERCONFIG\" ticket=\"" + >- Integer.toString(iTicket) + >- "\" timestamp=\"" + >- Long.toString(TimeStampDispatcher.getTimeStamp()) + "\">\r\n"; >-// // TODO MDD need to determine actual data elements for all these >-// "\">\r\n<BrowserName>"; >-// // TODO Must change this to get Browser from preference >-// if (Platform.getOS()=="win32") { >-// recorderInfo = recorderInfo + "\"Internet Explorer\"" + "</BrowserName>\r\n" + >-// } >-// else { >-// recorderInfo = recorderInfo + "\"Mozilla\"" + "</BrowserName>\r\n" + >-// } >- recorderInfo = recorderInfo + "<date>" + militaryTime.format(now) + "</date>\r\n" ; >- if (iProxyAddr != null && iProxyAddr.length() > 0) { >- recorderInfo = recorderInfo + "<ProxyEnabled>TRUE</ProxyEnabled>\r\n"+ >- "<ProxyAddress>" + iProxyAddr + "</ProxyAddress>\r\n"+ >- "<ProxyPort>" + iProxyPort + "</ProxyPort>\r\n"; >- } else { >- recorderInfo = recorderInfo + "<ProxyEnabled>FALSE</ProxyEnabled>\r\n"+ >- "<ProxyAddress>NONE</ProxyAddress>\r\n"+ >- "<ProxyPort>NONE</ProxyPort>\r\n"; >- } >- >- if (iSSLProxyAddr != null && iSSLProxyAddr.length() > 0) { >- recorderInfo = recorderInfo + "<SSLProxyAddress>" + iSSLProxyAddr + "</SSLProxyAddress>\r\n"+ >- "<SSLProxyPort>" + iSSLProxyPort + "</SSLProxyPort>\r\n"; >- } >- // TODO Now need ProxyOverride Info and AutoConfigURL info will do later >- >- if (iProxyOverride != null && iProxyOverride.length() > 0) { >- recorderInfo = recorderInfo + "<ProxyOverride>" + iProxyOverride + "</ProxyOverride>\r\n"; >- } else { >- recorderInfo = recorderInfo + "<ProxyOverride>" + "NONE" + "</ProxyOverride>\r\n"; >- } >- >- if (iProxyAutoConfigURL != null && iProxyAutoConfigURL.length() > 0) { >- recorderInfo = recorderInfo + "<ProxyAutoConfigURL>" + iProxyAutoConfigURL + "</ProxyAutoConfigURL>\r\n"; >- } else { >- recorderInfo = recorderInfo + "<ProxyAutoConfigURL>" + "NONE" + "</ProxyAutoConfigURL>\r\n"; >- } >- >- >-// recorderInfo = recorderInfo + "<ProxyOverride>" + "\"NONE\"" + "</ProxyOverride>\r\n" + >-// "<AutoConfigURL>" + "\"NONE\"" + "</AutoConfigURL>\r\n"; >- >- writeString(recorderInfo); >- writeString("</TRCRecorderInfo>\r\n\r\n"); >- >- //flushOutputStream(); >- } >- catch (Exception e){ >- } >- >- return true; >- } >- >- public synchronized boolean writeRecorderMessage(int type, String strMessage){ >- >- try{ >- >- >- // long timeStamp = TimeStampDispatcher.getTimeStamp(); >- iTicket = TicketDispatcher.getTicket(); >- String strType = null; >- >- switch (type){ >- case 2: >- strType = "ERROR"; >- break; >- default: >- strType = "INFORMATION"; >- break; >- }; >- >- writeString("<TRCRecorderInfo type=\"" + strType + "\" ticket=\"" + >- Integer.toString(iTicket) + >- "\" timestamp=\"" + >- Long.toString(TimeStampDispatcher.getTimeStamp())+ >- "\">\r\n<message>" + strMessage + "</message>\r\n"); >- writeString("</TRCRecorderInfo>\r\n\r\n"); >- //flushOutputStream(); >- } >- catch (Exception e){ >- } >- >- return true; >- } >- >- >- /** >- * This utility method converts a passed byte array into a Base 64 encoded >- * String according to the specification in RFC1521 section 5.2 >- */ >- private static final String mappings = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";//$NON-NLS-1$ >- private static final String filler = "=";//$NON-NLS-1$ >- /** >- * Answer a string representing the Base 64 encoded form of the passed >- * byte array >- * >- * @return java.lang.String >- * @param contents byte[] >- */ >- >- private String getBase64EncodedString(byte[] contents, int bufLength){ >- >- //public static String encode(byte[] contents) { >- StringBuffer result = new StringBuffer(); >- >- for (int i = 0; i < bufLength; i = i + 3) { >- if (result.length() == 76) >- result.append("\n\r");//$NON-NLS-1$ >- >- // output character 1 >- result.append(mappings.charAt((contents[i] & 0xFC) >> 2)); >- >- // output character 2 >- int c2 = (contents[i] & 0x03) << 4; >- // bugzilla 138644 - replace contents.length with bufLength in line below >- //if (i + 1 >= contents.length) { >- if (i + 1 >= bufLength) { >- result.append(mappings.charAt(c2)); >- result.append(filler); >- result.append(filler); >- return result.toString(); >- } >- >- c2 |= ((contents[i + 1] & 0xF0) >> 4); >- result.append(mappings.charAt(c2)); >- >- // output character 3 >- int c3 = (contents[i + 1] & 0x0F) << 2; >- // bugzilla 138644 - replace contents.length with bufLength in line below >- //if (i + 2 >= contents.length) { >- if (i + 2 >= bufLength) { >- result.append(mappings.charAt(c3)); >- result.append(filler); >- return result.toString(); >- } >- >- c3 |= ((contents[i + 2] & 0xC0) >> 6); >- result.append(mappings.charAt(c3)); >- >- // output character 4 >- result.append(mappings.charAt(contents[i + 2] & 0x3F)); >- } >- >- return result.toString(); >- } >- >- >- private byte [] getASCIIFYEncodedByteArray(byte[] buffer, int bufLength) >- { >- int iLoop, iLoc = 0; >- byte b1; >- boolean bEncoded = false, bNeedsEncoding = false; >- final byte [] asciiRef = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; >- >- byte [] encodedBuf = new byte[bufLength * 4 + 4]; >- >- try{ >- >- for (iLoop = 0; iLoop < bufLength; iLoop++){ >- b1 = buffer[iLoop]; >- bNeedsEncoding = isByteBinary(b1); >- >- // two ascii characters in a row are needed to switch back to >- // non-encoding mode >- if (bEncoded && !bNeedsEncoding){ >- // obviously, check so we don't go past the end >- if ((iLoop + 1) < bufLength){ >- bNeedsEncoding = isByteBinary(buffer[iLoop + 1]); >- } >- } >- if (bNeedsEncoding){ >- if (iLoop < 50) { //Check first 50 chars >- if (encodedNonASCIIs > 5) { //for Over 5 Non-ASCIIs >- encodedLength = -100; >- return encodedBuf; // Let us BASE64 this one >- } >- } >- if ((b1 != 13) && (b1 != 10) && (b1 != '`')) >- encodedNonASCIIs++; >- if (!bEncoded){ >- encodedBuf[iLoc] = '`'; >- iLoc++; >- } >- int i = (int)b1; >- if (i < 0) >- i += 256; >- i = i >> 4; >- if (i < 0 || i > 15){ >- i = 0; >- } >- encodedBuf[iLoc] = asciiRef[i]; >- iLoc++; >- i = (b1 & 0x0f); >- if (i < 0 || i > 15){ >- >- i = 0; >- } >- encodedBuf[iLoc] = asciiRef[i]; >- iLoc++; >- bEncoded = true; >- } >- else{ >- if (bEncoded){ >- encodedBuf[iLoc] = '`'; >- iLoc++; >- bEncoded = false; >- } >- encodedBuf[iLoc] = buffer[iLoop]; >- iLoc++; >- } >- } >- if (bEncoded){ >- encodedBuf[iLoc] = '`'; >- iLoc++; >- } >- encodedLength = iLoc; >- } >- catch (Exception e){ >- e.printStackTrace(); >- } >- >- return encodedBuf; >- } >- >-//[TDA Rewrote] >- private boolean isByteBinary(byte b){ >- boolean bRet = false; >- // the ']' character is included to guard against writing a "]]>" which >- // would terminate a CDATA tag and backQuote is the escape char >- if ((b == ']') || (b == '`')) >- bRet = true; >- else if ((b < 32) || (b > 126)){ >- if ((b != '\n') && (b != '\t')) //Preserve for readability >- bRet = true; >- } >- return bRet; >- } >-//[TDA Rewrote] >- >- protected void flushOutputStream() throws IOException >- { >- //if(agent==null) >- // to_file.flush(); >- } >- >- private void flushStreamWriter() throws IOException >- { >- //if(agent == null) >- // to_fileXML.flush(); >- } >- >- protected void writeString(String data) throws IOException >- { >- if (!bStopRecording) >- packetQueue.add(data); >- /*if(agent!=null && !bStopRecording) >- agent.sendByteDataToDataProcessor(data.getBytes(), 0, data.getBytes().length); >- */ >- //else >- // to_fileXML.write(data); >- } >- >- private void writeBytes(byte[] buffer, int iOffset, int buflength) throws IOException >- { >- if (!bStopRecording) >- packetQueue.add( buffer,iOffset,buflength); >- /*if(agent!=null && !bStopRecording) >- agent.sendByteDataToDataProcessor(buffer, iOffset, buflength); >- */ >- >- //else >- // to_file.write(buffer,0,buflength); >- } >- >- public void sendToDataProcessor(byte[] byteBuf) { >- if(agent!=null) { >- agent.sendByteDataToDataProcessor(byteBuf, 0, byteBuf.length); >- } >- } >- public void flushRemainingPackets () { >- //writeRecorderMessage(1, "IN flushRemainingPackets(), call Initiate Shutdown"); >- packetQueue.initiateShutdown(); >- try { >- packetQueue.join(); >- } catch (Exception e) { >- // >- } >- } >- >- /** >- * @return >- */ >- public RecorderAgent getAgentController() >- { >- return agent; >- } >- public String removeLeadingSlash(String originalString) { >- String prtString = ""; >- if (originalString.startsWith("/")) { >- prtString = originalString.substring(1); >- } >- else >- prtString = originalString; >- >- return prtString; >- } >- public String getAddressFromLocalhost(String originalString) { >- String retString = ""; >- int foundSlash = -1; >- >- foundSlash = originalString.indexOf("/"); >- if (foundSlash == -1) { >- retString = originalString; >- } else { >- retString = originalString.substring(foundSlash + 1); >- } >- >- return retString; >- } >- >- >- public synchronized boolean writeCloseConnectionInfo(String iConnection){ >- >- try{ >- >- //long timeStamp = TimeStampDispatcher.getTimeStamp(); >- iTicket = TicketDispatcher.getTicket(); >- >- writeString("<TRCConnection type=\"CLOSE\" ticket=\"" + >- Integer.toString(iTicket) + >- "\" connectionNumber=\"" + >- //Integer.toString(iConnection) + >- iConnection + >- "\" timestamp=\"" + >- Long.toString(TimeStampDispatcher.getTimeStamp())+ >- "\"/>\r\n"); >- //flushOutputStream(); >- } >- catch (Exception e){ >- e.printStackTrace(); >- } >- return true; >- } >- >-} >Index: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/messages.properties >=================================================================== >RCS file: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/messages.properties >diff -N src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/messages.properties >--- src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/messages.properties 19 Apr 2007 12:19:36 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,29 +0,0 @@ >-############################################################################### >-# Copyright (c) 2005, 2007 IBM Corporation and others. >-# All rights reserved. This program and the accompanying materials >-# are made available under the terms of the Eclipse Public License v1.0 >-# which accompanies this distribution, and is available at >-# http://www.eclipse.org/legal/epl-v10.html >-# $Id: messages.properties,v 1.2 2007/04/19 12:19:36 paules Exp $ >-# >-# Contributors: >-# IBM Corporation - initial API and implementation >-############################################################################### >-# >-# httprecRunner.properties >-# >-# NOTE: When using substitution parameters, all single quote characters (e.g. ') must be escaped with a preceding single quote character (e.g. ''text in single quotes''). >-# >-# NLS_MESSAGEFORMAT_VAR >-# NLS_ENCODING=UTF-8 >- >-RECORDER_CLIENTSIDE_READER_EXCEPTION=exception in ClientSideReader: >-RECORDER_SSL_SPYSOCKET_EXCEPTION=exception creating SSL SpySocket: >-RECORDER_ERR_STARTING=Exception trying to start proxy recorder: >-RECORDER_STARTING_SSLPROXYRECORDER=about to start SSLProxyServer >-RECORDER_LISTENING_TO_PORT=proxy recorder listening to port >-RECORDER_CREATING_CLIENTSIDEREADER=Error Creating ClientSideReader >-RECORDER_BIND_ERROR=Error Binding to Port: >-RECORDER_TOO_MANY_BIND_ERROR=Too Many Bind Errors - Error Binding to Port: >-RECORDER_NOTIFY_ON_ADD=TRUE >-RECORDER_PACKET_WAIT_TOLERANCE=500 >Index: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/GlobalSocketList.java >=================================================================== >RCS file: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/GlobalSocketList.java >diff -N src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/GlobalSocketList.java >--- src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/GlobalSocketList.java 2 May 2007 19:36:27 -0000 1.7 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,116 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: GlobalSocketList.java,v 1.7 2007/05/02 19:36:27 paules Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.hyades.execution.recorder.http.remote; >-import java.net.Socket; >-import java.util.HashMap; >-import java.util.Iterator; >-import java.util.Set; >- >-/** >- * This is the object that is used to put items on the linked list and take elements >- * off the linked list. >- * >- * @author mdunn >- * @deprecated This is not public API. It will be moved to internal in TPTP 5 >- * >- */ >-public class GlobalSocketList { >- private static HashMap socketList = new HashMap(); >- public static void add(String key, CleanupObj thisClean) { >- >- synchronized (socketList) { >- try { >- socketList.put(key, thisClean); >- } catch (Exception e) { >- } >- } >- } >- public static void remove(String key, PacketWriter tmpWriter) { >- synchronized (socketList) { >- socketList.remove(key); >- //tmpWriter.writeRecorderMessage(1, "After Remove Key: " + key + " Size is: " + numSockets); >- } >- } >- public static void killAllOpenSockets(PacketWriter tmpWriter) { >- Set thisSet = socketList.keySet(); >- Iterator it = thisSet.iterator(); >- String thisKey = ""; >- Socket thisSocket = null; >- int numSockets = 0; >- CleanupObj tmpCleanup = null; >- synchronized (socketList) { >- numSockets = thisSet.size(); >- >- if (numSockets > 0) { >- >- try { >- Thread.yield(); >- Thread.sleep(1000); >- } catch (InterruptedException e) { >- } >- while (it.hasNext()) { >- thisKey = (String) it.next(); >- //thisSocket = (Socket)socketList.get(thisKey); >- tmpCleanup = (CleanupObj) socketList.get(thisKey); >- thisSocket = tmpCleanup.getThisSocket(); >- >- try { >- thisSocket.close(); >- Thread.yield(); >- } catch (Exception ioe) { >- System.out.println("In killAllOpenSockets() exception: " >- + ioe.getMessage()); >- } >- } >- } >- } >- } >- public static void writeCloseMessages(PacketWriter tmpWriter) { >- >- String thisKey = ""; >- Socket thisSocket = null; >- int numSockets = 0; >- CleanupObj tmpCleanup = null; >- String tmpNumberStr = ""; >- >- try { >- // let close() finish and write close message if it can >- Thread.yield(); >- Thread.sleep(1000); >- } catch (InterruptedException e) { >- } >- >- synchronized (socketList) { >- Set thisSet = socketList.keySet(); >- Iterator it = thisSet.iterator(); >- numSockets = thisSet.size(); >- >- if (numSockets > 0) { >- >- while (it.hasNext()) { >- thisKey = (String) it.next(); >- tmpCleanup = (CleanupObj) socketList.get(thisKey); >- thisSocket = tmpCleanup.getThisSocket(); >- try { >- tmpNumberStr = tmpCleanup.getThisConnection(); >- tmpWriter.writeCloseConnectionInfo(tmpNumberStr); >- thisSocket.close(); >- Thread.yield(); >- } catch (Exception ioe) { >- System.out.println("In writeCloseMessages() exception: " >- + ioe.getMessage()); >- } >- } >- } >- } >- } >-} >\ No newline at end of file >Index: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/SSLCheckClass.java >=================================================================== >RCS file: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/SSLCheckClass.java >diff -N src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/SSLCheckClass.java >--- src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/SSLCheckClass.java 3 May 2007 01:50:21 -0000 1.11 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,448 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: SSLCheckClass.java,v 1.11 2007/05/03 01:50:21 paules Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >-/* >- * Created on Nov 14, 2003 >- * >- * To change the template for this generated file go to >- * Window>Preferences>Java>Code Generation>Code and Comments >- */ >-package org.eclipse.hyades.execution.recorder.http.remote; >-import java.io.FileInputStream; >-import java.io.IOException; >-import java.net.Socket; >-import java.security.KeyStore; >-import java.util.Enumeration; >-import java.util.StringTokenizer; >-import java.util.Vector; >- >-import javax.net.ssl.KeyManagerFactory; >-import javax.net.ssl.SSLContext; >-import javax.net.ssl.SSLSession; >-import javax.net.ssl.SSLSessionContext; >-import javax.net.ssl.SSLSocket; >-import javax.net.ssl.SSLSocketFactory; >-import javax.net.ssl.TrustManager; >- >-/** >- * @author mdunn >- * @deprecated This is not public API. It will be moved to internal in TPTP 5 >- * >- * This class does all the SSL connections >- * >- */ >-public class SSLCheckClass { >- String sslCipherSuite = ""; >- String sslProtocol = ""; >- SSLContext serverSideConnectionContext = null; >- String sslKeyFile = "C:\\testkeys"; >- >- >- public boolean makeSecureConnection() { >- //csr.packetWriter.writeRecorderMessage(1, "IN makeSecureConnection()- call connectToSecureServer() for connection: " + csr.iConnection); >- if ((connectToSecureServer(csr.destServer, csr.serverPort)) == true){ >- if ((createSSLSpyServerSocket()) == true) { >- checkRightSideContexts(); >- >- csr.packetWriter.writeOpenSecureConnectionInfo(csr.bSecure, csr.iConnection, >- csr.destServer, csr.serverPort, csr.client, csr.httpServer, spySocket, >- sslServer, csr.sslCipherSuite, csr.sslProtocol); >- } >- try { >- csr.to_client= spySocket.getOutputStream(); >- csr.from_client = spySocket.getInputStream(); >- >- // these are the decrypted streams >- csr.to_server = sslServer.getOutputStream(); >- csr.from_server = sslServer.getInputStream(); >- //Temporarily Removed - mdd 11/10/2004 >- //csr.httpServer.close(); >- csr.httpServer = sslServer; >- >- csr.bSecure = true; >- csr.serverReader = new ServerSideReader(csr.client, >- csr.httpServer, >- csr.from_server, >- csr.to_client, >- csr.packetWriter, >- //csr.iConnection, >- csr.connectionNumber, >- csr.bSecure, >- spySocket.getReceiveBufferSize()); >- csr.serverReader.start(); >- } >- catch (IOException e) { >- csr.packetWriter.writeRecorderMessage(2, "exception in creating SSL Spy Socket: " + e); >- csr.packetWriter.getAgentController().reportException(SpySocketException,e); >- return false; >- } >- } >- csr.bNoPrintToServer = true; >- //csr.bSecure = isSecure; >- //return isSecure; >- return csr.bSecure; >- } >- public boolean connectToSecureServer(String destStr, int port){ >- SSLContext ctx = null; >- try{ >- //csr.packetWriter.writeRecorderMessage(1, "IN connectToSecureServer() for connection: " + csr.iConnection); >- SSLSocketFactory ssf = null; >- //TODO use createSocket method that uses socket as input >- TrustManager[] myTM = new TrustManager [] {new RecorderX509TrustManager() }; >- //SSLContext ctx = SSLContext.getInstance("SSL"); >- ctx = SSLContext.getInstance("SSL"); >- ctx.init(null, myTM, null); >- >- ssf = ctx.getSocketFactory(); >- //sslServer = (SSLSocket)sslFact.createSocket(httpServer,destServer, serverPort,true); >- sslServer = (SSLSocket)ssf.createSocket(destStr, port); >- // when startHandshake returns, an SSL connection is >- // satisfied and handshaking is done transparently to this code >- // remove after testing >- >- sslServer.startHandshake(); >- } >- catch (Exception e){ >- csr.packetWriter.writeRecorderMessage(2, "exception in ClientSideReader: " + e); >- csr.packetWriter.getAgentController().reportException(ClientSideReaderException,e); >- return false; >- } >- serverSideConnectionContext = ctx; >- >- //csr.packetWriter.writeRecorderMessage(1, "LEAVING connectToSecureServer() for connection: " + csr.iConnection); >- return true; >- } >- >- SSLSocket sslServer = null; >- SSLSocket spySocket = null; >- ClientSideReader csr = null; >- SSLSocket HTTPServerSocket = null; >- >- // ClientSideReaderHTTP csrHTTP = null; >- static final String SpySocketException = HttpRecResourceBundle.RECORDER_SSL_SPYSOCKET_EXCEPTION; >- static final String ClientSideReaderException = HttpRecResourceBundle.RECORDER_CLIENTSIDE_READER_EXCEPTION; >- >- // a call here means the client has issued a CONNECT statement to this proxy server >- // we will attempt to open a separate secure connection to the requested server on the >- // requested port >- public SSLCheckClass(ClientSideReader thisCSR, String testKeys) { >- super(); >- this.sslKeyFile = testKeys; >- csr = thisCSR; >- >- } >- >- /** >- * @param thisCSR >- * @deprecated >- */ >- public SSLCheckClass(ClientSideReader thisCSR) >- { >- this(thisCSR, "C:\\testkeys"); >- } >- >- public boolean createSSLSpyServerSocket(){ >- >- SSLSocketFactory ssf = null; >- SSLContext ctx = null; >- try { >- // set up key manager to do server authentication >- >- KeyManagerFactory kmf; >- KeyStore ks; >- char[] passphrase = "passphrase".toCharArray(); >- String vendor = System.getProperty("java.vm.vendor"); >- >- if ((vendor.indexOf("Sun")) >= 0){ >- // The following to use Sun JVM >- ctx = SSLContext.getInstance("TLS"); >- kmf = KeyManagerFactory.getInstance("SunX509"); >- } >- else{ >- // or use the following for the IBM JVM >- ctx = SSLContext.getInstance("SSL_TLS"); >- kmf = KeyManagerFactory.getInstance("IbmX509"); >- } >- >- ks = KeyStore.getInstance("jks"); >- >- // TODO Need better place for testkeys file >- if (sslKeyFile == null || sslKeyFile.length() == 0) >- sslKeyFile = "C:\\testkeys"; >- ks.load(new FileInputStream(sslKeyFile), passphrase); >- kmf.init(ks, passphrase); >- ctx.init(kmf.getKeyManagers(), null, null); >- ssf = ctx.getSocketFactory(); >- >- spySocket = (SSLSocket)ssf.createSocket(csr.client, >- "localhost", csr.client.getLocalPort(), true); >- spySocket.setUseClientMode(false); >- } >- catch (Exception e) { >- csr.packetWriter.writeRecorderMessage(2, "exception in creating SSL Spy Socket: " + e); >- csr.packetWriter.getAgentController().reportException(SpySocketException,e); >- return false; >- } >- //clientSideConnectionContext = ctx; >- return true; >- } >- // bugzilla 137958 modify the call to use a byte array and length, not a string >- public boolean makeSecureConnectionHTTP(byte[] proxyConnect, int proxyLength, String proxyAddr,int proxyPort, boolean diffSSLProxy) { >- boolean isOK = false; >- boolean sslConnectOK = false; >- if (proxyLength > 0) { >- // defect 79219 mdd >- if (diffSSLProxy) { >- sslConnectOK = connectToProxyServerSSL(proxyAddr, proxyPort); >- if (sslConnectOK == false) >- return false; >- // point buffers to correct place >- try { >- csr.to_server = csr.httpSSLServer.getOutputStream(); >- csr.from_server = csr.httpSSLServer.getInputStream(); >- } catch (Exception e) { >- csr.packetWriter.writeRecorderMessage(2, "exception in ClientSideReader : " + e + " Connection: " + csr.iConnection); >- csr.packetWriter.getAgentController().reportException(ClientSideReaderException,e); >- } >- // bugzilla 137958 modify the call to use a byte array and length, not a string >- isOK = sendConnectToProxyServer(proxyConnect, proxyLength); >- } >- else { >- // Send CONNECT string to HTTP Proxy Server >- // bugzilla 137958 modify the call to use a byte array >- isOK = sendConnectToProxyServer(proxyConnect, proxyLength); >- } >- if (!isOK) { >- return false; >- } >- >- // Now convert current httpServer Socket into SSL Socket >- >- //if ((connectToSecureServer(csr.destServer, csr.serverPort)) == true){ >- boolean conversionOK = false; >- conversionOK = convertHTTPServerConnectionToSSL(proxyAddr,proxyPort); >- if (conversionOK == true) { >- if ((createSSLSpyServerSocket()) == true) >- checkRightSideContexts(); >- csr.packetWriter.writeOpenSecureConnectionInfo(csr.bSecure,csr.iConnection, >- proxyAddr, proxyPort, csr.client,csr.httpServer, >- spySocket, sslServer,csr.sslCipherSuite,csr.sslProtocol); >- try { >- csr.to_client= spySocket.getOutputStream(); >- csr.from_client = spySocket.getInputStream(); >- // csr.client=(SSLSocket)spySocket; >- >- // these are the decrypted streams >- // new thing below - mdd >- csr.httpServer = HTTPServerSocket; >- csr.to_server = HTTPServerSocket.getOutputStream(); >- csr.from_server = HTTPServerSocket.getInputStream(); >- csr.bSecure = true; >- csr.secureConnectionOK = true; >- csr.serverReader = new ServerSideReader(csr.client, >- csr.httpServer, >- csr.from_server, >- csr.to_client, >- csr.packetWriter, >- //csr.iConnection, >- csr.connectionNumber, >- csr.bSecure, >- spySocket.getReceiveBufferSize()); >- csr.serverReader.start(); >- } >- catch (IOException e) { >- csr.packetWriter.writeRecorderMessage(2, "exception in creating SSL Spy Socket: " + e); >- csr.packetWriter.getAgentController().reportException(SpySocketException,e); >- return false; >- } >- } >- } >- csr.bNoPrintToServer = true; >- return csr.bSecure; >- } >- >- // bugzilla 137958 modify the call to use a byte array >- boolean sendConnectToProxyServer(byte[] sendBuffer, int bufferLength){ >- boolean isOK = false; >- // bugzilla 103181 >- int status = -1; >- boolean foundOK = false; >- boolean proxyAuthentication = false; >- if (bufferLength > 0) { >- // Send CONNECT string to HTTP Proxy Server >- try { >- >- byte[] ackBuffer = new byte[csr.httpServer.getReceiveBufferSize()]; >- >- csr.to_server.write(sendBuffer, 0, bufferLength); >- csr.to_server.flush(); >- int ackBytes_read = csr.from_server.read(ackBuffer); >- if (ackBytes_read > 0){ >- // check for status >- String statusLine = new String(ackBuffer, 0, ackBytes_read); >- // bugzilla 103181 mdd 7/26/2006 >- // also send 407 (proxy authentication ) through to the browser client >- status = getStatus(statusLine); >- if (status == 200) { >- //int findOK = statusLine.indexOf(" 200 "); >- foundOK = true; >- } >- // bugzilla 103181 mdd 7/26/2006 >- else if (status == 407){ >- proxyAuthentication = true; >- } >- // bugzilla 103181 mdd 7/26/2006 >- if (foundOK || proxyAuthentication == true){ >- // send OK to client >- csr.to_client.write(ackBuffer,0,ackBytes_read); >- csr.to_client.flush(); >- isOK = true; >- } >- else{ >- isOK = false; >- } >- } >- >- } catch (IOException e) { >- csr.packetWriter.writeRecorderMessage(2, "exception in makeSecureConnection(): " + e); >- csr.packetWriter.getAgentController().reportException(SpySocketException,e); >- return false; >- } >- } >- return isOK; >- } >- boolean convertHTTPServerConnectionToSSL(String proxyAddr, int proxyPort) { >- boolean convertOK = true; >- SSLSocketFactory ssf = null; >- SSLContext ctx; >- >- try { >- >- TrustManager[] myTM = new TrustManager [] {new RecorderX509TrustManager() }; >- //SSLContext ctx = SSLContext.getInstance("SSL"); >- ctx = SSLContext.getInstance("SSL"); >- ctx.init(null, myTM, null); >- ssf = ctx.getSocketFactory(); >- >- HTTPServerSocket = (SSLSocket)ssf.createSocket(csr.httpServer, >- csr.destServer, csr.serverPort,true); >- // proxyAddr, proxyPort, true); >- HTTPServerSocket.setUseClientMode(true); >- >- csr.httpServer = HTTPServerSocket; >- // Handshake begins automatically when data passed through socket >- //HTTPServerSocket.startHandshake(); >- } >- catch (Exception e) { >- csr.packetWriter.writeRecorderMessage(2, "exception in creating HTTPServer Spy Socket: " + e); >- csr.packetWriter.getAgentController().reportException(SpySocketException,e); >- return false; >- } >- serverSideConnectionContext = ctx; >- return convertOK; >- } >- public void checkRightSideContexts() { >- byte [] clientID; >- //Vector allServerSessions = new Vector(); >- Vector allClientSessions = new Vector(); >- //Vector allServerCipherSuites = new Vector(); >- //Vector allServerProtocols = new Vector(); >- Vector allClientCipherSuites = new Vector(); >- Vector allClientProtocols = new Vector(); >- >- // first check ServerSide >- SSLSessionContext serverClientSessionContext = serverSideConnectionContext.getClientSessionContext(); >- Enumeration clientE = serverClientSessionContext.getIds(); >- >- >- // Get all Sessions for ClientSideSessionContext >- for ( ; clientE.hasMoreElements(); ) { >- clientID = (byte [])clientE.nextElement(); >- allClientSessions.add(serverClientSessionContext.getSession(clientID)); >- } >- >- >- // Get all CipherSuites for ClientSideSessions >- int clientSessionsCount = allClientSessions.size(); >- for (int i = 0; i < clientSessionsCount; i++){ >- SSLSession tempSess = (SSLSession)allClientSessions.elementAt(i); >- allClientCipherSuites.add(tempSess.getCipherSuite()); >- allClientProtocols.add(tempSess.getProtocol()); >- } >- >- for (int i = 0; i < clientSessionsCount; i++){ >- // String tmpProtStr = "Protocol for Client Session "; >- // String tmpProtStr1 = " is : "; >- // String tmpCipherStr = ", CipherSuite is: "; >- >- String tmpProtocol = (String)allClientProtocols.get(i); >- String tmpCipher = (String) allClientCipherSuites.get(i); >- if (i == 0) { >- csr.sslProtocol = tmpProtocol; >- csr.sslCipherSuite = tmpCipher; >- //csr.packetWriter.writeRecorderMessage(1, "In CheckRightSide, Assign cipherSuite: " + csr.sslCipherSuite + " Protocol: " + csr.sslProtocol); >- } >- >- // csr.packetWriter.writeRecorderMessage(1, tmpProtStr + i + tmpProtStr1 + tmpProtocol + tmpCipherStr + tmpCipher); >- } >- // now set sslCipherSuite if not already set >- if ((csr.sslCipherSuite.length() > 0) && (csr.sslProtocol.length()) > 0) { >- //csr.packetWriter.writeRecorderMessage(1, "In CheckRightSide, ASSIGN NEW DEFAULTS cipherSuite: " + csr.sslCipherSuite + " Protocol: " + csr.sslProtocol); >- csr.defaultCipherSuite = csr.sslCipherSuite; >- csr.defaultProtocol = csr.sslProtocol; >- } >- else { >- csr.sslCipherSuite = csr.defaultCipherSuite; >- csr.sslProtocol = csr.defaultProtocol; >- //csr.packetWriter.writeRecorderMessage(1, "In CheckRightSide, USE DEFAULTS cipherSuite: " + csr.sslCipherSuite + " Protocol: " + csr.sslProtocol); >- } >- } >- private boolean connectToProxyServerSSL(String sslProxyAddr, int sslProxyPort) { >- boolean isConnected = false; >- // now must connect to IP address >- >- try { >- >- csr.httpSSLServer = new Socket(sslProxyAddr, sslProxyPort); >- if (csr.httpSSLServer != null) { >- //respondToClient(true); >- isConnected = true; >- csr.httpServer = csr.httpSSLServer; >- >- } >- else { >- isConnected = false; >- // TODO write error msg to log >- //respondToClient(false); >- csr.packetWriter.writeRecorderMessage(1, "Error connecting to Server:" + sslProxyAddr + " Port: "+sslProxyPort); >- } >- } catch (IOException ioe){ >- csr.packetWriter.writeRecorderMessage(1, "Error Connecting to Proxy Server:" + sslProxyAddr + ":" + sslProxyPort + ioe); >- } >- >- return isConnected; >- } >- private int getStatus(String statLine) { >- String CRNL = "\r\n"; >- String BLANK = " "; >- >- StringTokenizer bodyTokenizer = new StringTokenizer(statLine, CRNL); >- String statusLine = bodyTokenizer.nextToken(); >- // at this point have HTTP/1.1 407 Proxy Authentication Required >- StringTokenizer status = new StringTokenizer(statusLine, BLANK); >- status.nextToken(); // This is HTTP/1.1 >- String actualStatus = status.nextToken();// This is 200 or 302 or 301, etc... >- Integer intStat = new Integer(actualStatus); >- int actualVal = intStat.intValue(); >- >- return actualVal; >- } >-} >Index: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/ServerSideReader.java >=================================================================== >RCS file: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/ServerSideReader.java >diff -N src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/ServerSideReader.java >--- src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/ServerSideReader.java 2 May 2007 19:36:27 -0000 1.8 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,141 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: ServerSideReader.java,v 1.8 2007/05/02 19:36:27 paules Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >- >-/* >- * NONE OF THE QUOTED STRINGS IN THIS FILE ARE TO BE LOCALIZED >- * THEY ARE ALL FOR XML TAGS, DEBUGGING SUPPORT, THEY ARE NOT FOR USER INTERFACES >- */ >-package org.eclipse.hyades.execution.recorder.http.remote; >- >-import java.io.FileOutputStream; >-import java.io.InputStream; >-import java.io.OutputStream; >-import java.net.Socket; >- >-/** >- * This object is the server side reader class. It handles all http traffic >- * from the server and the data is passed through to the client (browser) >- * >- * @author dmorris >- * modified by: mddunn 11/17/2003 for Hyades-O 1.2 >- * @deprecated This is not public API. It will be moved to internal in TPTP 5 >- * >- */ >- >-public class ServerSideReader extends Thread{ >- InputStream from_server; >- OutputStream to_spySocket; >- InputStream from_sslPassThroughStream; >- OutputStream to_client; >- FileOutputStream to_file; >- PacketWriter packetWriter = null; >- boolean bSecure; >- boolean bClosedByClient = false; >- int iConnection = 0; >- int iReceiveBufSize = 0; >- Socket client; >- Socket server; >- ConnectionObj connectionNumber; >- byte[] ssrBuffer = null; >- >- ServerSideReader(Socket client, >- Socket server, >- InputStream from_server, >- OutputStream to_client, >- PacketWriter packetWriter, >- //int iConnection, >- ConnectionObj connectionNumber, >- boolean bSecure, >- int iReceiveBufSize){ >- >- this.client = client; >- this.server = server; >- this.from_server = from_server; >- this.to_client = to_client; >- this.packetWriter = packetWriter; >- this.bSecure = bSecure; >- this.iConnection = connectionNumber.getConnectionNumber(); >- this.connectionNumber = connectionNumber; >- this.iReceiveBufSize = iReceiveBufSize; >- >- } >- public void setClosedByClient(){ >- bClosedByClient = true; >- } >- >- public void run(){ >- >- //byte[] buffer = new byte[iReceiveBufSize]; >- ssrBuffer = new byte[iReceiveBufSize]; >- int bytes_read = 0; >- >- this.setName("ServerSideReader-Conn:"+iConnection); >- >- try{ >- // Try new statement below mdd >- //packetWriter.writeRecorderMessage(1, "IN SERVERSIDEREADER BEGIN READING... for Connection: " + iConnection ); >- while ((bytes_read = from_server.read(ssrBuffer)) >= 0){ >- >-/* to_client.write(ssrBuffer,0, bytes_read); >- to_client.flush();*/ >- // Defect 83619 mdd synch for write to socket and write to file >- packetWriter.writePacket(bSecure, false, this.connectionNumber, ssrBuffer, bytes_read, to_client, false); >- } >- } >- catch (NullPointerException npc) { >- packetWriter.writeRecorderMessage(1, "IN SERVERSIDEREADER CAUGHT NULLPOINTEREXCEPTION for Connection: " + iConnection ); >- } >- catch (Exception e) { >- //packetWriter.writeRecorderMessage(1, "IN SERVERSIDEREADER GETMESSAGE() for Connection: " + iConnection ); >- >- String mess = e.getMessage(); >- // no record for the following exceptions, they are expected >- >- if (mess.indexOf("Stream closed") < 0 && mess.indexOf("Socket closed") < 0 && >- mess.indexOf("JVM_recv in socket input") <0 && mess.indexOf("onnection closed")<0 >- && mess.indexOf("socket closed")<0 && mess.indexOf("onnection reset") < 0 >- && mess.indexOf("Socket is closed") <0) { >- packetWriter.writeRecorderMessage(2, "exception in ServerSideReader connection " + iConnection + " : " + e.toString()); >- } >- >- } >- finally { >- try { >- // if the server we are connected to terminated the connection, close the client side also >- // if the client closed the connection, just exit >- // New stuff 042204 >- >- server.close(); >- //packetWriter.writeRecorderMessage(1, "WRITE CLOSE CONNECTION for SERVERSIDEREADER Input Side " + iConnection ); >- packetWriter.writeCloseConnectionInfo(connectionNumber); >- // MAY NEED if (!bClosedByClient) >- // client.close(); >- if (client != null) { >- if ((!client.isOutputShutdown()) && !client.isClosed() ) >- { >- client.shutdownOutput(); >- //packetWriter.writeRecorderMessage(1, "SHUTDOWN CLIENT OUTPUT IN SERVERSIDEREADER FOR Connection: " + iConnection ); >- } else { >- //packetWriter.writeRecorderMessage(1, "CLIENT WAS ALREADY CLOSED IN SERVERSIDEREADER FOR Connection: " + iConnection ); >- } >- } else { >- //packetWriter.writeRecorderMessage(1, "CLIENT WAS NULL IN SERVERSIDEREADER FOR Connection: " + iConnection ); >- } >- } >- catch (Exception e){ >- packetWriter.writeRecorderMessage(2, "exception in ServerSideReader executing finally block connection " + iConnection + " : " + e.toString()); >- >- } >- } >- //packetWriter.writeRecorderMessage(1, "LEAVING SERVERSIDEREADER " + iConnection ); >- } >-} >Index: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/ClientSideReader.java >=================================================================== >RCS file: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/ClientSideReader.java >diff -N src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/ClientSideReader.java >--- src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/ClientSideReader.java 26 Apr 2007 20:49:12 -0000 1.11 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,204 +0,0 @@ >-/*``````````````````````````````````````````````````````````````/********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: ClientSideReader.java,v 1.11 2007/04/26 20:49:12 paules Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >- >-/* >- * NONE OF THE QUOTED STRINGS IN THIS FILE ARE TO BE LOCALIZED >- * THEY ARE ALL FOR XML TAGS, DEBUGGING SUPPORT, THEY ARE NOT FOR USER INTERFACES >- */ >-package org.eclipse.hyades.execution.recorder.http.remote; >- >-import java.io.File; >-import java.io.InputStream; >-import java.io.OutputStream; >-import java.lang.reflect.Constructor; >-import java.lang.reflect.Field; >-import java.net.InetAddress; >-import java.net.Socket; >- >-/** >- * This object is the base client side reader class. It should be extended by specific >- * reader such as SOCKS or HTTP. It reads from the client (browswer) >- * >- * @author dmorris >- * modified by: mddunn 11/17/2003 for Hyades-O 1.2 >- * @deprecated This is not public API. It will be moved to internal in TPTP 5 >- * >- */ >-abstract public class ClientSideReader extends Thread{ >- >- public static final String ERROR_SSL_REQUEST_MADE = "-1"; //this is an error until SSL is supported >- public static final String ERROR_NO_TESTKEYS = "-2"; //this is an error until SSL is supported >- static final String STR_KEEP_ALIVE = "Proxy-Connection: Keep-Alive\r\n"; >- static int iConn = 0; >- static final String ClientSideReaderException = HttpRecResourceBundle.RECORDER_CLIENTSIDE_READER_EXCEPTION; >- String defaultCipherSuite = "SSL_RSA_WITH_RC4_128_MD5"; >- String defaultProtocol = "TLSv1"; >- >- InputStream from_client; >- OutputStream to_client; >- InputStream from_server; >- OutputStream to_server; >- //Socket client = null; >- PeekSocket client = null; >- Socket httpServer = null; >- // bugzilla 79219 mdd >- Socket httpSSLServer = null; >- ServerSideReader serverReader = null; >- // this flag indicates whether we are operating an SSL connection >- boolean bSecure = false; >- boolean bNoPrintToServer = false; >- PacketWriter packetWriter = null; >- boolean secureConnectionOK = false; >- >- String destServer = null; >- String keyFile = null; >- int serverPort = 80; >- int iConnection = 0; >- ConnectionObj connectionNumber = new ConnectionObj(); >- static int isSSLClassAvailable = -1; >- static boolean foundTestKeys = false; >- // new SSL info >- String sslCipherSuite = ""; >- String sslProtocol = ""; >- InetAddress newAddr = null; >- int destPort = 0; >- >- >- /** >- * Old constructor to keep old support. Not intended for new readers. Use ClientSideReader(PeekSocket, PacketWriter, String) >- * @param client >- * @param packetWriter >- * @deprecated >- */ >- ClientSideReader(PeekSocket client, PacketWriter packetWriter) >- { >- this(client, packetWriter, "C:\\testkeys"); >- } >- >- ClientSideReader(PeekSocket client, PacketWriter packetWriter, String keyFile){ >- try{ >- this.from_client = client.getInputStream(); >- this.to_client = client.getOutputStream(); >- this.client = client; >- this.iConnection = getNextConnection(); >- this.connectionNumber.setConnectionNumber(iConnection); >- this.packetWriter = packetWriter; >- this.keyFile = keyFile; >- packetWriter.writeRecorderMessage(1, "Client Connected, connection " + iConnection ); >- packetWriter.writeConnectConnectionInfo(iConnection ); >- >- } >- catch (Exception e){ >- packetWriter.writeRecorderMessage(2, "exception in ClientSideReader: " + e); >- packetWriter.getAgentController().reportException(ClientSideReaderException,e); >- } >- >- } >- ClientSideReader(){ >- >- } >- synchronized static int getNextConnection(){ >- iConn++; >- return iConn; >- } >- >- abstract public void run(); >- >- >- >-// private static String IP4ByteToString (byte myvar[]) { >-// String strResult = ""; >-// for (int i = 0; i < 4; i++) { >-// if ((int)myvar[i] >= 0) { >-// strResult += String.valueOf((int)myvar[i]); >-// } else { >-// strResult += String.valueOf(256 + (int)myvar[i]); >-// } >-// if (i < 3) { >-// strResult += "."; >-// } >-// } >-// return strResult; >-// } >- >- public int findSSLClass() { >- int gotSSL = -1; >- >- try{ >- Class.forName("javax.net.ssl.SSLSocket"); >- gotSSL = 1; >- } >- catch (ClassNotFoundException cnf){ >- gotSSL = 0; >- } >- return gotSSL; >- } >- >- public boolean checkForTestKeys() { >- if (keyFile == null || keyFile.length() == 0) >- keyFile = "C:\\testkeys"; >- boolean foundIt = false; >- File keysFile = new File(keyFile); >- foundIt = keysFile.exists(); >- return foundIt; >- } >- >- >- /** >- * This method creates a socket. If called from a 1.4 JRE, the no-arg >- * Socket() constructor is used. If called from a Java 5 JRE, we >- * reflectively call the Socket(Proxy) constructor with Proxy.NO_PROXY >- * as the argument. >- * >- * This is done becaust the Default Socket on 1.5+ does a Reverse DNS Lookup >- * on every new socket created. Much overhead for recording. >- * >- * @return an unconnected Socket. >- */ >- Socket createPlainSocket() { >- Socket socket = null; >- >- // Determine if the Socket(Proxy) constructor exists >- // (it was new in Java 5.) >- Class socketClass = Socket.class; >- Constructor[] constructors = socketClass.getDeclaredConstructors(); >- >- try { >- Class proxyClass = Class.forName("java.net.Proxy"); >- >- for (int i=0; i<constructors.length; i++) { >- Constructor cons = constructors[i]; >- Class[] params = cons.getParameterTypes(); >- if (params.length == 1 && params[0] == proxyClass) { >- // Get the NO_PROXY static field from the Proxy class >- Field noproxyField = proxyClass. >- getDeclaredField("NO_PROXY"); //$NON-NLS-1$ >- Object noproxy = noproxyField.get(null); >- >- // Call the Socket(Proxy) constructor >- socket = (Socket) cons.newInstance(new Object[]{noproxy}); >- break; >- } >- } >- } >- catch (Exception e) { >- // If an exception was thrown, it means we're not in Java 5. >- // Ignore the exception and create the socket the old fashioned way. >- } >- >- if ( socket == null ) >- socket = new Socket(); >- >- return socket; >- } >- >-} >\ No newline at end of file >Index: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/ClientSideReaderHTTP.java >=================================================================== >RCS file: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/ClientSideReaderHTTP.java >diff -N src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/ClientSideReaderHTTP.java >--- src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/ClientSideReaderHTTP.java 26 Apr 2007 20:56:11 -0000 1.12 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,340 +0,0 @@ >-/*``````````````````````````````````````````````````````````````/********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: ClientSideReaderHTTP.java,v 1.12 2007/04/26 20:56:11 paules Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >- >-/* >- * NONE OF THE QUOTED STRINGS IN THIS FILE ARE TO BE LOCALIZED >- * THEY ARE ALL FOR XML TAGS, DEBUGGING SUPPORT, THEY ARE NOT FOR USER INTERFACES >- */ >-package org.eclipse.hyades.execution.recorder.http.remote; >- >-import java.io.IOException; >-import java.net.InetSocketAddress; >- >-/** >- * This class extends the ClientSideReader class. This class handles the specific >- * transactions when the browser is 'talking' HTTP protocol. >- * >- * @author dmorris >- * modified by: mddunn 11/17/2003 for Hyades-O 1.2 >- * @deprecated This is not public API. It will be moved to internal in TPTP 5 >- * >- */ >-public class ClientSideReaderHTTP extends ClientSideReader { >- >- public static final String ERROR_SSL_REQUEST_MADE = "-1"; //this is an error until SSL is supported >- public static final String ERROR_NO_TESTKEYS = "-2"; //this is an error until SSL is supported >- static final String STR_KEEP_ALIVE = "Proxy-Connection: Keep-Alive\r\n"; >- static int iConn = 0; >- static final String ClientSideReaderException = HttpRecResourceBundle.RECORDER_CLIENTSIDE_READER_EXCEPTION; >- >- String iProxyAddr = ""; >- int iProxyPort = 0; >- boolean secureConnectionOK = false; >- // try this mdd >- boolean didOpenConnection = false; >- boolean wroteOnePacket = false; >- // defect 79219 mdd >- String iSSLProxyAddr = ""; >- int iSSLProxyPort = 0; >- >- ClientSideReaderHTTP(PeekSocket client, PacketWriter packetWriter, >- String keyFile, String proxyAddr, int proxyPort){ >- super(client,packetWriter, keyFile); >- iProxyAddr = proxyAddr; >- iProxyPort = proxyPort; >- } >- >- ClientSideReaderHTTP(PeekSocket client, PacketWriter packetWriter, >- String keyFile, String proxyAddr, int proxyPort, String sSLProxyAddr, int sSLProxyPort){ >- super(client,packetWriter, keyFile); >- iProxyAddr = proxyAddr; >- iProxyPort = proxyPort; >- iSSLProxyAddr = sSLProxyAddr; >- iSSLProxyPort = sSLProxyPort; >- } >- >- public void run(){ >- >- int bytes_read = 0; >- boolean isConnected = false; >- >- if (isSSLClassAvailable == -1) { >- isSSLClassAvailable = findSSLClass(); >- if (isSSLClassAvailable == 1) { >- foundTestKeys = checkForTestKeys(); >- } >- } >- >- this.setName("ClientSideReaderHTTP-"+"Conn:"+iConnection+":"+iProxyAddr+":"+iProxyPort); >- try { >- >- byte[] buffer = new byte[client.getReceiveBufferSize()]; >- >- isConnected = connectToProxyServer(); >- >- if (isConnected ) { >- while ((bytes_read = from_client.read(buffer)) != -1){ >- boolean isConnectRequest = false; >- >- yield(); >- bNoPrintToServer = false; >- >- if (buffer[0] == 'C') { >- String str = new String(buffer, 0, bytes_read); >- isConnectRequest = checkForSSLRequest(str); >- } >- wroteOnePacket = true; >- // If bSecure is set to true, leave it alone >- >- if (isConnectRequest){ >- if (isSSLClassAvailable == 1) { >- if (foundTestKeys) { >- SSLCheckClass thisSSLCheck = new SSLCheckClass(this, keyFile); >- to_server = httpServer.getOutputStream(); >- from_server = httpServer.getInputStream(); >- if (iSSLProxyAddr.length()> 0 && iSSLProxyPort > 0) { >- // defect 79219 last parameter 'true' means we are using a different Proxy for SSL >- // bugzilla 137958 modify the call to use a byte array >- thisSSLCheck.makeSecureConnectionHTTP(buffer, bytes_read, iSSLProxyAddr, iSSLProxyPort, true); >- } >- else { >- // bugzilla 137958 modify the call to use a byte array >- thisSSLCheck.makeSecureConnectionHTTP(buffer,bytes_read, iProxyAddr, iProxyPort, false); >- } >- } >- else { >- // send message to UI >- packetWriter.getAgentController().sendControlMessageToDataProcessor(ERROR_NO_TESTKEYS); >- return; >- } >- } >- } >- >- // if (!bSecure) >- if (!bSecure && !didOpenConnection ) >- makeRegularConnection(); >- >- // Defect 83619 mdd synch for write to socket and write to file >- packetWriter.writePacket(bSecure, true, connectionNumber, buffer, bytes_read, to_server, bNoPrintToServer); >- } >- } // isConnected is true >- >- // mdd this moved to serversidereader >- //packetWriter.writeCloseConnectionInfo(iConnection); >- if (httpServer != null){ >- httpServer.setSoLinger(false,0); >- if (!wroteOnePacket) { >- if (! httpServer.isClosed()) { >- //packetWriter.writeRecorderMessage(1, "IN CLIENTSIDEREADER A1 - CLOSED SERVERSIDE COnnection: " + iConnection); >- httpServer.close(); >- } >- } >- else if (! httpServer.isOutputShutdown()){ >- if (bSecure) { >- //packetWriter.writeRecorderMessage(1, "IN CLIENTSIDEREADER A WRITING SSL CLOSE ALERT for COnnection: " + iConnection); >- to_server.flush(); >-// // Bugzilla defect 78832 mdd >- httpServer.close(); >- } else { >- httpServer.shutdownOutput(); >- //packetWriter.writeRecorderMessage(1, "IN CLIENTSIDEREADER A - SHUTDOWN SERVERSIDE OUTPUT for COnnection: " + iConnection); >- } >- } >- // mdd tell Server reader we are closed >- if (serverReader != null) >- serverReader.setClosedByClient(); >- } >- >- } >- catch (Exception e) { >- // mdd add check >- /* OLD WAY >- if (!httpServer.isClosed()) >- packetWriter.writeCloseConnectionInfo(iConnection); >- try { >- if (httpServer != null) { >- if (!httpServer.isClosed()) >- httpServer.close(); >- // mdd tell Server reader we are closed >- if (serverReader != null) >- serverReader.setClosedByClient(); >- } >- } >- catch (IOException ioe){ >- packetWriter.writeRecorderMessage(2, "IOException in ClientSideReader connection " + iConnection + ": " + ioe); >- } */ >- // NEW WAY >- //packetWriter.writeRecorderMessage(1, "JUST CAUGHT AN EXCEPTION In ClientSideReader connection " + iConnection + " Exception: " +e.getLocalizedMessage() ); >- >- try { >- if (httpServer != null) { >- //if (!httpServer.isClosed()) >- // httpServer.close(); >- if (!wroteOnePacket) { >- if (! httpServer.isClosed()) { >- //packetWriter.writeRecorderMessage(1, "IN CLIENTSIDEREADER B1 - CLOSED SERVERSIDE COnnection: " + iConnection); >- httpServer.close(); >- } >- } else if (!httpServer.isOutputShutdown()){ >- if (bSecure) { >- //packetWriter.writeRecorderMessage(1, "IN CLIENTSIDEREADER B WRITING SSL CLOSE ALERT for COnnection: " + iConnection); >- to_server.flush(); >- // Bugzilla defect 78832 mdd >- httpServer.close(); >- } else { >- httpServer.shutdownOutput(); >- //packetWriter.writeRecorderMessage(1, "IN CLIENTSIDEREADER B - SHUTDOWN SERVERSIDE OUTPUT for COnnection: " + iConnection); >- } >- } >- // mdd tell Server reader we are closed >- // add check for null 032204 >- //if (serverReader != null) >- // MAT NEED serverReader.setClosedByClient(); >- } >- >- yield(); >- >- } >- catch (IOException ioe){ >- String mess = ioe.getMessage(); >- // no record for the following exceptions, they are expected >- >- if (mess.indexOf("Stream closed") < 0 && mess.indexOf("Socket closed") < 0 && >- mess.indexOf("JVM_recv in socket input") <0 && mess.indexOf("onnection closed")<0 >- && mess.indexOf("socket closed")<0 && mess.indexOf("onnection reset") < 0 >- && mess.indexOf("Socket is closed") <0) { >- packetWriter.writeRecorderMessage(2, "IOException in ClientSideReader connection " + iConnection + " : " + e.toString()); >- } >- } >- // NEW WAY >- } >- >- } >- >- >- private boolean connectToProxyServer() { >- boolean isConnected = false; >- // now must connect to IP address >- >- try { >- // This next line ensures we get a "plain" socket which does not do Reverse DNS LookUp >- httpServer = createPlainSocket(); >- InetSocketAddress epoint = new InetSocketAddress(iProxyAddr, iProxyPort); >- httpServer.connect(epoint); >- >- if (httpServer != null) { >- //respondToClient(true); >- isConnected = true; >- } >- else { >- isConnected = false; >- // TODO write error msg to log >- //respondToClient(false); >- packetWriter.writeRecorderMessage(1, "Error connecting to Server:" + destServer + " Port: "+serverPort); >- } >- } catch (IOException ioe){ >- packetWriter.writeRecorderMessage(1, "Error Connecting to Proxy Server:" + iProxyAddr + ":" + iProxyPort + ioe); >- } >- >- return isConnected; >- } >- >-// private void respondToClient(boolean flag) { >-// byte[] reply_buff = new byte[8]; >-// >-// reply_buff[0] = 0; >-// if (flag == true){ >-// reply_buff[1] = 90; >-// } >-// else { >-// reply_buff[1] = 91; >-// } >-// try { >-// to_client.write(reply_buff,0, 8); >-// to_client.flush(); >-// } catch (Exception e){ >-// } >-// } >- >- private boolean checkForSSLRequest(String request) { >- boolean returnCode = false; >- int index; >- // when a client connects to a proxy for SSL, we get a string of the following form from the client: >- // CONNECT whateverssl.server.com:443\r\n >- // that is the string we must parse to do the SSL connection >- if ((index = request.indexOf("CONNECT ")) >= 0){ >- // code here to connect to SSL server >- int indexEnd; >- returnCode = true; >- index += 8; // go past the word CONNECT + space >- if ((indexEnd = request.indexOf(":", index)) > index){ >- String destStr = request.substring(index, indexEnd); >- // now we have server string to go to in destStr, get the port >- index = indexEnd + 1; // next character after the colon >- if ((indexEnd = request.indexOf(" ", index)) > index){ >- int port; >- String portStr = request.substring(index, indexEnd); >- // now we have the port >- port = Integer.parseInt(portStr); >- // now we can try to connect to the secure port >- destServer = destStr; >- serverPort = port; >- //packetWriter.writeOpenConnectionInfo(bSecure, iConnection, destStr, port, client, httpServer, null, null); >- } >- } >- } >- return returnCode; >- } >- >- private String makeRegularConnection( ){ >- >- String strReturn = null; >- //int index; >- //int port = 80; >- //String destStr = null; >- //boolean bFoundMessage = false; >- >- try{ >- // Note : already have open port to server >- packetWriter.writeOpenConnectionInfo(bSecure, iConnection, iProxyAddr, iProxyPort, client, httpServer, null, null); >- >- to_server = httpServer.getOutputStream(); >- from_server = httpServer.getInputStream(); >- >- serverReader = new ServerSideReader(client, >- httpServer, >- from_server, >- to_client, >- packetWriter, >- connectionNumber, >- bSecure, >- httpServer.getReceiveBufferSize()); >- serverReader.start(); >- >- } >- catch (Exception e){ >- packetWriter.writeRecorderMessage(2, "exception in ClientSideReader: " + e); >- packetWriter.getAgentController().reportException(ClientSideReaderException,e); >- packetWriter.writeCloseConnectionInfo(connectionNumber); >- try { >- client.close(); >- strReturn = null; >- } >- catch (IOException ioe){ >- packetWriter.writeRecorderMessage(2, "IOException in ClientSideReader connection " + iConnection + ": " + ioe); >- } >- } >- didOpenConnection = true; >- return strReturn; >- } >- >-} >\ No newline at end of file >Index: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/TimeStampDispatcher.java >=================================================================== >RCS file: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/TimeStampDispatcher.java >diff -N src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/TimeStampDispatcher.java >--- src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/TimeStampDispatcher.java 2 May 2007 19:36:27 -0000 1.5 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,34 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: TimeStampDispatcher.java,v 1.5 2007/05/02 19:36:27 paules Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >-package org.eclipse.hyades.execution.recorder.http.remote; >- >-/** >- * This class creates the time stamp for each packet of information written to the >- * .rec file. >- * >- * @author morris >- * @deprecated This is not public API. It will be moved to internal in TPTP 5 >- */ >-public final class TimeStampDispatcher { >- static long refTimeStamp = System.currentTimeMillis(); >- >- synchronized static long getTimeStamp(){ >- long currTime = System.currentTimeMillis(); >- // the returned value will be the time in milliseconds since the recorder started >- return (currTime - refTimeStamp); >- } >- // method for convenience in case it is needed. >- synchronized static void resetRefTimeStamp(){ >- refTimeStamp = System.currentTimeMillis(); >- } >- >-} >Index: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/GlobalPacketQueue.java >=================================================================== >RCS file: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/GlobalPacketQueue.java >diff -N src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/GlobalPacketQueue.java >--- src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/GlobalPacketQueue.java 26 Apr 2007 18:49:54 -0000 1.6 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,172 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: GlobalPacketQueue.java,v 1.6 2007/04/26 18:49:54 paules Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.hyades.execution.recorder.http.remote; >-import java.util.Collection; >-import java.util.Iterator; >-import java.util.LinkedList; >-import java.util.MissingResourceException; >- >-/** >- * This class is used to hold a linked list of strings that represent the data >- * obtained from listening to the http data going from browser to server and >- * server to browser. That data is then used to generate XML fragments and then >- * encapsulated in strings. The generated strings are put on this 'queue' in real time, >- * and a separated process pulls the strings off the queue and writes them to the .rec file >- * when no other activity is taking place. >- * >- * @author mdunn >- * @deprecated This is not public API. It will be moved to internal in TPTP 5 >- * >- */ >-public class GlobalPacketQueue extends Thread { >- >- static boolean NOTIFY_ON_ADD = false; >- >- /** >- * Milliseconds to wait for inactivity. >- */ >- static long PACKET_WAIT_TOLERANCE = 500; >- >- >- static { >- try { >- String strValue = HttpRecResourceBundle.RECORDER_NOTIFY_ON_ADD; >- if (strValue.compareToIgnoreCase("TRUE") == 0) { >- NOTIFY_ON_ADD = true; >- } >- } catch (MissingResourceException e) { >- // Use default option >- } >- >- try { >- String strValue = HttpRecResourceBundle.RECORDER_PACKET_WAIT_TOLERANCE; >- PACKET_WAIT_TOLERANCE = Long.parseLong(strValue); >- } catch (Exception e) { >- // Use default option >- } >- >- } >- >- protected PacketWriter packetWriter; >- protected boolean shuttingDown = false; >- protected long timeOfLastPackedAdd = 0L; >- >- public GlobalPacketQueue (PacketWriter writer) { >- packetWriter = writer; >- } >- >- public void initiateShutdown () { >- shuttingDown = true; >- synchronized (this) { >- notify(); >- } >- } >- >- public void run () { >- this.setName("PacketQueueWriter"); >- //packetWriter.writeRecorderMessage(1,"IN GlobalPacketQueue.run(), PACKET_WAIT_TOLERANCE is: " + PACKET_WAIT_TOLERANCE); >- while (!shuttingDown) { >- synchronized (this) { >- if (packetQueue.size() == 0) { >- //If nothing on queue, wait for another thread to enqueue a packet >- try { >- wait(); >- } catch (InterruptedException e) { >- //no problem >- } >- } >- } >- removeAndWrite (); >- Thread.yield(); >- } >- removeAndWrite(); >- } >- >- >- protected void removeAndWrite () { >- Collection packetsCollection = removeAll(); >- if (packetsCollection != null) { >- Iterator iter = packetsCollection.iterator(); >- while (iter.hasNext()) { >- byte[] bytePacket = (byte[])iter.next(); // get rid of refer >- >- // only write packet when no activity has >- // occurred in a while >- waitForInactivity (); >- >- packetWriter.sendToDataProcessor (bytePacket); >- Thread.yield(); >- } >- } >- } >- >- /** >- * Sleep until no packet has been added for PACKET_WAIT_TOLERANCE >- * from the previous packet add. >- */ >- protected void waitForInactivity () { >- long lastUpdate, curTime, nextCheckTime; >- while (true) { >- curTime = System.currentTimeMillis(); >- lastUpdate = timeOfLastPackedAdd; >- nextCheckTime = lastUpdate + PACKET_WAIT_TOLERANCE; >- if (nextCheckTime > curTime) { >- try { >- Thread.sleep(nextCheckTime - curTime); >- } catch (InterruptedException e) { >- // doesn't matter >- } >- } else { >- break; >- } >- } >- } >- >- protected LinkedList packetQueue = new LinkedList(); >- >- public void add (byte buf[], int offset, int len) { >- byte[] tmpBuff = new byte[len]; >- System.arraycopy(buf,offset,tmpBuff,0,len); >- synchronized (this) { >- packetQueue.addLast(tmpBuff); >- timeOfLastPackedAdd = System.currentTimeMillis(); >- if (NOTIFY_ON_ADD) { >- notify(); >- } >- } >- } >- >- public void add (String thisPacket) { >- byte []buf = thisPacket.getBytes(); >- add (buf, 0, thisPacket.length()); >- } >- /** >- * Returns the LinkedList representing the queue and >- * creates a new LinkedList to represent the queue. >- * Returns null if no items are currently in the queue. >- * >- * @return LinkedList representing the queue. >- */ >- public Collection removeAll () { >- LinkedList workToDo = null; >- synchronized (this) { >- if (packetQueue.size() == 0) { >- workToDo = null; >- } else { >- workToDo = packetQueue; >- packetQueue = null; >- packetQueue = new LinkedList(); >- } >- } >- return workToDo; >- } >-} >\ No newline at end of file >Index: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/PeekSocket.java >=================================================================== >RCS file: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/PeekSocket.java >diff -N src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/PeekSocket.java >--- src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/PeekSocket.java 2 May 2007 19:36:27 -0000 1.5 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,61 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: PeekSocket.java,v 1.5 2007/05/02 19:36:27 paules Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >-package org.eclipse.hyades.execution.recorder.http.remote; >-import java.io.BufferedInputStream; >-import java.io.IOException; >-import java.io.InputStream; >-import java.net.Socket; >- >-/** >- * @author ptasnik@us.ibm.com >- * @deprecated This is not public API. It will be moved to internal in TPTP 5 >- * Created on Oct 14, 2003 >- * >- * Only designed currently to peek on read side of sockets >- * created from PeekServerSocket, could be changed to make >- * peek available from read side of client. >- */ >-public class PeekSocket extends Socket { >- >- public PeekSocket() { >- super(); >- } >- >- protected BufferedInputStream m_BufferedIn = null; >- protected synchronized void setupBufferedInputStream () throws IOException { >- // >- // Better be connected or we are screwed >- // >- if (m_BufferedIn == null) { >- m_BufferedIn = new BufferedInputStream (super.getInputStream()); >- } >- } >- >- public InputStream getInputStream() throws IOException { >- setupBufferedInputStream (); >- return (m_BufferedIn); >- } >- >- // >- // peek - method will block >- // >- public int peek () throws IOException { >- int peekbyte = 0; >- BufferedInputStream in = (BufferedInputStream)getInputStream(); >- >- in.mark (1); >- peekbyte = in.read(); >- in.reset (); >- >- return peekbyte; >- } >-} >Index: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/SSLProxyRecorder.java >=================================================================== >RCS file: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/SSLProxyRecorder.java >diff -N src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/SSLProxyRecorder.java >--- src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/SSLProxyRecorder.java 3 May 2007 01:34:39 -0000 1.12 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,439 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: SSLProxyRecorder.java,v 1.12 2007/05/03 01:34:39 paules Exp $ >- * >- * Contributors: >- * IBM - Initial API and implementation >- **********************************************************************/ >-/* >- * NONE OF THE QUOTED STRINGS IN THIS FILE ARE TO BE LOCALIZED >- * THEY ARE ALL FOR XML TAGS, DEBUGGING SUPPORT, THEY ARE NOT FOR USER INTERFACES >- */ >- >-/* >- * Created on Jun 21, 2003 >- * >- * To change this generated comment go to >- * Window>Preferences>Java>Code Generation>Code and Comments >- */ >-package org.eclipse.hyades.execution.recorder.http.remote; >- >-import java.io.IOException; >-import java.io.PrintWriter; >-import java.io.StringWriter; >-import java.io.Writer; >-import java.net.SocketException; >- >-import org.eclipse.hyades.execution.recorder.remote.RecorderAgent; >-import org.eclipse.hyades.internal.execution.recorder.remote.RecorderAgentController; >- >-/** >- * This is the main class for the HTTP Proxy Recorder >- * >- * @author morris >- * @deprecated This is not public API. It will be moved to internal in TPTP 5 >- */ >- >-public class SSLProxyRecorder extends RecorderAgent >-{ >- static int iProxyRecorderPort = 0; >- static Proxy proxy = null; >- // mdd Hyades 1.3 HTTP Proxy >- static String strProxyType = ""; >- static String strProxyAddr = ""; >- static int iProxyPort = 0; >- // defect 79219 mdd >- static String strSSLProxyAddr = ""; >- static int sslIProxyPort = 0; >- public static final String ERROR_CREATING_CLIENTSIDEREADER = "-3"; >- // mdd >- static String strProxyOverride = ""; >- static String strProxyAutoConfigURL = ""; >- >- //jn >- static String strKeyFile = "C:\\testkeys"; >- private static boolean bFinished = false; >- >- static final String ErrorStartingRecorder = HttpRecResourceBundle.RECORDER_ERR_STARTING; >- static final String StartingRecorder = HttpRecResourceBundle.RECORDER_STARTING_SSLPROXYRECORDER; >- static final String ListeningToPort = HttpRecResourceBundle.RECORDER_LISTENING_TO_PORT; >- static final String SocketBindError = HttpRecResourceBundle.RECORDER_BIND_ERROR; >- static final String CSRCreateError = HttpRecResourceBundle.RECORDER_CREATING_CLIENTSIDEREADER; >- static final String TooManyBindErrors = HttpRecResourceBundle.RECORDER_TOO_MANY_BIND_ERROR; >- >- >- public static void main(String[] args) >- { >- new SSLProxyRecorder().run(); >- >- } >- >- public Thread run() >- { >- >- try >- { >- sendDebugMessageToDataProcessor(StartingRecorder); >- proxy = new Proxy(this, controller); >- proxy.start(); >- sendDebugMessageToDataProcessor(ListeningToPort + iProxyRecorderPort); >- >- } >- >- catch (Exception e){ >- controller.reportException(ErrorStartingRecorder + e.getMessage(), e); >- System.err.println(e); >- System.exit(1); >- } >- >- setIsReady(true); >- return proxy; >- } >- >- >- static PacketWriter packetWriter = null; >- >- /** >- * This is the inner class for the HTTP Proxy Recorder >- * >- * @author morris >- * @deprecated This is not public API. It will be moved to internal in TPTP 5 >- */ >- public static class Proxy extends Thread >- { >- String host; >- RecorderAgent agent = null; >- RecorderAgentController controller = null; >- PeekServerSocket serversocket = null; >- Thread packetQueueThread = null; >- >- public Proxy(RecorderAgent agent, RecorderAgentController controller) >- { >- this.setName("Proxy"); >- this.agent = agent; >- this.controller = controller; >- packetWriter = new PacketWriter(agent); >- >- packetWriter.writeRecorderStartInfo(iProxyRecorderPort, >- strProxyAddr, iProxyPort, strSSLProxyAddr, sslIProxyPort); >- >- packetWriter.writeRecorderBrowserConfigInfo(iProxyRecorderPort, >- strProxyAddr, iProxyPort, strSSLProxyAddr, sslIProxyPort,strProxyOverride, strProxyAutoConfigURL); >- } >- >- public void run() { >- //ServerSocket serversocket = null; >- >- int numTries = 0; >- >- try{ >- >- //serversocket = new ServerSocket(iProxyRecorderPort); >- >- try { >- // to test throw new Exception ("bind IN USE"); >- >- serversocket = new PeekServerSocket(iProxyRecorderPort); >- serversocket.setSoTimeout(600000); >- } catch (IOException listen_exception) { >- //TODO tell user about error in eclipse >- this.agent.sendDebugMessageToDataProcessor(CSRCreateError + " Port: " + iProxyRecorderPort); >- packetWriter.writeRecorderMessage(2, CSRCreateError + " Exception: " +getStackTraceInfo (listen_exception)); >- //sendStatusMessageToControlView(CSRCreateError); >- agent.reportException(CSRCreateError,listen_exception); >- throw listen_exception; >- } >- >- while (!bFinished){ >- ClientSideReader cli_reader; >- >- try{ >- //Socket client = serversocket.accept(); >- >- PeekSocket client = serversocket.acceptPeekSocket(); >- if (strProxyType.equalsIgnoreCase("http")) { >- if (strSSLProxyAddr.length() > 0 && sslIProxyPort > 0){ >- cli_reader = new ClientSideReaderHTTP(client, packetWriter, strKeyFile, >- strProxyAddr, iProxyPort, strSSLProxyAddr ,sslIProxyPort); >- } else { >- cli_reader = new ClientSideReaderHTTP(client, packetWriter, strKeyFile, >- strProxyAddr, iProxyPort); >- } >- } >- else { >- cli_reader = new ClientSideReaderSOCKS(client, packetWriter, strKeyFile, iProxyRecorderPort); >- } >- cli_reader.start(); >- } catch (Exception e) { >- if (numTries >= 10){ >- throw new Exception (TooManyBindErrors); >- } >- numTries += 1; >- >- String mess = e.getLocalizedMessage(); >- // no record for the following exceptions, they are expected >- >- if (mess.indexOf("Stream closed") < 0 && mess.indexOf("Socket closed") < 0 && >- mess.indexOf("JVM_recv in socket input") <0 && mess.indexOf("onnection closed")<0 >- && mess.indexOf("socket closed")<0 && mess.indexOf("onnection reset") < 0 >- && mess.indexOf("Socket is closed") <0) { >- //PRINT THESE TO ECLIPSE TOO >- this.agent.sendDebugMessageToDataProcessor(SocketBindError + iProxyRecorderPort + " Exception: " + getStackTraceInfo(e)); >- packetWriter.writeRecorderMessage(2, SocketBindError + iProxyRecorderPort + " Exception: " + getStackTraceInfo (e)); >- } >- >- //controller.stopRecording(); >- >- } >- } >- >- } catch (Exception e) { >- >- //controller.sendCompleteNotification(); >- packetWriter.writeRecorderMessage(2, "exception in socket run: " + getStackTraceInfo (e)); >- packetWriter.getAgentController().sendControlMessageToDataProcessor(ERROR_CREATING_CLIENTSIDEREADER); >- controller.stopRecording(); >- >- } >- >- System.out.println("Exiting Proxy normally"); >- } >- >- } >- >- public static String getStackTraceInfo (Throwable exception) { >- Writer strResult = new StringWriter (); >- PrintWriter printWriter = new PrintWriter (strResult); >- exception.printStackTrace (printWriter); >- return strResult.toString(); >- } >- >- /** >- * init routine (String configuration) >- * configuration is the configuration string passed in when the class is executed >- */ >- >- public boolean init(String configuration ) >- { >-// final String sslFile = "sslkeyfile"; >- bFinished = false; >- setPortInfo(configuration); >- setProxyInfo(configuration); >- setSSLInfo(configuration); >- setBrowserConfigInfo(configuration); >- return true; >- } >-/* >- * (non-Javadoc) >- * @see org.eclipse.hyades.internal.execution.recorder.remote.RecorderAgent#handleCommand(int, java.lang.String) >- String proxyInfo = getProxyInfo(inputFileContents); >- if (proxyInfo.length()!= 0) { >- String[] proxySplit = proxyInfo.split(":"); >- String myProxyAddr = proxySplit[0]; >- String myProxyPort = proxySplit[1]; >- setProxyAddr(myProxyAddr); >- setProxyPort(myProxyPort); >- setProxyType("http"); >- } >- else { >- setProxyType("socks"); >- } >- * */ >- >- >- /** >- * @param configuration >- */ >- private void setPortInfo(String configuration) { >- int iStartPos; >- int iEndPos; >- int iPortPos = configuration.indexOf("port,"); >- if (iPortPos >= 0){ >- iStartPos = iPortPos + 5; >- iEndPos = configuration.indexOf(";", iStartPos); >- if (iEndPos >= 0){ >- iProxyRecorderPort = Integer.parseInt(configuration.substring(iStartPos, iEndPos )); >- } >- else{ >- iProxyRecorderPort = Integer.parseInt(configuration.substring(iStartPos)); >- } >- } >- } >- >- private void setSSLInfo(String configuration) { >- int iStartPos; >- int iEndPos; >- iStartPos = configuration.indexOf("sslkeyfile,"); >- if (iStartPos >= 0){ >- iStartPos = iStartPos + 11; >- iEndPos = configuration.indexOf(";", iStartPos); >- if (iEndPos >= 0){ >- strKeyFile = configuration.substring(iStartPos, iEndPos ); >- } >- else{ >- strKeyFile = configuration.substring(iStartPos); >- } >- } >- } >- /** >- * @param configuration >- */ >- private void setProxyInfo(String configuration) { >- int iStartPos = 0; >- int iEndPos = 0; >- final String proxyStr = "proxyInfo,"; >- final String httpStr = "http="; >-// final String socksStr = "socks"; >- // defect 79219 mdd >-// final String SSLproxyStr = "sslProxyInfo,"; >-// final String httpsStr = "https="; >- >- int iProxyInfoPos = configuration.indexOf(proxyStr); >- if (iProxyInfoPos >= 0) { >- iStartPos = iProxyInfoPos + proxyStr.length(); >- iEndPos = configuration.indexOf(';', iStartPos); >- String pInfo; >- if (iEndPos >= 0) >- pInfo = configuration.substring(iStartPos, iEndPos); >- else >- pInfo = configuration.substring(iStartPos); >- >- if (pInfo.startsWith(httpStr)) { >- strProxyType = "http"; >- String pAddr = pInfo.substring(httpStr.length()); >- if (pAddr.length() != 0) { >- String[] proxySplit = pAddr.split(":"); >- strProxyAddr = proxySplit[0]; >- String tmpPort = proxySplit[1]; >- iProxyPort = Integer.parseInt(tmpPort); >- } else { >- strProxyType = "socks"; >- } >- // defect 79219 mdd >- int isSame = -1; >- isSame = strProxyType.compareToIgnoreCase("http"); >- if (isSame == 0) { >- setSSLProxyInfo(configuration); >- } >- } >- else { >- strProxyType = "socks"; >- } >- } >- } >- private void setBrowserConfigInfo(String configuration) { >- int iStartPos = 0; >- >- // defect 79219 mdd >- final String proxyOverrideStr = "proxyOverride,"; >- final String autoConfigURLStr = "autoConfigURL,"; >- >- int iAutoConfigURLPos = configuration.indexOf(autoConfigURLStr); >- int iProxyOverridePos = configuration.indexOf(proxyOverrideStr); >- String tmpOverrideStr = ""; >- String tmpAutoConfigURLStr = ""; >- boolean foundProxyOverride = false; >- boolean foundAutoConfigURL = false; >- int tmpFirstInfo = 0; >- >- if (iProxyOverridePos >= 0) { >- foundProxyOverride = true; >- tmpFirstInfo = iProxyOverridePos; >- } >- if (iAutoConfigURLPos >= 0) { >- foundAutoConfigURL = true; >- if (iAutoConfigURLPos < tmpFirstInfo) { >- tmpFirstInfo = iAutoConfigURLPos; >- } >- } >- >- // This assumes ProxyOverride will be written before >- if (foundProxyOverride) { >- iStartPos = iProxyOverridePos + proxyOverrideStr.length(); >- // may have multiple ';' >- if (iAutoConfigURLPos > -1) { >- tmpOverrideStr = configuration.substring(iStartPos,iAutoConfigURLPos); >- } else { >- tmpOverrideStr = configuration.substring(iStartPos,configuration.length()); >- } >- strProxyOverride = tmpOverrideStr; >- } >- >- if (foundAutoConfigURL) { >- iStartPos = iAutoConfigURLPos + autoConfigURLStr.length(); >- tmpAutoConfigURLStr = configuration.substring(iStartPos,configuration.length()); >- >- strProxyAutoConfigURL = tmpAutoConfigURLStr ; >- } >- >- } >- >- public boolean handleCommand(int commandID, String commandData) >- { >- switch(commandID) >- { >- case STOP_RECORDING: >- bFinished = true; >- >- if (packetWriter != null) { >- GlobalSocketList.killAllOpenSockets(packetWriter); >- GlobalSocketList.writeCloseMessages(packetWriter); >- packetWriter.writeRecorderStopInfo(); >- packetWriter.flushRemainingPackets(); >- } >- // bugzilla_69967 >- try { >- proxy.serversocket.close(); >- } >- catch (SocketException se) { >- //this will occur if serversocket is in the middle of an accept(), >- //chance of incomplete data -- but probably it's just waiting for another page >- //System.out.println(se); >- }catch (IOException ioe) {} >- return true; >- >- default: >- return false; >- } >- } >- private void setSSLProxyInfo(String configuration) { >- int iStartPos = 0; >- int iEndPos = 0; >- >- // defect 79219 mdd >- final String SSLproxyStr = "sslProxyInfo,"; >- final String httpsStr = "https="; >- >- int iSSLProxyInfoPos = configuration.indexOf(SSLproxyStr); >- if (iSSLProxyInfoPos >= 0) { >- iStartPos = iSSLProxyInfoPos + SSLproxyStr.length(); >- // note - may not have ';' at end, may just be end of string >- iEndPos = configuration.indexOf(';', iStartPos); >- if (iEndPos == -1){ >- iEndPos = configuration.length(); >- } >- String pInfo; >- if (iEndPos >= 0) >- pInfo = configuration.substring(iStartPos, iEndPos); >- else >- pInfo = configuration.substring(iStartPos); >- >- if (pInfo.startsWith(httpsStr)) { >- >- String pAddr = pInfo.substring(httpsStr.length()); >- if (pAddr.length() != 0) { >- String[] proxySplit = pAddr.split(":"); >- strSSLProxyAddr = proxySplit[0]; >- String tmpPort = proxySplit[1]; >- sslIProxyPort = Integer.parseInt(tmpPort); >- } >- } >- } >- } >- >- >-} >Index: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/HttpRecResourceBundle.java >=================================================================== >RCS file: src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/HttpRecResourceBundle.java >diff -N src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/HttpRecResourceBundle.java >--- src-recorder-http-runner/org/eclipse/hyades/execution/recorder/http/remote/HttpRecResourceBundle.java 22 Mar 2007 00:31:24 -0000 1.5 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,47 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: HttpRecResourceBundle.java,v 1.5 2007/03/22 00:31:24 paules Exp $ >- * >- * Contributors: >- * IBM - Initial API and implementation >- **********************************************************************/ >-package org.eclipse.hyades.execution.recorder.http.remote; >- >-import org.eclipse.osgi.util.NLS; >- >-/** >- * Runner level resource bundle. >- * <p> >- * >- * >- * @author Paul E. Slauenwhite >- * @version March 21, 2007 >- * @since March 21, 2007 >- */ >-public final class HttpRecResourceBundle extends NLS { >- >- private static final String BUNDLE_NAME = "org.eclipse.hyades.execution.recorder.http.remote.messages";//$NON-NLS-1$ >- >- private HttpRecResourceBundle() { >- // Do not instantiate >- } >- >- public static String RECORDER_CLIENTSIDE_READER_EXCEPTION; >- public static String RECORDER_SSL_SPYSOCKET_EXCEPTION; >- public static String RECORDER_ERR_STARTING; >- public static String RECORDER_STARTING_SSLPROXYRECORDER; >- public static String RECORDER_LISTENING_TO_PORT; >- public static String RECORDER_CREATING_CLIENTSIDEREADER; >- public static String RECORDER_BIND_ERROR; >- public static String RECORDER_TOO_MANY_BIND_ERROR; >- public static String RECORDER_NOTIFY_ON_ADD; >- public static String RECORDER_PACKET_WAIT_TOLERANCE; >- >- static { >- NLS.initializeMessages(BUNDLE_NAME, HttpRecResourceBundle.class); >- } >-} >\ No newline at end of file >Index: src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCNodeAssembler.java >=================================================================== >RCS file: src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCNodeAssembler.java >diff -N src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCNodeAssembler.java >--- src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCNodeAssembler.java 9 Jun 2005 17:00:43 -0000 1.5 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,75 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: TRCNodeAssembler.java,v 1.5 2005/06/09 17:00:43 jnevicos Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >-package org.eclipse.hyades.execution.testgen.http; >- >-import org.eclipse.hyades.test.core.testgen.TestgenException; >- >- >-/** >- * @author dhinson >- * >- * @deprecated should not be public API. Will be changed to internal in TPTP 5. >- */ >-public class TRCNodeAssembler >-{ >- private TRCNodeDispatcher dispatcher; >- private TRCNode topNode; >- private TRCNode currentNode = topNode; >- private int previousDepth; >- >- public TRCNodeAssembler (TRCNodeDispatcher dispatcher) >- { >- this.dispatcher = dispatcher; >- } >- >- public void newElement (TRCElement element, int depth, String name) >- throws TestgenException >- { >- if (name.equals("TRACE")) >- return; >- >- TRCNode node = new TRCNode(name); >- // bind element with node >- element.setNode(node); >- node.setElement(element); >- >- if (depth == 2) >- topNode = node; >- else { >- if (depth < previousDepth) /* ascendant */ { >- node.setParentNode(currentNode.getParentNode().getParentNode()); >- } >- else if (depth > previousDepth) /* descendant */ { >- node.setParentNode(currentNode); >- } >- else /* sibling */ { >- node.setParentNode(currentNode.getParentNode()); >- } >- node.getParentNode().getSubNodes().addLast(node); >- } >- currentNode = node; >- previousDepth = depth; >- } >- >- public void completeElement (TRCElement element, int depth, String name) >- throws TestgenException >- { >- if (name.equals("TRACE")) >- return; >- >- TRCNode node = element.getNode(); >- >- if (depth == 2) >- dispatcher.dispatch(node); >- } >- >-} >Index: src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCContext.java >=================================================================== >RCS file: src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCContext.java >diff -N src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCContext.java >--- src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCContext.java 21 Jan 2008 19:09:05 -0000 1.16 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,292 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005, 2008 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: TRCContext.java,v 1.16 2008/01/21 19:09:05 paules Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >-package org.eclipse.hyades.execution.testgen.http; >- >-import java.util.ArrayList; >-import java.util.HashMap; >-import java.util.Iterator; >-import java.util.LinkedList; >-import java.util.List; >- >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.emf.common.util.URI; >-import org.eclipse.emf.ecore.resource.Resource; >-import org.eclipse.hyades.models.common.configuration.CFGInstance; >-import org.eclipse.hyades.models.common.configuration.impl.Common_ConfigurationFactoryImpl; >-import org.eclipse.hyades.models.common.facades.behavioral.ILoop; >-import org.eclipse.hyades.models.common.facades.behavioral.IProperty; >-import org.eclipse.hyades.models.common.facades.behavioral.IPropertyGroup; >-import org.eclipse.hyades.models.common.facades.behavioral.ITestCase; >-import org.eclipse.hyades.models.common.facades.behavioral.ITestInvocation; >-import org.eclipse.hyades.models.common.facades.behavioral.ITestSuite; >-import org.eclipse.hyades.models.common.facades.behavioral.impl.HyadesFactory; >-import org.eclipse.hyades.models.common.testprofile.TPFTestSuite; >-import org.eclipse.hyades.models.common.util.ICommonConstants; >-import org.eclipse.hyades.test.core.util.EMFUtil; >-import org.eclipse.hyades.test.core.util.JavaUtil; >-import org.eclipse.hyades.test.tools.core.common.TestCommon; >-import org.eclipse.hyades.test.tools.core.common.util.TestCommonUtil; >-import org.eclipse.hyades.test.tools.core.http.util.RequestHelper; >-import org.eclipse.hyades.test.tools.core.internal.resources.CorePluginResourceBundle; >- >-/** >- * @author dhinson >- * >- * @deprecated should not be public API. Will be changed to internal in TPTP 5. >- */ >-public class TRCContext >-{ >- private RequestHelper requestHelper; >- private List resources; >- >- private IPath testSuiteFolderPath; >- private String testSuiteBaseName; >- private ITestSuite currentTestSuite; >- >- private int testCaseCounter; >- private ITestCase currentTestCase; >- >- private ILoop currentLoop; >- private ILoop currentPage; >- >- // @TODO mdd new >- public static final String GLOBAL_LASTRECV = "__global"; >- private LinkedList pageList; >- private int pageNumber; >- private HashMap lastRecvHashMap = new HashMap(); >- >- >- public TRCContext () >- { >- requestHelper = new RequestHelper(); >- pageList = new LinkedList(); >- pageNumber = 0; >- lastRecvHashMap.put(GLOBAL_LASTRECV, new Integer(-1)); >- } >- >- public RequestHelper getRequestHelper () >- { >- return this.requestHelper; >- } >- >- public void setOutputFolder (IPath outputFolder) >- { >- this.testSuiteFolderPath = outputFolder; >- } >- >- public void setTestSuiteBaseName (String testSuiteBaseName) >- { >- this.testSuiteBaseName = testSuiteBaseName; >- } >- >- public ITestSuite newTestSuiteContext () >- { >- currentTestSuite = createTestSuite(); >- currentLoop = createLoop(); >- currentTestSuite.getImplementor().getBlock().getActions(). >- add(currentLoop); >- return currentTestSuite; >- } >- >- public ITestCase newTestCaseContext (String name) >- { >- currentTestCase = createTestCase(currentTestSuite, currentPage, name); >- requestHelper.setTestCase(currentTestCase); >- return currentTestCase; >- } >- >- public void finish () >- { >- saveResources(); >- dispose(); >- } >- >- public void dispose () >- { >- if(requestHelper != null) >- requestHelper.dispose(); >- if(resources != null) >- resources.clear(); >- } >- >- private ITestSuite createTestSuite() >- { >- if(resources == null) >- resources = new ArrayList(); >- >- IPath path = testSuiteFolderPath.append(testSuiteBaseName). >- addFileExtension(ICommonConstants.TEST_SUITE_FILE_EXTENSION); >- >- URI uri = URI.createPlatformResourceURI(path.toString()); >- Resource resource = EMFUtil.getResourceFactory(ICommonConstants. >- TEST_SUITE_FILE_EXTENSION).createResource(uri); >- resources.add(resource); >- >- ITestSuite testSuite = HyadesFactory.INSTANCE.createTestSuite(resource); >- testSuite.setType(TestCommon.HTTP_JUNIT_TEST_SUITE_TYPE); >- testSuite.setName(testSuiteBaseName); >- if(testSuite.getImplementor() == null) >- HyadesFactory.INSTANCE.createImplementor(testSuite, false); >- >- String clsName = JavaUtil.getValidClassName(testSuite.getName(), true); >- if(clsName == null) >- clsName = "Test"; >- testSuite.getImplementor().setResource("test." + clsName); >- >- //bugzilla_90127 - default 1 user >- if (testSuite instanceof TPFTestSuite) >- { >- TPFTestSuite tpftest = (TPFTestSuite) testSuite; >- CFGInstance instance = null; >- if (tpftest.getInstances().size() == 0) >- { >- instance = Common_ConfigurationFactoryImpl.eINSTANCE.createCFGInstance(); >- tpftest.getInstances().add(instance); >- } >- else >- instance = (CFGInstance) tpftest.getInstances().get(0); >- >- if (instance != null) >- instance.setMaxCount(1); >- } >- return testSuite; >- } >- >- private ITestCase createTestCase(ITestSuite testSuite, ILoop loop, >- String testCaseBaseName) >- { >- String testCaseName = (++testCaseCounter) + " " + testCaseBaseName; >- ITestCase testCase = TestCommonUtil.createTestCase(testSuite, >- TestCommon.HTTP_JUNIT_TEST_CASE_TYPE, false, testCaseName); >- >- ITestInvocation testInvocation = HyadesFactory.INSTANCE. >- createTestInvocation(testCase); >- loop.getBlock().getActions().add(testInvocation); >- >- String baseName = CorePluginResourceBundle.W_LWR_INV; >- String testName = testCase.getName(); >- if(testName == null) >- testInvocation.setName(TestCommonUtil.getUniqueName(baseName, >- loop.getBlock().getActions())); >- else >- testInvocation.setName((testName.concat(" - ").concat(baseName))); >- >- return testCase; >- } >- /** Create a default loop >- * >- * @return ILoop >- */ >- private ILoop createLoop() >- { >- return createLoop(CorePluginResourceBundle.W_LOOP + " " + 1, 1); >- } >- >-// private ILoop createLoop() >-// { >-// ILoop loop = HyadesFactory.INSTANCE.createLoop(); >-// loop.setName(TestJavaPlugin.getString("W_LOOP") + " " + >-// /* pageCount */ 1); >-// loop.getCondition().setConstraint("1"); >-// return loop; >-// } >- >- private void saveResources() >- { >- for (Iterator i = resources.iterator(); i.hasNext();) { >- try { >- EMFUtil.save((Resource)i.next()); >- } >- catch (Exception e) { >- } >- } >- } >- >- /** >- * @return >- */ >- public LinkedList getPageList() { >- return pageList; >- } >- >- /** >- * @param list >- */ >- public void setPageList(LinkedList list) { >- pageList = list; >- } >- public ILoop createNewPage(int i) { >- currentPage = createPage(i); >- currentLoop.getBlock().getActions().add(currentPage); >- return currentPage; >- } >- >- public ILoop createNewPage(String s) >- { >- currentPage = createPage(CorePluginResourceBundle.Page + " " + s); >- currentLoop.getBlock().getActions().add(currentPage); >- return currentPage; >- >- } >- private ILoop createLoop(String name, int constraint) >- { >- ILoop loop = HyadesFactory.INSTANCE.createLoop(); >- loop.setName(name); >- loop.getCondition().setConstraint(Integer.toString(constraint)); >- return loop; >- } >- private ILoop createPage(int n) >- { >- return createPage(CorePluginResourceBundle.Page + " " + Integer.toString(n)); >- } >- >- private ILoop createPage(String s) >- { >- ILoop page = createLoop(s, 1); >- IPropertyGroup props = page.getActionProperties(); >- List propList = props.getProperties(); >- //create new Page property >- IProperty prop = HyadesFactory.INSTANCE.createProperty(); >- prop.setName("HTTPPAGE"); >- prop.setValue("true"); >- propList.add(prop); >- return page; >- } >- /** >- * @return >- */ >- public int getPageNumber() { >- return pageNumber; >- } >- >- /** >- * @param i >- */ >- public void setPageNumber(int i) { >- pageNumber = i; >- } >- >- /** >- * @return >- */ >- public HashMap getLastRecvHashMap() { >- return lastRecvHashMap; >- } >- >- /** >- * @param map >- */ >- public void setLastRecvHashMap(HashMap map) { >- lastRecvHashMap = map; >- } >- >-} >Index: src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCPacketNodeHandler.java >=================================================================== >RCS file: src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCPacketNodeHandler.java >diff -N src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCPacketNodeHandler.java >--- src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCPacketNodeHandler.java 3 May 2007 01:36:55 -0000 1.8 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,70 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: TRCPacketNodeHandler.java,v 1.8 2007/05/03 01:36:55 paules Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >-package org.eclipse.hyades.execution.testgen.http; >- >-// import java.util.HashMap; >- >-import java.util.LinkedList; >- >-import org.eclipse.hyades.test.core.testgen.TestgenException; >- >-/** >- * @author dhinson >- * >- * @deprecated should not be public API. Will be changed to internal in TPTP 5. >- */ >-public class TRCPacketNodeHandler extends TRCNodeHandler implements ITRCNodeHandler >-{ >- >- private static final String PACKET_A_TYPE >- = "type"; >- private static final String PACKET_A_TYPE_V_HTTP >- = "HTTP"; >- private static final String PACKET_A_TYPE_V_HTTPS >- = "HTTPS"; >- >- >- // name of global last receive timestamp >-// private static final String GLOBAL_LASTRECV = "__global"; >- >- // private ParsedHttpMessage currentHttpRequest; >- >- public void init (TRCContext context) >- throws TestgenException >- { >- super.init(context); >- >- LinkedList myPageList = context.getPageList(); >- myPageList.clear(); >- context.setPageList(myPageList); >- } >- >- public void node (TRCNode node) >- throws TestgenException >- { >- LinkedList myPageList; >- // dispatch on type attribute >- String typeValue = getAttributeValue(PACKET_A_TYPE, node); >- if ((!typeValue.equals(PACKET_A_TYPE_V_HTTP))&& (!typeValue.equals(PACKET_A_TYPE_V_HTTPS)) ) >- // currently ignore anything but "HTTP" >- return; >- myPageList = context.getPageList(); >- myPageList.add(node); >- context.setPageList(myPageList); >- // Http Specific Call below >- // Skip this call to handle_node() mdd 11/24/2003 >- //thisHttp.handle_node(node); >- return; >- } >- >- >-} >Index: src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCNodeHandler.java >=================================================================== >RCS file: src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCNodeHandler.java >diff -N src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCNodeHandler.java >--- src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCNodeHandler.java 9 Jun 2005 17:00:43 -0000 1.5 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,169 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: TRCNodeHandler.java,v 1.5 2005/06/09 17:00:43 jnevicos Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >-package org.eclipse.hyades.execution.testgen.http; >- >-import java.io.PrintStream; >-import java.util.ArrayList; >-import java.util.List; >-import java.util.ListIterator; >- >-import org.eclipse.hyades.test.core.testgen.TestgenException; >- >- >-/** >- * @author dhinson >- * >- * @deprecated should not be public API. Will be changed to internal in TPTP 5. >- */ >-public class TRCNodeHandler implements ITRCNodeHandler >-{ >- protected TRCContext context; >- >- public void init (TRCContext context) >- throws TestgenException >- { >- this.context = context; >- } >- >- public void node (TRCNode node) >- throws TestgenException >- { >- // no-op >- } >- >- // >- // class utility methods >- // >- >- private static final String SPACES = " "; >- >- protected static String getAttributeValue (String name, TRCNode node) >- { >- TRCElement element = node.getElement(); >- TRCElement.TRCAttribute [] attributes = element.getAttributes(); >- for (int i = 0; i < attributes.length; ++i) >- if (attributes[i].name.equals(name)) >- return attributes[i].value; >- return null; >- } >- >- protected static TRCNode getSubNode (String name, TRCNode node) >- { >- ListIterator itr = node.getSubNodes().listIterator(); >- TRCNode subNode = null; >- while (itr.hasNext()) { >- subNode = (TRCNode)itr.next(); >- if (subNode.getName().equals(name)) >- break; >- } >- return subNode; >- } >- >- protected static List getSubNodeList (String name, TRCNode node) >- { >- ArrayList list = new ArrayList(); >- ListIterator itr = node.getSubNodes().listIterator(); >- while (itr.hasNext()) { >- TRCNode subNode = (TRCNode)itr.next(); >- if (subNode.getName().equals(name)) >- list.add(subNode); >- } >- return list; >- } >- >- protected static void dumpVertexElementName (PrintStream debugStream, int nSpaces, TRCElement element) >- { >- if (debugStream != null) >- debugStream.println(SPACES.substring(1, nSpaces) + "* [" + >- element.getName() + "]"); >- } >- >- protected static void dumpElementName (PrintStream debugStream, int nSpaces, TRCElement element) >- { >- if (debugStream != null) >- debugStream.println(SPACES.substring(1, nSpaces) + "[" + >- element.getName() + "]"); >- } >- >- protected static void dumpElementAttributes (PrintStream debugStream, int nSpaces, TRCElement element) >- { >- TRCElement.TRCAttribute [] attributes = element.getAttributes(); >- for (int i = 0; i < attributes.length; ++i) >- if (debugStream != null) >- debugStream.println(SPACES.substring(1, nSpaces)+ "([" + >- attributes[i].name + "] = [" + attributes[i].value + "])"); >- } >- >- protected static void dumpElementContent (PrintStream debugStream, int nSpaces, TRCElement element) >- { >- if (debugStream != null) >- debugStream.println(SPACES.substring(1, nSpaces) + "<" + >- element.getContent().trim() + ">"); >- } >- >- protected static void dumpFirstOrderSection (PrintStream debugStream, TRCNode topNode) >- { >- if (debugStream != null) >- debugStream.println(); >- dumpVertexElementName(debugStream, 2, topNode.getElement()); >- dumpElementAttributes(debugStream, 4, topNode.getElement()); >- >- ListIterator itr = topNode.getSubNodes().listIterator(); >- while (itr.hasNext()) { >- TRCNode node1 = (TRCNode)itr.next(); >- TRCElement element1 = node1.getElement(); >- >- dumpElementName(debugStream, 4, element1); >- dumpElementAttributes(debugStream, 6, element1); >- dumpElementContent(debugStream, 6, element1); >- } >- } >- >- protected static void dumpSecondOrderSection (PrintStream debugStream, TRCNode topNode, String [] vertices) >- { >- if (debugStream != null) >- debugStream.println(); >- dumpVertexElementName(debugStream, 2, topNode.getElement()); >- dumpElementAttributes(debugStream, 4, topNode.getElement()); >- >- ListIterator itr = topNode.getSubNodes().listIterator(); >- while (itr.hasNext()) { >- TRCNode node1 = (TRCNode)itr.next(); >- TRCElement element1 = node1.getElement(); >- >- boolean match = false; >- for (int i = 0; i < vertices.length; ++i) >- if (vertices[i].equals(element1.getName())) >- match = true; >- if (match) { >- dumpVertexElementName(debugStream, 4, element1); >- dumpElementAttributes(debugStream, 6, element1); >- >- ListIterator itr2 = node1.getSubNodes().listIterator(); >- while (itr2.hasNext()) { >- TRCNode node2 = (TRCNode)itr2.next(); >- TRCElement element2 = node2.getElement(); >- >- dumpElementName(debugStream, 6, element2); >- dumpElementAttributes(debugStream, 8, element2); >- dumpElementContent(debugStream, 8, element2); >- } >- } >- else { >- dumpElementName(debugStream, 4, element1); >- dumpElementAttributes(debugStream, 6, element1); >- dumpElementContent(debugStream, 6, element1); >- } >- } >- } >- >-} >Index: src-testgen-http/org/eclipse/hyades/execution/testgen/http/ITRCNodeHandler.java >=================================================================== >RCS file: src-testgen-http/org/eclipse/hyades/execution/testgen/http/ITRCNodeHandler.java >diff -N src-testgen-http/org/eclipse/hyades/execution/testgen/http/ITRCNodeHandler.java >--- src-testgen-http/org/eclipse/hyades/execution/testgen/http/ITRCNodeHandler.java 9 Jun 2005 17:00:43 -0000 1.5 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,32 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: ITRCNodeHandler.java,v 1.5 2005/06/09 17:00:43 jnevicos Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >-/* >- * Created on Oct 28, 2003 >- * >- * To change the template for this generated file go to >- * Window>Preferences>Java>Code Generation>Code and Comments >- */ >-package org.eclipse.hyades.execution.testgen.http; >- >-import org.eclipse.hyades.test.core.testgen.TestgenException; >- >- >-/** >- * @author dhinson >- * >- * @deprecated should not be public API. Will be changed to internal in TPTP 5. >- */ >-public interface ITRCNodeHandler >-{ >- public void init (TRCContext context) throws TestgenException; >- public void node (TRCNode node) throws TestgenException; >-} >Index: src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCAsciifier.java >=================================================================== >RCS file: src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCAsciifier.java >diff -N src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCAsciifier.java >--- src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCAsciifier.java 3 May 2007 01:35:29 -0000 1.5 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,114 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: TRCAsciifier.java,v 1.5 2007/05/03 01:35:29 paules Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >-package org.eclipse.hyades.execution.testgen.http; >- >-/** >- * @author dhinson >- * >- * @deprecated should not be public API. Will be changed to internal in TPTP 5. >- */ >-public class TRCAsciifier >-{ >- >- static private final char C_DELIM = '`'; >- >- public String encode (byte [] inBuf, int inDatOfs, int inDatLen) >- { >- StringBuffer outBuf = new StringBuffer(); >- boolean isHex = false; >- for (int inOfs = inDatOfs; inOfs < inDatLen; ++inOfs) { >- char c = (char)inBuf[inOfs]; >- if (Character.isISOControl(c) || c == '`') { >- if (!isHex) >- outBuf.append(C_DELIM); >- outBuf.append(Character.forDigit((c >> 4), 16)); >- outBuf.append(Character.forDigit((c & 0xf), 16)); >- if (inOfs == inDatLen - 1) >- outBuf.append(C_DELIM); >- isHex = true; >- } >- else { >- if (isHex) >- outBuf.append(C_DELIM); >- outBuf.append(c); >- isHex = false; >- } >- } >- return outBuf.toString(); >- } >- >- public int decode (String inBuf, int inDatOfs, int inDatLen, byte [] outBuf) >- { >- boolean inHex = false; >- int outOfs = 0; >- char c; >- for (int inOfs = inDatOfs; inOfs < inDatLen; ++inOfs) { >- if ((c = inBuf.charAt(inOfs)) == C_DELIM) >- inHex = !inHex; >- else >- outBuf[outOfs++] = inHex ? >- (byte)((Character.digit(c, 16) << 4) | >- Character.digit(inBuf.charAt(++inOfs), 16)) : >- (byte)c; >- } >- return outOfs; >- } >- >- >- public static void main (String[] args) >- { >- TRCAsciifier asciifier = new TRCAsciifier(); >- >- byte [] bytes; >- String encDat1; >- String encDat2; >- byte [] decBuf; >- int decLen; >- >- // encode >- bytes = new byte [] { '0', '`', '0', 1, '`', 1, '2', '`', '2', 3, '`', 3 }; >- encDat1 = asciifier.encode(bytes, 0, bytes.length); >- System.out.println("[" + encDat1 + "]"); >- >- // decode >- decBuf = new byte[encDat1.length()]; >- decLen = asciifier.decode(encDat1, 0, encDat1.length(), decBuf); >- >- // re-encode & compare >- encDat2 = asciifier.encode(decBuf, 0, decLen); >- System.out.println("[" + encDat2 + "]"); >- if (encDat2.equals(encDat1)) >- System.out.println("same"); >- else >- System.out.println("wrong"); >- >- // encode >- bytes = new byte [] { 0, '`', 0, '1', '`', '1', 2, '`', 2, '3', '`', '3' }; >- encDat1 = asciifier.encode(bytes, 0, bytes.length); >- System.out.println("[" + encDat1 + "]"); >- >- // decode >- decBuf = new byte[encDat1.length()]; >- decLen = asciifier.decode(encDat1, 0, encDat1.length(), decBuf); >- >- // re-encode & compare >- encDat2 = asciifier.encode(decBuf, 0, decLen); >- System.out.println("[" + encDat2 + "]"); >- if (encDat2.equals(encDat1)) >- System.out.println("same"); >- else >- System.out.println("wrong"); >- >- } >- >-} >- >Index: src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCFileLoader.java >=================================================================== >RCS file: src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCFileLoader.java >diff -N src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCFileLoader.java >--- src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCFileLoader.java 3 May 2007 01:35:52 -0000 1.10 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,218 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: TRCFileLoader.java,v 1.10 2007/05/03 01:35:52 paules Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >-package org.eclipse.hyades.execution.testgen.http; >- >-import java.io.File; >-import java.io.IOException; >-import java.io.InputStream; >-import java.io.PrintStream; >-import java.util.LinkedList; >- >-import javax.xml.parsers.ParserConfigurationException; >-import javax.xml.parsers.SAXParser; >-import javax.xml.parsers.SAXParserFactory; >- >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.Path; >-import org.eclipse.hyades.test.core.testgen.TestgenException; >-import org.eclipse.hyades.test.tools.core.internal.resources.CorePluginResourceBundle; >-import org.xml.sax.Attributes; >-import org.xml.sax.InputSource; >-import org.xml.sax.SAXException; >-import org.xml.sax.XMLReader; >-import org.xml.sax.helpers.DefaultHandler; >- >- >-/** >- * @author dhinson >- * >- * @deprecated should not be public API. Will be changed to internal in TPTP 5. >- */ >-public class TRCFileLoader extends DefaultHandler >-{ >- private XMLReader xmlReader; >- private LinkedList list = new LinkedList(); >- >- private TRCFileLoader handler; >- private TRCNodeAssembler assembler; >- private TRCNodeDispatcher dispatcher; >- >- private Testgen.ProgressUpdater updater; >- >- public TRCFileLoader (Testgen.ProgressUpdater updater) >- { >- super(); >- >- handler = this; >- this.updater = updater; >- } >- >- public TRCFileLoader (Testgen.ProgressUpdater updater, >- PrintStream debugStream) >- { >- super(); >- >- handler = this; >- this.updater = updater; >- } >- >- public boolean load (IFile recFile, String outputFileName) >- throws TestgenException >- { >- if (recFile == null) >- throw new TestgenException(CorePluginResourceBundle.E_INVALID_REC_FILE); >- >- // create and initialize decoding context >- TRCContext context = new TRCContext(); >- File file = new File(outputFileName.toString()); >- context.setOutputFolder(new Path(file.getParent())); >- String baseName = file.getName(); >- baseName = baseName.substring(0, baseName.lastIndexOf('.')); >- context.setTestSuiteBaseName(baseName); >- context.newTestSuiteContext(); >- >- // create node dispatcher >- dispatcher = new TRCNodeDispatcher(context); >- >- // create node assembler >- assembler = new TRCNodeAssembler(dispatcher); >- >- // initialize SAX parser >- SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); >- saxParserFactory.setNamespaceAware(true); >- saxParserFactory.setValidating(false); >- >- try { >- saxParserFactory.setFeature("http://xml.org/sax/features/validation", false); >- saxParserFactory.setFeature("http://xml.org/sax/features/namespaces", true); >- saxParserFactory.setFeature("http://xml.org/sax/features/namespace-prefixes", true); >- SAXParser saxParser = saxParserFactory.newSAXParser(); >- >- xmlReader = saxParser.getXMLReader(); >- } >- catch ( SAXException exc ) >- { >- throw new TestgenException(CorePluginResourceBundle.E_SAX_DRIVER_FAILURE, exc); >- } >- catch ( ParserConfigurationException exc ) >- { >- throw new TestgenException(CorePluginResourceBundle.E_SAX_DRIVER_FAILURE, exc); >- } >- >- if (xmlReader == null) >- throw new TestgenException(CorePluginResourceBundle.E_SAX_DRIVER_FAILURE); >- >- xmlReader.setContentHandler(handler); >- xmlReader.setErrorHandler(handler); >- >- // derive inputSource >- InputStream inputStream = null; >- try { >- inputStream = recFile.getContents(); >- } >- catch (CoreException e) { >- e.printStackTrace(); >- } >- InputSource inputSource = new InputSource(inputStream); >- >- // call SAX to parse inputSource >- try { >- xmlReader.parse(inputSource); >- } >- catch (IOException e) { >- throw new TestgenException(CorePluginResourceBundle.E_SAX_IOEXCEPTION, e); >- } >- catch (SAXException e) { >- throw new TestgenException(CorePluginResourceBundle.E_SAX_SAXEXCEPTION, e); >- } >- >- context.finish(); >- >- return true; >- } >- >- // >- // begin SAX callbacks >- // >- >- public void startElement (String uri, String localName, >- String qName, Attributes attributes) >- { >- updater.progress(CorePluginResourceBundle.I_PROCESSING); >- >- TRCElement element = new TRCElement(attributes.getLength()); >- element.setName(qName); >- for (int i = 0; i < attributes.getLength(); ++i) >- element.addAttribute(attributes.getQName(i), >- attributes.getValue(i)); >- list.addLast(element); >- >- try { >- assembler.newElement(element, list.size() /* depth */, qName); >- } >- catch (TestgenException e) { >- e.printStackTrace(); >- } >- } >- >- public void endElement (String uri, String localName, >- String qName) >- { >- TRCElement element = (TRCElement)list.removeLast(); >- try { >- assembler.completeElement(element, list.size() + 1 /* depth */, >- qName); >- } >- catch (TestgenException e) { >- e.printStackTrace(); >- } >- } >- >- public void characters (char [] ch, int start, int length) >- { >- TRCElement element = (TRCElement)list.getLast(); >- element.setContent(new String(ch, start, length)); >- } >- >-// public void startDocument () >-// { >-// } >- >-// public void endDocument () >-// { >-// } >- >-// public void ignorableWhitespace (char [] ch, int start, int length) >-// { >-// } >- >-// public void warning (SAXParseException e) >-// { >-// System.err.println(e.getMessage()); >-// } >- >-// public void error (SAXParseException e) >-// { >-// System.err.println(e.getMessage()); >-// } >- >-// public void fatalError (SAXParseException e) >-// { >-// System.err.println(e.getMessage()); >-// } >- >- // >- // end SAX callbacks >- // >- >-} >Index: src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCNodeDispatcher.java >=================================================================== >RCS file: src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCNodeDispatcher.java >diff -N src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCNodeDispatcher.java >--- src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCNodeDispatcher.java 22 Mar 2007 14:42:21 -0000 1.10 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,182 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: TRCNodeDispatcher.java,v 1.10 2007/03/22 14:42:21 paules Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >-package org.eclipse.hyades.execution.testgen.http; >- >-import java.lang.reflect.Constructor; >-import java.util.HashMap; >- >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IConfigurationElement; >-import org.eclipse.core.runtime.IExtension; >-import org.eclipse.core.runtime.IExtensionPoint; >-import org.eclipse.core.runtime.Platform; >-import org.eclipse.hyades.test.core.testgen.TestgenException; >-import org.eclipse.hyades.test.tools.core.internal.resources.CorePluginResourceBundle; >- >- >-/** >- * @author dhinson >- * >- * TRCNodeDispatcher is responsible for managing and invoking trace element (node) >- * handlers. On creation, TRCNodeDispatcher first searches for node handlers that >- * have extended the plugin's nodeHandlers extension. Next, for each handler kind >- * defined in HANDLER_KINDS which does not have an extension handler, a handler >- * defining plugin properties entry is sought (using a standard naming convention). >- * Failing that, a handler class using the same naming convention is searched for in >- * the local package. If not found then a handler not found exception is thrown. >- * >- * This design requires, at minimum, a handler be bound to each kind defined in >- * HANDLER_KINDS. The node handler base class TRCNodeHandler can be used as a >- * default handler for any required kinds in lieu of a real implementation. In this >- * case a CorePlugin.properties entry should be made of the form: >- * <node-kind>NodeHandler=org.eclipse.hyades.execution.testgen.http.TRCNodeHandler >- * for each node-kind without an implementation. >- * >- * Note that handler binding via the nodeHandlers extension overrides any properties >- * or local package bindings, and additionally permits handlers to be defined for >- * kinds not listed in HANDLER_KINDS. Although the later feature should be used >- * with caution as it would involve trace elements not present in >- * schema/TRCHTTPSchema.xsd. >- * >- * @deprecated should not be public API. Will be changed to internal in TPTP 5. >- */ >-public class TRCNodeDispatcher >-{ >- private static final String DEFAULT_HANDLER_PACKAGE_NAME ="org.eclipse.hyades.test.tools.core"; >- >- // add additional handler kinds here. note: the handler kinds listed here >- // should be consistent with the set of trace elements defined in >- // schema/TRCHTTPSchema.xsd. >- private static final String [] HANDLER_KINDS = { >- "TRCAnnotation", >- "TRCConnection", >- "TRCExecutorInfo", >- "TRCPacket", >- "TRCRecorderInfo" >- }; >- >- private HashMap map = new HashMap(); >- >- public TRCNodeDispatcher (TRCContext context) >- throws TestgenException >- { >- registerHandlersFromRegistry(context); >- registerHandlersFromProperties(context); >- } >- >- private void registerHandlersFromRegistry (TRCContext context) >- throws TestgenException >- { >- IExtensionPoint extPoint = Platform.getExtensionRegistry().getExtensionPoint(DEFAULT_HANDLER_PACKAGE_NAME, >- "nodeHandlers"); >- >- IExtension[] exts = extPoint.getExtensions(); >- for (int i = 0; i < exts.length; ++i) { >- IExtension ext = exts[i]; >- IConfigurationElement [] confElems = ext.getConfigurationElements(); >- for (int j = 0; j < confElems.length; ++j) { >- IConfigurationElement confElem = confElems[j]; >- >- String nodeKind = confElem.getAttribute("nodeKind"); >- >- TRCNodeHandler handler = null; >- try { >- handler = (TRCNodeHandler)confElem.createExecutableExtension("class"); >- } >- catch (CoreException exc) { >- exc.printStackTrace(); >- } >- handler.init(context); >- registerHandler(nodeKind, handler); >- } >- } >- } >- >- private void registerHandlersFromProperties (TRCContext context) >- throws TestgenException >- { >- for (int kind = 0; kind < HANDLER_KINDS.length; ++kind) { >- String handlerKind = HANDLER_KINDS[kind]; >- >- // if a handler is already registered for this kind then skip >- if (handlerIsRegistered(handlerKind)) >- continue; >- >- String handlerClassFQName = null; >- >- if((handlerKind.equals("TRCAnnotation")) || (handlerKind.equals("TRCConnection")) || (handlerKind.equals("TRCExecutorInfo"))){ >- handlerClassFQName = "org.eclipse.hyades.execution.testgen.http.TRCNodeHandler"; >- } >- else if(handlerKind.equals("TRCPacket")){ >- handlerClassFQName = "org.eclipse.hyades.execution.testgen.http.TRCPacketNodeHandler"; >- } >- else if(handlerKind.equals("TRCRecorderInfo")){ >- handlerClassFQName = "org.eclipse.hyades.execution.testgen.http.TRCRecorderInfoNodeHandler"; >- } >- else{ >- handlerClassFQName = DEFAULT_HANDLER_PACKAGE_NAME + "." + handlerKind + "NodeHandler"; >- } >- >- TRCNodeHandler handler = newNodeHandler(handlerClassFQName, context); >- handler.init(context); >- registerHandler(HANDLER_KINDS[kind], handler); >- } >- } >- >- private void registerHandler (String name, TRCNodeHandler handler) >- { >-// System.err.println("registerHandler: [" + name + "] [" + handler + "]"); >- map.put(name, handler); >- } >- >- private boolean handlerIsRegistered (String name) >- { >- return (map.get(name) == null) ? false : true; >- } >- >- private TRCNodeHandler newNodeHandler (String classFQName, TRCContext context) >- throws TestgenException >- { >- Class clas = null; >- try { >- clas = Class.forName(classFQName); >- } >- catch (Exception e) { >- throw new TestgenException(CorePluginResourceBundle.E_LOAD_NODE_HANDLER + " " + classFQName, e); >- } >- >- TRCNodeHandler handler = null; >- try { >- Constructor constructor = clas.getConstructor(null); >- handler = (TRCNodeHandler)constructor.newInstance(null); >- } >- catch (Exception e) { >- throw new TestgenException(null, e); >- } >- return handler; >- } >- >- public void dispatch (TRCNode node) >- throws TestgenException >- { >- TRCNodeHandler handler = (TRCNodeHandler)map.get(node.getName()); >- // if no handler is registered for this kind then automatically register >- // a default one. note that this will only happen if a new trace element >- // is discovered during trace parsing that is not listed in HANDLER_KINDS. >- if (handler == null) { >- handler = new TRCNodeHandler(); >- registerHandler(node.getName(), handler); >- } >- handler.node(node); >- } >- >-} >Index: src-testgen-http/org/eclipse/hyades/execution/testgen/http/Testgen.java >=================================================================== >RCS file: src-testgen-http/org/eclipse/hyades/execution/testgen/http/Testgen.java >diff -N src-testgen-http/org/eclipse/hyades/execution/testgen/http/Testgen.java >--- src-testgen-http/org/eclipse/hyades/execution/testgen/http/Testgen.java 9 Jun 2005 17:00:43 -0000 1.5 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,96 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: Testgen.java,v 1.5 2005/06/09 17:00:43 jnevicos Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >-package org.eclipse.hyades.execution.testgen.http; >- >-import java.io.PrintStream; >- >-import org.eclipse.core.resources.IFile; >-import org.eclipse.hyades.test.core.testgen.TestGenerator; >-import org.eclipse.hyades.test.core.testgen.TestgenException; >-import org.eclipse.hyades.test.core.testgen.util.TestGenFileUtil; >- >-/** >- * @author dhinson >- * >- * @deprecated should not be public API. Will be changed to internal in TPTP 5. >- */ >-public class Testgen extends TestGenerator >-{ >- >- PrintStream debugStream; >- >- public class ProgressUpdater >- { >- public int ticks; >- >- public void progress () >- { >- setProgress(ticks = (++ticks % 100)); >- } >- >- public void message (String message) >- { >- setMessage(message); >- } >- >- public void progress (String message) >- { >- progress(); >- if (message != null) >- message(message); >- } >- >- public void finishedOk () >- { >- setProgress(100); >- closeProgressDialog(); >- } >- >- public void finishedError () >- { >- closeProgressDialog(); >- } >- } >- >- public boolean runTestGen () >- throws TestgenException >- { >- debugStream = System.out; >- >- // get IFile from recModelFile parser >- IFile file = TestGenFileUtil.getTraceFile(recModelFile); >- >- ProgressUpdater updater = new ProgressUpdater(); >- TRCFileLoader loader = new TRCFileLoader(updater, debugStream); >- try { >- loader.load(file, outputFileName); >- } >- catch (TestgenException e) { >- e.dumpMessages(System.err); >- e.printStackTrace(); >- updater.finishedError(); >- return false; >- } >- updater.finishedOk(); >- >- return true; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.hyades.loadtest.testgen.TestGenerator#showProgress() >- */ >- public boolean showProgress() >- { >- return true; >- } >- >-} >Index: src-testgen-http/org/eclipse/hyades/execution/testgen/http/TestGenHttp.java >=================================================================== >RCS file: src-testgen-http/org/eclipse/hyades/execution/testgen/http/TestGenHttp.java >diff -N src-testgen-http/org/eclipse/hyades/execution/testgen/http/TestGenHttp.java >--- src-testgen-http/org/eclipse/hyades/execution/testgen/http/TestGenHttp.java 26 Apr 2007 21:07:34 -0000 1.14 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,1203 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: TestGenHttp.java,v 1.14 2007/04/26 21:07:34 paules Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >-package org.eclipse.hyades.execution.testgen.http; >- >-import java.net.MalformedURLException; >-import java.net.URL; >-import java.util.ArrayList; >-import java.util.Collections; >-import java.util.Comparator; >-import java.util.HashMap; >-import java.util.LinkedList; >-import java.util.List; >-import java.util.ListIterator; >-import java.util.StringTokenizer; >- >-import org.eclipse.hyades.test.core.testgen.TestgenException; >-import org.eclipse.hyades.test.http.runner.HttpRequest; >-import org.eclipse.hyades.test.tools.core.http.util.RequestHelper; >-import org.eclipse.hyades.test.tools.core.internal.resources.CorePluginResourceBundle; >- >- >-/** >- * @author mdunn >- * >- * @deprecated should not be public API. Will be changed to internal in TPTP 5. >- */ >-public class TestGenHttp >-{ >- private static final String PACKET_A_CONNECTIONNAME >- = "connectionNumber"; >- private static final String PACKET_S_DATA >- = "data"; >- private static final String PACKET_S_DATA_A_ENCODING >- = "encoding"; >- private static final String PACKET_S_DATA_A_ENCODING_V_NONE >- = "NONE"; >- private static final String PACKET_S_DATA_A_ENCODING_V_ASCIIFY >- = "ASCIIFY"; >- private static final String PACKET_S_DATA_A_ENCODING_V_BASE64 >- = "BASE64"; >-// private static final String PACKET_S_DATA_A_LENGTH >-// = "length"; >- private static final String PACKET_S_DATA_A_TYPE >- = "type"; >- private static final String PACKET_S_DATA_A_TYPE_V_HTTPCONTENT >- = "HTTPCONTENT"; >- private static final String PACKET_S_DATA_A_TYPE_V_HTTPMESSAGE >- = "HTTPMESSAGE"; >- //added for bugzilla #90867 - tejas.patel@ca.com >- private static final String PACKET_S_DATA_A_TYPE_V_HTTPDATA >- = "HTTPDATA"; >- private static final String PACKET_A_FROM >- = "from"; >- private static final String PACKET_A_FROM_V_CLIENT >- = "CLIENT"; >- private static final String PACKET_A_FROM_V_SERVER >- = "SERVER"; >-// private static final String PACKET_A_TICKET >-// = "ticket"; >- private static final String PACKET_A_TIMESTAMP >- = "timestamp"; >- private static final String PACKET_A_TYPE >- = "type"; >-// private static final String PACKET_A_TYPE_V_HTTP >-// = "HTTP"; >- private static final String PACKET_A_TYPE_V_HTTPS >- = "HTTPS"; >- >- private static final String HTTP_POST = "POST"; >- >- private static final String CRNL = "\r\n"; >- private static final char SLASH = '/'; >- private static final char COLON = ':'; >- private static final String BLANK = " "; >- >- private boolean isNewType = false; >- >- private class ParsedHttpMessage >- { >- String method; >- String protocol; >- String host; >- int port; >- String path; >- String version; >- boolean bSSL; >- int enumPage; >- int nPageNum; >- int nConnID; >- boolean newPage; >- String timeStampString; >- ArrayList headerNames = new ArrayList(); >- ArrayList headerValues = new ArrayList(); >- StringBuffer body = new StringBuffer(); >- } >- // New Object to handle >- private class ConnectionNode >- { >- int connectionNumber; >- LinkedList childrenNodes; >- } >-// Object to hold Response information >- private class ResponseInfo { >- String timeStampString; >- boolean newPage; >- } >- /** >- * Comparator class which compares the nodes in the linked list according >- * to the timestamp values >- * @author shobhit.maini@ca.com >- * >- */ >- private class NewPageListComparator implements Comparator{ >- >- public int compare(Object Node1, Object Node2) { >- >- TRCNode node1 = (TRCNode) Node1; >- TRCNode node2 = (TRCNode) Node2; >- >- String node1Timestamp = TRCNodeHandler.getAttributeValue(PACKET_A_TIMESTAMP, node1); >- String node2Timestamp = TRCNodeHandler.getAttributeValue(PACKET_A_TIMESTAMP, node2); >- >- int node1TimestampVal = Integer.parseInt(node1Timestamp); >- int node2TimestampVal = Integer.parseInt(node2Timestamp); >- >- if(node1TimestampVal > node2TimestampVal){ >- return 1; >- } >- else if (node1TimestampVal < node2TimestampVal){ >- return -1; >- }else return 0; >- } >- } >- >- LinkedList connectionsList; >- >- // private HashMap lastRecvHashMap = new HashMap(); >- private ParsedHttpMessage currentHttpRequest; >- private ParsedHttpMessage previousHttpRequest; >- TRCContext context = null; >- LinkedList newPageList; >- >- /** >- * @param context >- */ >- public TestGenHttp (TRCContext context) >- { >- super(); >- >- this.context = context; >- connectionsList = new LinkedList(); >- newPageList = new LinkedList(); >- } >- >- /** >- * Parse Request Message for Message information >- * modified for bugzilla #90867 & #83976 -george.sebastian@ca.com >- * @param dataNode >- * @throws TestgenException >- */ >- private void httpRequestMessage (TRCNode dataNode) >- throws TestgenException >- { >- String tempContent = null; >- byte[] decContent = null; >- String content = dataNode.getElement().getContent(); >- if (content == null) >- throw new TestgenException(CorePluginResourceBundle.E_DATA_NO_CONTENT, null); >- >- String encoding = getAttributeValue(PACKET_S_DATA_A_ENCODING, dataNode); >- if (encoding == null) >- throw new TestgenException(CorePluginResourceBundle.E_DATA_NO_ENCODING_ATT, null); >- // TODO: dhinson: needs to handle non-NONE encodings eventually >- // TODO: dhinson: change to equals() when DuWayne fixes value >- if (encoding.equalsIgnoreCase(PACKET_S_DATA_A_ENCODING_V_NONE)) >- ; // do nothing (no translation required) >- else if (encoding.equals(PACKET_S_DATA_A_ENCODING_V_ASCIIFY)) { >- TRCAsciifier myasc = new TRCAsciifier(); >- decContent = new byte[content.length()]; >- myasc.decode(content, 0, content.length(), decContent); >- tempContent = new String(decContent); >- String tmp = tempContent.trim(); >- content = tmp; >- //return; // silently ignore >- } >- else if (encoding.equals(PACKET_S_DATA_A_ENCODING_V_BASE64)) >- return; // silently ignore >- else >- return; // silently ignore >- >- StringTokenizer bodyTokenizer = new StringTokenizer(content, CRNL); >- for (int headerCount = 0; bodyTokenizer.hasMoreTokens(); >- ++headerCount) { >- String header = bodyTokenizer.nextToken(); >- if (headerCount == 0) { >- StringTokenizer headerTokenizer = new StringTokenizer(header); >- >- currentHttpRequest.method = headerTokenizer.nextToken(); >- >- String urn = headerTokenizer.nextToken(); >- if (urn.length() > 6 && urn.substring(0, 7).equals("http://")) { >- try { >- URL url = new URL(urn); >- currentHttpRequest.path = url.getPath(); >- } >- catch (MalformedURLException e) { >- } >- } else >- currentHttpRequest.path = urn; >- >- String version = headerTokenizer.nextToken(); >- currentHttpRequest.version = >- version.substring(version.indexOf(SLASH) + 1, >- version.length()); >- } >- else { >- int colonIndex = header.indexOf(COLON); >- if(colonIndex!=-1){ >- String name = header.substring(0, colonIndex); >- String value = header.substring(colonIndex + 1, header.length()); >- currentHttpRequest.headerNames.add(name); >- currentHttpRequest.headerValues.add(value); >- >- // fetch host and port from Host: header >- if (name.trim().equals("Host")) { >- try { >- URL url = new URL("http://" + value.trim()); >- currentHttpRequest.host = url.getHost(); >- currentHttpRequest.port = url.getPort(); >- if (currentHttpRequest.port == -1) { >- // Check if SSL - if so, use 443 for port >- if (currentHttpRequest.bSSL) >- currentHttpRequest.port = 443; >- else >- currentHttpRequest.port = 80; >- } >- } >- catch (MalformedURLException e) { >- e.printStackTrace(); >- } >- } >- } >- else if(!(CRNL+CRNL).equalsIgnoreCase(header)){ >- currentHttpRequest.body.append(header); >- } >- } >- } >- } >- >- /** >- >- * >- * @param dataNode >- * modified for bugzilla #90867 & #83976 - tejas.patel.ca.com,george.sebastian@ca.com >- * @throws TestgenException >- */ >- private void httpRequestContent (TRCNode dataNode) >- throws TestgenException >- { >- String content = dataNode.getElement().getContent(); >- if (content == null) >- throw new TestgenException(CorePluginResourceBundle.E_DATA_NO_CONTENT, null); >- >- String encoding = getAttributeValue(PACKET_S_DATA_A_ENCODING, dataNode); >- if (encoding == null) >- throw new TestgenException(CorePluginResourceBundle.E_DATA_NO_ENCODING_ATT, null); >- // TODO: dhinson: needs to handle non-NONE encodings eventually >- // TODO: dhinson: change to equals() when DuWayne fixes value >- if (encoding.equalsIgnoreCase(PACKET_S_DATA_A_ENCODING_V_NONE)) >- currentHttpRequest.body.append(content); >- else if (encoding.equals(PACKET_S_DATA_A_ENCODING_V_ASCIIFY)) >- ; // silently ignore >- else if (encoding.equals(PACKET_S_DATA_A_ENCODING_V_BASE64)) >- ; // silently ignore >- else >- ; // silently ignore >- } >- >- /** >- * This method is called when the TRCRecordingInfo node handler >- * has determined that a STOP message has been found >- * >- * This method will call reorderNodeList() to reorder the list of >- * nodes, then call writeNewPageList() to parse the node list and >- * write the information into the behavior model. >- * >- * @throws TestgenException >- * modified for bugzilla #90867 - george.sebastian@ca.com >- */ >- protected void handle_http_stop() throws TestgenException { >- // remove_unwanted_responses(); >- // Call new routine to group the nodes >- reorderNodeList(); >- reorderNodeListAccordingToTimestamp(); >- writeNewPageList(); >- //determinePageEnum(); >- //writePageList(); >- context.setPageNumber(0); >- >- } >- /** >- * This method will parse a http response and return whether it >- * is a new page or not (Content-Type: equals text/html ) >- * >- * @param node >- * @return true if Content-Type header equals text/html >- * modified for bugzilla #90867 & #83976 - tejas.patel.ca.com,george.sebastian@ca.com >- * @throws TestgenException >- */ >- private boolean checkResponseForNewPage(TRCNode node) >- throws TestgenException { >- boolean retcode = false; >- >- >- List dataNodeList = TRCNodeHandler.getSubNodeList(PACKET_S_DATA, node); >- if (dataNodeList.isEmpty()) >- throw new TestgenException(CorePluginResourceBundle.E_PACKET_NO_DATA, null); >- >- // populate currentHttpRequest >- ListIterator itr = dataNodeList.listIterator(); >- while (itr.hasNext()) { >- TRCNode dataNode = (TRCNode)itr.next(); >- >- String type = TRCNodeHandler.getAttributeValue(PACKET_S_DATA_A_TYPE, dataNode); >- if (type == null) >- throw new TestgenException(CorePluginResourceBundle.E_DATA_NO_TYPE_ATT, null); >- >- if(type.equalsIgnoreCase(PACKET_S_DATA_A_TYPE_V_HTTPDATA)){ >- retcode = httpRequestMessageContentType(dataNode); >- break; >- } >- if (type.equals(PACKET_S_DATA_A_TYPE_V_HTTPMESSAGE)){ >- retcode = httpRequestMessageContentType(dataNode); >- break; >- } >- else >- // ignore any others >- continue; >- } >- return retcode; >- } >- /** >- * Parse http Request to see if Content-Type: is >- * text/html. Return true to indicate new page. >- * >- * @param dataNode >- * modified for bugzilla #90867 & #83976 -george.sebastian@ca.com >- * @return >- * @throws TestgenException >- */ >- private boolean httpRequestMessageContentType(TRCNode dataNode) >- throws TestgenException { >- boolean isNewPage = false; >- >- String content = dataNode.getElement().getContent(); >- if (content == null) >- throw new TestgenException(CorePluginResourceBundle.E_DATA_NO_CONTENT, null); >- int contentLocation = getContentLocation(content); >- if (contentLocation!=-1){ >- content = content.substring(0,contentLocation-CRNL.length()); >- } >- StringTokenizer bodyTokenizer = new StringTokenizer(content, CRNL); >- for (int headerCount = 0; bodyTokenizer.hasMoreTokens(); >- ++headerCount) { >- String header = bodyTokenizer.nextToken(); >- if (headerCount == 0) { >- // Do nothing >- } >- else { >- int colonIndex = header.indexOf(COLON); >- if(colonIndex==-1){ >- continue; >- } >- String name = header.substring(0, colonIndex); >- String value = header.substring(colonIndex + 1, header.length()); >- >- // fetch Content-Type >- if (name.trim().equalsIgnoreCase("Content-Type")) { >- String tempstr = value.trim().toLowerCase(); >- if (tempstr.trim().startsWith("text/html")) >- isNewPage = true; >- else >- isNewPage = false; >- break; >- } >- } >- } >- if (!isNewPage) { >- // now check for Redirection - status code of 301 or 302 >- isNewPage = checkForRedirect(dataNode); >- } >- return isNewPage; >- } >- /** >- * Loops through the original list of TRCNode nodes, removing responses >- * that contain html or jpeg information (that don't have headers) >- * >- * @throws TestgenException >- */ >- private void remove_unwanted_responses() throws TestgenException { >- LinkedList pageList = null; >- boolean writethisNode = true; >- int totalNodes = 0; >- int i = 0; >- TRCNode node = null; >- LinkedList newPageList = new LinkedList(); >- >- pageList = context.getPageList(); >- totalNodes = pageList.size(); >- for (i = 0; i < totalNodes; i++) { >- node = (TRCNode)pageList.get(i); >- writethisNode = shouldIWriteNode(node); >- if (writethisNode) >- newPageList.add(node); >- } >- int newTotalNodes = newPageList.size(); >- if (newTotalNodes > 0){ >- pageList.clear(); >- context.setPageList(newPageList); >- } >- } >- /** >- * Determine whether a node has information we need and should be >- * included in the new list of nodes. >- * >- * @param node >- * modified for bugzilla #90867 & #83976 - tejas.patel.ca.com,george.sebastian@ca.com >- * @return false if this node is from server and is content only >- * @throws TestgenException >- */ >- boolean shouldIWriteNode(TRCNode node) throws TestgenException { >- boolean writeNode = true; >- boolean fromServer = false; >- boolean isContent = false; >- >- // populate currentHttpRequest >- >- String from = TRCNodeHandler.getAttributeValue(PACKET_A_FROM, node); >- if (from.equals(PACKET_A_FROM_V_CLIENT)) { >- return true; >- } >- else if (from.equals(PACKET_A_FROM_V_SERVER)) { >- fromServer = true; >- } >- >- List dataNodeList = TRCNodeHandler.getSubNodeList(PACKET_S_DATA, node); >- if (dataNodeList.isEmpty()) >- throw new TestgenException(CorePluginResourceBundle.E_PACKET_NO_DATA, null); >- >- ListIterator itr = dataNodeList.listIterator(); >- while (itr.hasNext()) { >- TRCNode dataNode = (TRCNode)itr.next(); >- >- String type = TRCNodeHandler.getAttributeValue(PACKET_S_DATA_A_TYPE, dataNode); >- if (type == null) >- throw new TestgenException(CorePluginResourceBundle.E_DATA_NO_TYPE_ATT, null); >- if (type.equals(PACKET_S_DATA_A_TYPE_V_HTTPMESSAGE)) { >- return true; >- } >- if (type.equals(PACKET_S_DATA_A_TYPE_V_HTTPCONTENT)) { >- isContent = true; >- break; >- } >- if (type.equals(PACKET_S_DATA_A_TYPE_V_HTTPDATA)){ >- isNewType = true; >- return true; >- } >- else >- // ignore any others >- continue; >- } >- if (fromServer && isContent) >- writeNode = false; >- >- return writeNode; >- } >- >- /** >- * @param node >- * @return true if this node is a response (from server) >- */ >- boolean checkIsResponse(TRCNode node) { >- boolean isResponse = false; >- >- String from = TRCNodeHandler.getAttributeValue(PACKET_A_FROM, node); >- if (from.equals(PACKET_A_FROM_V_CLIENT)){ >- isResponse = false; >- } >- else if (from.equals(PACKET_A_FROM_V_SERVER)) { >- isResponse = true; >- } >- return isResponse; >- } >- >- /** >- * @param node >- * @return true if this node is from the CLIENT >- */ >- boolean checkIsRequest(TRCNode node) { >- boolean isRequest = false; >- >- String from = TRCNodeHandler.getAttributeValue(PACKET_A_FROM, node); >- if (from.equals(PACKET_A_FROM_V_CLIENT)){ >- isRequest = true; >- } >- else if (from.equals(PACKET_A_FROM_V_SERVER)) { >- isRequest = false; >- } >- return isRequest; >- } >- /** >- * Check response for status code of 301 or 302 which indicates redirection >- * >- * @param node >- * @return >- * @throws TestgenException >- */ >- boolean checkForRedirect(TRCNode node) throws TestgenException { >- >- boolean isRedirect = false; >- String content = node.getElement().getContent(); >- if (content == null) { >- throw new TestgenException(CorePluginResourceBundle.E_DATA_NO_CONTENT, null); >- } >- StringTokenizer bodyTokenizer = new StringTokenizer(content, CRNL); >- String statusLine = bodyTokenizer.nextToken(); >- // at this point have HTTP/1.1 301 Object Temporarily Moved >- StringTokenizer status = new StringTokenizer(statusLine, BLANK); >- status.nextToken(); // This is HTTP/1.1 >- String actualStatus = status.nextToken();// This is 200 or 302 or 301, etc... >- Integer intStat = new Integer(actualStatus); >- int actualVal = intStat.intValue(); >- if ((actualVal == 302) || (actualVal == 301)) >- isRedirect = true; >- >- return isRedirect; >- } >- /** >- * @param node >- * modifed for bugzilla #90867 & #83976 - tejas.patel.ca.com,george.sebastian@ca.com >- * @return >- * @throws TestgenException >- */ >- private boolean parseHttpRequest (TRCNode node) >- throws TestgenException >- { >- boolean retcode = false; >- String timestampString = TRCNodeHandler.getAttributeValue(PACKET_A_TIMESTAMP, node); >- >- List dataNodeList = TRCNodeHandler.getSubNodeList(PACKET_S_DATA, node); >- if (dataNodeList.isEmpty()) >- throw new TestgenException(CorePluginResourceBundle.E_PACKET_NO_DATA, null); >- >- // reset currentHttpRequest >- currentHttpRequest = new ParsedHttpMessage(); >- >- String typeValue = TRCNodeHandler.getAttributeValue(PACKET_A_TYPE, node); >- if (typeValue.equals(PACKET_A_TYPE_V_HTTPS)) >- currentHttpRequest.bSSL = true; >- else >- currentHttpRequest.bSSL = false; >- >- // populate currentHttpRequest >- ListIterator itr = dataNodeList.listIterator(); >- while (itr.hasNext()) { >- TRCNode dataNode = (TRCNode)itr.next(); >- >- String type = TRCNodeHandler.getAttributeValue(PACKET_S_DATA_A_TYPE, dataNode); >- if (type == null) >- throw new TestgenException(CorePluginResourceBundle.E_DATA_NO_TYPE_ATT, null); >- >- if(type.equals(PACKET_S_DATA_A_TYPE_V_HTTPDATA)){ >- httpRequestMessage(dataNode); >- //httpRequestContent(dataNode); >- } >- else if (type.equals(PACKET_S_DATA_A_TYPE_V_HTTPMESSAGE)) >- httpRequestMessage(dataNode); >- else if (type.equals(PACKET_S_DATA_A_TYPE_V_HTTPCONTENT)) >- httpRequestContent(dataNode); >- else >- // ignore any others >- continue; >- } >- >- int pageNumber = context.getPageNumber(); >- currentHttpRequest.nPageNum = pageNumber; >- String connectionNumber = TRCNodeHandler.getAttributeValue(PACKET_A_CONNECTIONNAME, node); >- Integer thisConn = new Integer(connectionNumber); >- currentHttpRequest.nConnID = thisConn.intValue(); >- currentHttpRequest.timeStampString = timestampString; >- >- return retcode; >- } >- /** >- * @param thisMessage >- * @return >- */ >- private boolean createPage(ParsedHttpMessage thisMessage){ >- boolean retcode = false; >- >- int timestamp = 0; >- >- int pageNumber = context.getPageNumber(); >- >- String timestampString = thisMessage.timeStampString; >- if (timestampString != null) >- timestamp = Integer.parseInt(timestampString); >- if ((thisMessage.enumPage == HttpRequest.PAGE_ONLY) || (thisMessage.enumPage == HttpRequest.PAGE_START) >- || (pageNumber == 0)) >- { >- pageNumber += 1; >- context.setPageNumber(pageNumber); >- // thisLoop = context.createNewPage(pageNumber); >- String newPageName = thisMessage.host + thisMessage.path; >- context.createNewPage(newPageName); >- } >- String testCaseName = thisMessage.method + " " + >- thisMessage.host; >- context.newTestCaseContext(testCaseName); >- thisMessage.nPageNum = pageNumber; >- // fetch and populate RequestHelper... >- RequestHelper requestHelper = context.getRequestHelper(); >- >- // ... headers >- requestHelper.setAttribute(RequestHelper.ATT_METHOD, >- thisMessage.method); >- requestHelper.setAttribute(RequestHelper.ATT_HOST, >- thisMessage.host); >- requestHelper.setAttribute(RequestHelper.ATT_PORT, >- Integer.toString(thisMessage.port)); >- requestHelper.setAttribute(RequestHelper.ATT_ABS_PATH, >- thisMessage.path); >- requestHelper.setAttribute(RequestHelper.ATT_VERSION, >- thisMessage.version); >- for (int i = 0; i < thisMessage.headerNames.size(); ++i) >- requestHelper.setHeader(((String)thisMessage.headerNames. >- get(i)).trim(), ((String)thisMessage.headerValues. >- get(i)).trim()); >- >- // New attributes from RequestHelper mdd >- // ATT_PAGE_NUM = 8; >- // ATT_PAGE_ORDER = 9; >- // ATT_CONN_ID = 10; >- // ATT_CONN_ORDER = 11; >- // ATT_IS_SSL = 12; >- >- requestHelper.setAttribute(RequestHelper.ATT_PAGE_NUM, >- Integer.toString(thisMessage.nPageNum)); >- requestHelper.setAttribute(RequestHelper.ATT_PAGE_ORDER, >- Integer.toString(thisMessage.enumPage)); >- requestHelper.setAttribute(RequestHelper.ATT_CONN_ID, >- Integer.toString(thisMessage.nConnID)); >- if (thisMessage.bSSL) >- requestHelper.setAttribute(RequestHelper.ATT_IS_SSL, "true"); >- else >- requestHelper.setAttribute(RequestHelper.ATT_IS_SSL, "false"); >- >- // ... body >- requestHelper.setAttribute(RequestHelper.ATT_BODY, >- thisMessage.body.toString()); >- >- // ... calculate and set request's think time >- HashMap myLastRecvHashMap = context.getLastRecvHashMap(); >- >- int thinkTime = 0; >- Integer lastRecvInteger = (Integer)myLastRecvHashMap.get(TRCContext.GLOBAL_LASTRECV); >- if (lastRecvInteger != null) { >- int lastRecv = lastRecvInteger.intValue(); >- // thinkTime = (lastRecv == -1) ? timestamp : timestamp - lastRecv; >- thinkTime = (lastRecv == -1) ? 0 : timestamp - lastRecv; >- if (thinkTime < 0) >- thinkTime = 0; >- } >- requestHelper.setAttribute(RequestHelper.ATT_THINK_TIME, >- Integer.toString(thinkTime)); >- >- return retcode; >- } >- >- /** >- * @param node >- * @return >- * @throws TestgenException >- */ >- private ResponseInfo parseHttpResponse(TRCNode node) throws TestgenException { >- ResponseInfo thisResponse = new ResponseInfo(); >- HashMap myLastRecvHashMap = context.getLastRecvHashMap(); >- >- int timestamp = Integer.parseInt(TRCNodeHandler.getAttributeValue(PACKET_A_TIMESTAMP, >- node)); >- myLastRecvHashMap.put(TRCContext.GLOBAL_LASTRECV, new Integer(timestamp)); >- context.setLastRecvHashMap(myLastRecvHashMap); >- thisResponse.timeStampString = TRCNodeHandler.getAttributeValue(PACKET_A_TIMESTAMP,node); >- thisResponse.newPage = checkResponseForNewPage(node); >- >- return thisResponse; >- } >- >- /** >- * @throws TestgenException >- * This routine will reorder the node list in connections then use the new >- * this list to process. >- */ >- private void reorderNodeList() throws TestgenException { >- int totalNodes = -1; >- int i = 0; >- remove_unwanted_responses(); >- LinkedList originalNodeList = context.getPageList(); >- totalNodes = originalNodeList.size(); >- TRCNode node; >- int connectionIndex = -1; >- int connectionNumber = -1; >- >- for (i = 0; i < totalNodes; i++){ >- // check connection number first >- node = (TRCNode)originalNodeList.get(i); >- String strConnectionNumber = TRCNodeHandler.getAttributeValue(PACKET_A_CONNECTIONNAME, node); >- Integer thisConn = new Integer(strConnectionNumber); >- connectionNumber = thisConn.intValue(); >- >- connectionIndex = findConnection(connectionNumber); >- if (connectionIndex == -1) { >- addConnectionNode(connectionNumber,node); >- } >- else { >- addConnectionChild(connectionIndex, node); >- } >- } >- // Now replace old List with New List >- createNewPageList(); >- } >- /** >- * Reorders the nodes in newpage list in the ascending order of time stamp >- * added for for bugzilla #90867 & #83976 - shobhit.maini@ca.com >- * @throws TestgenException >- */ >- >- private void reorderNodeListAccordingToTimestamp() throws TestgenException { >- >- Collections.sort(newPageList, new NewPageListComparator()); >- } >- >- >- >- /** >- * This routine will return the index for this connection, if it exists >- * >- * @param connectionNumber >- * the connection number to find >- * @return >- * The index of the found connection number or >- * -1 if not found >- */ >- private int findConnection(int connectionNumber) { >- int foundIndex = -1; >- int numberOfConnections = -1; >- int i = 0; >- ConnectionNode thisConnection; >- >- numberOfConnections = connectionsList.size(); >- if (numberOfConnections == 0) { >- foundIndex = -1; >- } >- else { >- for (i = 0; i < numberOfConnections; i++) { >- thisConnection = (ConnectionNode)connectionsList.get(i); >- if (thisConnection.connectionNumber == connectionNumber) { >- foundIndex = i; >- break; >- } >- } >- } >- return foundIndex; >- } >- >- /** >- * This method creates a new Connection node, and adds newNode as >- * the first child of that node >- * >- * @param connectionNumber >- * @param newNode >- * @return >- */ >- private boolean addConnectionNode(int connectionNumber, TRCNode newNode){ >- boolean retcode = true; >- >- // Create a new ConnectionNode >- ConnectionNode newConnectionNode = new ConnectionNode(); >- // Add the connection number and the new child >- newConnectionNode.connectionNumber = connectionNumber; >- newConnectionNode.childrenNodes = new LinkedList(); >- newConnectionNode.childrenNodes.add(newNode); >- // Add this connectionNode to the ConnectionsList >- connectionsList.add(newConnectionNode); >- >- >- return retcode; >- } >- /** >- * This method adds newNode as a child of the Connection node found >- * at connectionIndex >- * >- * @param connectionIndex >- * @param newNode >- * @return >- */ >- public boolean addConnectionChild(int connectionIndex, TRCNode newNode){ >- boolean retcode = true; >- >- ConnectionNode thisConnection = (ConnectionNode)connectionsList.get(connectionIndex); >- thisConnection.childrenNodes.add(newNode); >- return retcode; >- } >- >- /** >- * This method goes through each Connection node, and adds each child >- * found for that Connection node to the reordered list of TRCNode nodes >- * >- * This newPageList will be processed to create the testsuite. >- * @return >- * modified for bugzilla #90867 & #83976 - george.sebastian@ca.com >- * @throws TestgenException >- * >- */ >- private void createNewPageList() throws TestgenException { >- >- if (isNewType()){ >- createPageListNew(); >- return; >- } >- createPageListOld(); >- } >- >- //added for bugzilla #90867 & #83976 - tejas.patel.ca.com,george.sebastian@ca.com >- private void createPageListOld() throws TestgenException { >- int totalConnections = -1; >- int i = 0; >- int j = 0; >- ConnectionNode thisConnection = null; >- TRCNode thisNode = null; >- TRCNode nextNode = null; >- int totalChildren = -1; >- totalConnections = connectionsList.size(); >- for (i = 0; i < totalConnections; i++){ >- thisConnection = (ConnectionNode)connectionsList.get(i); >- totalChildren = thisConnection.childrenNodes.size(); >- childrenLoop: >- for (j = 0; j < totalChildren; j++){ >- thisNode = (TRCNode)thisConnection.childrenNodes.get(j); >- for(int counter = 1; ; counter++) >- { >- if((counter+j) >= totalChildren){ >- break; >- } >- if(checkIsPOSTRequest(thisNode)){ >- >- nextNode = (TRCNode)thisConnection.childrenNodes.get(j+counter); >- String from = TRCNodeHandler.getAttributeValue(PACKET_A_FROM,nextNode); >- if(!from.equalsIgnoreCase(PACKET_A_FROM_V_SERVER)){ >- thisNode.getElement().setContent(nextNode.getElement().getContent()); >- ((TRCNode)thisNode.getSubNodes().getFirst()).getElement().setContent( >- ((TRCNode)nextNode.getSubNodes().getFirst()).getElement().getContent()); >- j++; >- } >- else{ >- boolean isContinue = checkForContinue(nextNode); >- if(true == isContinue) >- { >- ((TRCNode)thisNode.getSubNodes().getFirst()).getElement().setContent( >- ((TRCNode)nextNode.getSubNodes().getFirst()).getElement().getContent()); >- continue; >- } >- else >- { >- newPageList.add(thisNode); >- j = j + counter - 1; >- continue childrenLoop; >- } >- } >- } >- } >- newPageList.add(thisNode); >- continue childrenLoop; >- } >- } >- >- } >- // added for bugzilla #90867 & #83976 - tejas.patel.ca.com,george.sebastian@ca.com >- private void createPageListNew() throws TestgenException { >- int totalConnections = -1; >- int i = 0; >- int j = 0; >- int counter = 0; >- ConnectionNode thisConnection = null; >- TRCNode thisNode = null; >- int totalChildren = -1; >- >- totalConnections = connectionsList.size(); >- connectionLoop: >- for (i = 0; i < totalConnections; i++){ >- >- thisConnection = (ConnectionNode)connectionsList.get(i); >- totalChildren = thisConnection.childrenNodes.size(); >- >- childrenLoop: >- for (j = 0; j < totalChildren; j++){ >- >- thisNode = (TRCNode)thisConnection.childrenNodes.get(j); >- String from = TRCNodeHandler.getAttributeValue(PACKET_A_FROM, thisNode); >- >- if(from.equals(PACKET_A_FROM_V_CLIENT)) >- { >- for(counter = 1; ; counter++) >- { >- if((j + counter) >= totalChildren) >- { >- newPageList.add(thisNode); >- continue connectionLoop; >- } >- >- TRCNode nextNode = (TRCNode)thisConnection.childrenNodes.get(j + counter); >- from = TRCNodeHandler.getAttributeValue(PACKET_A_FROM, nextNode); >- >- if(from.equals(PACKET_A_FROM_V_SERVER)) >- { >- if(checkIsPOSTRequest(thisNode)) >- { >- boolean isContinue = checkForContinue(nextNode); >- if(true == isContinue) >- { >- ((TRCNode)thisNode.getSubNodes().getFirst()).getElement().setContent( >- ((TRCNode)nextNode.getSubNodes().getFirst()).getElement().getContent()); >- continue; >- } >- else >- { >- newPageList.add(thisNode); >- j = j + counter - 1; >- continue childrenLoop; >- } >- } >- newPageList.add(thisNode); >- j = j + counter - 1; >- continue childrenLoop; >- }else{ >- //thisNode.getElement().setContent(nextNode.getElement().getContent()); >- ((TRCNode)thisNode.getSubNodes().getFirst()).getElement().setContent( >- ((TRCNode)nextNode.getSubNodes().getFirst()).getElement().getContent()); >- } >- } >- >- } >- if (from.equals(PACKET_A_FROM_V_SERVER)) { >- >- for(counter = 1; ; counter++) >- { >- if((j + counter) >= totalChildren) >- { >- newPageList.add(thisNode); >- continue connectionLoop; >- } >- >- TRCNode nextNode = (TRCNode)thisConnection.childrenNodes.get(j + counter); >- from = TRCNodeHandler.getAttributeValue(PACKET_A_FROM, nextNode); >- if(from.equals(PACKET_A_FROM_V_CLIENT)) >- { >- newPageList.add(thisNode); >- j = j + counter - 1; >- continue childrenLoop; >- } >- thisNode.getElement().setContent(nextNode.getElement().getContent()); >- } >- >- } >- newPageList.add(thisNode); >- } >- } >- >- } >- >- /** Check request for POST method >- * >- * @param dataNode >- * @return >- * added for bugzilla #90867 & #83976 - tejas.patel.ca.com,george.sebastian@ca.com >- * @throws TestgenException >- */ >- boolean checkIsPOSTRequest(TRCNode dataNode) throws TestgenException { >- boolean isPOSTRequest = false; >- String tempContent = null; >- byte[] decContent = null; >- String content = ((TRCNode)dataNode.getSubNodes().getFirst()).getElement().getContent(); >- if (content == null) >- throw new TestgenException(CorePluginResourceBundle.E_DATA_NO_CONTENT, null); >- >- String encoding = getAttributeValue(PACKET_S_DATA_A_ENCODING, dataNode); >- if (encoding == null) >- throw new TestgenException(CorePluginResourceBundle.E_DATA_NO_ENCODING_ATT, null); >- // TODO: dhinson: needs to handle non-NONE encodings eventually >- // TODO: dhinson: change to equals() when DuWayne fixes value >- if (encoding.equalsIgnoreCase(PACKET_S_DATA_A_ENCODING_V_NONE)) >- ; // do nothing (no translation required) >- else if (encoding.equals(PACKET_S_DATA_A_ENCODING_V_ASCIIFY)) { >- TRCAsciifier myasc = new TRCAsciifier(); >- decContent = new byte[content.length()]; >- myasc.decode(content, 0, content.length(), decContent); >- tempContent = new String(decContent); >- String tmp = tempContent.trim(); >- content = tmp; >- >- } >- else if (encoding.equals(PACKET_S_DATA_A_ENCODING_V_BASE64)) >- return false; >- else >- return false; >- >- StringTokenizer bodyTokenizer = new StringTokenizer(content, CRNL); >- for (int headerCount = 0; bodyTokenizer.hasMoreTokens(); >- ++headerCount) { >- String header = bodyTokenizer.nextToken(); >- if (headerCount == 0) { >- StringTokenizer headerTokenizer = new StringTokenizer(header); >- if(HTTP_POST.equalsIgnoreCase(headerTokenizer.nextToken().trim())){ >- return true; >- >- } >- >- } >- } >- return isPOSTRequest; >- } >- >- /** Check response for status code of 100 which indicates continue >- * >- * @param node >- * added for bugzilla #90867 & #83976 - tejas.patel.ca.com >- * @return >- * @throws TestgenException >- */ >- boolean checkForContinue(TRCNode node) throws TestgenException { >- >- boolean isContinue = false; >- String content = ((TRCNode)node.getSubNodes().getFirst()).getElement().getContent(); >- //String content = node.getElement().getContent(); >- if (content == null) { >- throw new TestgenException(CorePluginResourceBundle.E_DATA_NO_CONTENT, null); >- } >- StringTokenizer bodyTokenizer = new StringTokenizer(content, CRNL); >- String statusLine = bodyTokenizer.nextToken(); >- // at this point have HTTP/1.1 100 Continue >- StringTokenizer status = new StringTokenizer(statusLine, BLANK); >- status.nextToken(); // This is HTTP/1.1 >- String actualStatus = status.nextToken();// This is 200 or 100 or 301, etc... >- Integer intStat = new Integer(actualStatus); >- int actualVal = intStat.intValue(); >- if (actualVal == 100){ >- isContinue = true; >- } >- return isContinue; >- } >- /** >- * This method goes through the newly reordered TRCNode node list, >- * and creates Behavior Model entries for each. One of the elements of >- * the behavior model is page enumeration (begin, middle, end or only). >- * Since you don't know the enumeration of a particular request/response >- * pair until you have looked at the subsequent pair, we must store the >- * request and compare the current request to the previous response to >- * determine enumeration. >- * >- * Determine if node is a HttpRequest or HttpResponse >- * If HttpRequest >- * parse request and populate currentHttpRequest >- * If HttpResponse >- * parse request and determine if it is a New Page >- * >- * If have both the request and response >- * Determine the Page Enumeration for Previous Response >- * Write Previous Response >- * >- * @throws TestgenException >- */ >- public void writeNewPageList() throws TestgenException { >- int totalNodes = -1; >- int i = 0; >- boolean isARequest = false; >- TRCNode currentNode = null; >- boolean haveRequest = false; >- boolean haveResponse = false; >- ResponseInfo responseInfo = null; >- >- // Process the entire node list >- totalNodes = newPageList.size(); >- for (i = 0; i < totalNodes; i++) { >- currentNode = (TRCNode)newPageList.get(i); >- isARequest = checkIsRequest(currentNode); >- if (isARequest) { >- haveRequest = true; >- parseHttpRequest(currentNode); >- } >- else { >- haveResponse = true; >- responseInfo = parseHttpResponse(currentNode); >- currentHttpRequest.timeStampString = responseInfo.timeStampString; >- currentHttpRequest.newPage = responseInfo.newPage; >- } >- >- if (haveRequest && haveResponse) { >- haveRequest = false; >- haveResponse = false; >- if (totalNodes == 2) { >- currentHttpRequest.newPage = true; >- currentHttpRequest.enumPage = HttpRequest.PAGE_ONLY; >- createPage(currentHttpRequest); >- break; >- } >- if ((previousHttpRequest == null) || (i == 1)) { >- // This is the First Page >- currentHttpRequest.newPage = true; >- currentHttpRequest.enumPage = HttpRequest.PAGE_START; >- previousHttpRequest = currentHttpRequest; >- } >- else { >- if (previousHttpRequest.newPage) { >- // Previous Request IS a new page >- if (currentHttpRequest.newPage) { >- previousHttpRequest.enumPage = HttpRequest.PAGE_ONLY; >- } >- else { >- // Current Request NOT a new page >- previousHttpRequest.enumPage = HttpRequest.PAGE_START; >- } >- } >- else { >- // Previous Message NOT a new page >- if (currentHttpRequest.newPage) { >- previousHttpRequest.enumPage = HttpRequest.PAGE_END; >- } >- else { >- previousHttpRequest.enumPage = HttpRequest.PAGE_MID; >- } >- } >- createPage(previousHttpRequest); >- previousHttpRequest = currentHttpRequest; >- previousHttpRequest.enumPage = HttpRequest.PAGE_END; >- if (i == (totalNodes - 1)) { >- if (previousHttpRequest.newPage) >- previousHttpRequest.enumPage = HttpRequest.PAGE_ONLY; >- createPage(previousHttpRequest); >- } >- >- } >- } >- } >- } >- >- /** >- * >- * @param attribute >- * added for bugzilla #90867 & #83976 - george.sebastian@ca.com >- * @param node >- * @return >- */ >- >- private String getAttributeValue(String attribute, TRCNode node) { >- >- String value = TRCNodeHandler.getAttributeValue(attribute,node); >- if (value == null ){ >- >- for (int i = 0 ; i <node.getSubNodes().size() ; i++) { >- value = getAttributeValue(attribute, (TRCNode) node.getSubNodes().get(i)); >- if (value != null) >- return value; >- } >- } >- return value; >- } >- // added for bugzilla #90867 & #83976 - george.sebastian@ca.com >- public boolean isNewType() { >- return isNewType; >- } >- // added for bugzilla #90867 & #83976 - tejas.patel.ca.com >- private int getContentLocation(String str) >- { >- int iRet = -1; >- >- iRet = str.indexOf(CRNL + CRNL); >- >- if(-1 != iRet) >- iRet += 4; >- >- return iRet; >- >- } >-} >Index: src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCElement.java >=================================================================== >RCS file: src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCElement.java >diff -N src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCElement.java >--- src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCElement.java 9 Jun 2005 17:00:43 -0000 1.4 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,87 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: TRCElement.java,v 1.4 2005/06/09 17:00:43 jnevicos Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >-package org.eclipse.hyades.execution.testgen.http; >- >- >-/** >- * @author dhinson >- * >- * @deprecated should not be public API. Will be changed to internal in TPTP 5. >- */ >-public class TRCElement >-{ >- public class TRCAttribute >- { >- public String name; >- public String value; >- >- public TRCAttribute (String name, String value) >- { >- this.name = name; >- this.value = value; >- } >- } >- >- private String name; >- private TRCAttribute [] attributes; >- private int attributeCount; >- private StringBuffer contentBuffer; >- private TRCNode node; >- >- public TRCElement (int nAttributes) >- { >- attributes = new TRCAttribute[nAttributes]; >- } >- >- public void setName (String name) >- { >- this.name = name; >- } >- >- public String getName () >- { >- return this.name; >- } >- >- public void addAttribute (String name, String value) >- { >- attributes[attributeCount++] = new TRCElement.TRCAttribute(name, value); >- } >- >- public TRCAttribute [] getAttributes () >- { >- return this.attributes; >- } >- >- public void setContent (String content) >- { >- if (contentBuffer == null) >- contentBuffer = new StringBuffer(); >- contentBuffer.append(content); >- } >- >- public String getContent () >- { >- return contentBuffer.toString(); >- } >- >- public void setNode (TRCNode node) >- { >- this.node = node; >- } >- >- public TRCNode getNode () >- { >- return this.node; >- } >- >-} >Index: src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCNode.java >=================================================================== >RCS file: src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCNode.java >diff -N src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCNode.java >--- src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCNode.java 9 Jun 2005 17:00:43 -0000 1.4 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,74 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: TRCNode.java,v 1.4 2005/06/09 17:00:43 jnevicos Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >-package org.eclipse.hyades.execution.testgen.http; >- >-import java.util.LinkedList; >- >- >-/** >- * @author dhinson >- * >- * @deprecated should not be public API. Will be changed to internal in TPTP 5. >- */ >-public class TRCNode >-{ >- private String name; >- private TRCElement element; >- private TRCNode parentNode; >- private LinkedList subNodes = new LinkedList(); >- >- public TRCNode (String name) >- { >- this.name = name; >- } >- >- public void setName (String name) >- { >- this.name = name; >- } >- >- public String getName () >- { >- return name; >- } >- >- public void setElement (TRCElement element) >- { >- this.element = element; >- } >- >- public TRCElement getElement () >- { >- return element; >- } >- >- public void setParentNode (TRCNode parentNode) >- { >- this.parentNode = parentNode; >- } >- >- public TRCNode getParentNode () >- { >- return parentNode; >- } >- >- public void setSubNodes (LinkedList subNodes) >- { >- this.subNodes = subNodes; >- } >- >- public LinkedList getSubNodes () >- { >- return subNodes; >- } >- >-} >Index: src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCRecorderInfoNodeHandler.java >=================================================================== >RCS file: src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCRecorderInfoNodeHandler.java >diff -N src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCRecorderInfoNodeHandler.java >--- src-testgen-http/org/eclipse/hyades/execution/testgen/http/TRCRecorderInfoNodeHandler.java 3 May 2007 18:21:00 -0000 1.7 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,63 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: TRCRecorderInfoNodeHandler.java,v 1.7 2007/05/03 18:21:00 paules Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >-package org.eclipse.hyades.execution.testgen.http; >- >-import org.eclipse.hyades.test.core.testgen.TestgenException; >- >- >- >-/** >- * @author mdunn >- * >- * @deprecated should not be public API. Will be changed to internal in TPTP 5. >- * >- */ >-public class TRCRecorderInfoNodeHandler extends TRCNodeHandler implements ITRCNodeHandler >-{ >- >- private static final String RECORDERINFO_A_TYPE >- = "type"; >- private static final String RECORDERINFO_A_TYPE_V_STOP >- = "STOP"; >- >- public void init (TRCContext context) >- throws TestgenException >- { >- super.init(context); >- } >- >- public void node (TRCNode node) >- throws TestgenException >- { >- >- // dispatch on type attribute >- String typeValue = getAttributeValue(RECORDERINFO_A_TYPE, node); >- if (typeValue.equals(RECORDERINFO_A_TYPE_V_STOP)) { >- handle_stop(); >- return; >- } >- else { >- // currently ignore anything but "STOP" >- return; >- } >- } >- // write all this info out from the pageList LinkedList >- private void handle_stop() throws TestgenException { >- TestGenHttp myHttp = new TestGenHttp(context); >- myHttp.handle_http_stop(); >- >- >- } >- >- >- >-} >#P org.eclipse.hyades.test.ui >Index: src-testgen/org/eclipse/hyades/execution/testgen/TestgenPlugin.java >=================================================================== >RCS file: src-testgen/org/eclipse/hyades/execution/testgen/TestgenPlugin.java >diff -N src-testgen/org/eclipse/hyades/execution/testgen/TestgenPlugin.java >--- src-testgen/org/eclipse/hyades/execution/testgen/TestgenPlugin.java 3 May 2007 17:36:06 -0000 1.10 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,144 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: TestgenPlugin.java,v 1.10 2007/05/03 17:36:06 paules Exp $ >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- **********************************************************************/ >-package org.eclipse.hyades.execution.testgen; >- >-import java.util.MissingResourceException; >-import java.util.ResourceBundle; >- >-import org.eclipse.core.resources.IWorkspace; >-import org.eclipse.core.resources.ResourcesPlugin; >-import org.eclipse.core.runtime.Platform; >-import org.eclipse.hyades.test.core.testgen.TestGeneratorFactory; >-import org.eclipse.hyades.test.ui.UiPlugin; >-import org.eclipse.jface.preference.IPreferenceStore; >-import org.eclipse.ui.plugin.AbstractUIPlugin; >- >-/** >- * The main Testgen plugin >- * @author Ernest Jessee >- * @deprecated use main UIPlugin >- */ >-public class TestgenPlugin extends AbstractUIPlugin { >- /** >- * The default instance of this plugin >- */ >- private static TestgenPlugin plugin; >- >- /** >- * preference store keys >- */ >- public static final String TEST_GENERATOR="default_test_generator"; //$NON-NLS-1$ >- //public static final String SELECTED_GENERATOR="selected_generator"; //$NON-NLS-1$ >- public static final String ID = "org.eclipse.hyades.test.ui"; //$NON-NLS-1$ >- private ResourceBundle resourceBundle; >- >- public TestgenPlugin() { >- super(); >- getResourceBundle(); >- plugin=this; >- } >- >- /** >- * Returns the shared instance. >- */ >- public static TestgenPlugin getDefault() { >- return plugin; >- } >- >- /** >- * Returns the workspace instance. >- */ >- public static IWorkspace getWorkspace() { >- return ResourcesPlugin.getWorkspace(); >- } >- >- /** >- * Resolves the localized message associated with the parameter <code>key</code> >- * based on the default locale from the plugin's resource bundle. >- * <p> >- * If the <code>key</code> does not exist in the plugin's resource bundle, the >- * <code>key</code> is returned. >- * <p> >- * Noteworthy, the resultant message is not formatted (e.g. no message parameter substitution). >- * <p> >- * >- * @param key The <code>key</code> of the message in the plugin's resource bundle. >- * @return The localized message associated with the parameter <code>key</code> from the plugin's resource bundle, otherwise the <code>key</code>. >- * @deprecated As of TPTP V4.4, use {@link org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle} for resolving resources. The plugin.properties property file ONLY contains messages for the this plug-in's MANIFEST.MF and plugin.xml files. >- */ >- public static String getResourceString(String key) { >- ResourceBundle bundle = UiPlugin.getDefault().getResourceBundle(); >- try { >- return (bundle != null) ? bundle.getString(key) : key; >- } catch (MissingResourceException e) { >- return key; >- } >- } >- >- /** >- * Resolves the plugin's resource bundle. >- * <p> >- * If the plugin's resource bundle can not be resolved, <code>null</code> is returned. >- * <p> >- * IMPORTANT: Do not use this method to retrieve values from the resource bundle. This method >- * is provided so this plugin's resource bundle can be used as the parent of another plugin's >- * resource bundle. >- * <p> >- * >- * @return The plugin's resource bundle, otherwise <code>null</code>. >- * @deprecated As of TPTP V4.4, use {@link org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle} for resolving resources. The plugin.properties property file ONLY contains messages for the this plug-in's MANIFEST.MF and plugin.xml files. >- */ >- public ResourceBundle getResourceBundle() { >- try { >- if (resourceBundle == null) >- resourceBundle = Platform.getResourceBundle(Platform.getBundle(ID)); >- } catch (MissingResourceException x) { >- resourceBundle = null; >- } >- return resourceBundle; >- } >- >- /** >- * acquires a reference to a plugin preference specified by "key" >- * @param key >- * @return >- */ >- public static String getPreference(String key) >- { >- return getDefault().getPreferenceStore().getString(key); >- } >- >- /** >- * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeDefaultPreferences(org.eclipse.jface.preference.IPreferenceStore) >- */ >- protected void initializeDefaultPreferences(IPreferenceStore store) >- { >- >- store.setDefault(TestgenPlugin.TEST_GENERATOR,getDefaultGeneratorID()); //$NON-NLS-1$ >- >- } >- >- public String getDefaultGeneratorID() >- { >- //find all registered generators, select the highest priority >- String[] ids = TestGeneratorFactory.getInstance().getGeneratorIDs(); >- String defaultID = "org.eclipse.hyades.test.tools.core.TestGenerator.HTTPGenerator"; >- int nMax = -1; >- for (int i = 0; i < ids.length; i++) >- { >- if (TestGeneratorFactory.getInstance().getGeneratorPriority(ids[i]) > nMax) >- defaultID = ids[i]; >- } >- return defaultID; >- } >- >-} >#P org.eclipse.hyades.test.tools.ui >Index: testkeys >=================================================================== >RCS file: testkeys >diff -N testkeys >Binary files /tmp/cvse6ljU7 and /dev/null differ
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 208110
:
92210
|
92211
|
92212
| 92286