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 76930 Details for
Bug 168597
[Vista] HTTP Recorder requires work-around on Windows Vista for Internet Explorer
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 for org.eclipse.hyades.test.core
bugzilla168597.txt (text/plain), 13.96 KB, created by
DuWayne Morris
on 2007-08-24 13:24:53 EDT
(
hide
)
Description:
patch for org.eclipse.hyades.test.core
Filename:
MIME Type:
Creator:
DuWayne Morris
Created:
2007-08-24 13:24:53 EDT
Size:
13.96 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.hyades.test.core >Index: src/org/eclipse/hyades/execution/recorder/local/appadapters/InternetExplorerAdapter.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.core/src/org/eclipse/hyades/execution/recorder/local/appadapters/InternetExplorerAdapter.java,v >retrieving revision 1.11 >diff -u -r1.11 InternetExplorerAdapter.java >--- src/org/eclipse/hyades/execution/recorder/local/appadapters/InternetExplorerAdapter.java 26 Apr 2007 21:03:39 -0000 1.11 >+++ src/org/eclipse/hyades/execution/recorder/local/appadapters/InternetExplorerAdapter.java 24 Aug 2007 16:28:35 -0000 >@@ -27,6 +27,8 @@ > import org.eclipse.hyades.test.core.internal.resources.TestCorePluginResourceBundle; > > >+ >+ > /** > * This object is the client object for a RecorderApplication extension point (point org.eclipse.hyades.execution.recorder.RecorderApplication) > * it contains logic for initializing, starting, and stopping Internet Explorer. In particular, this object is able >@@ -78,13 +80,32 @@ > // bugzilla 165310 mdd > final String mylocalhost = "127.0.0.1:"; > >+ // bugzilla 168597 >+ /* Later we may want to change this to always use native code >+ * to get and set Internet Explorer registry settings. >+ * >+ * For this defect fix, we will determine that our attempt to run regedit.exe >+ * has failed running on Vista without using "Run as Administrator" elevated privileges >+ * >+ * When this happens, we will set the boolean below true and create an instance of JNIWrapper class. >+ * The JNIWrapper class will load the native DLL and make the calls into native code. >+ * >+ */ >+ private boolean bUseNativeRegistryInterface = false; >+ private JNIWrapper jniWrapper = null; >+ > public void init(String initInfo) throws RecorderApplicationAdapterException > { >+ > // bugzilla 114253 set the path of temp files to the workspace path > setTempFilePaths(); > >- parseInitInfo(initInfo); >+ parseInitInfo(initInfo); > StringBuffer inputFileContents = getRegistryInfo(); >+ // Bugilla 168597 >+ if (bUseNativeRegistryInterface) >+ inputFileContents = getRegistryInfoUsingNativeAPI(); >+ createOriginalRegSettingsFile(inputFileContents); > > StringBuffer outputFileContents = new StringBuffer(); > // new mdd hyades 1.3 check for http >@@ -101,16 +122,19 @@ > StringTokenizer lineTokenizer = new StringTokenizer(line,":");//$NON-NLS-1$ > newLine=lineTokenizer.nextToken(); > newLine+=":00000001";//$NON-NLS-1$ >+ setNativeRegistryValue(newLine); >+ outputFileContents.append(newLine+"\r\n");//$NON-NLS-1$ > if (isProxyEnabled){ > // newLine+="\r\n\"ProxyServer\"=\"http=localhost:" + portnum;//$NON-NLS-1$ >- newLine+="\r\n\"ProxyServer\"=\"http=" + mylocalhost+ portnum;//$NON-NLS-1$ >+ newLine="\"ProxyServer\"=\"http=" + mylocalhost+ portnum;//$NON-NLS-1$ > newLine += ";https=" + mylocalhost + portnum + "\""; > } > else { > // newLine+="\r\n\"ProxyServer\"=\"socks=localhost:";//$NON-NLS-1$ >- newLine+="\r\n\"ProxyServer\"=\"socks=" + mylocalhost;//$NON-NLS-1$ >+ newLine="\"ProxyServer\"=\"socks=" + mylocalhost;//$NON-NLS-1$ > newLine+=portnum+"\"";//$NON-NLS-1$ >- } >+ } >+ > } > else if(line.startsWith("\"ProxyHttp1.1"))//$NON-NLS-1$ > { >@@ -121,6 +145,7 @@ > } > else if(line.startsWith("\"ProxyServer"))//$NON-NLS-1$ > { >+ > //it has been found that if the target computer has never been pointed to a proxy. This > //entry may not be present. Therefore, we will ignore it if it is there and always create it from scratch. > newLine=null; >@@ -176,17 +201,42 @@ > } > newLine = null; //don't update this > } >- if(newLine!=null) >+ if(newLine!=null){ >+ setNativeRegistryValue(newLine); > outputFileContents.append(newLine+"\r\n");//$NON-NLS-1$ >+ } > } > > > > createRegSettingsFile(outputFileContents); >+ if (bUseNativeRegistryInterface){ >+ launchPath = launchPath.replaceAll("%1", ""); >+ int n = launchPath.indexOf("\\\\"); //replaceAll doesn't work for these cases >+ int m = launchPath.indexOf("\\\""); >+ while (n > -1 || m > -1) >+ { >+ if (n > -1) >+ { >+ launchPath = launchPath.substring(0, n) + launchPath.substring(n+1, launchPath.length()); >+ >+ } >+ else if (m > -1) //wait until next loop (have to reassign indeces) >+ { >+ launchPath = launchPath.substring(0, m) + launchPath.substring(m+1, launchPath.length()); >+ >+ } >+ n = launchPath.indexOf("\\\\"); >+ m = launchPath.indexOf("\\\""); >+ } >+ System.out.println(launchPath); >+ } >+ > > try > { >- pushRegFile(tempSettingsFilePath); >+ if (!bUseNativeRegistryInterface) >+ pushRegFile(tempSettingsFilePath); > } > catch (Exception e) > { >@@ -207,6 +257,20 @@ > } > > } >+ >+ private void setNativeRegistryValue(String newLine){ >+ if (bUseNativeRegistryInterface){ >+ int index1 = 1; // next character after beginning quote >+ int index2 = newLine.indexOf("="); >+ String keyname = newLine.substring(index1, index2 - 1); >+ String value = newLine.substring(index2 + 1); >+ if (value.charAt(0) == '\"') >+ value = value.substring(1); >+ if (value.endsWith("\"")) >+ value = value.substring(0, value.length() - 1); >+ jniWrapper.setInternetSetting(keyname, value); >+ } >+ } > > /* > * Bugzilla 114253 - move location of temp files >@@ -291,6 +355,36 @@ > > } > >+ /** >+ * method which creates a registry settings file (*.reg) >+ * @param StringBuffer ouputFileContents >+ */ >+ private void createOriginalRegSettingsFile(StringBuffer inputFileContents) >+ { >+ // Bugzilla 114253 - use new path for temp files to put them in workspace >+ File newFile = new File(originalSettingsFilePath); >+ >+ try >+ { >+ OutputStreamWriter outputWriter = new OutputStreamWriter(new FileOutputStream(newFile),"UnicodeLittle");//$NON-NLS-1$ >+ outputWriter.write(inputFileContents.toString()); >+ outputWriter.close(); >+ } >+ catch (UnsupportedEncodingException e1) >+ { >+ e1.printStackTrace(); >+ } >+ catch (FileNotFoundException e1) >+ { >+ e1.printStackTrace(); >+ } >+ catch (IOException e) >+ { >+ e.printStackTrace(); >+ } >+ >+ } >+ > > /** > * method which exports the registry keys of interested into a file using regedit and then reads the file >@@ -299,6 +393,7 @@ > private StringBuffer getRegistryInfo() > { > >+ > String[] regInfo = {"\"HKEY_CLASSES_ROOT\\Applications\\iexplore.exe\\shell\\open\\command\"", > "\"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\"", > "\"HKEY_CURRENT_USER\\Software\\Microsoft\\Java VM\""}; >@@ -328,10 +423,30 @@ > { > if (i == 2){ > registryChange = Runtime.getRuntime().exec(consolecmdLine + regInfo[i],null); >+ > } > else { >- registryChange = Runtime.getRuntime().exec(cmdLine + regInfo[i],null); >+ try{ >+ // the reason for putting this try catch block in at the point >+ // is to catch the first failure of CreateProcess on regedit.exe >+ >+ registryChange = Runtime.getRuntime().exec(cmdLine + regInfo[i],null); >+ } >+ catch (IOException e){ >+ // running on Vista, so regedit.exe would not start because we >+ // did not kick off eclipse with "Run as Administrator" >+ String currentOS = Platform.getOS(); >+ if (currentOS.equals("win32")) { >+ String myVersion = System.getProperty("os.version"); >+ if (myVersion.startsWith("6")) { >+ bUseNativeRegistryInterface = true; >+ // re-throw the IOException to break out >+ throw e; >+ } >+ } >+ } > } >+ > registryChange.waitFor(); > if (i == 2){ > inputReader= new InputStreamReader(new FileInputStream(consoleFile),"UTF-16");//$NON-NLS-1$ >@@ -373,7 +488,38 @@ > } > return inputFileContents; > } >- >+ //Bugilla 168597 >+ StringBuffer getRegistryInfoUsingNativeAPI(){ >+ bUseNativeRegistryInterface = true; >+ >+ StringBuffer inputFileContents = new StringBuffer(); >+ // fire up an instance of the JNI layer to start using native code >+ jniWrapper = new JNIWrapper(); >+ launchPath = jniWrapper.getIEPath(); >+ AddSettingToBuffer(jniWrapper, inputFileContents, "ProxyEnable"); >+ AddSettingToBuffer(jniWrapper, inputFileContents, "AutoConfigURL"); >+ AddSettingToBuffer(jniWrapper, inputFileContents, "ProxyServer"); >+ AddSettingToBuffer(jniWrapper, inputFileContents, "ProxyOverride"); >+ AddSettingToBuffer(jniWrapper, inputFileContents, "ProxyHttp1.1"); >+ AddSettingToBuffer(jniWrapper, inputFileContents, "WarnonBadCertRecving"); >+ AddSettingToBuffer(jniWrapper, inputFileContents, "WarnOnBadCertRecving"); >+ AddSettingToBuffer(jniWrapper, inputFileContents, "WarnonZoneCrossing"); >+ AddSettingToBuffer(jniWrapper, inputFileContents, "WarnOnZoneCrossing"); >+ >+ // left out ZonesMixedContent for now, that would require reading many more keys >+ // to set all that >+ >+ return inputFileContents; >+ } >+ >+ private void AddSettingToBuffer(JNIWrapper jniWrapper, StringBuffer inputFileContents, String name){ >+ String setting = jniWrapper.getInternetSetting(name); >+ if (setting != null && setting.length() > 0){ >+ inputFileContents.append("\"" + name + "\"=" + setting + "\r\n"); >+ } >+ return; >+ } >+ > > /** > * method called by the recorder to start the target application (Internet Explorer) >@@ -404,9 +550,34 @@ > { > // bugzilla 114253 - write temp files in workspace instead of eclipse instance location > // use the new path for the temp files >- pushRegFile(originalSettingsFilePath); >- >- pushRegFile(consoleSettingsFilePath); >+ if (bUseNativeRegistryInterface){ >+ StringBuffer inputFileContents = new StringBuffer(); >+ String str; >+ byte [] buffer = new byte[4096]; >+ int bytes_read; >+ File newFile = new File(originalSettingsFilePath); >+ FileInputStream inputStream = new FileInputStream(newFile);//$NON-NLS-1$ >+ while ((bytes_read = inputStream.read(buffer)) != -1){ >+ str = new String(buffer, 0, bytes_read, "UnicodeLittle"); >+ inputFileContents.append(str); >+ } >+ inputStream.close(); >+ StringTokenizer fileTokenizer = new StringTokenizer(inputFileContents.toString(),"\r\n");//$NON-NLS-1$ >+ while(fileTokenizer.hasMoreTokens()) >+ { >+ String line=fileTokenizer.nextToken(); >+ // check to see if it is a real setting or a blank line >+ int index = line.indexOf('='); >+ if (index > 0) >+ setNativeRegistryValue(line); >+ } >+ >+ } >+ else{ >+ pushRegFile(originalSettingsFilePath); >+ >+ pushRegFile(consoleSettingsFilePath); >+ } > } > catch (Exception e) > { >Index: src/org/eclipse/hyades/execution/recorder/local/appadapters/JNIWrapper.java >=================================================================== >RCS file: src/org/eclipse/hyades/execution/recorder/local/appadapters/JNIWrapper.java >diff -N src/org/eclipse/hyades/execution/recorder/local/appadapters/JNIWrapper.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/execution/recorder/local/appadapters/JNIWrapper.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,103 @@ >+/********************************************************************** >+ * 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: JNIWrapper.java,v 1 2007/08/24 1:03:39 dmorris Exp $ >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.execution.recorder.local.appadapters; >+ >+ >+import java.net.URL; >+ >+import org.eclipse.core.runtime.FileLocator; >+import org.eclipse.core.runtime.Platform; >+import org.osgi.framework.Bundle; >+import java.io.IOException; >+ >+ >+// added this file for bugzilla 168597 >+ >+public class JNIWrapper { >+ >+ private static final native String getLastError(); >+ private static final native String getIEAppPath(); >+ private static final native String getEnableJavaConsole(); >+ private static final native String getIESetting(String name); >+ private static final native int setIESetting(String name, String value, int type); >+ >+ public static final int REG_SZ = 1; >+ public static final int REG_DWORD = 4; >+ >+ public synchronized String getIEPath(){ >+ >+ String path = getIEAppPath(); >+ return path; >+ } >+ >+ public synchronized String getEnableJava(){ >+ >+ String path = getEnableJavaConsole(); >+ return path; >+ } >+ >+ >+ public synchronized String getInternetSetting(String name){ >+ String setting = getIESetting(name); >+ >+ >+ return setting; >+ } >+ >+ public synchronized boolean setInternetSetting(String name, String value){ >+ int i = 0; >+ >+ if (value.startsWith("dword:", 0)){ >+ int index = value.indexOf(":"); >+ index++; >+ value = value.substring(index); >+ value = value.trim(); >+ Integer intVal = new Integer(value); >+ value = intVal.toString(); >+ i = setIESetting(name, value, REG_DWORD); >+ >+ >+ }else{ >+ i = setIESetting(name, value, REG_SZ); >+ } >+ if (i > 0) >+ return true; >+ else >+ return false; >+ } >+ >+ public synchronized String getErrorMessage(){ >+ String errorMsg = getLastError(); >+ return errorMsg; >+ >+ } >+ >+ >+ static { >+ // load our utility dll, it should be in the org.eclipse.hyades.test.core plugin directory >+ try{ >+ Bundle b = Platform.getBundle("org.eclipse.hyades.test.core"); >+ URL u = FileLocator.resolve(b.getEntry("/")); >+ String path = u.getPath(); >+ path = path.substring(1); >+ String finalPath = path + "TPTPRegistryUpdater.dll"; >+ System.load(finalPath); >+ } >+ catch (IOException e){ >+ >+ } >+ } >+ >+} >+ >+
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 168597
:
76930
|
76931
|
80259
|
80260
|
80261
|
80262
|
80270
|
80900
|
80901
|
80902