Reputation: 33
For debugging, I want a way to discover, for a running JVM at a given moment, all the names and all the values of all the properties maintained in the java.security.Security class.
I've learned a few things from studying the API specification and the Java Cryptography Architecture Guide...
If I know the name of a property, I can find its current value using getProperty. But I don't know how to discover all the names.
Initial settings for the properties can be made in configuration files, but settings can later be added and changed dynamically, using setProperty. I'm interested in the current settings, which would not necessarily be the initial settings.
Thank you for any guidance!
Upvotes: 3
Views: 2078
Reputation: 827
use Security
class :
String certDisabled = Security.getProperty("jdk.certpath.disabledAlgorithms");
String tlsDisabled= Security.getProperty("jdk.tls.disabledAlgorithms");
Upvotes: -1
Reputation: 4956
setProperty
and getProperty
both manipulate the internal props
field. You could access it using reflection API. Use this strictly as throwaway code for debugging! Should never get into production code.
Field f = Security.class.getDeclaredField("props");
f.setAccessible(true);
Properties allProps = (Properties) f.get(null); // Static field, so null object.
System.out.println(allProps); //Or iterate over elements()/propertyNames() and print them individually
Upvotes: 5