524N/A/*
524N/A * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
524N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
524N/A *
524N/A * This code is free software; you can redistribute it and/or modify it
524N/A * under the terms of the GNU General Public License version 2 only, as
524N/A * published by the Free Software Foundation. Oracle designates this
524N/A * particular file as subject to the "Classpath" exception as provided
524N/A * by Oracle in the LICENSE file that accompanied this code.
524N/A *
524N/A * This code is distributed in the hope that it will be useful, but WITHOUT
524N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
524N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
524N/A * version 2 for more details (a copy is included in the LICENSE file that
524N/A * accompanied this code).
524N/A *
524N/A * You should have received a copy of the GNU General Public License version
524N/A * 2 along with this work; if not, write to the Free Software Foundation,
524N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
524N/A *
524N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
524N/A * or visit www.oracle.com if you need additional information or have any
524N/A * questions.
524N/A */
524N/A
524N/Apackage org.xml.sax.helpers;
524N/A
524N/Aimport java.io.*;
524N/Aimport java.security.*;
524N/A
524N/A/**
524N/A * This class is duplicated for each JAXP subpackage so keep it in sync.
524N/A * It is package private and therefore is not exposed as part of the JAXP
524N/A * API.
524N/A *
524N/A * Security related methods that only work on J2SE 1.2 and newer.
524N/A */
524N/Aclass SecuritySupport {
524N/A
524N/A
524N/A ClassLoader getContextClassLoader() throws SecurityException{
524N/A return (ClassLoader)
524N/A AccessController.doPrivileged(new PrivilegedAction() {
524N/A public Object run() {
524N/A ClassLoader cl = null;
524N/A //try {
524N/A cl = Thread.currentThread().getContextClassLoader();
524N/A //} catch (SecurityException ex) { }
524N/A
524N/A if (cl == null)
524N/A cl = ClassLoader.getSystemClassLoader();
524N/A
524N/A return cl;
524N/A }
524N/A });
524N/A }
524N/A
524N/A String getSystemProperty(final String propName) {
524N/A return (String)
524N/A AccessController.doPrivileged(new PrivilegedAction() {
524N/A public Object run() {
524N/A return System.getProperty(propName);
524N/A }
524N/A });
524N/A }
524N/A
524N/A FileInputStream getFileInputStream(final File file)
524N/A throws FileNotFoundException
524N/A {
524N/A try {
524N/A return (FileInputStream)
524N/A AccessController.doPrivileged(new PrivilegedExceptionAction() {
524N/A public Object run() throws FileNotFoundException {
524N/A return new FileInputStream(file);
524N/A }
524N/A });
524N/A } catch (PrivilegedActionException e) {
524N/A throw (FileNotFoundException)e.getException();
524N/A }
524N/A }
524N/A
524N/A InputStream getResourceAsStream(final ClassLoader cl,
524N/A final String name)
524N/A {
524N/A return (InputStream)
524N/A AccessController.doPrivileged(new PrivilegedAction() {
524N/A public Object run() {
524N/A InputStream ris;
524N/A if (cl == null) {
524N/A ris = Object.class.getResourceAsStream(name);
524N/A } else {
524N/A ris = cl.getResourceAsStream(name);
524N/A }
524N/A return ris;
524N/A }
524N/A });
524N/A }
524N/A
524N/A boolean doesFileExist(final File f) {
524N/A return ((Boolean)
524N/A AccessController.doPrivileged(new PrivilegedAction() {
524N/A public Object run() {
524N/A return new Boolean(f.exists());
524N/A }
524N/A })).booleanValue();
524N/A }
524N/A
524N/A}