1. /*
  2. * The Apache Software License, Version 1.1
  3. *
  4. *
  5. * Copyright (c) 2002 The Apache Software Foundation. All rights
  6. * reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in
  17. * the documentation and/or other materials provided with the
  18. * distribution.
  19. *
  20. * 3. The end-user documentation included with the redistribution,
  21. * if any, must include the following acknowledgment:
  22. * "This product includes software developed by the
  23. * Apache Software Foundation (http://www.apache.org/)."
  24. * Alternately, this acknowledgment may appear in the software itself,
  25. * if and wherever such third-party acknowledgments normally appear.
  26. *
  27. * 4. The name "Apache Software Foundation" must not be used to endorse or
  28. * promote products derived from this software without prior written
  29. * permission. For written permission, please contact apache@apache.org.
  30. *
  31. * 5. Products derived from this software may not be called "Apache",
  32. * nor may "Apache" appear in their name, without prior written
  33. * permission of the Apache Software Foundation.
  34. *
  35. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38. * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46. * SUCH DAMAGE.
  47. * ====================================================================
  48. *
  49. * This software consists of voluntary contributions made by many
  50. * individuals on behalf of the Apache Software Foundation and was
  51. * originally based on software copyright (c) 1999-2002, Sun Microsystems,
  52. * Inc., http://www.sun.com. For more information on the Apache Software
  53. * Foundation, please see <http://www.apache.org/>.
  54. */
  55. package com.sun.org.apache.html.internal.dom;
  56. import java.io.*;
  57. /**
  58. * This class is duplicated for each JAXP subpackage so keep it in sync.
  59. * It is package private and therefore is not exposed as part of the JAXP
  60. * API.
  61. *
  62. * Base class with security related methods that work on JDK 1.1.
  63. */
  64. class SecuritySupport {
  65. /*
  66. * Make this of type Object so that the verifier won't try to
  67. * prove its type, thus possibly trying to load the SecuritySupport12
  68. * class.
  69. */
  70. private static final Object securitySupport;
  71. static {
  72. SecuritySupport ss = null;
  73. try {
  74. Class c = Class.forName("java.security.AccessController");
  75. // if that worked, we're on 1.2.
  76. /*
  77. // don't reference the class explicitly so it doesn't
  78. // get dragged in accidentally.
  79. c = Class.forName("javax.mail.SecuritySupport12");
  80. Constructor cons = c.getConstructor(new Class[] { });
  81. ss = (SecuritySupport)cons.newInstance(new Object[] { });
  82. */
  83. /*
  84. * Unfortunately, we can't load the class using reflection
  85. * because the class is package private. And the class has
  86. * to be package private so the APIs aren't exposed to other
  87. * code that could use them to circumvent security. Thus,
  88. * we accept the risk that the direct reference might fail
  89. * on some JDK 1.1 JVMs, even though we would never execute
  90. * this code in such a case. Sigh...
  91. */
  92. ss = new SecuritySupport12();
  93. } catch (Exception ex) {
  94. // ignore it
  95. } finally {
  96. if (ss == null)
  97. ss = new SecuritySupport();
  98. securitySupport = ss;
  99. }
  100. }
  101. /**
  102. * Return an appropriate instance of this class, depending on whether
  103. * we're on a JDK 1.1 or J2SE 1.2 (or later) system.
  104. */
  105. static SecuritySupport getInstance() {
  106. return (SecuritySupport)securitySupport;
  107. }
  108. ClassLoader getContextClassLoader() {
  109. return null;
  110. }
  111. ClassLoader getSystemClassLoader() {
  112. return null;
  113. }
  114. ClassLoader getParentClassLoader(ClassLoader cl) {
  115. return null;
  116. }
  117. String getSystemProperty(String propName) {
  118. return System.getProperty(propName);
  119. }
  120. FileInputStream getFileInputStream(File file)
  121. throws FileNotFoundException
  122. {
  123. return new FileInputStream(file);
  124. }
  125. InputStream getResourceAsStream(ClassLoader cl, String name) {
  126. InputStream ris;
  127. if (cl == null) {
  128. ris = ClassLoader.getSystemResourceAsStream(name);
  129. } else {
  130. ris = cl.getResourceAsStream(name);
  131. }
  132. return ris;
  133. }
  134. boolean getFileExists(File f) {
  135. return f.exists();
  136. }
  137. long getLastModified(File f) {
  138. return f.lastModified();
  139. }
  140. }