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