mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-07 08:39:12 +00:00
Merge pull request #225 from Parabot/bugfix/protected-domain
[BUGFIX] Added getProtectionDomain to ClassRedirect
This commit is contained in:
@@ -8,9 +8,22 @@ import java.io.InputStream;
|
|||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.security.AccessController;
|
||||||
|
import java.security.PrivilegedAction;
|
||||||
|
import java.security.ProtectionDomain;
|
||||||
|
|
||||||
public class ClassRedirect {
|
public class ClassRedirect {
|
||||||
|
|
||||||
|
public static ProtectionDomain getProtectionDomain(final Class<?> clazz) {
|
||||||
|
System.err.println(clazz.getName() + " getProtectionDomain request granted.");
|
||||||
|
|
||||||
|
return AccessController.doPrivileged(new PrivilegedAction<ProtectionDomain>() {
|
||||||
|
public ProtectionDomain run() {
|
||||||
|
return clazz.getProtectionDomain();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static Object newInstance(Class<?> c) throws IllegalAccessException, InstantiationException {
|
public static Object newInstance(Class<?> c) throws IllegalAccessException, InstantiationException {
|
||||||
if (validStack()) {
|
if (validStack()) {
|
||||||
return c.newInstance();
|
return c.newInstance();
|
||||||
@@ -136,8 +149,9 @@ public class ClassRedirect {
|
|||||||
private static boolean validStack() {
|
private static boolean validStack() {
|
||||||
Exception e = new Exception();
|
Exception e = new Exception();
|
||||||
for (StackTraceElement elem : e.getStackTrace()) {
|
for (StackTraceElement elem : e.getStackTrace()) {
|
||||||
if (elem.getClassName().equals(Script.class.getName()))
|
if (elem.getClassName().equals(Script.class.getName())) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.awt.datatransfer.Clipboard;
|
|||||||
import java.awt.datatransfer.DataFlavor;
|
import java.awt.datatransfer.DataFlavor;
|
||||||
import java.awt.datatransfer.Transferable;
|
import java.awt.datatransfer.Transferable;
|
||||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||||
|
import java.awt.image.ImageProducer;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
@@ -46,7 +47,11 @@ public class ToolkitRedirect {
|
|||||||
public static Image createImage(Toolkit t, String s){
|
public static Image createImage(Toolkit t, String s){
|
||||||
return t.createImage(s);
|
return t.createImage(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Image createImage(Toolkit t, ImageProducer i){
|
||||||
|
return t.createImage(i);
|
||||||
|
}
|
||||||
|
|
||||||
public static Image getImage(Toolkit t,URL u){
|
public static Image getImage(Toolkit t,URL u){
|
||||||
return t.getImage(u);
|
return t.getImage(u);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user