Is it possible to limit file access of certain classes to a certain directory?

KJKalle :

I am creating a plugin system which dynamically loads classes, and since the plugins are user created, I want to restrict their access to everywhere but a working directory. Is there a solution for this in Java?

GhostCat salutes Monica C. :

Basically the JVM offers the Security manager architecture.

One part of that are FilePermissions, which enable some sort of control here.

But note: this is really an advanced topic, and easy to get wrong, but your primary use case of isolating plugins coming from different packages should be doable.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=99295&siteId=1