99 lines
3.1 KiB
Java
99 lines
3.1 KiB
Java
package org.apache.xerces.parsers;
|
|
|
|
import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.io.FileNotFoundException;
|
|
import java.io.InputStream;
|
|
import java.security.AccessController;
|
|
import java.security.PrivilegedAction;
|
|
import java.security.PrivilegedActionException;
|
|
import java.security.PrivilegedExceptionAction;
|
|
|
|
class SecuritySupport12 extends SecuritySupport {
|
|
ClassLoader getContextClassLoader() {
|
|
return AccessController.<ClassLoader>doPrivileged(new PrivilegedAction(this) {
|
|
private final SecuritySupport12 this$0;
|
|
|
|
public Object run() {
|
|
ClassLoader cl = null;
|
|
try {
|
|
cl = Thread.currentThread().getContextClassLoader();
|
|
} catch (SecurityException ex) {}
|
|
return cl;
|
|
}
|
|
});
|
|
}
|
|
|
|
String getSystemProperty(String propName) {
|
|
return AccessController.<String>doPrivileged(new PrivilegedAction(this, propName) {
|
|
private final String val$propName;
|
|
|
|
private final SecuritySupport12 this$0;
|
|
|
|
public Object run() {
|
|
return System.getProperty(this.val$propName);
|
|
}
|
|
});
|
|
}
|
|
|
|
FileInputStream getFileInputStream(File file) throws FileNotFoundException {
|
|
try {
|
|
return AccessController.<FileInputStream>doPrivileged(new PrivilegedExceptionAction(this, file) {
|
|
private final File val$file;
|
|
|
|
private final SecuritySupport12 this$0;
|
|
|
|
public Object run() throws FileNotFoundException {
|
|
return new FileInputStream(this.val$file);
|
|
}
|
|
});
|
|
} catch (PrivilegedActionException e) {
|
|
throw (FileNotFoundException)e.getException();
|
|
}
|
|
}
|
|
|
|
InputStream getResourceAsStream(ClassLoader cl, String name) {
|
|
return AccessController.<InputStream>doPrivileged(new PrivilegedAction(this, cl, name) {
|
|
private final ClassLoader val$cl;
|
|
|
|
private final String val$name;
|
|
|
|
private final SecuritySupport12 this$0;
|
|
|
|
public Object run() {
|
|
InputStream ris;
|
|
if (this.val$cl == null) {
|
|
ris = ClassLoader.getSystemResourceAsStream(this.val$name);
|
|
} else {
|
|
ris = this.val$cl.getResourceAsStream(this.val$name);
|
|
}
|
|
return ris;
|
|
}
|
|
});
|
|
}
|
|
|
|
boolean getFileExists(File f) {
|
|
return ((Boolean)AccessController.<Boolean>doPrivileged(new PrivilegedAction(this, f) {
|
|
private final File val$f;
|
|
|
|
private final SecuritySupport12 this$0;
|
|
|
|
public Object run() {
|
|
return new Boolean(this.val$f.exists());
|
|
}
|
|
})).booleanValue();
|
|
}
|
|
|
|
long getLastModified(File f) {
|
|
return ((Long)AccessController.<Long>doPrivileged(new PrivilegedAction(this, f) {
|
|
private final File val$f;
|
|
|
|
private final SecuritySupport12 this$0;
|
|
|
|
public Object run() {
|
|
return new Long(this.val$f.lastModified());
|
|
}
|
|
})).longValue();
|
|
}
|
|
}
|