File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Applets and the fly likes security issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "security issue" Watch "security issue" New topic
Author

security issue

Mike Croteau
Greenhorn

Joined: Apr 09, 2007
Posts: 8
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");
}
}
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41525
    
  53
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.


Ping & DNS - my free Android networking tools app
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: security issue