用于为JVM指定Java.Security文件的Java参数 [英] Java argument to specify Java.Security file for JVM

查看:498
本文介绍了用于为JVM指定Java.Security文件的Java参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个Java参数(或其他方法)来允许我将JVM要使用的文件指定为java.security文件,而不是使用JDK中的文件(在JRE库).

I'm looking for a java argument (or perhaps some different method) to allow me to specify a file to be used by the JVM as the java.security file, rather than using the one found in the JDK (in the JRE lib).

为了给您更多的上下文,我正在使用由其他人设置的WebLogic服务器,该服务器正在同一JDK上运行两个(或多个)不同的JVM.现在,我们遇到了一个问题,即我在一个JVM上所做的工作需要与另一个JVM当前正在使用的java.security文件不同的java.security文件.我希望有一种方法可以将JVM指向新的java.security文件,而不必将其指向全新的JDK(由于空间限制,我们希望避免上载针对每个JVM的JDK ).

To give you a little more context, I am working with a WebLogic server that was set up by someone else and is running two (or more) different JVMs off the same JDK. We have run into an issue now where the work I'm doing on one JVM requires a different java.security file than the one that is currently being used by the other JVM. I am hoping there will be a way for me to just point my JVM at a new java.security file without having to point it at an entirely new JDK (due to space constraints, we would like to avoid uploading a JDK specific to each JVM).

我意识到服务器的设置不是理想的,但是完全重新安排现有的设置是不可行的,这不是我可以做的事情.因此,我希望有人能够提供一个创新的解决方案,以允许多个JVM在同一JDK上运行,但具有不同的安全配置.

I realize that the server's set up is not ideal, but completely rearranging the existing set up is not viable and not something I am in a position to do. So, I am hoping someone might have a creative solution that would allow for multiple JVMs running off the same JDK but with different security configurations.

我一直在尝试寻找解决方案,但看来我的Google-Foo并不如我所希望的那样强大.这是希望你们中的一个能得到答案!

I have been trying to find solutions out there, but it seems my Google-Foo is not as strong as I had hoped. Here's to hoping one of you has the answer!

非常感谢.

编辑
抱歉,我的原始帖子不清楚,但是我对指定java.security文件感兴趣,该文件通常也称为 Java主安全属性文件,而不是在同一目录.

EDIT
Sorry maybe my original post was not clear, but I am interested in specifying the java.security file, also often referred to as the Java master security properties file, not the java.policy file which is found in the same directory.

我的解决方案

我将在此处发布我的解决方案,仅供其他可能遇到类似情况的人参考.

I will post my solution here just for reference of others who might fall into a similar situation.

由于我似乎找不到启动时要指定的参数,因此我决定必须放弃java.security属性文件.可以使用Security类(java.security.Security)在代码内设置属性和提供程序(通常在文件中配置).因此,至少在过渡期间,我计划编写一个类,该类将在启动后设置我的JVM特定的安全配置(基本上覆盖该文件为其他JVM提供的默认配置).尽管此解决方案的明显缺点是没有外部化此JVM的安全配置,但该解决方案确实为我提供了一种设置JVM特定属性和提供程序的方式,而不会影响运行同一JDK的其他JVM的配置.

As I can't seem to find an argument to specify at start up, I have decided that I will have to forgo the java.security properties file. It is possible to set properties and providers (typically configured in the file) within code using the Security class (java.security.Security). So, at least in the interim, I plan to write a class that will go through setting up my JVM specific security configurations after startup (essentially overwriting the default configurations provided by the file for the other JVM). While the obvious downside of this solution is that is does not externalize security configurations of this JVM, the solution does provide me a way to set JVM specific properties and providers without affecting the configuration of other JVMs running off the same JDK.

我感谢其他人的时间和考虑.谢谢=)

I appreciate the time and consideration given by others. Thanks =)

推荐答案

查看

Looking at the OpenJDK source, you cannot change the loading of the java.security file. However, that file has a property called security.overridePropertiesFile which, if set to true (as it is in my current, vanilla install), allows you to load an additional security properties file specified through the system property named java.security.properties. Note also, that the command line syntax follows a similar pattern to the policy file where = specifies additional configuration and == specifies a complete replacement configuration.

这篇关于用于为JVM指定Java.Security文件的Java参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆