|
Lines 27-32
Link Here
|
| 27 |
import org.eclipse.hyades.test.core.internal.resources.TestCorePluginResourceBundle; |
27 |
import org.eclipse.hyades.test.core.internal.resources.TestCorePluginResourceBundle; |
| 28 |
|
28 |
|
| 29 |
|
29 |
|
|
|
30 |
|
| 31 |
|
| 30 |
/** |
32 |
/** |
| 31 |
* This object is the client object for a RecorderApplication extension point (point org.eclipse.hyades.execution.recorder.RecorderApplication) |
33 |
* This object is the client object for a RecorderApplication extension point (point org.eclipse.hyades.execution.recorder.RecorderApplication) |
| 32 |
* it contains logic for initializing, starting, and stopping Internet Explorer. In particular, this object is able |
34 |
* it contains logic for initializing, starting, and stopping Internet Explorer. In particular, this object is able |
|
Lines 78-90
Link Here
|
| 78 |
// bugzilla 165310 mdd |
80 |
// bugzilla 165310 mdd |
| 79 |
final String mylocalhost = "127.0.0.1:"; |
81 |
final String mylocalhost = "127.0.0.1:"; |
| 80 |
|
82 |
|
|
|
83 |
// bugzilla 168597 |
| 84 |
/* Later we may want to change this to always use native code |
| 85 |
* to get and set Internet Explorer registry settings. |
| 86 |
* |
| 87 |
* For this defect fix, we will determine that our attempt to run regedit.exe |
| 88 |
* has failed running on Vista without using "Run as Administrator" elevated privileges |
| 89 |
* |
| 90 |
* When this happens, we will set the boolean below true and create an instance of JNIWrapper class. |
| 91 |
* The JNIWrapper class will load the native DLL and make the calls into native code. |
| 92 |
* |
| 93 |
*/ |
| 94 |
private boolean bUseNativeRegistryInterface = false; |
| 95 |
private JNIWrapper jniWrapper = null; |
| 96 |
|
| 81 |
public void init(String initInfo) throws RecorderApplicationAdapterException |
97 |
public void init(String initInfo) throws RecorderApplicationAdapterException |
| 82 |
{ |
98 |
{ |
|
|
99 |
|
| 83 |
// bugzilla 114253 set the path of temp files to the workspace path |
100 |
// bugzilla 114253 set the path of temp files to the workspace path |
| 84 |
setTempFilePaths(); |
101 |
setTempFilePaths(); |
| 85 |
|
102 |
|
| 86 |
parseInitInfo(initInfo); |
103 |
parseInitInfo(initInfo); |
| 87 |
StringBuffer inputFileContents = getRegistryInfo(); |
104 |
StringBuffer inputFileContents = getRegistryInfo(); |
|
|
105 |
// Bugilla 168597 |
| 106 |
if (bUseNativeRegistryInterface) |
| 107 |
inputFileContents = getRegistryInfoUsingNativeAPI(); |
| 108 |
createOriginalRegSettingsFile(inputFileContents); |
| 88 |
|
109 |
|
| 89 |
StringBuffer outputFileContents = new StringBuffer(); |
110 |
StringBuffer outputFileContents = new StringBuffer(); |
| 90 |
// new mdd hyades 1.3 check for http |
111 |
// new mdd hyades 1.3 check for http |
|
Lines 101-116
Link Here
|
| 101 |
StringTokenizer lineTokenizer = new StringTokenizer(line,":");//$NON-NLS-1$ |
122 |
StringTokenizer lineTokenizer = new StringTokenizer(line,":");//$NON-NLS-1$ |
| 102 |
newLine=lineTokenizer.nextToken(); |
123 |
newLine=lineTokenizer.nextToken(); |
| 103 |
newLine+=":00000001";//$NON-NLS-1$ |
124 |
newLine+=":00000001";//$NON-NLS-1$ |
|
|
125 |
setNativeRegistryValue(newLine); |
| 126 |
outputFileContents.append(newLine+"\r\n");//$NON-NLS-1$ |
| 104 |
if (isProxyEnabled){ |
127 |
if (isProxyEnabled){ |
| 105 |
// newLine+="\r\n\"ProxyServer\"=\"http=localhost:" + portnum;//$NON-NLS-1$ |
128 |
// newLine+="\r\n\"ProxyServer\"=\"http=localhost:" + portnum;//$NON-NLS-1$ |
| 106 |
newLine+="\r\n\"ProxyServer\"=\"http=" + mylocalhost+ portnum;//$NON-NLS-1$ |
129 |
newLine="\"ProxyServer\"=\"http=" + mylocalhost+ portnum;//$NON-NLS-1$ |
| 107 |
newLine += ";https=" + mylocalhost + portnum + "\""; |
130 |
newLine += ";https=" + mylocalhost + portnum + "\""; |
| 108 |
} |
131 |
} |
| 109 |
else { |
132 |
else { |
| 110 |
// newLine+="\r\n\"ProxyServer\"=\"socks=localhost:";//$NON-NLS-1$ |
133 |
// newLine+="\r\n\"ProxyServer\"=\"socks=localhost:";//$NON-NLS-1$ |
| 111 |
newLine+="\r\n\"ProxyServer\"=\"socks=" + mylocalhost;//$NON-NLS-1$ |
134 |
newLine="\"ProxyServer\"=\"socks=" + mylocalhost;//$NON-NLS-1$ |
| 112 |
newLine+=portnum+"\"";//$NON-NLS-1$ |
135 |
newLine+=portnum+"\"";//$NON-NLS-1$ |
| 113 |
} |
136 |
} |
|
|
137 |
|
| 114 |
} |
138 |
} |
| 115 |
else if(line.startsWith("\"ProxyHttp1.1"))//$NON-NLS-1$ |
139 |
else if(line.startsWith("\"ProxyHttp1.1"))//$NON-NLS-1$ |
| 116 |
{ |
140 |
{ |
|
Lines 121-126
Link Here
|
| 121 |
} |
145 |
} |
| 122 |
else if(line.startsWith("\"ProxyServer"))//$NON-NLS-1$ |
146 |
else if(line.startsWith("\"ProxyServer"))//$NON-NLS-1$ |
| 123 |
{ |
147 |
{ |
|
|
148 |
|
| 124 |
//it has been found that if the target computer has never been pointed to a proxy. This |
149 |
//it has been found that if the target computer has never been pointed to a proxy. This |
| 125 |
//entry may not be present. Therefore, we will ignore it if it is there and always create it from scratch. |
150 |
//entry may not be present. Therefore, we will ignore it if it is there and always create it from scratch. |
| 126 |
newLine=null; |
151 |
newLine=null; |
|
Lines 176-192
Link Here
|
| 176 |
} |
201 |
} |
| 177 |
newLine = null; //don't update this |
202 |
newLine = null; //don't update this |
| 178 |
} |
203 |
} |
| 179 |
if(newLine!=null) |
204 |
if(newLine!=null){ |
|
|
205 |
setNativeRegistryValue(newLine); |
| 180 |
outputFileContents.append(newLine+"\r\n");//$NON-NLS-1$ |
206 |
outputFileContents.append(newLine+"\r\n");//$NON-NLS-1$ |
|
|
207 |
} |
| 181 |
} |
208 |
} |
| 182 |
|
209 |
|
| 183 |
|
210 |
|
| 184 |
|
211 |
|
| 185 |
createRegSettingsFile(outputFileContents); |
212 |
createRegSettingsFile(outputFileContents); |
|
|
213 |
if (bUseNativeRegistryInterface){ |
| 214 |
launchPath = launchPath.replaceAll("%1", ""); |
| 215 |
int n = launchPath.indexOf("\\\\"); //replaceAll doesn't work for these cases |
| 216 |
int m = launchPath.indexOf("\\\""); |
| 217 |
while (n > -1 || m > -1) |
| 218 |
{ |
| 219 |
if (n > -1) |
| 220 |
{ |
| 221 |
launchPath = launchPath.substring(0, n) + launchPath.substring(n+1, launchPath.length()); |
| 222 |
|
| 223 |
} |
| 224 |
else if (m > -1) //wait until next loop (have to reassign indeces) |
| 225 |
{ |
| 226 |
launchPath = launchPath.substring(0, m) + launchPath.substring(m+1, launchPath.length()); |
| 227 |
|
| 228 |
} |
| 229 |
n = launchPath.indexOf("\\\\"); |
| 230 |
m = launchPath.indexOf("\\\""); |
| 231 |
} |
| 232 |
System.out.println(launchPath); |
| 233 |
} |
| 234 |
|
| 186 |
|
235 |
|
| 187 |
try |
236 |
try |
| 188 |
{ |
237 |
{ |
| 189 |
pushRegFile(tempSettingsFilePath); |
238 |
if (!bUseNativeRegistryInterface) |
|
|
239 |
pushRegFile(tempSettingsFilePath); |
| 190 |
} |
240 |
} |
| 191 |
catch (Exception e) |
241 |
catch (Exception e) |
| 192 |
{ |
242 |
{ |
|
Lines 207-212
Link Here
|
| 207 |
} |
257 |
} |
| 208 |
|
258 |
|
| 209 |
} |
259 |
} |
|
|
260 |
|
| 261 |
private void setNativeRegistryValue(String newLine){ |
| 262 |
if (bUseNativeRegistryInterface){ |
| 263 |
int index1 = 1; // next character after beginning quote |
| 264 |
int index2 = newLine.indexOf("="); |
| 265 |
String keyname = newLine.substring(index1, index2 - 1); |
| 266 |
String value = newLine.substring(index2 + 1); |
| 267 |
if (value.charAt(0) == '\"') |
| 268 |
value = value.substring(1); |
| 269 |
if (value.endsWith("\"")) |
| 270 |
value = value.substring(0, value.length() - 1); |
| 271 |
jniWrapper.setInternetSetting(keyname, value); |
| 272 |
} |
| 273 |
} |
| 210 |
|
274 |
|
| 211 |
/* |
275 |
/* |
| 212 |
* Bugzilla 114253 - move location of temp files |
276 |
* Bugzilla 114253 - move location of temp files |
|
Lines 291-296
Link Here
|
| 291 |
|
355 |
|
| 292 |
} |
356 |
} |
| 293 |
|
357 |
|
|
|
358 |
/** |
| 359 |
* method which creates a registry settings file (*.reg) |
| 360 |
* @param StringBuffer ouputFileContents |
| 361 |
*/ |
| 362 |
private void createOriginalRegSettingsFile(StringBuffer inputFileContents) |
| 363 |
{ |
| 364 |
// Bugzilla 114253 - use new path for temp files to put them in workspace |
| 365 |
File newFile = new File(originalSettingsFilePath); |
| 366 |
|
| 367 |
try |
| 368 |
{ |
| 369 |
OutputStreamWriter outputWriter = new OutputStreamWriter(new FileOutputStream(newFile),"UnicodeLittle");//$NON-NLS-1$ |
| 370 |
outputWriter.write(inputFileContents.toString()); |
| 371 |
outputWriter.close(); |
| 372 |
} |
| 373 |
catch (UnsupportedEncodingException e1) |
| 374 |
{ |
| 375 |
e1.printStackTrace(); |
| 376 |
} |
| 377 |
catch (FileNotFoundException e1) |
| 378 |
{ |
| 379 |
e1.printStackTrace(); |
| 380 |
} |
| 381 |
catch (IOException e) |
| 382 |
{ |
| 383 |
e.printStackTrace(); |
| 384 |
} |
| 385 |
|
| 386 |
} |
| 387 |
|
| 294 |
|
388 |
|
| 295 |
/** |
389 |
/** |
| 296 |
* method which exports the registry keys of interested into a file using regedit and then reads the file |
390 |
* method which exports the registry keys of interested into a file using regedit and then reads the file |
|
Lines 299-304
Link Here
|
| 299 |
private StringBuffer getRegistryInfo() |
393 |
private StringBuffer getRegistryInfo() |
| 300 |
{ |
394 |
{ |
| 301 |
|
395 |
|
|
|
396 |
|
| 302 |
String[] regInfo = {"\"HKEY_CLASSES_ROOT\\Applications\\iexplore.exe\\shell\\open\\command\"", |
397 |
String[] regInfo = {"\"HKEY_CLASSES_ROOT\\Applications\\iexplore.exe\\shell\\open\\command\"", |
| 303 |
"\"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\"", |
398 |
"\"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\"", |
| 304 |
"\"HKEY_CURRENT_USER\\Software\\Microsoft\\Java VM\""}; |
399 |
"\"HKEY_CURRENT_USER\\Software\\Microsoft\\Java VM\""}; |
|
Lines 328-337
Link Here
|
| 328 |
{ |
423 |
{ |
| 329 |
if (i == 2){ |
424 |
if (i == 2){ |
| 330 |
registryChange = Runtime.getRuntime().exec(consolecmdLine + regInfo[i],null); |
425 |
registryChange = Runtime.getRuntime().exec(consolecmdLine + regInfo[i],null); |
|
|
426 |
|
| 331 |
} |
427 |
} |
| 332 |
else { |
428 |
else { |
| 333 |
registryChange = Runtime.getRuntime().exec(cmdLine + regInfo[i],null); |
429 |
try{ |
|
|
430 |
// the reason for putting this try catch block in at the point |
| 431 |
// is to catch the first failure of CreateProcess on regedit.exe |
| 432 |
|
| 433 |
registryChange = Runtime.getRuntime().exec(cmdLine + regInfo[i],null); |
| 434 |
} |
| 435 |
catch (IOException e){ |
| 436 |
// running on Vista, so regedit.exe would not start because we |
| 437 |
// did not kick off eclipse with "Run as Administrator" |
| 438 |
String currentOS = Platform.getOS(); |
| 439 |
if (currentOS.equals("win32")) { |
| 440 |
String myVersion = System.getProperty("os.version"); |
| 441 |
if (myVersion.startsWith("6")) { |
| 442 |
bUseNativeRegistryInterface = true; |
| 443 |
// re-throw the IOException to break out |
| 444 |
throw e; |
| 445 |
} |
| 446 |
} |
| 447 |
} |
| 334 |
} |
448 |
} |
|
|
449 |
|
| 335 |
registryChange.waitFor(); |
450 |
registryChange.waitFor(); |
| 336 |
if (i == 2){ |
451 |
if (i == 2){ |
| 337 |
inputReader= new InputStreamReader(new FileInputStream(consoleFile),"UTF-16");//$NON-NLS-1$ |
452 |
inputReader= new InputStreamReader(new FileInputStream(consoleFile),"UTF-16");//$NON-NLS-1$ |
|
Lines 373-379
Link Here
|
| 373 |
} |
488 |
} |
| 374 |
return inputFileContents; |
489 |
return inputFileContents; |
| 375 |
} |
490 |
} |
| 376 |
|
491 |
//Bugilla 168597 |
|
|
492 |
StringBuffer getRegistryInfoUsingNativeAPI(){ |
| 493 |
bUseNativeRegistryInterface = true; |
| 494 |
|
| 495 |
StringBuffer inputFileContents = new StringBuffer(); |
| 496 |
// fire up an instance of the JNI layer to start using native code |
| 497 |
jniWrapper = new JNIWrapper(); |
| 498 |
launchPath = jniWrapper.getIEPath(); |
| 499 |
AddSettingToBuffer(jniWrapper, inputFileContents, "ProxyEnable"); |
| 500 |
AddSettingToBuffer(jniWrapper, inputFileContents, "AutoConfigURL"); |
| 501 |
AddSettingToBuffer(jniWrapper, inputFileContents, "ProxyServer"); |
| 502 |
AddSettingToBuffer(jniWrapper, inputFileContents, "ProxyOverride"); |
| 503 |
AddSettingToBuffer(jniWrapper, inputFileContents, "ProxyHttp1.1"); |
| 504 |
AddSettingToBuffer(jniWrapper, inputFileContents, "WarnonBadCertRecving"); |
| 505 |
AddSettingToBuffer(jniWrapper, inputFileContents, "WarnOnBadCertRecving"); |
| 506 |
AddSettingToBuffer(jniWrapper, inputFileContents, "WarnonZoneCrossing"); |
| 507 |
AddSettingToBuffer(jniWrapper, inputFileContents, "WarnOnZoneCrossing"); |
| 508 |
|
| 509 |
// left out ZonesMixedContent for now, that would require reading many more keys |
| 510 |
// to set all that |
| 511 |
|
| 512 |
return inputFileContents; |
| 513 |
} |
| 514 |
|
| 515 |
private void AddSettingToBuffer(JNIWrapper jniWrapper, StringBuffer inputFileContents, String name){ |
| 516 |
String setting = jniWrapper.getInternetSetting(name); |
| 517 |
if (setting != null && setting.length() > 0){ |
| 518 |
inputFileContents.append("\"" + name + "\"=" + setting + "\r\n"); |
| 519 |
} |
| 520 |
return; |
| 521 |
} |
| 522 |
|
| 377 |
|
523 |
|
| 378 |
/** |
524 |
/** |
| 379 |
* method called by the recorder to start the target application (Internet Explorer) |
525 |
* method called by the recorder to start the target application (Internet Explorer) |
|
Lines 404-412
Link Here
|
| 404 |
{ |
550 |
{ |
| 405 |
// bugzilla 114253 - write temp files in workspace instead of eclipse instance location |
551 |
// bugzilla 114253 - write temp files in workspace instead of eclipse instance location |
| 406 |
// use the new path for the temp files |
552 |
// use the new path for the temp files |
| 407 |
pushRegFile(originalSettingsFilePath); |
553 |
if (bUseNativeRegistryInterface){ |
| 408 |
|
554 |
StringBuffer inputFileContents = new StringBuffer(); |
| 409 |
pushRegFile(consoleSettingsFilePath); |
555 |
String str; |
|
|
556 |
byte [] buffer = new byte[4096]; |
| 557 |
int bytes_read; |
| 558 |
File newFile = new File(originalSettingsFilePath); |
| 559 |
FileInputStream inputStream = new FileInputStream(newFile);//$NON-NLS-1$ |
| 560 |
while ((bytes_read = inputStream.read(buffer)) != -1){ |
| 561 |
str = new String(buffer, 0, bytes_read, "UnicodeLittle"); |
| 562 |
inputFileContents.append(str); |
| 563 |
} |
| 564 |
inputStream.close(); |
| 565 |
StringTokenizer fileTokenizer = new StringTokenizer(inputFileContents.toString(),"\r\n");//$NON-NLS-1$ |
| 566 |
while(fileTokenizer.hasMoreTokens()) |
| 567 |
{ |
| 568 |
String line=fileTokenizer.nextToken(); |
| 569 |
// check to see if it is a real setting or a blank line |
| 570 |
int index = line.indexOf('='); |
| 571 |
if (index > 0) |
| 572 |
setNativeRegistryValue(line); |
| 573 |
} |
| 574 |
|
| 575 |
} |
| 576 |
else{ |
| 577 |
pushRegFile(originalSettingsFilePath); |
| 578 |
|
| 579 |
pushRegFile(consoleSettingsFilePath); |
| 580 |
} |
| 410 |
} |
581 |
} |
| 411 |
catch (Exception e) |
582 |
catch (Exception e) |
| 412 |
{ |
583 |
{ |