1. /*
  2. * @(#)ResourceLoader.java 1.4 00/02/02
  3. *
  4. * Copyright 1998-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package javax.swing.text.html;
  11. import java.io.InputStream;
  12. /**
  13. * Simple class to load resources using the 1.2
  14. * security model. Since the html support is loaded
  15. * lazily, it's resources are potentially fetched with
  16. * applet code in the call stack. By providing this
  17. * functionality in a class that is only built on 1.2,
  18. * reflection can be used from the code that is also
  19. * built on 1.1 to call this functionality (and avoid
  20. * the evils of preprocessing). This functionality
  21. * is called from HTMLEditorKit.getResourceAsStream.
  22. *
  23. * @author Timothy Prinzing
  24. * @version 1.4 02/02/00
  25. */
  26. class ResourceLoader implements java.security.PrivilegedAction {
  27. ResourceLoader(String name) {
  28. this.name = name;
  29. }
  30. public Object run() {
  31. Object o = HTMLEditorKit.class.getResourceAsStream(name);
  32. return o;
  33. }
  34. public static InputStream getResourceAsStream(String name) {
  35. java.security.PrivilegedAction a = new ResourceLoader(name);
  36. return (InputStream) java.security.AccessController.doPrivileged(a);
  37. }
  38. private String name;
  39. }