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