Forums Register Login

security issue

+Pie Number of slices to send: Send
I am using the Reflection API, trying to obtain class information. Displaying in an applet, when using the .getDeclaredMethods or .getDeclaredFields, I come across a Security Exception error. How do I get around this? Thanks in advance!


Here is sample code which I think is throwing the Exception:

public String getPublicMethods(String a) throws ClassNotFoundException{

this.initializeVariable(a);
sb.append(PB + MTD);
sb.append(HEADER);
Method[] theMethods = clas.getDeclaredMethods();
for (int i = 0; i < theMethods.length; i++) {
mod = theMethods[i].getModifiers();
Modifier modifier = new Modifier();
if(modifier.isPublic(mod)) {
methodName = theMethods[i].getName();
returnType = theMethods[i].getReturnType().getName();
sb.append(" " + returnType + " " + methodName + " (");

Class[] parameterTypes = theMethods[i].getParameterTypes();
boolean first = true;
for (int k = 0; k < parameterTypes.length; k ++) {
if(first) {
sb.append(parameterTypes[k].getName());
first = false;
} else {
sb.append(", " +parameterTypes[k].getName());
}
}
sb.append(" )\n");
}
}
+Pie Number of slices to send: Send
For security reasons, applets aren't allowed to do a number of things, including use of the Reflection API. If you really need to do this, then the two principal ways around that -applet signing, and altering the local security policy- are described here.
See ya later boys, I think I'm in love. Oh wait, she's just a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 815 times.
Similar Threads
calling methods with reflection
iterate to all List type property of my objects recursively
Reflection
Problem with Reflection
ClassLoader question
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 09:32:41.