Blame SOURCES/TestSecurityProperties.java

e74e6c
import java.io.File;
e74e6c
import java.io.FileInputStream;
e74e6c
import java.security.Security;
e74e6c
import java.util.Properties;
e74e6c
e74e6c
public class TestSecurityProperties {
e74e6c
    // JDK 11
e74e6c
    private static final String JDK_PROPS_FILE_JDK_11 = System.getProperty("java.home") + "/conf/security/java.security";
e74e6c
    // JDK 8
e74e6c
    private static final String JDK_PROPS_FILE_JDK_8 = System.getProperty("java.home") + "/lib/security/java.security";
e74e6c
e74e6c
    public static void main(String[] args) {
e74e6c
        Properties jdkProps = new Properties();
e74e6c
        loadProperties(jdkProps);
e74e6c
        for (Object key: jdkProps.keySet()) {
e74e6c
            String sKey = (String)key;
e74e6c
            String securityVal = Security.getProperty(sKey);
e74e6c
            String jdkSecVal = jdkProps.getProperty(sKey);
e74e6c
            if (!securityVal.equals(jdkSecVal)) {
e74e6c
                String msg = "Expected value '" + jdkSecVal + "' for key '" + 
e74e6c
                             sKey + "'" + " but got value '" + securityVal + "'";
e74e6c
                throw new RuntimeException("Test failed! " + msg);
e74e6c
            } else {
e74e6c
                System.out.println("DEBUG: " + sKey + " = " + jdkSecVal + " as expected.");
e74e6c
            }
e74e6c
        }
e74e6c
        System.out.println("TestSecurityProperties PASSED!");
e74e6c
    }
e74e6c
    
e74e6c
    private static void loadProperties(Properties props) {
e74e6c
        String javaVersion = System.getProperty("java.version");
e74e6c
        System.out.println("Debug: Java version is " + javaVersion);
e74e6c
        String propsFile = JDK_PROPS_FILE_JDK_11;
e74e6c
        if (javaVersion.startsWith("1.8.0")) {
e74e6c
            propsFile = JDK_PROPS_FILE_JDK_8;
e74e6c
        }
e74e6c
        try (FileInputStream fin = new FileInputStream(new File(propsFile))) {
e74e6c
            props.load(fin);
e74e6c
        } catch (Exception e) {
e74e6c
            throw new RuntimeException("Test failed!", e);
e74e6c
        }
e74e6c
    }
e74e6c
}