Blame SOURCES/TestSecurityProperties.java

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