2
* Copyright 2002-2005 The Apache Software Foundation.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
package org.xml.sax.helpers;
20
import java.io.FileInputStream;
21
import java.io.FileNotFoundException;
22
import java.io.InputStream;
23
import java.security.AccessController;
24
import java.security.PrivilegedAction;
25
import java.security.PrivilegedActionException;
26
import java.security.PrivilegedExceptionAction;
29
* This class is duplicated for each JAXP subpackage so keep it in sync.
30
* It is package private and therefore is not exposed as part of the JAXP
33
* Security related methods that only work on J2SE 1.2 and newer.
35
class SecuritySupport12 extends SecuritySupport {
37
public ClassLoader getContextClassLoader() {
39
AccessController.doPrivileged(new PrivilegedAction() {
41
ClassLoader cl = null;
43
cl = Thread.currentThread().getContextClassLoader();
44
} catch (SecurityException ex) { }
50
public String getSystemProperty(final String propName) {
52
AccessController.doPrivileged(new PrivilegedAction() {
54
return System.getProperty(propName);
59
public FileInputStream getFileInputStream(final File file)
60
throws FileNotFoundException
63
return (FileInputStream)
64
AccessController.doPrivileged(new PrivilegedExceptionAction() {
65
public Object run() throws FileNotFoundException {
66
return new FileInputStream(file);
69
} catch (PrivilegedActionException e) {
70
throw (FileNotFoundException)e.getException();
74
public InputStream getResourceAsStream(final ClassLoader cl,
78
AccessController.doPrivileged(new PrivilegedAction() {
82
ris = ClassLoader.getSystemResourceAsStream(name);
84
ris = cl.getResourceAsStream(name);