本文介绍了在Embedded Groovy中限制某些API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在我的应用程序中嵌入了Groovy,并且想知道是否可以限制对某些API的访问,例如java.io.File,java.net.URL等。

I just embedded Groovy in my application and wondering if it's possible to restrict access to some APIs i.e. java.io.File, java.net.URL, etc

或者,而不是完全限制java.io.File访问,我只想允许访问机器上的某些目录。

Or instead of completely restricting java.io.File access, I want to ONLY allow access to certain directories on the machine.

任何指导都非常感谢!

Any guidance is greatly appreciated!

推荐答案

使用Java安全管理器。有关示例,请参阅答案。

Use the Java Security Manager. Refer this answer for an example.

这篇关于在Embedded Groovy中限制某些API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 01:40