I'm running a Java application as a Windows Service and am using another Java application, which is executed by another user, to set a directory used by the Windows Service application.
我正在运行Java应用程序作为Windows服务,并使用另一个Java应用程序(由另一个用户执行)来设置Windows服务应用程序使用的目录。
Is there a way in Java to determine the file permissions of a directory for another user? In my case, I want to know the file permissions of the Windows Service application while running a separate Java application executed by another user.
Java中有没有办法为另一个用户确定目录的文件权限?就我而言,我想知道运行由另一个用户执行的单独Java应用程序时Windows服务应用程序的文件权限。
1 个解决方案
#1
This kind of filesystem support is not available in standard Java, because Java is cross-platform and filesystem security differs greatly across platforms (or may not exist at all). However, there are plans to add this support to Java 7 (which we have been waiting for years to get!)
这种文件系统支持在标准Java中不可用,因为Java是跨平台的,并且文件系统安全性在不同平台之间存在很大差异(或者可能根本不存在)。但是,有计划将这种支持添加到Java 7(我们已经等了好几年了!)
If you are only using it on Windows and you know C/C++, you can use a JNI (Java Native Interface) like JNA to tap into the Windows DLLs and get this information. Otherwise, you can get a trial or a paid version of JNIWrapper which works out-of-the-box. I'm not sure if it provides support for file security, but it does provide other filesystem support - you'll need to review the feature list.
如果您只在Windows上使用它并且您了解C / C ++,则可以使用JNA等JNI(Java本机接口)来访问Windows DLL并获取此信息。否则,您可以获得试用版或付费版的JNIWrapper,它可以开箱即用。我不确定它是否提供对文件安全性的支持,但它确实提供了其他文件系统支持 - 您需要查看功能列表。
#1
This kind of filesystem support is not available in standard Java, because Java is cross-platform and filesystem security differs greatly across platforms (or may not exist at all). However, there are plans to add this support to Java 7 (which we have been waiting for years to get!)
这种文件系统支持在标准Java中不可用,因为Java是跨平台的,并且文件系统安全性在不同平台之间存在很大差异(或者可能根本不存在)。但是,有计划将这种支持添加到Java 7(我们已经等了好几年了!)
If you are only using it on Windows and you know C/C++, you can use a JNI (Java Native Interface) like JNA to tap into the Windows DLLs and get this information. Otherwise, you can get a trial or a paid version of JNIWrapper which works out-of-the-box. I'm not sure if it provides support for file security, but it does provide other filesystem support - you'll need to review the feature list.
如果您只在Windows上使用它并且您了解C / C ++,则可以使用JNA等JNI(Java本机接口)来访问Windows DLL并获取此信息。否则,您可以获得试用版或付费版的JNIWrapper,它可以开箱即用。我不确定它是否提供对文件安全性的支持,但它确实提供了其他文件系统支持 - 您需要查看功能列表。