开发者

Trace file access from Java applet

Is it possible to trace (log) all file access from a (3rd party) Java applet, that has been granted access to the local disk?

Just logging of which files are accessed is need开发者_StackOverflow中文版ed.


I don't think this is possible out of the box - after all, it is an applet without security restrictions.

If you can modify this applet (or run it inside some environment which you control), you can install a security manager whose checkRead and checkWrite (maybe also checkDelete and similar) methods do your logging.

Other than that, maybe there are some debugging features you could use.

In general, if your applet does not need arbitrary access, you should use the JNLP API to access local files - then the user has control over it.


Possible (untested) strategy

File Logging Applet Loader

  1. Create your own (trusted) applet to load the 3rd party applet that performs file access.
  2. Use the stub and applet context from the parent applet, for the newly loaded applet.
  3. Install a custom SecurityManager.
  4. In the FileLoggingSecurityManager, override checkPermission(Permission) to check for instances of FilePermission.
  5. Log them.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜