267 *
268 * @param extensionName key in the attibute list
269 * @param attr manifest file attributes
270 * @param file installed extension jar file to compare the requested
271 * extension against.
272 */
273 protected boolean checkExtensionAgainst(String extensionName,
274 Attributes attr,
275 final File file)
276 throws IOException,
277 FileNotFoundException,
278 ExtensionInstallationException
279 {
280
281 debug("Checking extension " + extensionName +
282 " against " + file.getName());
283
284 // Load the jar file ...
285 Manifest man;
286 try {
287 man = (Manifest) AccessController.doPrivileged
288 (
289 new PrivilegedExceptionAction() {
290 public Object run()
291 throws IOException, FileNotFoundException {
292 if (!file.exists())
293 throw new FileNotFoundException(file.getName());
294 JarFile jarFile = new JarFile(file);
295 return jarFile.getManifest();
296 }
297 });
298 } catch(PrivilegedActionException e) {
299 if (e.getException() instanceof FileNotFoundException)
300 throw (FileNotFoundException) e.getException();
301 throw (IOException) e.getException();
302 }
303
304 // Construct the extension information object
305 ExtensionInfo reqInfo = new ExtensionInfo(extensionName, attr);
306 debug("Requested Extension : " + reqInfo);
307
308 int isCompatible = ExtensionInfo.INCOMPATIBLE;
309 ExtensionInfo instInfo = null;
310
374 debug(reqInfo.name + " installation failed");
375 return false;
376 }
377
378 /**
379 * <p>
380 * Checks if the extension, that is specified in the extension-list in
381 * the applet jar manifest, is already installed (i.e. exists in the
382 * extension directory).
383 * </p>
384 *
385 * @param extensionName extension name in the extension-list
386 *
387 * @return the extension if it exists in the extension directory
388 */
389 private File checkExtensionExists(String extensionName) {
390 // Function added to fix bug 4504166
391 final String extName = extensionName;
392 final String[] fileExt = {".jar", ".zip"};
393
394 return (File) AccessController.doPrivileged
395 (new PrivilegedAction() {
396 public Object run() {
397 try {
398 File fExtension;
399 File[] dirs = getExtDirs();
400
401 // Search the extension directories for the extension that is specified
402 // in the attribute extension-list in the applet jar manifest
403 for (int i=0;i<dirs.length;i++) {
404 for (int j=0;j<fileExt.length;j++) {
405 if (extName.toLowerCase().endsWith(fileExt[j])) {
406 fExtension = new File(dirs[i], extName);
407 } else {
408 fExtension = new File(dirs[i], extName+fileExt[j]);
409 }
410 debug("checkExtensionExists:fileName " + fExtension.getName());
411 if (fExtension.exists()) {
412 return fExtension;
413 }
414 }
415 }
416 return null;
443 dirs[i] = new File(st.nextToken());
444 debug("getExtDirs dirs["+i+"] "+ dirs[i]);
445 }
446 } else {
447 dirs = new File[0];
448 debug("getExtDirs dirs " + dirs);
449 }
450 debug("getExtDirs dirs.length " + dirs.length);
451 return dirs;
452 }
453
454 /*
455 * <p>
456 * Scan the directories and return all files installed in those
457 * </p>
458 * @param dirs list of directories to scan
459 *
460 * @return the list of files installed in all the directories
461 */
462 private static File[] getExtFiles(File[] dirs) throws IOException {
463 Vector urls = new Vector();
464 for (int i = 0; i < dirs.length; i++) {
465 String[] files = dirs[i].list(new JarFilter());
466 if (files != null) {
467 debug("getExtFiles files.length " + files.length);
468 for (int j = 0; j < files.length; j++) {
469 File f = new File(dirs[i], files[j]);
470 urls.add(f);
471 debug("getExtFiles f["+j+"] "+ f);
472 }
473 }
474 }
475 File[] ua = new File[urls.size()];
476 urls.copyInto(ua);
477 debug("getExtFiles ua.length " + ua.length);
478 return ua;
479 }
480
481 /*
482 * <p>
483 * @return the list of installed extensions jar files
484 * </p>
485 */
486 private File[] getInstalledExtensions() throws IOException {
487 return (File[]) AccessController.doPrivileged
488 (
489 new PrivilegedAction() {
490 public Object run() {
491 try {
492 return getExtFiles(getExtDirs());
493 } catch(IOException e) {
494 debug("Cannot get list of installed extensions");
495 debugException(e);
496 return new URL[0];
497 }
498 }
499 });
500 }
501
502 /*
503 * <p>
504 * Add the newly installed jar file to the extension class loader.
505 * </p>
506 *
507 * @param cl the current installed extension class loader
508 *
509 * @return true if successful
510 */
511 private Boolean addNewExtensionsToClassLoader(Launcher.ExtClassLoader cl) {
512 try {
513 File[] installedExts = getInstalledExtensions();
514 for (int i=0;i<installedExts.length;i++) {
515 final File instFile = installedExts[i];
516 URL instURL = AccessController.doPrivileged(
|
267 *
268 * @param extensionName key in the attibute list
269 * @param attr manifest file attributes
270 * @param file installed extension jar file to compare the requested
271 * extension against.
272 */
273 protected boolean checkExtensionAgainst(String extensionName,
274 Attributes attr,
275 final File file)
276 throws IOException,
277 FileNotFoundException,
278 ExtensionInstallationException
279 {
280
281 debug("Checking extension " + extensionName +
282 " against " + file.getName());
283
284 // Load the jar file ...
285 Manifest man;
286 try {
287 man = AccessController.doPrivileged(
288 new PrivilegedExceptionAction<Manifest>() {
289 public Manifest run()
290 throws IOException, FileNotFoundException {
291 if (!file.exists())
292 throw new FileNotFoundException(file.getName());
293 JarFile jarFile = new JarFile(file);
294 return jarFile.getManifest();
295 }
296 });
297 } catch(PrivilegedActionException e) {
298 if (e.getException() instanceof FileNotFoundException)
299 throw (FileNotFoundException) e.getException();
300 throw (IOException) e.getException();
301 }
302
303 // Construct the extension information object
304 ExtensionInfo reqInfo = new ExtensionInfo(extensionName, attr);
305 debug("Requested Extension : " + reqInfo);
306
307 int isCompatible = ExtensionInfo.INCOMPATIBLE;
308 ExtensionInfo instInfo = null;
309
373 debug(reqInfo.name + " installation failed");
374 return false;
375 }
376
377 /**
378 * <p>
379 * Checks if the extension, that is specified in the extension-list in
380 * the applet jar manifest, is already installed (i.e. exists in the
381 * extension directory).
382 * </p>
383 *
384 * @param extensionName extension name in the extension-list
385 *
386 * @return the extension if it exists in the extension directory
387 */
388 private File checkExtensionExists(String extensionName) {
389 // Function added to fix bug 4504166
390 final String extName = extensionName;
391 final String[] fileExt = {".jar", ".zip"};
392
393 return AccessController.doPrivileged(
394 new PrivilegedAction<File>() {
395 public File run() {
396 try {
397 File fExtension;
398 File[] dirs = getExtDirs();
399
400 // Search the extension directories for the extension that is specified
401 // in the attribute extension-list in the applet jar manifest
402 for (int i=0;i<dirs.length;i++) {
403 for (int j=0;j<fileExt.length;j++) {
404 if (extName.toLowerCase().endsWith(fileExt[j])) {
405 fExtension = new File(dirs[i], extName);
406 } else {
407 fExtension = new File(dirs[i], extName+fileExt[j]);
408 }
409 debug("checkExtensionExists:fileName " + fExtension.getName());
410 if (fExtension.exists()) {
411 return fExtension;
412 }
413 }
414 }
415 return null;
442 dirs[i] = new File(st.nextToken());
443 debug("getExtDirs dirs["+i+"] "+ dirs[i]);
444 }
445 } else {
446 dirs = new File[0];
447 debug("getExtDirs dirs " + dirs);
448 }
449 debug("getExtDirs dirs.length " + dirs.length);
450 return dirs;
451 }
452
453 /*
454 * <p>
455 * Scan the directories and return all files installed in those
456 * </p>
457 * @param dirs list of directories to scan
458 *
459 * @return the list of files installed in all the directories
460 */
461 private static File[] getExtFiles(File[] dirs) throws IOException {
462 Vector<File> urls = new Vector<File>();
463 for (int i = 0; i < dirs.length; i++) {
464 String[] files = dirs[i].list(new JarFilter());
465 if (files != null) {
466 debug("getExtFiles files.length " + files.length);
467 for (int j = 0; j < files.length; j++) {
468 File f = new File(dirs[i], files[j]);
469 urls.add(f);
470 debug("getExtFiles f["+j+"] "+ f);
471 }
472 }
473 }
474 File[] ua = new File[urls.size()];
475 urls.copyInto(ua);
476 debug("getExtFiles ua.length " + ua.length);
477 return ua;
478 }
479
480 /*
481 * <p>
482 * @return the list of installed extensions jar files
483 * </p>
484 */
485 private File[] getInstalledExtensions() throws IOException {
486 return AccessController.doPrivileged(
487 new PrivilegedAction<File[]>() {
488 public File[] run() {
489 try {
490 return getExtFiles(getExtDirs());
491 } catch(IOException e) {
492 debug("Cannot get list of installed extensions");
493 debugException(e);
494 return new File[0];
495 }
496 }
497 });
498 }
499
500 /*
501 * <p>
502 * Add the newly installed jar file to the extension class loader.
503 * </p>
504 *
505 * @param cl the current installed extension class loader
506 *
507 * @return true if successful
508 */
509 private Boolean addNewExtensionsToClassLoader(Launcher.ExtClassLoader cl) {
510 try {
511 File[] installedExts = getInstalledExtensions();
512 for (int i=0;i<installedExts.length;i++) {
513 final File instFile = installedExts[i];
514 URL instURL = AccessController.doPrivileged(
|